Re: [PATCH] nvmem: Change to unified property interface
Hi Kevin, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v5.12-rc5 next-20210329] [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] url: https://github.com/0day-ci/linux/commits/Kevin-Paul-Herbert/nvmem-Change-to-unified-property-interface/20210330-064121 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1e43c377a79f9189fea8f2711b399d4e8b4e609b config: mips-allmodconfig (attached as .config) compiler: mips-linux-gcc (GCC) 9.3.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/0day-ci/linux/commit/edbc7632702cf638265a6d7180bd8c951cda6ad9 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Kevin-Paul-Herbert/nvmem-Change-to-unified-property-interface/20210330-064121 git checkout edbc7632702cf638265a6d7180bd8c951cda6ad9 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): drivers/thermal/sprd_thermal.c: In function 'sprd_thm_cal_read': >> drivers/thermal/sprd_thermal.c:128:9: error: implicit declaration of >> function 'of_nvmem_cell_get'; did you mean 'nvmem_cell_get'? >> [-Werror=implicit-function-declaration] 128 | cell = of_nvmem_cell_get(np, cell_id); | ^ | nvmem_cell_get drivers/thermal/sprd_thermal.c:128:7: warning: assignment to 'struct nvmem_cell *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 128 | cell = of_nvmem_cell_get(np, cell_id); | ^ cc1: some warnings being treated as errors vim +128 drivers/thermal/sprd_thermal.c 554fdbaf19b188 Freeman Liu 2020-02-18 120 554fdbaf19b188 Freeman Liu 2020-02-18 121 static int sprd_thm_cal_read(struct device_node *np, const char *cell_id, 554fdbaf19b188 Freeman Liu 2020-02-18 122 u32 *val) 554fdbaf19b188 Freeman Liu 2020-02-18 123 { 554fdbaf19b188 Freeman Liu 2020-02-18 124 struct nvmem_cell *cell; 554fdbaf19b188 Freeman Liu 2020-02-18 125 void *buf; 554fdbaf19b188 Freeman Liu 2020-02-18 126 size_t len; 554fdbaf19b188 Freeman Liu 2020-02-18 127 554fdbaf19b188 Freeman Liu 2020-02-18 @128 cell = of_nvmem_cell_get(np, cell_id); 554fdbaf19b188 Freeman Liu 2020-02-18 129 if (IS_ERR(cell)) 554fdbaf19b188 Freeman Liu 2020-02-18 130 return PTR_ERR(cell); 554fdbaf19b188 Freeman Liu 2020-02-18 131 554fdbaf19b188 Freeman Liu 2020-02-18 132 buf = nvmem_cell_read(cell, ); 554fdbaf19b188 Freeman Liu 2020-02-18 133 nvmem_cell_put(cell); 554fdbaf19b188 Freeman Liu 2020-02-18 134 if (IS_ERR(buf)) 554fdbaf19b188 Freeman Liu 2020-02-18 135 return PTR_ERR(buf); 554fdbaf19b188 Freeman Liu 2020-02-18 136 554fdbaf19b188 Freeman Liu 2020-02-18 137 if (len > sizeof(u32)) { 554fdbaf19b188 Freeman Liu 2020-02-18 138 kfree(buf); 554fdbaf19b188 Freeman Liu 2020-02-18 139 return -EINVAL; 554fdbaf19b188 Freeman Liu 2020-02-18 140 } 554fdbaf19b188 Freeman Liu 2020-02-18 141 554fdbaf19b188 Freeman Liu 2020-02-18 142 memcpy(val, buf, len); 554fdbaf19b188 Freeman Liu 2020-02-18 143 554fdbaf19b188 Freeman Liu 2020-02-18 144 kfree(buf); 554fdbaf19b188 Freeman Liu 2020-02-18 145 return 0; 554fdbaf19b188 Freeman Liu 2020-02-18 146 } 554fdbaf19b188 Freeman Liu 2020-02-18 147 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
Re: [PATCH] nvmem: Change to unified property interface
Hi Kevin, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on linus/master] [also build test WARNING on v5.12-rc5 next-20210329] [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] url: https://github.com/0day-ci/linux/commits/Kevin-Paul-Herbert/nvmem-Change-to-unified-property-interface/20210330-064121 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1e43c377a79f9189fea8f2711b399d4e8b4e609b config: x86_64-randconfig-a014-20210329 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 482283042f795ecc27838a3b2f76b5494991401c) 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 # install x86_64 cross compiling tool for clang build # apt-get install binutils-x86-64-linux-gnu # https://github.com/0day-ci/linux/commit/edbc7632702cf638265a6d7180bd8c951cda6ad9 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Kevin-Paul-Herbert/nvmem-Change-to-unified-property-interface/20210330-064121 git checkout edbc7632702cf638265a6d7180bd8c951cda6ad9 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (new ones prefixed by >>): drivers/thermal/sprd_thermal.c:128:9: error: implicit declaration of function 'of_nvmem_cell_get' [-Werror,-Wimplicit-function-declaration] cell = of_nvmem_cell_get(np, cell_id); ^ drivers/thermal/sprd_thermal.c:128:9: note: did you mean 'nvmem_cell_get'? include/linux/nvmem-consumer.h:60:20: note: 'nvmem_cell_get' declared here struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *id); ^ >> drivers/thermal/sprd_thermal.c:128:7: warning: incompatible integer to >> pointer conversion assigning to 'struct nvmem_cell *' from 'int' >> [-Wint-conversion] cell = of_nvmem_cell_get(np, cell_id); ^ ~~ 1 warning and 1 error generated. vim +128 drivers/thermal/sprd_thermal.c 554fdbaf19b188 Freeman Liu 2020-02-18 120 554fdbaf19b188 Freeman Liu 2020-02-18 121 static int sprd_thm_cal_read(struct device_node *np, const char *cell_id, 554fdbaf19b188 Freeman Liu 2020-02-18 122 u32 *val) 554fdbaf19b188 Freeman Liu 2020-02-18 123 { 554fdbaf19b188 Freeman Liu 2020-02-18 124 struct nvmem_cell *cell; 554fdbaf19b188 Freeman Liu 2020-02-18 125 void *buf; 554fdbaf19b188 Freeman Liu 2020-02-18 126 size_t len; 554fdbaf19b188 Freeman Liu 2020-02-18 127 554fdbaf19b188 Freeman Liu 2020-02-18 @128 cell = of_nvmem_cell_get(np, cell_id); 554fdbaf19b188 Freeman Liu 2020-02-18 129 if (IS_ERR(cell)) 554fdbaf19b188 Freeman Liu 2020-02-18 130 return PTR_ERR(cell); 554fdbaf19b188 Freeman Liu 2020-02-18 131 554fdbaf19b188 Freeman Liu 2020-02-18 132 buf = nvmem_cell_read(cell, ); 554fdbaf19b188 Freeman Liu 2020-02-18 133 nvmem_cell_put(cell); 554fdbaf19b188 Freeman Liu 2020-02-18 134 if (IS_ERR(buf)) 554fdbaf19b188 Freeman Liu 2020-02-18 135 return PTR_ERR(buf); 554fdbaf19b188 Freeman Liu 2020-02-18 136 554fdbaf19b188 Freeman Liu 2020-02-18 137 if (len > sizeof(u32)) { 554fdbaf19b188 Freeman Liu 2020-02-18 138 kfree(buf); 554fdbaf19b188 Freeman Liu 2020-02-18 139 return -EINVAL; 554fdbaf19b188 Freeman Liu 2020-02-18 140 } 554fdbaf19b188 Freeman Liu 2020-02-18 141 554fdbaf19b188 Freeman Liu 2020-02-18 142 memcpy(val, buf, len); 554fdbaf19b188 Freeman Liu 2020-02-18 143 554fdbaf19b188 Freeman Liu 2020-02-18 144 kfree(buf); 554fdbaf19b188 Freeman Liu 2020-02-18 145 return 0; 554fdbaf19b188 Freeman Liu 2020-02-18 146 } 554fdbaf19b188 Freeman Liu 2020-02-18 147 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
Re: [PATCH] nvmem: Change to unified property interface
Hi Kevin, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on linus/master] [also build test WARNING on v5.12-rc5 next-20210329] [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] url: https://github.com/0day-ci/linux/commits/Kevin-Paul-Herbert/nvmem-Change-to-unified-property-interface/20210330-064121 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1e43c377a79f9189fea8f2711b399d4e8b4e609b config: arc-allyesconfig (attached as .config) compiler: arceb-elf-gcc (GCC) 9.3.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/0day-ci/linux/commit/edbc7632702cf638265a6d7180bd8c951cda6ad9 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Kevin-Paul-Herbert/nvmem-Change-to-unified-property-interface/20210330-064121 git checkout edbc7632702cf638265a6d7180bd8c951cda6ad9 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (new ones prefixed by >>): drivers/thermal/sprd_thermal.c: In function 'sprd_thm_cal_read': drivers/thermal/sprd_thermal.c:128:9: error: implicit declaration of function 'of_nvmem_cell_get'; did you mean 'nvmem_cell_get'? [-Werror=implicit-function-declaration] 128 | cell = of_nvmem_cell_get(np, cell_id); | ^ | nvmem_cell_get >> drivers/thermal/sprd_thermal.c:128:7: warning: assignment to 'struct >> nvmem_cell *' from 'int' makes pointer from integer without a cast >> [-Wint-conversion] 128 | cell = of_nvmem_cell_get(np, cell_id); | ^ cc1: some warnings being treated as errors vim +128 drivers/thermal/sprd_thermal.c 554fdbaf19b188 Freeman Liu 2020-02-18 120 554fdbaf19b188 Freeman Liu 2020-02-18 121 static int sprd_thm_cal_read(struct device_node *np, const char *cell_id, 554fdbaf19b188 Freeman Liu 2020-02-18 122 u32 *val) 554fdbaf19b188 Freeman Liu 2020-02-18 123 { 554fdbaf19b188 Freeman Liu 2020-02-18 124 struct nvmem_cell *cell; 554fdbaf19b188 Freeman Liu 2020-02-18 125 void *buf; 554fdbaf19b188 Freeman Liu 2020-02-18 126 size_t len; 554fdbaf19b188 Freeman Liu 2020-02-18 127 554fdbaf19b188 Freeman Liu 2020-02-18 @128 cell = of_nvmem_cell_get(np, cell_id); 554fdbaf19b188 Freeman Liu 2020-02-18 129 if (IS_ERR(cell)) 554fdbaf19b188 Freeman Liu 2020-02-18 130 return PTR_ERR(cell); 554fdbaf19b188 Freeman Liu 2020-02-18 131 554fdbaf19b188 Freeman Liu 2020-02-18 132 buf = nvmem_cell_read(cell, ); 554fdbaf19b188 Freeman Liu 2020-02-18 133 nvmem_cell_put(cell); 554fdbaf19b188 Freeman Liu 2020-02-18 134 if (IS_ERR(buf)) 554fdbaf19b188 Freeman Liu 2020-02-18 135 return PTR_ERR(buf); 554fdbaf19b188 Freeman Liu 2020-02-18 136 554fdbaf19b188 Freeman Liu 2020-02-18 137 if (len > sizeof(u32)) { 554fdbaf19b188 Freeman Liu 2020-02-18 138 kfree(buf); 554fdbaf19b188 Freeman Liu 2020-02-18 139 return -EINVAL; 554fdbaf19b188 Freeman Liu 2020-02-18 140 } 554fdbaf19b188 Freeman Liu 2020-02-18 141 554fdbaf19b188 Freeman Liu 2020-02-18 142 memcpy(val, buf, len); 554fdbaf19b188 Freeman Liu 2020-02-18 143 554fdbaf19b188 Freeman Liu 2020-02-18 144 kfree(buf); 554fdbaf19b188 Freeman Liu 2020-02-18 145 return 0; 554fdbaf19b188 Freeman Liu 2020-02-18 146 } 554fdbaf19b188 Freeman Liu 2020-02-18 147 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
[PATCH] nvmem: Change to unified property interface
Change from using device tree (Open Firmware) APIs to the unified 'fwnode' interface. Change of_nvmem_cell_get() to fwnode_nvmem_cell_get(), and add a wrapper for of_nvmem_cell_get(). Change of_nvmem_device_get() to fwnode_nvmem_device_get(). There are no known accessors to the OF interface, so no need for a wrapper. Signed-off-by: Kevin Paul Herbert --- drivers/nvmem/core.c | 176 - include/linux/nvmem-consumer.h | 27 ++--- 2 files changed, 123 insertions(+), 80 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index a5ab1e0c74cf..2e49304cd9a8 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -6,6 +6,7 @@ * Copyright (C) 2013 Maxime Ripard */ +#include #include #include #include @@ -17,6 +18,7 @@ #include #include #include +#include #include struct nvmem_device { @@ -52,7 +54,7 @@ struct nvmem_cell { int bytes; int bit_offset; int nbits; - struct device_node *np; + struct fwnode_handle*fwnode; struct nvmem_device *nvmem; struct list_headnode; }; @@ -424,7 +426,7 @@ static void nvmem_cell_drop(struct nvmem_cell *cell) mutex_lock(_mutex); list_del(>node); mutex_unlock(_mutex); - of_node_put(cell->np); + fwnode_handle_put(cell->fwnode); kfree_const(cell->name); kfree(cell); } @@ -670,39 +672,40 @@ static int nvmem_validate_keepouts(struct nvmem_device *nvmem) return 0; } -static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) +static int nvmem_add_cells_from_fw(struct nvmem_device *nvmem) { - struct device_node *parent, *child; + struct fwnode_handle *parent, *child; struct device *dev = >dev; struct nvmem_cell *cell; - const __be32 *addr; - int len; + int rval; + u32 vals[2]; - parent = dev->of_node; + parent = dev_fwnode(dev); - for_each_child_of_node(parent, child) { - addr = of_get_property(child, "reg", ); - if (!addr) + fwnode_for_each_child_node(parent, child) { + rval = fwnode_property_read_u32_array(child, "reg", NULL, 2); + if (rval < 0) continue; - if (len < 2 * sizeof(u32)) { - dev_err(dev, "nvmem: invalid reg on %pOF\n", child); + if (rval < 2) { + dev_err(dev, "nvmem: invalid reg %d on %pfw\n", + rval, child); return -EINVAL; } - + rval = fwnode_property_read_u32_array(child, "reg", vals, 2); cell = kzalloc(sizeof(*cell), GFP_KERNEL); if (!cell) return -ENOMEM; cell->nvmem = nvmem; - cell->np = of_node_get(child); - cell->offset = be32_to_cpup(addr++); - cell->bytes = be32_to_cpup(addr); - cell->name = kasprintf(GFP_KERNEL, "%pOFn", child); - - addr = of_get_property(child, "bits", ); - if (addr && len == (2 * sizeof(u32))) { - cell->bit_offset = be32_to_cpup(addr++); - cell->nbits = be32_to_cpup(addr); + cell->fwnode = child; + cell->offset = vals[0]; + cell->bytes = vals[1]; + cell->name = kasprintf(GFP_KERNEL, "%pfwn", child); + + rval = fwnode_property_read_u32_array(child, "bits", vals, 2); + if (rval >= 0) { + cell->bit_offset = vals[0]; + cell->nbits = vals[1]; } if (cell->nbits) @@ -715,7 +718,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) cell->name, nvmem->stride); /* Cells already added will be freed later. */ kfree_const(cell->name); - of_node_put(cell->np); + fwnode_handle_put(cell->fwnode); kfree(cell); return -EINVAL; } @@ -789,8 +792,10 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) nvmem->reg_write = config->reg_write; nvmem->keepout = config->keepout; nvmem->nkeepout = config->nkeepout; - if (!config->no_of_node) + if (!config->no_of_node) { nvmem->dev.of_node = config->dev->of_node; + nvmem->dev.fwnode = config->dev->fwnode; + } switch (config->id) { case NVMEM_DEVID_NONE: @@ -841,7 +846,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) if (rval) goto err_remove_cells; - rval = nvmem_add_cells_from_of(nvmem); +
[PATCH] nvmem: Change to unified property interface
Change from using device tree (Open Firmware) APIs to the unified 'fwnode' interface. Change of_nvmem_cell_get() to fwnode_nvmem_cell_get(), and add a wrapper for of_nvmem_cell_get(). Change of_nvmem_device_get() to fwnode_nvmem_device_get(). There are no known accessors to the OF interface, so no need for a wrapper. Signed-off-by: Kevin Paul Herbert --- drivers/nvmem/core.c | 176 - include/linux/nvmem-consumer.h | 27 ++--- 2 files changed, 123 insertions(+), 80 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index a5ab1e0c74cf..2e49304cd9a8 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -6,6 +6,7 @@ * Copyright (C) 2013 Maxime Ripard */ +#include #include #include #include @@ -17,6 +18,7 @@ #include #include #include +#include #include struct nvmem_device { @@ -52,7 +54,7 @@ struct nvmem_cell { int bytes; int bit_offset; int nbits; - struct device_node *np; + struct fwnode_handle*fwnode; struct nvmem_device *nvmem; struct list_headnode; }; @@ -424,7 +426,7 @@ static void nvmem_cell_drop(struct nvmem_cell *cell) mutex_lock(_mutex); list_del(>node); mutex_unlock(_mutex); - of_node_put(cell->np); + fwnode_handle_put(cell->fwnode); kfree_const(cell->name); kfree(cell); } @@ -670,39 +672,40 @@ static int nvmem_validate_keepouts(struct nvmem_device *nvmem) return 0; } -static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) +static int nvmem_add_cells_from_fw(struct nvmem_device *nvmem) { - struct device_node *parent, *child; + struct fwnode_handle *parent, *child; struct device *dev = >dev; struct nvmem_cell *cell; - const __be32 *addr; - int len; + int rval; + u32 vals[2]; - parent = dev->of_node; + parent = dev_fwnode(dev); - for_each_child_of_node(parent, child) { - addr = of_get_property(child, "reg", ); - if (!addr) + fwnode_for_each_child_node(parent, child) { + rval = fwnode_property_read_u32_array(child, "reg", NULL, 2); + if (rval < 0) continue; - if (len < 2 * sizeof(u32)) { - dev_err(dev, "nvmem: invalid reg on %pOF\n", child); + if (rval < 2) { + dev_err(dev, "nvmem: invalid reg %d on %pfw\n", + rval, child); return -EINVAL; } - + rval = fwnode_property_read_u32_array(child, "reg", vals, 2); cell = kzalloc(sizeof(*cell), GFP_KERNEL); if (!cell) return -ENOMEM; cell->nvmem = nvmem; - cell->np = of_node_get(child); - cell->offset = be32_to_cpup(addr++); - cell->bytes = be32_to_cpup(addr); - cell->name = kasprintf(GFP_KERNEL, "%pOFn", child); - - addr = of_get_property(child, "bits", ); - if (addr && len == (2 * sizeof(u32))) { - cell->bit_offset = be32_to_cpup(addr++); - cell->nbits = be32_to_cpup(addr); + cell->fwnode = child; + cell->offset = vals[0]; + cell->bytes = vals[1]; + cell->name = kasprintf(GFP_KERNEL, "%pfwn", child); + + rval = fwnode_property_read_u32_array(child, "bits", vals, 2); + if (rval >= 0) { + cell->bit_offset = vals[0]; + cell->nbits = vals[1]; } if (cell->nbits) @@ -715,7 +718,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) cell->name, nvmem->stride); /* Cells already added will be freed later. */ kfree_const(cell->name); - of_node_put(cell->np); + fwnode_handle_put(cell->fwnode); kfree(cell); return -EINVAL; } @@ -789,8 +792,10 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) nvmem->reg_write = config->reg_write; nvmem->keepout = config->keepout; nvmem->nkeepout = config->nkeepout; - if (!config->no_of_node) + if (!config->no_of_node) { nvmem->dev.of_node = config->dev->of_node; + nvmem->dev.fwnode = config->dev->fwnode; + } switch (config->id) { case NVMEM_DEVID_NONE: @@ -841,7 +846,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) if (rval) goto err_remove_cells; - rval = nvmem_add_cells_from_of(nvmem); +