From patchwork Fri Jul 5 10:40:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13724917 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4003148312 for ; Fri, 5 Jul 2024 10:40:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176058; cv=none; b=GDVZSRrZPG9JKucqQDR77UVpRMSJ+Addv27CylQc8fL6/PkFAQCh3UhAP4xIf1SUY15p7gR2zvC7VziBC+nprLVLUd5kU6HhtV62xWuXA7hUK3r0GTZyPYDKe5WzVsXOq7e3l5gf3OOpCIzLUHpOhXGwX7Pqs9msqWQZQA8S+B4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176058; c=relaxed/simple; bh=2JNEEDT0yqg0ZpezS+vJkAIFphubIucu2CrwWdLhExA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GKBPcCKPRHvyyZzgTXtl5FsD/7qGTCAM0RUSOgyKXPMKS2XGM5lN+5+YwnqA7CJEltvpoIgXvYr4twzmd6rx49lMiFI9cqi1ILjX2y2hgBTa5nInmrZjNWr1TrzAQfsTXArj+81aF5gF3AkmuIbNSYbhmb5FgYb9JFPsi+VtWMo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=IeiwXAGx; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="IeiwXAGx" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4265921b0f6so1733295e9.2 for ; Fri, 05 Jul 2024 03:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720176055; x=1720780855; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=mPUGB6WWLvSgcH0G9Q4p2N02Tp+SMaWAilQNUIzP9x8=; b=IeiwXAGxBTyEnIO9Us4XvDbvXCw7pmEzKczda6qvJEYejW5KjVRFGdOT9EEKU3j5SK 6+yRVIJtNXmiBXlB3EzG5EXG7dVCnzMLzUIwYpsvJKQXHmKbKe36Tlvs2Bz0hldxGXHc vlZnEB5NvlLZJhC/uKKCq4pXmCNQudqRCBmfcwOZHzKCbsFzCgjpeZq5ZtbV78aRdsqa FwbsdDv+RohVAcYfk/9TY5nF6H0QoERWnJE0jArtfB6Sz4mAD4fQOeGtvAuhWH/jQgIS l7OZwpRr2kXL89X6ZTSFVz+CfOzgSvNa0a6OHZJN4uDwJDb/RtJw0etr+daHXKQhouTK YDrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176055; x=1720780855; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mPUGB6WWLvSgcH0G9Q4p2N02Tp+SMaWAilQNUIzP9x8=; b=kijbZk9NfrrVX0bpkvEe/YwEqXmR6gK3YHNYS2LxCpZfzFgIRkqVSyjtyf5ooxpGHu 0yQNW39oHIwY3fXGDZOUDqLbxAd48E/HQtWGB9OAhsrROS5fbRmq7SvnHqv/rXKLz9ze G02goAOC65hCvbzwa8UUSuvrTQowgyEyl6N6pqFSXpnrKBunRJ4YCBZObPs5A4RTlW5y A6Fwr9ylsJMNJTJ5BNcsjnKazSJD2OaMMOgqsjzwPY1s840ITidHqbfVXrI0l4O7x4Ff dzFDNo9mb0wDhQ+YTnJ8NJ4BWYEoUlrprXyJ48C2nqEr9q7khx25e7XsPIFnJnbm/1zY oMlA== X-Gm-Message-State: AOJu0YzrV/sl+DlnJVxsBdP7/8HS1wSBnezK/svAk17t0Wx1YpBpzTSF gkCrF16J/tlxnOgUW7z9NPbov2ckeUvBgRYRtIs2ofc454m0SHcQeAYNXZf5YtpfSIPBBahMUJ4 u X-Google-Smtp-Source: AGHT+IG91L1QiQgNWqSWoacLRT/4TO/Dx2hLrfRAQx3fZ6Bx/+xCR5Xz6K+GVEbHWRxKNEP2hp8MbA== X-Received: by 2002:a05:600c:3b87:b0:425:6bea:8554 with SMTP id 5b1f17b1804b1-4264a44dd7emr27116585e9.27.1720176055057; Fri, 05 Jul 2024 03:40:55 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36789d5ec1csm8680446f8f.37.2024.07.05.03.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:40:54 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 05 Jul 2024 12:40:44 +0200 Subject: [PATCH 1/6] iio: accel: bma400: simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-cleanup-h-iio-v1-1-77114c7e84c5@linaro.org> References: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> In-Reply-To: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> To: Dan Robertson , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Oleksij Rempel , kernel@pengutronix.de Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1335; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=2JNEEDT0yqg0ZpezS+vJkAIFphubIucu2CrwWdLhExA=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmh82t2yoLgw7U/d/3WF1lw6Sbpe0R3WznQ7bXQ zvidEQNGzqJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZofNrQAKCRDBN2bmhouD 18eFD/99kCbJW7rMBIrokTGQp+teP0OMxk9HEiucDrZMQqy964A/H6w6db7bxlu/FqpIge6xQfZ pgShtD2t06mxtvYqI8U7yZJgNkkNoOY8Mzy1NJncQrBuEXHf66NEGrsoMYwpPl31WIGH7LN6EsI Ghx3oPDxEmtAAuHBGsEhdCdDzuartmIyR0WnmgMSBT43VYTwVglMAg0Ep48AuxCZnm4PDQD89zo bPvUgyFgchmkNQEFwAByBkrlygUVTQ+IPLRa2TlVN+gsau951q2k5VgHgWhtzwqk+5uEWLZHYf6 wc6adZUHqX43cgbEfSaINs2Mszebw7ONrWbCMLyJLtJsYEAo/UyDrSk8AwM3CXeCzFjkKUE0gem N4LryYcpQ0eZ+PKKK/2HL50uDBF+MoMhmJQyOrb5MWFCTQ4Yo54ImehbKCayJSNQg6wx+0fE1OY I5KBjLZbj579jh2iLHlCdWNuDwDG6JugmcbLsnJt9D/ZxzDLrGWU3nphOqADk6rOpFUARMuc3ms ZLcIPlDzNFu0ntch5S3pAJ5mSW8zKSv65ZGz4qcHkVlVysAPcs4/pKU2ewf0L4x8LOano98sgKg /Wp5hbOhQDKwhrdvno18IAYmmFh+9K4rLxikmurZbqTx43Y1luTowQ57+5oh4A5yl4L8c6+DW6P 7AiqGyaPLAdiiwA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/iio/accel/bma400_core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c index e90e2f01550a..89db242f06e0 100644 --- a/drivers/iio/accel/bma400_core.c +++ b/drivers/iio/accel/bma400_core.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -795,21 +796,19 @@ static int bma400_enable_steps(struct bma400_data *data, int val) static int bma400_get_steps_reg(struct bma400_data *data, int *val) { - u8 *steps_raw; int ret; - steps_raw = kmalloc(BMA400_STEP_RAW_LEN, GFP_KERNEL); + u8 *steps_raw __free(kfree) = kmalloc(BMA400_STEP_RAW_LEN, GFP_KERNEL); if (!steps_raw) return -ENOMEM; ret = regmap_bulk_read(data->regmap, BMA400_STEP_CNT0_REG, steps_raw, BMA400_STEP_RAW_LEN); - if (ret) { - kfree(steps_raw); + if (ret) return ret; - } + *val = get_unaligned_le24(steps_raw); - kfree(steps_raw); + return IIO_VAL_INT; } From patchwork Fri Jul 5 10:40:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13724919 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84723148848 for ; Fri, 5 Jul 2024 10:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176061; cv=none; b=IVq1mfg+DMD05C9RiUmYCjDR4l99L83ecEDehuSgom+trDnt8EZcrWuJ/Q5eV+mmR3Cm0eS7AmMuz/IaW4YCqXJQFFN0qShwYSiqw+t8QSg4m3sEfInzk/u+abw3UEB7CNKoBPEoMlN0clK8Rk9naMf5xIo+Qp4GcpPUiRBKdUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176061; c=relaxed/simple; bh=QARo7BUFibdiwmopTR5ANV4tiDr14JhYaFByIK5Byzw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=C4qH9MuWh9Ub5zjRpj6Rx2YosJ2J6ft9hV0MsS1lSjDj1xxh9KoBo8hHhzsVlHk7DQpfzRL6dLUjs5UEVpIuOYWDiFaQ7ZvKRYEwBIDZjYZbh29CJ5+kBTpMB1yDI0N4VeqTI//HT+TbQ4NjceOGQvEZuu+dkXW0U8RBaj0u/f0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=OkPR04q3; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OkPR04q3" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-52e9c55febcso1950419e87.2 for ; Fri, 05 Jul 2024 03:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720176057; x=1720780857; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1eXR3A0Apjdz/ufMLdA1641K3n5tF+YJ5/SI81Vd25s=; b=OkPR04q3uzKpLOs1blTtyQ6XFY/LmLXMEOvahGuwDm8A7XlIyzjibpMQildKXWVIy0 TMFG/L7V94LlFSoNkU4SU02dmn753XhqCnSAjx7ilmhbt1LFCrE4dyGanMB+mJq3cWz8 ayGdqzfSuxipg2RUA75qr44z0U7J3MEVPhBIGD8O8Cwq43lV9RMVf+kGsvprzIGrQ5Pb OvNn6lYldJaQo0xAF/PFKaQ78ul8Zz+9xr23VeoXXLDdeLDa9jai7R2NJGsacepGGrG2 p845++lBETRX7Dt5CLKCjMMTkwCVGEaOMJ26LHVMrXzQuepj70R5kfpkwYxB0IA3aq78 onwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176057; x=1720780857; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1eXR3A0Apjdz/ufMLdA1641K3n5tF+YJ5/SI81Vd25s=; b=uP60NWSFbDDdrvsiJoQjk1m3iRc+jZ86RQZ1oZEtZ3dUEnLTzNtnPL92MaVFtH4Do0 2oQ63MaC26TMfbMjerFS7st6czcp93VwCaAy228dwIOPkakMHQf7HkEY4Nyg2wcefc8N 0ek0/LPfHknHxnUP0FBj6yExATf5EZ4/vxhqaFoxe2xbcia3n5a3L22PS3g6IzJcLYN7 YCw/CDa3b3zdXDuAN5HF0SrUG1bqu8YLoyJwHS8Z5GgNulfnFt1L1Qt+J+oSh6hMZd1J BFZCfMHF4jJGCVAqyidAFZJdIPr2utEKalVrx07gvCL4xREhi9GnnZKxVeEbLOQWkr9c j+sg== X-Gm-Message-State: AOJu0YzexoRWSA9/RvLfb38YS2D2yVYX03Vk/knSOrlH0U4o3QhkbHAT b2OvTnd+w6AKjohUaW07md+oxsp6d0IkHvX7Cy8ZtYB/0ojlQ2k8AUOqe1+XyW0= X-Google-Smtp-Source: AGHT+IEuhBIHVHatXqi8z2wyYNIT9Lh+Ls2S9+zIz61+j9staS9hXEuX+FfBkFJ8fOmyILywkwPT4Q== X-Received: by 2002:ac2:5e6a:0:b0:52e:9b92:4999 with SMTP id 2adb3069b0e04-52ea0636e2fmr2584439e87.2.1720176056640; Fri, 05 Jul 2024 03:40:56 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36789d5ec1csm8680446f8f.37.2024.07.05.03.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:40:55 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 05 Jul 2024 12:40:45 +0200 Subject: [PATCH 2/6] iio: adc: ad7280a: simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-cleanup-h-iio-v1-2-77114c7e84c5@linaro.org> References: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> In-Reply-To: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> To: Dan Robertson , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Oleksij Rempel , kernel@pengutronix.de Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1441; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=QARo7BUFibdiwmopTR5ANV4tiDr14JhYaFByIK5Byzw=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmh82uDOsWBkZE1MS94UeFMZdoWUjtORN8+1Oef iInuGL8Z3eJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZofNrgAKCRDBN2bmhouD 11beD/98CTFr2lTq/EVP4vRTt2IiXlvOrBvBMcJmJPzXzLJ8bIkeaqjo06OJLaIDRQZYBNPnVuh iCB2ROEzC7zxYyVsUR/0PLtX3CUYblcKXaJRB2eUx5EnKv2muKesTT1f8imdJLzkdd+yt5A/pqZ ttpJvI70vmv7h0XO0Lu+kjHrXA3dtkGsRIfvIKaFNs261+GuLAKylmm89b7TraS72nPGqu103En iaTXldI75WXk97F7pU5M8adFpOoZ4BjRUtjgvY7nfQOzJ+dGhFcyLRPg187QTHs1SiYEaIIRZCl kozqwrmXIU3ST2+IfKoCE609dvgGWzi43Aq9g3nHvV3JmXdo9WjXbER/iQlSDIHx6L69gUYlD14 WsrYJX3w8jqpNmeXQY6z2RBjMRMJu6lrrETwaTNlpbBp3bnXPyKqsuOAwSP9k8o/orNrGU1goof R7znoCoTfOU+/wFgaBKBWhvGMiTZhSiAJf8Ai0TQ04VuEBYYOUik4LBgaDyf5UziepsKEbPw2FP IrYwDIvRTRujbE096pInBQS5Qg9tu7N5ZYXPy8zFL/d+qotPVgUmSr1q3yH5a59Bid6jgB6hvmc 6DsuaNdFpC1fBtjgUFZ9viCxxX80G7AFRkWHz1LEYU9RgLeQRecmLe9LBr4K6XyMoG2J0n+HOnv EtHG2o0AIPzSVRg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Nuno Sa --- drivers/iio/adc/ad7280a.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/ad7280a.c b/drivers/iio/adc/ad7280a.c index d4a4e15c8244..7bfa090da4df 100644 --- a/drivers/iio/adc/ad7280a.c +++ b/drivers/iio/adc/ad7280a.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -803,16 +804,16 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) { struct iio_dev *indio_dev = private; struct ad7280_state *st = iio_priv(indio_dev); - unsigned int *channels; int i, ret; - channels = kcalloc(st->scan_cnt, sizeof(*channels), GFP_KERNEL); + unsigned int *channels __free(kfree) = kcalloc(st->scan_cnt, sizeof(*channels), + GFP_KERNEL); if (!channels) return IRQ_HANDLED; ret = ad7280_read_all_channels(st, st->scan_cnt, channels); if (ret < 0) - goto out; + return IRQ_HANDLED; for (i = 0; i < st->scan_cnt; i++) { unsigned int val; @@ -852,9 +853,6 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) } } -out: - kfree(channels); - return IRQ_HANDLED; } From patchwork Fri Jul 5 10:40:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13724918 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8D3E149002 for ; Fri, 5 Jul 2024 10:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176061; cv=none; b=S+/f1dGI+fihn/RBCWgXFcWW8dnA7Jfq2rOg57/Uty4Zkoo93Yuoh7IzAMlQ4VA/wXv9zwr+sOZt+A953vfdQD9mcDi0v6LqTSrfviDh+CafPJOiOpIvenz2ph3JQO6CB/7yRUia9QCMp5Lq4dgnaoVB3TPbEbCToZk0KbhKilI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176061; c=relaxed/simple; bh=p8oWdKJIvI/s9h6AmtHd1y9/mEFkDnWkbWLkspoDv58=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z4RdQt6ZMG9OLWmeqxCOK1uD9TU+6tvliWmVb/dgTTZx+mbmwKapaZdf25eogd6RSh/DRntoJMw1hAnvEIWlE0xR542Gejcl+QiTYh4Z5F2PADB0ta6E9i4Jqlvk1pMaegKQvUyljWhofYnw3fHLYxf1729dGBmiS5ATclQyH4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Tog5x2NA; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Tog5x2NA" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-367ab50a07aso298494f8f.0 for ; Fri, 05 Jul 2024 03:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720176058; x=1720780858; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=O7oWBhtqk3xwW6JyxZwaMMLkFEk7F/Zbtq+Lnku9XgY=; b=Tog5x2NALYnHmcso3U533v4FSLGzHqEAnqN58d4BAiyJ9nIqu/fHU+mB1lD5H7ItwI icFR9v4oCU/5AYdnK51IV02LciYmeyE2ipYaa69XFntMOz4RFBlZOVF2RNxx88nj65/C L0ssJOPV0JQqGgaa6iL3/u/Z5yQ3r7mvuwyBdREkey79Ib56JpiNMkuFrYbtjFspe1k0 S0610MV+Pe/wSjbmF+QGjFcxBuylRLiqQ2epkanC51bU904zEl/tP/zAP69b0OdpfNM9 MDGO5BRG1zecXl5FWavpgP75IIp4rKgBaS25nHWUoDmuYjF4QU377jVrCDmzlTZbAln9 eNcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176058; x=1720780858; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O7oWBhtqk3xwW6JyxZwaMMLkFEk7F/Zbtq+Lnku9XgY=; b=tRTUJfp+4BFVQE4zx9BNbz3mpq1WMfViRuZDnsrEdqqR/O1pmnfmsEclgNGOKG7sYM wzF3hhEZi1i2yduJZhdr77AfXt/svOszM2OttcAGpNXrpF1eFWBKTtsHYMd8pXIcgKRQ ezR7cAqKIw4c3Efzy9qnQ5vyhrwgC13D6Bm7REftUEmQ6JQKQzDa3hdBIN1QECQyCfEo Jr+StxsVY0TWB6hhPeJCSQgXj798dypjDJwGjkk3T/1rChoTFc98cpUqPykSi0gjSHNA cGFQLjY2btHE05USwTWesMAYdHrsYuFJNIWgkBDM87bEjHn7hqlqTdT2VkRSDFDw3hN6 LrAQ== X-Gm-Message-State: AOJu0YwS00xPZFSbgv9dlWrLX8y2kJR8LnkERk9pm6EvhV6YoXGn128y o7sTaykBLu3Clv2FH12CClOeSbYji4hvm8O5NbXn8hxai7lHROdg2TA/mm/XItM= X-Google-Smtp-Source: AGHT+IHPMMzu5kdlcoZYnKj2xBCDHrdAzNmKY1tb0qjEiMJJj0RsjyKrxPl+gMGzYZqJroN4prirIQ== X-Received: by 2002:adf:e68a:0:b0:35f:11c5:5c74 with SMTP id ffacd0b85a97d-3679dd34d4bmr3095033f8f.36.1720176058373; Fri, 05 Jul 2024 03:40:58 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36789d5ec1csm8680446f8f.37.2024.07.05.03.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:40:57 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 05 Jul 2024 12:40:46 +0200 Subject: [PATCH 3/6] iio: adc: at91: simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-cleanup-h-iio-v1-3-77114c7e84c5@linaro.org> References: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> In-Reply-To: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> To: Dan Robertson , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Oleksij Rempel , kernel@pengutronix.de Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1335; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=p8oWdKJIvI/s9h6AmtHd1y9/mEFkDnWkbWLkspoDv58=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmh82v0r6Jh34sMwY1mn3FW86/CEhm6tM4W7RnL uiEVj4Vr+mJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZofNrwAKCRDBN2bmhouD 1/3TD/9Na/SvzzL4bKKGkbGVC3TdFpp+yHgCyH52qQr8o7KQlHBEJKaH1jYv9NZmWAfRjEp/6WM DX8l8spwS2QfhfjRD61w2RJxeNHKpMOhfRUVIL3iBAHrwDkv2wUlIi6iYH421pgx8LKaMK7Oadh ZI8wacXDVGz0RHyrdOt5dYKeE/bzhdXMc6PD3z/VfdipVRtAkyUqdkqaof9EW1cm24JddMncVl7 GgUa2VE6T9e59sqS3YfaM3QfvlZsxRdPFfGHba5PyoE4dUv0ppeTyKzWouv9GySZayvSnNVDQmd Sncvw4nm/LyKQKKIpLpjRv6t8r4aKWGastRB8/Xkq/6CaeR9geqf8/cepA6LiNsd5XqtTMgyCy0 x/tyceFDPl7QQaZXKGuD4CbscN2FxQyZYNsxx1YGEopceTWnUa09mmhHCGKCnCJplvXIlHGa2F+ fHZj0Z9dGL0kS8rP5ZdeEAZ+213jyU+fzDu9kapEegaH/3ycs+i/+6roOFLOONLTdJi3kbfykKl HwM/9WrCzw2ruPd5Kx1vu51mz7IU9QgbsKj9QqfhRRoxvK/9bKdWhvOLBSkz4ofs8CbE1zpJSFi eiARICHKU25nhyGaKKZUWQRdrUnt1N6n1Z5Xv7340vFdMMvK5C58k/NoPAoimRL1HlKPrF7Pery tEe0GOCnirntzpw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/iio/adc/at91_adc.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index eb501e3c86a5..7bcda203436b 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -543,22 +544,18 @@ static int at91_adc_get_trigger_value_by_name(struct iio_dev *idev, int i; for (i = 0; i < st->caps->trigger_number; i++) { - char *name = kasprintf(GFP_KERNEL, - "%s-dev%d-%s", - idev->name, - iio_device_id(idev), - triggers[i].name); + char *name __free(kfree) = kasprintf(GFP_KERNEL, "%s-dev%d-%s", + idev->name, + iio_device_id(idev), + triggers[i].name); if (!name) return -ENOMEM; if (strcmp(trigger_name, name) == 0) { - kfree(name); if (triggers[i].value == 0) return -EINVAL; return triggers[i].value; } - - kfree(name); } return -EINVAL; From patchwork Fri Jul 5 10:40:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13724920 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 948051494CB for ; Fri, 5 Jul 2024 10:41:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176063; cv=none; b=G/h0wgJrHaEi4IM8bLbB4g5W4Z5mca1EeKEy7/J1zAdh+N5I3va79Ln91A2t3tXJYXbVMCFj6JpvUUcGhQC1r8Gx5yuomlKITXXqGpCm9baUABolcG+cWDnYmeXt9HGf5hpX89/mpdTYbTTSlWj6uZP0T3W5M42EVtirLUn8dHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176063; c=relaxed/simple; bh=8UqNvu97RyQCvnTqNuJYZZnXKv3X2QTRkCh8H7bl7SE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kw9X38jM2bp/5qoQQlI3KNmi+EjoG9H70cl1WoZHEJKrisMRjHqdWs6xa98t9Lkawa67Pdp0Fzx1cxklLQgqhpEbLJ0VbNcUIYj93IkusYDX3SwzCX4VPHszIaADuXZHXbNNhOABp9o5l5CLhpl0cOLa8kMQgEhbTJ4daUPIBgE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SiNH4KMn; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SiNH4KMn" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4257a390a4eso10186365e9.0 for ; Fri, 05 Jul 2024 03:41:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720176060; x=1720780860; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=oTC/Azk6QuGeCqi4nXZfSzWiS7YtP2rKGZn+knA+oxU=; b=SiNH4KMn4/W5UrURy7iRNUkdTW2nR5pQCry48i/9dBH7GJkCZ3j7SdyRGMW1LA+Ha3 yReU965Z1p6/GedPT4OihCuesExJ5oz9dQ5KkJn9DDuB6fS22zQWXNJwhQc8r/t4nJ0q FE2eqLGzzyQXHH4nJemhfE59CFJCEORiAmNgaG0Dlnq9YPR/PE2pRQtfHWo4CKj2pown soUmsoctNudhR6ShYXhtLRY12w1TSKEuFgyvETa2w+V/yZ0APgYbKNcK+gCCHkZ1kT70 uZkt26mFOX2lYrqL1HkB+yTKIXKjpZ+nJpZrX/o7SXr5QMcQMjHYkv13eDvTjN8lfZSl fhXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176060; x=1720780860; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oTC/Azk6QuGeCqi4nXZfSzWiS7YtP2rKGZn+knA+oxU=; b=VBKCOjfH8gqBvR9cKLr6Kt6rfx616YIk4z1Rj2LAnxjja7pqS+B6Wut+NLW1Tiz6RF 7Ph+nJs9NoSsu9CJ/slAHmu82UXaDKh03WtcsJxwCqv3QI7aKt3TNQB7gy33iZtUj7EF hPm4pR9sta6y7mQ1HMQedBiSJYO4aqF1vE1Hc4g8EzAK4PxZuqR9DdAeKm93uMdagOFy AwgTjCP2HXA4JduwaV0bk7RxgJqU1aHLeD1pS4hnOSuyBNjzeEQGss/rYxGnlLWu6j+O wCbWOSOiHzwomFNpRy6Y9t7tPIKtxMHqzIO6n1mqdsZDR3c1hP5wmc6Na5O52STZN3uz nX2g== X-Gm-Message-State: AOJu0Yw+ZDJCrOy6Kbh6rQrIh8EhDEYD9Zzdujed3VyFQWgVx7mh3/sF ye9pCzVq7gmonOUccr5dEMXmSDBMoXcLRwtMtJGDOsIfrD6odJsi5iF8D5kS+BXJTPP/Sfgufoi z X-Google-Smtp-Source: AGHT+IFpPHqmjxp2CPDg1mV84p7LQ3rhp2DLU/4rV2/xi9+XlRjQpCs244ba3YRg8O8NY0lubgaIhw== X-Received: by 2002:adf:f7d1:0:b0:366:eade:bfbb with SMTP id ffacd0b85a97d-3679dd651ddmr2544484f8f.46.1720176060011; Fri, 05 Jul 2024 03:41:00 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36789d5ec1csm8680446f8f.37.2024.07.05.03.40.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:40:59 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 05 Jul 2024 12:40:47 +0200 Subject: [PATCH 4/6] iio: adc: max1363: simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-cleanup-h-iio-v1-4-77114c7e84c5@linaro.org> References: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> In-Reply-To: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> To: Dan Robertson , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Oleksij Rempel , kernel@pengutronix.de Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2264; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=8UqNvu97RyQCvnTqNuJYZZnXKv3X2QTRkCh8H7bl7SE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmh82wGqZAMadIz1XR5aj+8tdWoDISp1r2Kw1oO rXfx9a4AMKJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZofNsAAKCRDBN2bmhouD 16lzD/9AhnxwXv5OrwJjGIWy8uU3qbq+Ay+EYJfL4l7G5eN2ahNnoKc2trvkQGgIk4WpPVAl/We GkkGk91bFiIseEUezi8Pq2WkeJE4jah4gZ1ygbkxeSoKAVnlO+SAGNANz7jDm41gc/Cdxfb7gfw RoxJrHybC9EUzc/Snj1m8vWzWcqbw6cMpbaZwsYGNA3hOxzdM41aC0zySf1oV/XpDuUoaAfthbA M0YWsOzOt987EMMYpFobfLLz9XC3M6CZ3vX4dvm/RRnGqtwg99piq5uPgVHV0lSgCi8EfyJLSZN zejEnA1hsYNUX8M22MABU7/A5LHcKcuT54Qm2bqIBl0vV4VqDMnHp1QcTyiVAG9TVcbk4ikpMCM iSd3V+bj1cxn2zQfR8C+UxzTzHX92pK5G0YYcL8x4MFdemOQ6VN0Icb46+2qHYmirioczwvybFJ 500larK7cxtaZ75pdWVz0Snsfwk6C7wcsPY7n1gf0NZOG14tx2Cc5K6LyWNsfoB9xFndwAAKiUJ WETcQ86+nEMU0vwIPBMsPc30EF36mLPmM1ImODNcM9VXC5Myq5luyWftG3KqH+BJXoGGg/KYA8+ rs9rV6DqNRDyFhplpy3WFo7+5A//cOVA98Oo548YWTh2Qgmbe/ynrm7kVPK6pVp6ACc5YkeH/sx FBbXnIJipqkVO6g== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Nuno Sa --- drivers/iio/adc/max1363.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index bf4b6dc53fd2..d0c6e94f7204 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -818,7 +819,6 @@ static int max1363_read_event_config(struct iio_dev *indio_dev, static int max1363_monitor_mode_update(struct max1363_state *st, int enabled) { - u8 *tx_buf; int ret, i = 3, j; unsigned long numelements; int len; @@ -850,11 +850,10 @@ static int max1363_monitor_mode_update(struct max1363_state *st, int enabled) } numelements = bitmap_weight(modemask, MAX1363_MAX_CHANNELS); len = 3 * numelements + 3; - tx_buf = kmalloc(len, GFP_KERNEL); - if (!tx_buf) { - ret = -ENOMEM; - goto error_ret; - } + u8 *tx_buf __free(kfree) = kmalloc(len, GFP_KERNEL); + if (!tx_buf) + return -ENOMEM; + tx_buf[0] = st->configbyte; tx_buf[1] = st->setupbyte; tx_buf[2] = (st->monitor_speed << 1); @@ -893,11 +892,9 @@ static int max1363_monitor_mode_update(struct max1363_state *st, int enabled) ret = st->send(st->client, tx_buf, len); if (ret < 0) - goto error_ret; - if (ret != len) { - ret = -EIO; - goto error_ret; - } + return ret; + if (ret != len) + return -EIO; /* * Now that we hopefully have sensible thresholds in place it is @@ -910,18 +907,13 @@ static int max1363_monitor_mode_update(struct max1363_state *st, int enabled) tx_buf[1] = MAX1363_MON_INT_ENABLE | (st->monitor_speed << 1) | 0xF0; ret = st->send(st->client, tx_buf, 2); if (ret < 0) - goto error_ret; - if (ret != 2) { - ret = -EIO; - goto error_ret; - } - ret = 0; + return ret; + if (ret != 2) + return -EIO; + st->monitor_on = true; -error_ret: - kfree(tx_buf); - - return ret; + return 0; } /* From patchwork Fri Jul 5 10:40:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13724921 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33E73149C61 for ; Fri, 5 Jul 2024 10:41:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176064; cv=none; b=YoCrtNPkdQ0JQPJ2/Pf5W051ZiA37cZu4QZkK+RlsaQD5zYggIvq2Cfh9V91tcoFq8nWMVmORHnr3qL+qdcnqyGjIu0kdRVfWThsMu98a0KHC1Idzu2f9FQb2bnIL35Xj35mPA65+9RXjufVFJd9kG0iirb+rRSTzlRS+GgMjHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176064; c=relaxed/simple; bh=Q9zojN0lSJs1YYfBNhUpVI/gmwKKpCb9hKgz9Y0tOzs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OGIM6vLkQxMUZbhAl1Ps/EuCRHdVkwnaaNYO+XQ8bzB41MFSZ+qpXogA+MvcS5ZuXw88Phz2FE09lvihP4HV4Htc67J/2B1lHoXcJU1jLiKGsXIgAsugNNNEOoKCt446wKj25wBr0qEatRq5CslbIuMDQ0C+9mmp5BcVTWqewH8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=S+B9waix; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="S+B9waix" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-42562a984d3so9976435e9.3 for ; Fri, 05 Jul 2024 03:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720176062; x=1720780862; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=BhWBPupwX+ZV/PG2cNtfNm2papiU6MGLdZkiMCHlF1s=; b=S+B9waixOtlwy3W2Nfl9Gw3htcDuSzJe0Is25UDUQJmYLAx67pF/b3ow5QtbksHgqH 9NwFc3VOBmBd5Ln8W/Q+819nQcmoGd5/6l/9/lah5N3z4Id0HibendrmsZBBe/0GvsCz LnV9pPcxZkNxyIV0YyIsp7HxwjZOZJ3YvW3BxxW8EYetGTHxq6M3e9Jba3Pq8eTQeYmq sVC9NdiY8CY2vinXjerH9Or4pTRsyf1yj13uW8Xv0CVhVb2kYJWn3BSLUgZFTLGChVjT ABbcSgxsH8nMHIH6UB13bj/l8RoLTN6o6vfatlm7JFoGYDigKR9vN96gsA3VsCt7y0wz 761A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176062; x=1720780862; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BhWBPupwX+ZV/PG2cNtfNm2papiU6MGLdZkiMCHlF1s=; b=mKZ0WptCl6T4wtIfzNlXnp8rvKB0SJfSj1yXAbiV2gksE34f6OjnveqcKBN8rQpiio wY5FvA43WvLsdrT3KiD7qC0d6xq3lh30RXMUXolobRahZDsPY1YVEyIrAR0Q2RiO14b4 KnFXlWa/0SPwsJ+fvikq4tCQBRmmG2K+v8JFlxIcu97IBCPJBLIPXRi135r8oivXU/dp 8ghV+ke93e+NIQBiIc89F37Z7DMrdIhuatzB47h4k4dGa+9XwXlP2hwSxv7M4xqk7KMS Rmh9k8mjwcoyeXhTppDsyG9B4JKy69kOakUMC/6b6bZRGOEdO/g+3jR76SoWxDWqOinx jtsA== X-Gm-Message-State: AOJu0YyKtnN1Ro6aidrXC/IP+YS3HWAO0Ta53W3kf1Zzp0BEhXOZleLN WlcrkVnNS0AOvZcO3NcOjTOnjt3IUCataQtw70wLt9nh/iNcEBv4QjuUrtrSsTA= X-Google-Smtp-Source: AGHT+IGsdaXR6rm0bitoeZHc34IGbosRLdkp7efd1biuK+GLd9lJQp9j0A7j0UvRmz0KfTlDkj8IXw== X-Received: by 2002:a5d:5045:0:b0:367:437f:177f with SMTP id ffacd0b85a97d-3679dd66ce7mr3019783f8f.55.1720176061775; Fri, 05 Jul 2024 03:41:01 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36789d5ec1csm8680446f8f.37.2024.07.05.03.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:41:01 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 05 Jul 2024 12:40:48 +0200 Subject: [PATCH 5/6] iio: adc: ti-tsc2046: simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-cleanup-h-iio-v1-5-77114c7e84c5@linaro.org> References: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> In-Reply-To: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> To: Dan Robertson , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Oleksij Rempel , kernel@pengutronix.de Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2566; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Q9zojN0lSJs1YYfBNhUpVI/gmwKKpCb9hKgz9Y0tOzs=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmh82xNTfAtLA3fFZQMr0Dq/c0vYqvqV7SsUlId 1rAnYusAfCJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZofNsQAKCRDBN2bmhouD 1+3fD/4sL/hhE1j5QMAxUYCzRGwqWbEQgfb3K7Uxn0NF7P0KlpULd+VsUVPo6hmvCmr24t6u21V xyuEaFBs4lFfKmOcJnLwAK+94+RwJ8ovC58O1sy3PGFiK9dNUXg/sMoYdU1LHPxGKSZkMFsZL3H XwsH7cCrp2kbN3S7qnpZhNZSsCJ3L7MMrPq3AxlDkc6whTwU30ykFeYBKC0ZgsSMVv6Vcl82N/B UpMdwksfdG9cGQ3NSJJngRM66Y653oTBCntzx/v5PJREsi/r7OgumHoWP1quy6zz/5j4JCu+3q3 8KEcxWohPAYEHyWBQ0oONbSSS++/Lm7C2v1MGer++Smb3MRL8lz8CPo4CmcN2R8aI8Av9GlLyDu KUTmN/QPl/pzMbAhdNPcx1d0aWV8Q5OZXwYUWK/cMpxsNAxz+Idogn54oYXUBTusHAZmOpFhnl9 ZmeydR7PZWiycGVwSygPMl/sI3/zKAOChwqDB/ZxcffM+hQzZe9tbU3RWLcgERasVQ2pwM+wTsq rWrakRDR7p9B3zDqWAfcWa5GUrtS6JAMQ2bOaCBkk9467AmSPZL7FCcyoW5uvSsFsd/w77UISWs kwp5AaeOy2m12nZ8kbWnf17pxeQPo4NYnRG9rPKq/SWjS+FjyEG/lu5ZL0gicUgObX8+CSljs+p N+CmDnovJrdSSbQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Oleksij Rempel --- drivers/iio/adc/ti-tsc2046.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/iio/adc/ti-tsc2046.c b/drivers/iio/adc/ti-tsc2046.c index edcef8f11522..24b1d4390872 100644 --- a/drivers/iio/adc/ti-tsc2046.c +++ b/drivers/iio/adc/ti-tsc2046.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -273,7 +274,6 @@ static int tsc2046_adc_read_one(struct tsc2046_adc_priv *priv, int ch_idx, u32 *effective_speed_hz) { struct tsc2046_adc_ch_cfg *ch = &priv->ch_cfg[ch_idx]; - struct tsc2046_adc_atom *rx_buf, *tx_buf; unsigned int val, val_normalized = 0; int ret, i, count_skip = 0, max_count; struct spi_transfer xfer; @@ -287,18 +287,20 @@ static int tsc2046_adc_read_one(struct tsc2046_adc_priv *priv, int ch_idx, max_count = 1; } - if (sizeof(*tx_buf) * max_count > PAGE_SIZE) + if (sizeof(struct tsc2046_adc_atom) * max_count > PAGE_SIZE) return -ENOSPC; - tx_buf = kcalloc(max_count, sizeof(*tx_buf), GFP_KERNEL); + struct tsc2046_adc_atom *tx_buf __free(kfree) = kcalloc(max_count, + sizeof(*tx_buf), + GFP_KERNEL); if (!tx_buf) return -ENOMEM; - rx_buf = kcalloc(max_count, sizeof(*rx_buf), GFP_KERNEL); - if (!rx_buf) { - ret = -ENOMEM; - goto free_tx; - } + struct tsc2046_adc_atom *rx_buf __free(kfree) = kcalloc(max_count, + sizeof(*rx_buf), + GFP_KERNEL); + if (!rx_buf) + return -ENOMEM; /* * Do not enable automatic power down on working samples. Otherwise the @@ -326,7 +328,7 @@ static int tsc2046_adc_read_one(struct tsc2046_adc_priv *priv, int ch_idx, if (ret) { dev_err_ratelimited(&priv->spi->dev, "SPI transfer failed %pe\n", ERR_PTR(ret)); - goto free_bufs; + return ret; } if (effective_speed_hz) @@ -337,14 +339,7 @@ static int tsc2046_adc_read_one(struct tsc2046_adc_priv *priv, int ch_idx, val_normalized += val; } - ret = DIV_ROUND_UP(val_normalized, max_count - count_skip); - -free_bufs: - kfree(rx_buf); -free_tx: - kfree(tx_buf); - - return ret; + return DIV_ROUND_UP(val_normalized, max_count - count_skip); } static size_t tsc2046_adc_group_set_layout(struct tsc2046_adc_priv *priv, From patchwork Fri Jul 5 10:40:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13724922 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2054149E0A for ; Fri, 5 Jul 2024 10:41:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176066; cv=none; b=sn8GuoT7K91UTihlu/Exle6UVcyF8d/W19sGgf0G5v9QZoIu4jHJ77ZyqoXelh1I1m7+bj24sJubU5oHBEO+X/yl4xPK1sulkBE1CMv0Y/iT555iKB4WN59eN3U8VlEvIB2SB5dHYxq2BsESz5FV+6pNgHL9ULgd1Q94Uw8P1j0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176066; c=relaxed/simple; bh=wAVpbgQ5bIpyCcGTaGFP8RLhuVeOqnrOwZ6oTfnW4nw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jRCXAyON5JVtriL8iXNywUsdzd+UDMwz9+5rTbYqkSuCOZAqMPTAK/FXidb9xAk8gAf/Rqt+MCWDuwewwbIVMME2Lx3v1cZbqDRuwmXmGacuo6tYejaOnSmFp8bigX8khBtxcXCTktYgns+TrE/dc+pxkO9n75Ie6Fzxel7QJCI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=e2j88sPp; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="e2j88sPp" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-36799fb93baso1012945f8f.0 for ; Fri, 05 Jul 2024 03:41:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720176063; x=1720780863; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=z9Np41486ZPQDGlzQweAJezAFo0bzffLP3y8AkeihYA=; b=e2j88sPpT2RQ3VOX7GWnDTllKD8AuIuBchKRXPZ0jGzcDtmZFcYknABYUolITP0BqK fIg4mi55vzxGNBqxRcupDh3ezgn7QIdZJp/dFB3w/n9W31YoaGTlVb74G//4Bir/eNsg K1j3TbeP4JAo1npaszj39xZHDQKwg+KULfHnfjlFYN2iLAenDglkHkJXveZES7QJzw8f tBqn6xGTzgTR9f+XB3lMVCg153w0WMHJ4TX/YZUk5WnYryjo1IgreC32zARESyynC9tf aiFHw6EbwFfxYE0aAVrNOQkUziBq2HKpo7iAje6lPSWrlmc1XbfCAzmH8yWS/PKTCvL6 5DHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176063; x=1720780863; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z9Np41486ZPQDGlzQweAJezAFo0bzffLP3y8AkeihYA=; b=pTcBNvVbIiuLOD9w0Ab6gPjHbN3lviobj2rhywBubIA/Nh0iZZ53CjP3pJRc4Th6xt tfea6pTdm53WnX6UbYApoA2Qth2nXINbkmtxbs8sf4AQEr5IPW/7InLJ6AigD/thMTUW sO3oLrtqU9lzsw6vIEFMEmtzjL+f1ibC8qvgUIwEgBITckDpLcaEvaX5lr7ZkvEfgvEK CJa40hBlbSQ3QefxGooEdlnKG16oSM4mhr/fkKVU2I/xl29MbxFdeekOsW0qsyqP3NMT ebsaoPs6/Np5tsn4iWelvr5ZsFgihNJa1RjUyAGHBWtRbQYtlKcBYGl83I20vzNIiW2Q IrPQ== X-Gm-Message-State: AOJu0Yy80UJMHFaoaSIiHSA27t2e9/W7i24puKVjf5B1ewfNsOm1TlEl J/NnnNaNmdd3MeqwncSzGxOLuJTYXTnUDNrz4cBPt+DUq84R0/06D15NfIiI43g= X-Google-Smtp-Source: AGHT+IGJmF2yz6CclwNaZobfkh+KzmhezsSI6pZ1+CVEOHBJkhN00D9Q5QVyJPreYMVR2oHvYBqtxQ== X-Received: by 2002:a5d:6849:0:b0:367:9614:fb99 with SMTP id ffacd0b85a97d-3679dd31137mr2795078f8f.10.1720176063285; Fri, 05 Jul 2024 03:41:03 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36789d5ec1csm8680446f8f.37.2024.07.05.03.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:41:02 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 05 Jul 2024 12:40:49 +0200 Subject: [PATCH 6/6] iio: adc: ad5755: drop redundant devm_kfree() Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-cleanup-h-iio-v1-6-77114c7e84c5@linaro.org> References: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> In-Reply-To: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> To: Dan Robertson , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Oleksij Rempel , kernel@pengutronix.de Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=661; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=wAVpbgQ5bIpyCcGTaGFP8RLhuVeOqnrOwZ6oTfnW4nw=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmh82yqE4WDfmxPDBzauwZ3Iq6vku5GtvtWvYVd MK7kTqYSIKJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZofNsgAKCRDBN2bmhouD 1+4WD/0QMoTcaJIkRnw0sl/FKPn/9xu4+bNaTVtxm3Oxvxf02oev5VhaxB/RJzKUopuc9Cv9TPc t5V+qudWwmVC3/6vIMZGISLvYkNkpTBIg7SZs74tbZ//7NGVeYfC8s4ev8SJ9r5X3TvMgihmu32 JDEMyQ0+klT275tvSKA+cYiaBmUDRGolzvO+uLc/ZMTdTrBOvajCSrjP1LNCSNVaCX7uc4gvXQ0 I6VGNMb1glQMD+CqNQQ2/7wHcctG/vqmmMneeln6lYioC3njEV2NVJ7txWExIB3w4NhMQWyIswZ QzPh1o70THWr0Hv7KhbeC6o3777jFBthV8k66WA9cybDPF6SuNwzyFOAIhyuFrBv8q+NxhVeTDr +MUCHc90reVhXMlmtSxpU5I0apW01OHOThkXoKs6GE6/10879YqP4xAcpZYW1hIH52q4dsxmSzh 2J0fts9TPugTQvZO1IU4U4i/1Sk8N/WbyjCzbCuNgjsRXigEtrDALzXboSrFCr4LEijx8y/t8OQ EeYHwqDY8qrVPGVsRCTIg2XARx/A/0pC5G5CEB7vHDQ2IKCDSQ0Bs1f6bSgGXhNI6x5QFVg8Z94 zbF2g56BKULxngx2n4TgUEXShv3yzJR5xRh8rRncc0BIluerLglDleXmovbT3iCGLf4g/nWp/kE gfF4RCMThWVj7tQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B The driver calls ad5755_parse_fw() only from probe() function, so devm_kfree() during error path is not necessary and only makes code weirder. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Nuno Sa --- drivers/iio/dac/ad5755.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index 0b24cb19ac9d..bfbfc3c1b6a5 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c @@ -803,7 +803,6 @@ static struct ad5755_platform_data *ad5755_parse_fw(struct device *dev) error_out: fwnode_handle_put(pp); - devm_kfree(dev, pdata); return NULL; }