diff mbox series

nvmem: core: fix nvmem_layout_get_match_data()

Message ID 20230110104645.11705-1-zajec5@gmail.com (mailing list archive)
State Superseded
Headers show
Series nvmem: core: fix nvmem_layout_get_match_data() | expand

Commit Message

Rafał Miłecki Jan. 10, 2023, 10:46 a.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

This function was trying to match wrong OF node (parent device's)
against an of_match_table. It was always returning NULL.

Make it match layout's OF node against layout's of_match_table.

Fixes: f5709a684a0a ("nvmem: core: introduce NVMEM layouts")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 drivers/nvmem/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Michael Walle Jan. 10, 2023, 10:49 a.m. UTC | #1
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> This function was trying to match wrong OF node (parent device's)
> against an of_match_table. It was always returning NULL.
> 
> Make it match layout's OF node against layout's of_match_table.
> 
> Fixes: f5709a684a0a ("nvmem: core: introduce NVMEM layouts")
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

Reviewed-by: Michael Walle <michael@walle.cc>

Thanks!
-michael
kernel test robot Jan. 10, 2023, 1:33 p.m. UTC | #2
Hi Rafał,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linux-next/master]
[cannot apply to soc/for-next linus/master v6.2-rc3]
[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/nvmem-core-fix-nvmem_layout_get_match_data/20230110-184843
patch link:    https://lore.kernel.org/r/20230110104645.11705-1-zajec5%40gmail.com
patch subject: [PATCH] nvmem: core: fix nvmem_layout_get_match_data()
config: alpha-defconfig
compiler: alpha-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/cfe1a8f0e01284c430ab2395b321a460862aed4f
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Rafa-Mi-ecki/nvmem-core-fix-nvmem_layout_get_match_data/20230110-184843
        git checkout cfe1a8f0e01284c430ab2395b321a460862aed4f
        # 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=alpha olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash drivers/nvmem/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/nvmem/core.c: In function 'nvmem_layout_get_match_data':
>> drivers/nvmem/core.c:828:29: warning: variable 'layout_np' set but not used [-Wunused-but-set-variable]
     828 |         struct device_node *layout_np;
         |                             ^~~~~~~~~


vim +/layout_np +828 drivers/nvmem/core.c

   823	
   824	const void *nvmem_layout_get_match_data(struct nvmem_device *nvmem,
   825						struct nvmem_layout *layout)
   826	{
   827		const struct of_device_id *match;
 > 828		struct device_node *layout_np;
   829	
   830		layout_np = of_nvmem_layout_get_container(nvmem);
   831		match = of_match_node(layout->of_match_table, layout_np);
   832	
   833		return match ? match->data : NULL;
   834	}
   835	EXPORT_SYMBOL_GPL(nvmem_layout_get_match_data);
   836
diff mbox series

Patch

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index d112bb1328c1..1f05f0a50d86 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -825,8 +825,10 @@  const void *nvmem_layout_get_match_data(struct nvmem_device *nvmem,
 					struct nvmem_layout *layout)
 {
 	const struct of_device_id *match;
+	struct device_node *layout_np;
 
-	match = of_match_node(layout->of_match_table, nvmem->dev.of_node);
+	layout_np = of_nvmem_layout_get_container(nvmem);
+	match = of_match_node(layout->of_match_table, layout_np);
 
 	return match ? match->data : NULL;
 }