1 From 4a1a40233b4a9fc159a5c7a27dc34c5c7bc5be55 Mon Sep 17 00:00:00 2001
2 From: Miquel Raynal <miquel.raynal@bootlin.com>
3 Date: Fri, 15 Dec 2023 11:15:28 +0000
4 Subject: [PATCH] nvmem: Move of_nvmem_layout_get_container() in another header
6 nvmem-consumer.h is included by consumer devices, extracting data from
7 NVMEM devices whereas nvmem-provider.h is included by devices providing
10 The only users of of_nvmem_layout_get_container() outside of the core
11 are layout drivers, so better move its prototype to nvmem-provider.h.
13 While we do so, we also move the kdoc associated with the function to
14 the header rather than the .c file.
16 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
17 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
18 Link: https://lore.kernel.org/r/20231215111536.316972-3-srinivas.kandagatla@linaro.org
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21 drivers/nvmem/core.c | 8 --------
22 include/linux/nvmem-consumer.h | 7 -------
23 include/linux/nvmem-provider.h | 21 +++++++++++++++++++++
24 3 files changed, 21 insertions(+), 15 deletions(-)
26 --- a/drivers/nvmem/core.c
27 +++ b/drivers/nvmem/core.c
28 @@ -847,14 +847,6 @@ static int nvmem_add_cells_from_layout(s
31 #if IS_ENABLED(CONFIG_OF)
33 - * of_nvmem_layout_get_container() - Get OF node to layout container.
35 - * @nvmem: nvmem device.
37 - * Return: a node pointer with refcount incremented or NULL if no
38 - * container exists. Use of_node_put() on it when done.
40 struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
42 return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout");
43 --- a/include/linux/nvmem-consumer.h
44 +++ b/include/linux/nvmem-consumer.h
45 @@ -241,7 +241,6 @@ struct nvmem_cell *of_nvmem_cell_get(str
47 struct nvmem_device *of_nvmem_device_get(struct device_node *np,
49 -struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem);
51 static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
53 @@ -254,12 +253,6 @@ static inline struct nvmem_device *of_nv
55 return ERR_PTR(-EOPNOTSUPP);
58 -static inline struct device_node *
59 -of_nvmem_layout_get_container(struct nvmem_device *nvmem)
63 #endif /* CONFIG_NVMEM && CONFIG_OF */
65 #endif /* ifndef _LINUX_NVMEM_CONSUMER_H */
66 --- a/include/linux/nvmem-provider.h
67 +++ b/include/linux/nvmem-provider.h
68 @@ -244,6 +244,27 @@ nvmem_layout_get_match_data(struct nvmem
70 #endif /* CONFIG_NVMEM */
72 +#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
75 + * of_nvmem_layout_get_container() - Get OF node of layout container
77 + * @nvmem: nvmem device
79 + * Return: a node pointer with refcount incremented or NULL if no
80 + * container exists. Use of_node_put() on it when done.
82 +struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem);
84 +#else /* CONFIG_NVMEM && CONFIG_OF */
86 +static inline struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
91 +#endif /* CONFIG_NVMEM && CONFIG_OF */
93 #define module_nvmem_layout_driver(__layout_driver) \
94 module_driver(__layout_driver, nvmem_layout_register, \
95 nvmem_layout_unregister)