From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99722606A325 for ; Wed, 2 Dec 2026 08:35:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=T04w1vUY; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=hLikF2lI 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:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=XOh+ZwInbXQiDjHFZ5qe12sUnJzMSlzi2jhqvKXyiEo=; b=T04w1vUYkaMoCBci59RzeQRY1Q 1hRyMBQMeu++KF9xH21UwspgNx/Q2LfDbaMMnpPkV/89t2fHZ1VksMxJinHEW4gRMCeQGrUGsItPG KnhX8ebEXBNdo+dcHxdhCxitl/Toa6Czyzy0cARgN1rYvDwZZpyWeyOMlOnizkof2YwevVFKV3lDT OkB50Sob2NAxuHmjuKCton6+eyed4AyLHyPGaGR/zz5xDsrflimbEDXATQnJMSCEs/DWtGQpCDb+P 1TJJ6FP4V1Eu1EiJR81JpVmNoIcJi+nfrEVxT1CZ8vkUO86SDiPJ7vyBgBxFoti9wbsQT+4N9+QIs oO4IrqcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYeqY-0000000AWtH-0LTa; Wed, 02 Dec 2026 07:33:46 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYeqV-0000000AWlr-27sv for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2026 07:33:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796196823; x=1827732823; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Vcq4Qpa7ZGrSi2wVbly9Jex0Y3J6Pqx/6rRZClb9uqg=; b=hLikF2lIAkePWYwyFpucmnmcT3zRFLZhEV0F6mmMz3SyJu1Rd/r3qiST FR2oh/2RAiK5Yg2CHG8+D3TRb640SdU/d/DGN7A2wZvwOjuwXYTOXkj4J jw66sDFpVRZ3H4pw/eip6t1yrDJ5PqtExOW2WGP1LnoKxTQU4/8oG2QYz EhDBmOG0FT91oX79vlgXo49Ois96cjJGtoZQKNrUvfKAtJ/bFc1MuRwRt Dnsxpy8xKM9KU4hWjh6luGpJlxUTApieZOKyTKa0CzvEivM2OKtE7Siv7 GOkgwkXgL0gUTTvwR27ZMXvvqxuFjP3o7EKD++1xTFENtZorAGsP9fFSH w==; X-CSE-ConnectionGUID: bp8qBLGwSQuB9K54thqi7g== X-CSE-MsgGUID: 1zgGJuycSv2VSh9ik5pqmw== X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="67550380" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 00:05:28 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.87.151) by chn-vm-ex1.mchp-main.com (10.10.87.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.57; Wed, 2 Dec 2026 00:05:27 -0700 Received: from che-ll-i67070a.microchip.com (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Wed, 2 Dec 2026 00:05:22 -0700 From: Varshini Rajendran To: Jonathan Cameron , Srinivas Kandagatla , Claudiu Beznea CC: Eugen Hristev , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Nicolas Ferre" , Alexandre Belloni , , , , , , "Andy Shevchenko" Subject: [PATCH v7 04/18] iio: adc: at91-sama5d2_adc: use cleanup.h for NVMEM buffer Date: Wed, 2 Dec 2026 12:34:42 +0530 Message-ID: <20261202070458.87970-5-varshini.rajendran@microchip.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261202070458.87970-1-varshini.rajendran@microchip.com> References: <20261202070458.87970-1-varshini.rajendran@microchip.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261201_233343_626723_654F8486 X-CRM114-Status: GOOD ( 14.43 ) X-Spam-Score: -4.4 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Use __free(kfree) and __free(nvmem_cell_put) cleanup helpers in at91_adc_temp_sensor_init() to simplify error handling paths. Reviewed-by: Andy Shevchenko Signed-off-by: Varshini Rajendran --- drivers/iio/adc/at91-sama5d2_adc.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index 78081cbfde5e..52d2bdff3203 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -2252,8 +2252,6 @@ static int at91_adc_temp_sensor_init(struct at91_adc_state *st, struct device *dev) { struct at91_adc_temp_sensor_clb *clb = &st->soc_info.temp_sensor_clb; - struct nvmem_cell *temp_calib; - u32 *buf; size_t len; int ret = 0; @@ -2261,7 +2259,8 @@ static int at91_adc_temp_sensor_init(struct at91_adc_state *st, return 0; /* Get the calibration data from NVMEM. */ - temp_calib = nvmem_cell_get(dev, "temperature_calib"); + struct nvmem_cell *temp_calib __free(nvmem_cell_put) = + nvmem_cell_get(dev, "temperature_calib"); if (IS_ERR(temp_calib)) { ret = PTR_ERR(temp_calib); if (ret != -ENOENT) @@ -2269,16 +2268,14 @@ static int at91_adc_temp_sensor_init(struct at91_adc_state *st, return ret; } - buf = nvmem_cell_read(temp_calib, &len); - nvmem_cell_put(temp_calib); - if (IS_ERR(buf)) { - dev_err(dev, "Failed to read calibration data!\n"); - return PTR_ERR(buf); - } - if (len < AT91_ADC_TS_CLB_IDX_MAX * 4) { + u32 *buf __free(kfree) = nvmem_cell_read(temp_calib, &len); + if (IS_ERR(buf)) + return dev_err_probe(dev, PTR_ERR(buf), + "Failed to read calibration data!\n"); + + if (len < AT91_ADC_TS_CLB_IDX_MAX * sizeof(*buf)) { dev_err(dev, "Invalid calibration data!\n"); - ret = -EINVAL; - goto free_buf; + return -EINVAL; } /* Store calibration data for later use. */ @@ -2291,9 +2288,7 @@ static int at91_adc_temp_sensor_init(struct at91_adc_state *st, */ clb->p1 = clb->p1 * 1000; -free_buf: - kfree(buf); - return ret; + return 0; } static int at91_adc_probe(struct platform_device *pdev) -- 2.43.0