From nobody Tue Apr 7 00:44:31 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 572E3ECAAD2 for ; Thu, 1 Sep 2022 22:23:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234938AbiIAWXN (ORCPT ); Thu, 1 Sep 2022 18:23:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235315AbiIAWWN (ORCPT ); Thu, 1 Sep 2022 18:22:13 -0400 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0573A3D28; Thu, 1 Sep 2022 15:19:40 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id B428E2215; Fri, 2 Sep 2022 00:19:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1662070754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N9wQTn8dC8bPriyX4SQQmb5oAnnt3YF+DVu2omjw3q0=; b=c0/5bLSF9fHzm+ZVLZ0QjPdba/j5vXimofHWypL1EtuVd62/K6bVwF+Bd5owz+nwBI9E+a KyF0GQt+nxmSExwWxbRFCr9wL9UFPNhrJGI4pKJOXwjlo2kFCBN3GgzBxQxpuzhj8wYbXF OZ+fCpBgiPLzG58nDeq8saEEO1EjgKfnMmyv4gx/PHx3H8mTpZ31FrXRll2ddtu2SuxAW1 pRj9porzJqzbIFjHSjQF/1qJ8LSI8UXV6YF4OyZZRdJzeqagtTmdsYRaVudWpSovulOaNo Wr6s/bObnSQ8oCyS9cxOIkaUdRGV9Sfd7+kC2v5Dyphd51D1W1ZQLlX4EkZ5KA== From: Michael Walle To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla , Shawn Guo , Li Yang , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Frank Rowand Cc: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ahmad Fatoum , Philipp Zabel , Michael Walle Subject: [PATCH v2 17/20] nvmem: core: export nvmem device size Date: Fri, 2 Sep 2022 00:18:54 +0200 Message-Id: <20220901221857.2600340-18-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220901221857.2600340-1-michael@walle.cc> References: <20220901221857.2600340-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Export the size of the nvmem device. NVMEM layout drivers might need it and might not have access to the device which is registering the NVMEM device. Signed-off-by: Michael Walle --- changes since v1: - none drivers/nvmem/core.c | 13 +++++++++++++ include/linux/nvmem-consumer.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 6910796937f9..81fca32a7418 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -2045,6 +2045,19 @@ const char *nvmem_dev_name(struct nvmem_device *nvme= m) } EXPORT_SYMBOL_GPL(nvmem_dev_name); =20 +/** + * nvmem_device_size() - Get the size of a given nvmem device. + * + * @nvmem: nvmem device. + * + * Return: size of the nvmem device. + */ +size_t nvmem_device_size(struct nvmem_device *nvmem) +{ + return nvmem->size; +} +EXPORT_SYMBOL_GPL(nvmem_device_size); + static int __init nvmem_init(void) { return bus_register(&nvmem_bus_type); diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index 1f62f7ba71ca..6607f9a1d6dc 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -77,6 +77,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem, struct nvmem_cell_info *info, void *buf); int nvmem_device_cell_write(struct nvmem_device *nvmem, struct nvmem_cell_info *info, void *buf); +size_t nvmem_device_size(struct nvmem_device *nvmem); =20 const char *nvmem_dev_name(struct nvmem_device *nvmem); =20 @@ -206,6 +207,11 @@ static inline int nvmem_device_write(struct nvmem_devi= ce *nvmem, return -EOPNOTSUPP; } =20 +static inline size_t nvmem_device_size(struct nvmem_device *nvmem) +{ + return 0; +} + static inline const char *nvmem_dev_name(struct nvmem_device *nvmem) { return NULL; --=20 2.30.2