Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1297086rwe; Thu, 1 Sep 2022 16:18:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR73FXDfvRest5YVoW+19Kglr6SU9V8bD6rrgGtLn9U+g6JaJrxmdYzvt9+C0Ao5WaEywIgt X-Received: by 2002:a17:907:3f0c:b0:73d:60fc:6594 with SMTP id hq12-20020a1709073f0c00b0073d60fc6594mr26171302ejc.669.1662074314775; Thu, 01 Sep 2022 16:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662074314; cv=none; d=google.com; s=arc-20160816; b=IrZmcz5jbMvcYCGL1HA93YnGJiCAfkTdvYenE0JKkprfV1eNHUAsVOQQekk6EASxvb TVYvq7o+VxBzOO31M4gFeYPpAyBCvYeOSYDbOA6UT2HI+hTbK9IWlIlcX39Ks6k2HvNn sU1nhkPti0Nfl8Dn6z3kuS/YNdg09a6IdkufxBL4f8me9CYObOJNnWW+SW2xnfpuC8Xp 07HE/N0fSst+jizx6P0ch/kbRT3tehrQEp2og1a+HIzGauwBKzCCh9V2IFVHaFcYoCe+ 3U9B35Ju0EUwXudsRJkZvnLJeixI0jb9O0PbXr/f9LGDT0htSsdE/lgjHHY1DJM0/hIB uBOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N9wQTn8dC8bPriyX4SQQmb5oAnnt3YF+DVu2omjw3q0=; b=hFgaivvMYLSpTcEJl+JV6kluZQ/+4aTZQ0KhDd8UxdBQ3vuueNX1uhh4n8mNEGEt0j o8prxcy6n+GrsSQh3GoUC1mA3ufc9Hrb8qpMO6Poj5CU+NEWhOVacys2iwaEETh4P8On BOIZVVL8OsrLkBZhiakuih/M4btkzulZ1vyEeR4WfSSISUaCPkrERLIuKKFLDOisHQ+i ksfwTIGWLy4OPAgcQySXHPRUuQJjCfDWLc0kd89XJNJNbNxvAB/DnVnXwgwi7esfFTUT cB+UJfkSldWFibu6o55ekoLxG4QWh/+ZBwcLzUbCIFZqi2tWvAwz0rnNhhFb8/horckc 4hQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b="c0/5bLSF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s18-20020a170906061200b0073d62f62c9csi420317ejb.217.2022.09.01.16.18.09; Thu, 01 Sep 2022 16:18:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b="c0/5bLSF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235235AbiIAWXL (ORCPT + 99 others); Thu, 1 Sep 2022 18:23:11 -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: 8bit X-Spam: Yes X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 *nvmem) } EXPORT_SYMBOL_GPL(nvmem_dev_name); +/** + * 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); const char *nvmem_dev_name(struct nvmem_device *nvmem); @@ -206,6 +207,11 @@ static inline int nvmem_device_write(struct nvmem_device *nvmem, return -EOPNOTSUPP; } +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; -- 2.30.2