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 5939C606A31A for ; Wed, 2 Dec 2026 07:33:44 +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=3v/mEjC5; dkim=pass (2048-bit key, unprotected) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=B0sItBPz 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=W5kaD7C+BX4SgYapoclOHaJnErz1RiQyHy90Pobazs0=; b=3v/mEjC5YwrdLOhDjJEdgOJEOj r5pgZ2bXOSB2pB+KJtGHK7pJaM46ha64Aq51NGi/nLBfPQGWl6lB9ftpxw7VZcDVZorWanVEsBUWP AGIHFyAmqMCatfRHRv/1PFZQiTkB8oXi2185z1EEy/0a0nhVN1HujvALnXEb2JrrEY4Cnk/ajgwkL EhvChqYQCwnnYptWIuC5dEUkUNFXLZMYLOzKMLZIOQdyt0PRmMgTdIkEtE046UDc27TrfeG/I6j5D gO0XrNkcdDz9DCV1Rz6DlDWPbgMaI41HRPhhvi9hLyJ4QEhKXX+MT/uXyyhLakkLuDIhuQyZfXu+W fw1ddmsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYeqI-0000000AWY5-1G4j; Wed, 02 Dec 2026 07:33:30 +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 1xYeqF-0000000AWWA-44K4 for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2026 07:33:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796196807; x=1827732807; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8TwE6tHKFkAkpxs1K+Tc9afcgRugC7VXhgjjf57uqtQ=; b=B0sItBPznhnuyZI5S7Z9NHvWVdFW+SF8+XY4NBIugzK9odkoBxeIvIoo TU0tK6q45YGMQIgWqX0qrNp53p/3LkjMT3Rg0snUQThoF8+bmGHeEx9aY cJY1kKR1iO/yk1se/+zsAVBhhQYjeXY0yMWoF6mdVd07LXFGjqgQSu/7a jS7jEApnTA+u6A1Wisk1buI52CYIFtSMrTe815l2Ob/Amkme+uApQZuRF zQuKtay+ncj7+q1tLj+W1JLA4ch/h+m36NwIaHSvZkzR/HLlftk/WnUi8 ywOZLcz5yMHzuLsqrRMhxLzVVxiWGxbO6mERAiwalC5By+FuFb7SvLCQ5 A==; X-CSE-ConnectionGUID: EGt52F+MR2WGD5Dr9Dmogg== X-CSE-MsgGUID: TQ5/zDKwThyS8cxtzsg1kQ== X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="234356578" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Dec 2026 00:05:22 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Wed, 2 Dec 2026 00:05:22 -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:17 -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 , , , , , Subject: [PATCH v7 03/18] nvmem: add DEFINE_FREE for nvmem_cell_put cleanup Date: Wed, 2 Dec 2026 12:34:41 +0530 Message-ID: <20261202070458.87970-4-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_233328_070398_B8F28A8A X-CRM114-Status: GOOD ( 10.61 ) 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 Add cleanup.h helper for nvmem_cell_put() to enable automatic resource cleanup using __free(nvmem_cell_put) annotation. Use IS_ERR_OR_NULL() since nvmem_cell_get() can return error pointers, and passing an ERR_PTR to nvmem_cell_put() would cause issues. Signed-off-by: Varshini Rajendran Acked-by: Srinivas Kandagatla --- include/linux/nvmem-consumer.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index 34c0e58dfa26..5315bd862f5f 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -9,6 +9,7 @@ #ifndef _LINUX_NVMEM_CONSUMER_H #define _LINUX_NVMEM_CONSUMER_H +#include #include #include #include @@ -243,6 +244,8 @@ static inline struct nvmem_device *nvmem_device_find(void *data, #endif /* CONFIG_NVMEM */ +DEFINE_FREE(nvmem_cell_put, struct nvmem_cell *, if (!IS_ERR_OR_NULL(_T)) nvmem_cell_put(_T)) + #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF) struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id); -- 2.43.0