From nobody Mon Feb 9 12:45:40 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 ACC52148304 for ; Fri, 5 Jul 2024 10:40:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176059; cv=none; b=U0Flp1410LrDtp2b5v0d5ckE/hwDV6RE3I0jhL0gmI6bf7P/9+Q6jP3eKgxB9wtjz9ofxmJgMjnbre7kQZm6gPuB4iruQPrHf4qE+9rHxRwhrSMBs/m47XW1BQjE1tw2ARJ94vjruo7WWg1I16Uw53LmzEBr7a9flDW5GoqA2aw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176059; c=relaxed/simple; bh=2JNEEDT0yqg0ZpezS+vJkAIFphubIucu2CrwWdLhExA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R9Sq5jlPiSLgKfbRHgt0Zmqny77JuE8CHlRo4s0mU0vcWP7Y8xdWp3QLuIJCIpmUlwUM40KH4fnHI2bq2d709j8gGYCPpLcIH62iocUhY1RBdXrqHX8pWU65D17iwXVNU66Smjhj+07SFWVAdQQO6s4z2CINJTP470RAg48dae8= 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.45 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-f45.google.com with SMTP id 5b1f17b1804b1-4265921b0f6so1733275e9.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=hAZCTx4yi4SzpryWn2p6sPQW2V2zkFMRVhYkPpilkLh+gEH107Wpo6nqlraJQ0firV bbq7CpEJHi/SLiRF8GGpWKz5CpT44dqUeM636CtV56JxSAcd9VNd6ARKKbIJT1dW53ip I0SYmWwoqGz2f6G1kEyjB6VuBJuHKPYuIt9Xv6GXWs6xdS+gxNQL63WbwFw6/nPTpe4w 4Ds8BYaQFq16g7gsjiu3euFHOGY+wMlh7LbVcQEJNJFCbpIW1ExAwcBMkJur0F1pRTd2 cmAGBjWsLUfYrzFtqRb/BRVjfLCQLw707oVUfvSe8PAEGb71lj9Mh5Qos1KsyUdufteR +YYA== X-Forwarded-Encrypted: i=1; AJvYcCXaxt4uStREVll3rzCVfUMBPQ/R5fH0om/3qplArYrGCbWE/WSCQhE+rwduQw1TUgAZMs8RK6jeRPOwJkqOkJDD/4S55MEaQzloZ7fk X-Gm-Message-State: AOJu0YwubEqB0UN1NG2BAoI8f/Ej2mYJIzJSZlzqb3eXIKbuB8g5IIpv goeR9fPHxo9hf3kPwCCHnFGxUPbcl2VKo5uabkmVDRhtCi2QzjOMtj7pZZ5GAuM= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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_cor= e.c index e90e2f01550a..89db242f06e0 100644 --- a/drivers/iio/accel/bma400_core.c +++ b/drivers/iio/accel/bma400_core.c @@ -13,6 +13,7 @@ =20 #include #include +#include #include #include #include @@ -795,21 +796,19 @@ static int bma400_enable_steps(struct bma400_data *da= ta, int val) =20 static int bma400_get_steps_reg(struct bma400_data *data, int *val) { - u8 *steps_raw; int ret; =20 - steps_raw =3D kmalloc(BMA400_STEP_RAW_LEN, GFP_KERNEL); + u8 *steps_raw __free(kfree) =3D kmalloc(BMA400_STEP_RAW_LEN, GFP_KERNEL); if (!steps_raw) return -ENOMEM; =20 ret =3D 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 =3D get_unaligned_le24(steps_raw); - kfree(steps_raw); + return IIO_VAL_INT; } =20 --=20 2.43.0 From nobody Mon Feb 9 12:45:40 2026 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 842B9148840 for ; Fri, 5 Jul 2024 10:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176060; cv=none; b=Gv4JMbpWd7/KCBKn28OiSzNj/qZjwajZpCgzKuMv91k/ie3Y2o64G1JqNM5uH1NO5GLRxSYuSKRyaiqUHOHqB/LGBxGvrR+xELjPvUu4wHYQkfCCc2PKbvnrSaDhGf3MetEAa8jUHdLScQMYV+0CjPi6joaEDLVqAsN2Mv7KO6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176060; c=relaxed/simple; bh=QARo7BUFibdiwmopTR5ANV4tiDr14JhYaFByIK5Byzw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MCA0/lMbkrk63IpQLgOdl7ehxD2Ua5jYmRELRb9+TOdiZLQSsbaRSxPuVikfgmvZMRED/D7uMqaEVdY7FmtnyuDr27XhJ/YkKzQ4vuEcCoGd7GzVH9xVRtktCgGMukg39YbRJR7cy5Ej958/L1+lOWbdnMZ0YwezcaNj22EWSoo= 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.47 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-f47.google.com with SMTP id 2adb3069b0e04-52e9c6b5a62so1595915e87.0 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=fzavNhHgkRC9ha6oFXRKFF4PME7csDWIx6UZunjzOAC2b7sVGTQgsxMgA59vfKlc7C f2nI7cJdwhL6ZuuY2ruh2xyc0f/jrIAnaqjzPtbkl4fwDoxnc4pEu1ijgMVDvS91PB1P fpEdfB8mVY70RJvQ9oEehXNGav2GJ4LUIV9qFIAQ1SiHH/3Z32VxrDcWw95UAyNs+jP+ W2WYsWccWXZropDBggyNIMInajc29E2tHkBKJqI7Np7g2mhTSp3crzVykr56gGep3JHO QBckAZGXdmyQ7QjYz/0WrFUZzr9C8xd9EbgVk3ECHiRfhRgTVY3qQp3ProPE/NCgmyjT JPiA== X-Forwarded-Encrypted: i=1; AJvYcCV9690k4+Qi1Wy6yhvQ1eSHE7LIkSF2c7bpz2C829d8XibDWxPC+t6vYIdnBeONEMQRwHH63Pfu/iG1Q8X7CT57QdWj+yRbyU98n60r X-Gm-Message-State: AOJu0YzeZIVAtZQzINPZc49W3VJ+dc0DYeW4vluszKKLtMU6tZk69+rq SWxmFTQJP9IaMvIUuAG9EHDUp9HszcG+zorw5QR7RCkqGR/wyqXXJnDW4FxaZxI= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 @@ =20 #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 =3D private; struct ad7280_state *st =3D iio_priv(indio_dev); - unsigned int *channels; int i, ret; =20 - channels =3D kcalloc(st->scan_cnt, sizeof(*channels), GFP_KERNEL); + unsigned int *channels __free(kfree) =3D kcalloc(st->scan_cnt, sizeof(*ch= annels), + GFP_KERNEL); if (!channels) return IRQ_HANDLED; =20 ret =3D ad7280_read_all_channels(st, st->scan_cnt, channels); if (ret < 0) - goto out; + return IRQ_HANDLED; =20 for (i =3D 0; i < st->scan_cnt; i++) { unsigned int val; @@ -852,9 +853,6 @@ static irqreturn_t ad7280_event_handler(int irq, void *= private) } } =20 -out: - kfree(channels); - return IRQ_HANDLED; } =20 --=20 2.43.0 From nobody Mon Feb 9 12:45:40 2026 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 D06F4148FF9 for ; Fri, 5 Jul 2024 10:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176061; cv=none; b=q0k+bR42Ex4aFhAP4ssCK9A8LGN54matrTdLeWVMW/7kgn9mV7Wleb9wq2jJhlGk/JepHthKDZu7Cjja3VKy0IAinBKaE1KMtz15bvRnwMlGBVZtjjXCIxSBXH4pVwCRXy6do74JlHjXNBhHYTXycN9K/KKOs2V7gIvXxn225rI= 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.41 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-f41.google.com with SMTP id ffacd0b85a97d-36796aee597so874086f8f.1 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=PEViwLOSnYcO12XvG5jfjarRdM1glHShetUorQC9ucLOc9wDVYPlv/ArOMbUuF2WE0 p9FvUlfuJpiES+WAmfdXR3Ep3gEmSw3LdcUATMfr2NgmInxY5d0UoJiciIjyKepq1vvv FFEnHV+B4rURA58eU7BOVeOXz2WBudiuw1Fovo8Y11N5N4Qv3ZHLSjI7AgARZN+zHvS6 KIQNWp5BpvSRp1WsY29FTawokkIsMUl4ngI++Q9yw0cKyYz3EpdhmJFzEkAO3U2Mj4Z2 v/1hgeaAWQEQ1mkFYoL7NIpD2TSygYq/RnD/DTrGmJTYdUjiyuRNzoT0xscNVxjiIfM2 AtnA== X-Forwarded-Encrypted: i=1; AJvYcCW9H515ZhRlhSvqJmL7m0SS0Yo11HO6EPp4Kozu35qOBIregznpn3h2FAQ3EWIhF0akm2dIwrRJ+y1PqA2lCfhk2w8ZgC+pllnwiUg5 X-Gm-Message-State: AOJu0YzBD9Rcr1W2pHm7oFaeSn3pXmTb41vHN1zTbN98KRXvAbVKWndj h/6vboRaYsfJK55gWZbKHk9HHdrbNWrfI0h3cSJaSqFJa6jId4se3CsQIQG3QqA= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 @@ =20 #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; =20 for (i =3D 0; i < st->caps->trigger_number; i++) { - char *name =3D kasprintf(GFP_KERNEL, - "%s-dev%d-%s", - idev->name, - iio_device_id(idev), - triggers[i].name); + char *name __free(kfree) =3D kasprintf(GFP_KERNEL, "%s-dev%d-%s", + idev->name, + iio_device_id(idev), + triggers[i].name); if (!name) return -ENOMEM; =20 if (strcmp(trigger_name, name) =3D=3D 0) { - kfree(name); if (triggers[i].value =3D=3D 0) return -EINVAL; return triggers[i].value; } - - kfree(name); } =20 return -EINVAL; --=20 2.43.0 From nobody Mon Feb 9 12:45:40 2026 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 8A3EC1494C8 for ; Fri, 5 Jul 2024 10:41:01 +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=1720176063; cv=none; b=aEoZZS8fiIj/LZwLkhABTaidCu/AclD1O2YPG5JcjGvp5jIfcL6W+QJ6WPoE/0R7r7EbI4Qyf9hpbsx/0oTpFnZUGcSP4LfrORfBujvURev4t9PJHiINENr9YwY2GiAWpvAhJlG/HmMSVi1r2eOCl03UtuqoAXJ8AHRyKSXlKEc= 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.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="SiNH4KMn" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-367a081d1cdso811315f8f.1 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=UjIdfGxY6f0Y8C9HkndroC0JZ2UiAR25Krq6BAb1KIzn6HZvbYPJ+o2rEg7YcZlKJh at1nkkm/dOemiSADxLYdmMUZLgzZguE0GfhkhGwVq1FipMTgwePmq3wcdOe5X2ndL2v8 +f9z+/HLVVjEokHwLzD2QCyq/BLK4yVVawMTrRXS+EXTFHy2aldOUayhgVlH/nqYm2Xa oIHg+1kvZ7+DQc+Hhi1m1A+qPeA2L+fJx8WXQXbho0AHvOVKg3vHHT/UbtmPPE6Zgb+L 25TmguTtH5SRz/kdaTRCWs57sAJAqNPh10Vh8f9oM4DyJAE2N2QTYKMRfvYgA2K3J/2k LFIQ== X-Forwarded-Encrypted: i=1; AJvYcCVKYmBXoeF97II3AL0quaaiP/QJeV+mrZknjEEwK5USMWv5+Bi1/XnEcuxM+IG4BnWQRz2QK4lmQbSBGwrS453Y8RLV0yrtrusy9/Ca X-Gm-Message-State: AOJu0YxSWIxU9lCFE/l4lWDE+twDe7A2Tqq1RZEiR5WA2OvxN3+pAdoB YRsUs5kS/F6NzWOsAwLqW8xAih2x4dK4RTI6dU4LMss/tgUgI2Jr3ZWmYDp5b+U= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 @@ */ =20 #include +#include #include #include #include @@ -818,7 +819,6 @@ static int max1363_read_event_config(struct iio_dev *in= dio_dev, =20 static int max1363_monitor_mode_update(struct max1363_state *st, int enabl= ed) { - u8 *tx_buf; int ret, i =3D 3, j; unsigned long numelements; int len; @@ -850,11 +850,10 @@ static int max1363_monitor_mode_update(struct max1363= _state *st, int enabled) } numelements =3D bitmap_weight(modemask, MAX1363_MAX_CHANNELS); len =3D 3 * numelements + 3; - tx_buf =3D kmalloc(len, GFP_KERNEL); - if (!tx_buf) { - ret =3D -ENOMEM; - goto error_ret; - } + u8 *tx_buf __free(kfree) =3D kmalloc(len, GFP_KERNEL); + if (!tx_buf) + return -ENOMEM; + tx_buf[0] =3D st->configbyte; tx_buf[1] =3D st->setupbyte; tx_buf[2] =3D (st->monitor_speed << 1); @@ -893,11 +892,9 @@ static int max1363_monitor_mode_update(struct max1363_= state *st, int enabled) =20 ret =3D st->send(st->client, tx_buf, len); if (ret < 0) - goto error_ret; - if (ret !=3D len) { - ret =3D -EIO; - goto error_ret; - } + return ret; + if (ret !=3D len) + return -EIO; =20 /* * 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] =3D MAX1363_MON_INT_ENABLE | (st->monitor_speed << 1) | 0xF0; ret =3D st->send(st->client, tx_buf, 2); if (ret < 0) - goto error_ret; - if (ret !=3D 2) { - ret =3D -EIO; - goto error_ret; - } - ret =3D 0; + return ret; + if (ret !=3D 2) + return -EIO; + st->monitor_on =3D true; -error_ret: =20 - kfree(tx_buf); - - return ret; + return 0; } =20 /* --=20 2.43.0 From nobody Mon Feb 9 12:45:40 2026 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.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 348D8149C69 for ; Fri, 5 Jul 2024 10:41:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176066; cv=none; b=KT8Qza8Qt2x6ZoSscTn1UJd/RV3FhnPEr3kLRSR+gZrmYbc1GbLKCk+BQQf3gBKD0tARbO9EcWB/ZtgQhuMMqPaBvc9i2TF6UT+COpa8KwsLIJUU4U6Etw7YGRF9aYqZh2r/BvmW8THJi8+qWG3zF1eVT4nxYjgHfqmgOEwBXtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176066; c=relaxed/simple; bh=Q9zojN0lSJs1YYfBNhUpVI/gmwKKpCb9hKgz9Y0tOzs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UEOznRfrpECqO8c337DNAk+p0HHkXHu1zDGYh+tv1D/yRCSoV6v50nz5kq2AJAiVFgp+I8lYPmNYgYYITwmMBPVrmGod5TSS3cNxkL8XzbpI2qPmVsN+bh7gaYAEFE3OxBC04HhcPG3ytz+W8vBRbD5re3zzeZ9EwtWr4IT5jmo= 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.221.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-wr1-f42.google.com with SMTP id ffacd0b85a97d-36740e64749so846881f8f.0 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=tgxLQwATSmCKnhJEnNEkMha0HHe7HOYYKcC+xwFPDUD7FFnfv1IvqAWxEksenM+SyC kkok++YrS3ietzT8DvRoDTFNQ4MpueKyNJONuCtRtenKWCKn82697niHFib8yRIJQHKL EIXOoxFwKoRR0kYLcIHHVxz4KvahbHl7cwF/+GacHvp9GtpMPnnqUstXTJHIpJdO4X4X vRktPhGcurrXMvAh6hJjRQoIq4YPgF1u4fKMEdLTg2h7jaJ9s2+ZFbpyv9mqxB5R2V6C rqgroEVAP0BjbKRNuhKRCmLbYEAr1d7lv1Xx7vwQA3O6a03m6NIyyBZcxq2aYbVX6LCf Zj6g== X-Forwarded-Encrypted: i=1; AJvYcCVftS8+0gGeOwEAUtuNdWQXtL2BV3a8WsFS4peaJ0NWn8wOtFIJy+dIIPO4x6pcuCqyev+jewL9vX35nXtbi8rcYtZTnJQ3VKFUcNqH X-Gm-Message-State: AOJu0YzvTs0DioToIu97ZIxl0q2d5hJlPiSyc1oTECkKRIx9DtShZ15r v2tVdOG1qCGgze4e+QeCzVd4JOK/QcamULoj+i3uXLEm20kkPdthS22covN5twA= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 @@ */ =20 #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 =3D &priv->ch_cfg[ch_idx]; - struct tsc2046_adc_atom *rx_buf, *tx_buf; unsigned int val, val_normalized =3D 0; int ret, i, count_skip =3D 0, max_count; struct spi_transfer xfer; @@ -287,18 +287,20 @@ static int tsc2046_adc_read_one(struct tsc2046_adc_pr= iv *priv, int ch_idx, max_count =3D 1; } =20 - if (sizeof(*tx_buf) * max_count > PAGE_SIZE) + if (sizeof(struct tsc2046_adc_atom) * max_count > PAGE_SIZE) return -ENOSPC; =20 - tx_buf =3D kcalloc(max_count, sizeof(*tx_buf), GFP_KERNEL); + struct tsc2046_adc_atom *tx_buf __free(kfree) =3D kcalloc(max_count, + sizeof(*tx_buf), + GFP_KERNEL); if (!tx_buf) return -ENOMEM; =20 - rx_buf =3D kcalloc(max_count, sizeof(*rx_buf), GFP_KERNEL); - if (!rx_buf) { - ret =3D -ENOMEM; - goto free_tx; - } + struct tsc2046_adc_atom *rx_buf __free(kfree) =3D kcalloc(max_count, + sizeof(*rx_buf), + GFP_KERNEL); + if (!rx_buf) + return -ENOMEM; =20 /* * 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; } =20 if (effective_speed_hz) @@ -337,14 +339,7 @@ static int tsc2046_adc_read_one(struct tsc2046_adc_pri= v *priv, int ch_idx, val_normalized +=3D val; } =20 - ret =3D 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); } =20 static size_t tsc2046_adc_group_set_layout(struct tsc2046_adc_priv *priv, --=20 2.43.0 From nobody Mon Feb 9 12:45:40 2026 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.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 C7604149E03 for ; Fri, 5 Jul 2024 10:41:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176066; cv=none; b=HxV4A0lrX+SPPAERfcKknH8c/qD6MehFqY5Rjv/UPh8f15TNxm2oJUXtXTsiWREEKBTHWwlHt4nhnbfeD6uK0oDVwpM8PEQK1LL4lHY++U829o8Z5K5aL1b/U0UYPBJa87aVbGzENhCRMXLtFztR+sP3JuOhDR7N+fZ6Nyehq88= 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.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="e2j88sPp" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-3678f36f154so795275f8f.2 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=JVxkrXuhcy8q2r4ip1XO1to94I/y1oFy/A/mz9k8Dl98DcPRn+ZWhcaYf6lBjN0piC 2pAJS+zH2k/NPSDecxkRUulSGuhloUei7lWaPHJ2w2sept5r5hG1a/jjmfRLrrO53PGh +euU+DYy4hz1XS9SZ2rx4fbkR0E5Bqed11hj4CWNEHfo1JQiUmJxVwXgB/+NOxpWWtdo bz7jlIdBe+rqlyfjhg1wzAEQPQgvIY3dfMU9M7EsEWyRq9YXfMjLtR6y0K4swwHwTVz0 16nC+RCB4C9c4TjbkA44CQEAnJgJuZ3s8lqq5dMAErwj60JPawGBfsqZMXbtUL6Ta7hU /gvw== X-Forwarded-Encrypted: i=1; AJvYcCU3vTcZUYrXjsKiMwi6qteTJOT/jF7E4j6Sfz3EYyj3FJMDg9Mm465VR+HEO4FK4Q/ULOd3ONTbZWAzeA6dj8OZnh5GLMqvBDsTt99R X-Gm-Message-State: AOJu0Yy1nwNrbxoRdh2AXUUwF2axSFIuPJc6U55pqVHB45zum/Yn5DOM cM9hUM/TyaG0+7BYz1jUWY/mBdsCromzbsJpsd4eLZNA8qfzCjvnEgfHGDhpg8s= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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(str= uct device *dev) =20 error_out: fwnode_handle_put(pp); - devm_kfree(dev, pdata); return NULL; } =20 --=20 2.43.0