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
Am 2023-03-17 14:26, schrieb Rafał Miłecki: > 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) I'm not sure, how to feel about exposing an "internal" function to the layouts module. I mean all these nvmem_add_cells_from_* are internal to the core. Also the help text of the add_cells() callback tells you to use nvmem_add_one_cell(). Although there is a bit of code duplication, I'd rather refactor the nvmem_add_cells_from_of() to split it into parsing and adding. Then re-use just the parsing from the fixed layout module and call the appropriate nvmem_add_one_cell() yourself there. -michael
Hi Rafał,
I love your patch! Yet something to improve:
[auto build test ERROR on next-20230317]
[cannot apply to robh/for-next krzk-dt/for-next char-misc/char-misc-testing char-misc/char-misc-next char-misc/char-misc-linus linus/master v6.3-rc2 v6.3-rc1 v6.2 v6.3-rc2]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Rafa-Mi-ecki/dt-bindings-nvmem-layouts-add-fixed-layout/20230317-212948
patch link: https://lore.kernel.org/r/20230317132620.31142-4-zajec5%40gmail.com
patch subject: [PATCH V4 3/4] nvmem: core: export nvmem_add_cells_from_of()
config: powerpc-allnoconfig (https://download.01.org/0day-ci/archive/20230318/202303180709.WSD6mSsu-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/70d21b7988db0cad28a2cb4b0d7f5d77d587a51f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Rafa-Mi-ecki/dt-bindings-nvmem-layouts-add-fixed-layout/20230317-212948
git checkout 70d21b7988db0cad28a2cb4b0d7f5d77d587a51f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash arch/powerpc/kernel/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303180709.WSD6mSsu-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from include/linux/rtc.h:18,
from arch/powerpc/kernel/time.c:48:
>> include/linux/nvmem-provider.h:230:12: error: 'nvmem_add_cells_from_of' defined but not used [-Werror=unused-function]
230 | static int nvmem_add_cells_from_of(struct nvmem_device *nvmem, struct device_node *np)
| ^~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
vim +/nvmem_add_cells_from_of +230 include/linux/nvmem-provider.h
229
> 230 static int nvmem_add_cells_from_of(struct nvmem_device *nvmem, struct device_node *np)
231 {
232 return -EOPNOTSUPP;
233 }
234
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
© 2016 - 2026 Red Hat, Inc.