Skip to contentSkip to conversation

nvmem: core: fix nvmem_layout_get_match_data()

PATCH In review Rafał Miłecki 2 participants 2 messages Jan 10, 2023 – Jan 20, 2023 NVMEM framework

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nvmem: core: fix nvmem_layout_get_match_data()

From: Rafał Miłecki <[email protected]>

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.

Note: __maybe_unused is needed to avoid:
warning: variable 'layout_np' set but not used [-Wunused-but-set-variable] (of_match_node() is no-op without CONFIG_OF).

Fixes f5709a684a0a ("nvmem: core: introduce NVMEM layouts")
---
 drivers/nvmem/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvmem/core.c +3 -1
index d112bb1328c1..d3be50ed2d0b 100644
@@ -824,9 +824,11 @@ EXPORT_SYMBOL_GPL(of_nvmem_layout_get_container);
 const void *nvmem_layout_get_match_data(struct nvmem_device *nvmem,
 					struct nvmem_layout *layout)
 {
+	struct device_node __maybe_unused *layout_np;
 	const struct of_device_id *match;
 
-	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;
 }
Signature · 1 line
2.34.1
#1 lore raw
Quoted 7 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

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.

Quoted 7 lines

Note: __maybe_unused is needed to avoid:
warning: variable 'layout_np' set but not used [-Wunused-but-set-variable] (of_match_node() is no-op without CONFIG_OF).

Fixes f5709a684a0a ("nvmem: core: introduce NVMEM layouts")

Applied thanks,

--srini

Quoted 21 lines
---
  drivers/nvmem/core.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvmem/core.c +3 -1
index d112bb1328c1..d3be50ed2d0b 100644
@@ -824,9 +824,11 @@ EXPORT_SYMBOL_GPL(of_nvmem_layout_get_container);
  const void *nvmem_layout_get_match_data(struct nvmem_device *nvmem,
  					struct nvmem_layout *layout)
  {
+	struct device_node __maybe_unused *layout_np;
  	const struct of_device_id *match;
 
-	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;
  }