devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafał Miłecki" <zajec5@gmail.com>
To: Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Michael Walle" <michael@walle.cc>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Rafał Miłecki" <rafal@milecki.pl>
Subject: [PATCH V4 3/4] nvmem: core: export nvmem_add_cells_from_of()
Date: Fri, 17 Mar 2023 14:26:19 +0100	[thread overview]
Message-ID: <20230317132620.31142-4-zajec5@gmail.com> (raw)
In-Reply-To: <20230317132620.31142-1-zajec5@gmail.com>

From: Rafał Miłecki <rafal@milecki.pl>

This symbol can be cleanly re-used by the fixed NVMEM layout driver.
Allow passing DT node as argument to make it a bit more generic.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 drivers/nvmem/core.c           | 7 ++++---
 include/linux/nvmem-provider.h | 7 +++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 212c5ba5789f..985a42cfb0a2 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -694,7 +694,7 @@ static int nvmem_validate_keepouts(struct nvmem_device *nvmem)
 	return 0;
 }
 
-static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
+int nvmem_add_cells_from_of(struct nvmem_device *nvmem, struct device_node *np)
 {
 	struct nvmem_layout *layout = nvmem->layout;
 	struct device *dev = &nvmem->dev;
@@ -702,7 +702,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
 	const __be32 *addr;
 	int len, ret;
 
-	for_each_child_of_node(dev->of_node, child) {
+	for_each_child_of_node(np, child) {
 		struct nvmem_cell_info info = {0};
 
 		addr = of_get_property(child, "reg", &len);
@@ -739,6 +739,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(nvmem_add_cells_from_of);
 
 int __nvmem_layout_register(struct nvmem_layout *layout, struct module *owner)
 {
@@ -970,7 +971,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 	if (rval)
 		goto err_remove_cells;
 
-	rval = nvmem_add_cells_from_of(nvmem);
+	rval = nvmem_add_cells_from_of(nvmem, nvmem->dev.of_node);
 	if (rval)
 		goto err_remove_cells;
 
diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
index 3e97c8315c45..2b5410be2636 100644
--- a/include/linux/nvmem-provider.h
+++ b/include/linux/nvmem-provider.h
@@ -195,6 +195,8 @@ void nvmem_del_cell_table(struct nvmem_cell_table *table);
 int nvmem_add_one_cell(struct nvmem_device *nvmem,
 		       const struct nvmem_cell_info *info);
 
+int nvmem_add_cells_from_of(struct nvmem_device *nvmem, struct device_node *np);
+
 int __nvmem_layout_register(struct nvmem_layout *layout, struct module *owner);
 #define nvmem_layout_register(layout) \
 	__nvmem_layout_register(layout, THIS_MODULE)
@@ -226,6 +228,11 @@ static inline int nvmem_add_one_cell(struct nvmem_device *nvmem,
 	return -EOPNOTSUPP;
 }
 
+static int nvmem_add_cells_from_of(struct nvmem_device *nvmem, struct device_node *np)
+{
+	return -EOPNOTSUPP;
+}
+
 static inline int nvmem_layout_register(struct nvmem_layout *layout)
 {
 	return -EOPNOTSUPP;
-- 
2.34.1


  parent reply	other threads:[~2023-03-17 13:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 13:26 [PATCH V4 0/4] nvmem: add fixed cells layout Rafał Miłecki
2023-03-17 13:26 ` [PATCH V4 1/4] dt-bindings: nvmem: layouts: add fixed-layout Rafał Miłecki
2023-03-17 13:26 ` [PATCH V4 2/4] dt-bindings: nvmem: convert base example to use NVMEM fixed cells layout Rafał Miłecki
2023-03-17 13:26 ` Rafał Miłecki [this message]
2023-03-18  0:06   ` [PATCH V4 3/4] nvmem: core: export nvmem_add_cells_from_of() kernel test robot
2023-03-20  8:23   ` Michael Walle
2023-03-17 13:26 ` [PATCH V4 4/4] nvmem: layouts: add fixed cells layout Rafał Miłecki
2023-03-17 15:54   ` kernel test robot
2023-03-17 16:04     ` Rafał Miłecki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230317132620.31142-4-zajec5@gmail.com \
    --to=zajec5@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael@walle.cc \
    --cc=miquel.raynal@bootlin.com \
    --cc=rafal@milecki.pl \
    --cc=robh+dt@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).