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: 13724926 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A5C0C3271F for ; Fri, 5 Jul 2024 10:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1eXR3A0Apjdz/ufMLdA1641K3n5tF+YJ5/SI81Vd25s=; b=icZR/W3U66T07pWBxLH9RBY0fr jSLBNqnA0CqjtzcxGfpSWkG4hhVqnAWEyYKhkIPphapmCWOP4BYCx8B2Y0wEa+HXRhFljmgFOfV/s FUq2I1xZzWsJ+nw3UkWb58MKXFx2mvs8FiwuPZ1D0xvwURUP1QP4f334pbBBv/n26uMkFN8IByLRY G8sUuBF88YmWWI38rBdntF2mWfp6euMbI051d6nW4FpyM9O1qy7CBUcGhoEPf+oVWoXhVtdOp5/JM 1qm4/O2lQFvR1D4/kwk891+eLLHToF3QLHuObtBvs2g8JsmA/OwlxYtP4P/zEIVwUXw6W3iUbPwmn We9cW3ow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPgNf-0000000Ffuz-47Y9; Fri, 05 Jul 2024 10:41:31 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPgN8-0000000Ffk6-27aZ for linux-arm-kernel@lists.infradead.org; Fri, 05 Jul 2024 10:40:59 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-52e9c55febcso1950421e87.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=lists.infradead.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=HdIfkXmnLMrEjVI+hKgD56M+HTN/RE4620aHJfwwEm9b82duuSkWFdZGJV9Zsl6c6z RCUkHskSPjTyUTcm78/oFA99R8fBUuUlsW4zvkmW/ndSasVB4Y65LGo4Q71JBhA8IWoc ou2hUWuFgQWDYoe9vB7+vVs0AZSCBl39z9Kuv4UCGAZMXYEUpV9iUN++cpq3MJtE2nym VqQ+TKWRdprRHS5MYjwgH5Cehg6qGgQH7sigWd6Pop3CxVY1j3qilcIIMV3dwz7u53hD cF67hxXNauNscxN2LpP061/5BWHNfeIs2fli84P4ueLLtYag7pqk+aXyehi3JiwRJc/s DWRw== 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=ckMfmsdlZZYzaAaqjjLcuYPMO47rDNpZM5+NHQAjB+RoZMMO5VeZMc0GJEah38kHpC AHVl2E6NaIla2uXtZ72sTT8IZOVanz1yfzZKZmURCxoDfaoKhw4nFe6Ue4cW2l4WeiVU z2biPcc9VuGGIVj/v4tWG8zgZMFZRrSKPB6KebwCNAb9drLZR3G+Z+s91nRq1lxC5Q+d ImnlIhwUObJP4AMrjJZJvDQOt80yan7qnKW0SmwFKzf4E5sMppvC2cY+UBFI50VEzvaQ 9b/TJxjOjTY9mgmJCbmwHT4aWk3ZBoJRenD7kIqwGMTXDRy/nJNy2szURCjjjoVeGEgX j4LA== X-Forwarded-Encrypted: i=1; AJvYcCV0/HpO2B+mgyNivbV3Wq7RVqQsD0j35LApMBgwvvMW6gYNem2YgWoiwden6bXl3wdogPIV3CAKp+wePFFKHyvqzgIV5ykiThdYGG+APnyCdKRfDRI= X-Gm-Message-State: AOJu0YzkcnanJHfcWqq/LZSBP1z0PzkORNnrsb6g9jkbkXaSxqYrNziA k8ddKM8H8pGjkun014AG/DFSy/XR+sIwuTNCEVvyJWYBG2gpr5sRxNuGf85yjQ4= 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240705_034058_577968_8B709D06 X-CRM114-Status: GOOD ( 15.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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; }