[v6.8,2/2] nvmem: drop nvmem_layout_get_match_data()

Message ID 20231219120104.3422-2-zajec5@gmail.com
State New
Headers
Series [v6.8,1/2] nvmem: layouts: refactor .add_cells() callback arguments |

Commit Message

Rafał Miłecki Dec. 19, 2023, 12:01 p.m. UTC
  From: Rafał Miłecki <rafal@milecki.pl>

Thanks for layouts refactoring we now have "struct device" associated
with layout. Also its OF pointer points directly to the "nvmem-layout"
DT node.

All it takes to get match data is a generic of_device_get_match_data().

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

Comments

Michael Walle Dec. 19, 2023, 12:21 p.m. UTC | #1
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> Thanks for layouts refactoring we now have "struct device" associated
> with layout. Also its OF pointer points directly to the "nvmem-layout"
> DT node.
> 
> All it takes to get match data is a generic of_device_get_match_data().

Isn't device_get_match_data() preferred?

> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Michael Walle <michael@walle.cc>

-michael
  
Rafał Miłecki Dec. 19, 2023, 12:33 p.m. UTC | #2
On 19.12.2023 13:21, Michael Walle wrote:
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> Thanks for layouts refactoring we now have "struct device" associated
>> with layout. Also its OF pointer points directly to the "nvmem-layout"
>> DT node.
>>
>> All it takes to get match data is a generic of_device_get_match_data().
> 
> Isn't device_get_match_data() preferred?

You're right. I think a big crusade against of_device_get_match_data()
is still ahead of us but I'll make sure to use device_get_match_data()
in U-Boot env layout to shine as an example :)


>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> Reviewed-by: Michael Walle <michael@walle.cc>

Thank you for quick reviews!
  
Miquel Raynal Dec. 19, 2023, 12:56 p.m. UTC | #3
Hi Rafał,

zajec5@gmail.com wrote on Tue, 19 Dec 2023 13:01:04 +0100:

> From: Rafał Miłecki <rafal@milecki.pl>
> 
> Thanks for layouts refactoring we now have "struct device" associated
> with layout. Also its OF pointer points directly to the "nvmem-layout"
> DT node.
> 
> All it takes to get match data is a generic of_device_get_match_data().
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl
  

Patch

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 441d132ebb61..4ed54076346d 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -876,19 +876,6 @@  void nvmem_layout_unregister(struct nvmem_layout *layout)
 }
 EXPORT_SYMBOL_GPL(nvmem_layout_unregister);
 
-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;
-
-	layout_np = of_nvmem_layout_get_container(nvmem);
-	match = of_match_node(layout->dev.driver->of_match_table, layout_np);
-
-	return match ? match->data : NULL;
-}
-EXPORT_SYMBOL_GPL(nvmem_layout_get_match_data);
-
 /**
  * nvmem_register() - Register a nvmem device for given nvmem_config.
  * Also creates a binary entry in /sys/bus/nvmem/devices/dev-name/nvmem
diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
index 81a67642ac55..f0ba0e03218f 100644
--- a/include/linux/nvmem-provider.h
+++ b/include/linux/nvmem-provider.h
@@ -205,9 +205,6 @@  void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv);
 	module_driver(__nvmem_layout_driver, nvmem_layout_driver_register, \
 		      nvmem_layout_driver_unregister)
 
-const void *nvmem_layout_get_match_data(struct nvmem_device *nvmem,
-					struct nvmem_layout *layout);
-
 #else
 
 static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
@@ -238,13 +235,6 @@  static inline int nvmem_layout_register(struct nvmem_layout *layout)
 
 static inline void nvmem_layout_unregister(struct nvmem_layout *layout) {}
 
-static inline const void *
-nvmem_layout_get_match_data(struct nvmem_device *nvmem,
-			    struct nvmem_layout *layout)
-{
-	return NULL;
-}
-
 #endif /* CONFIG_NVMEM */
 
 #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)