59175c8051d571a481cedc811bd6fe9f91fd1dc0
[openwrt/openwrt.git] /
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
5
6 nvmem-consumer.h is included by consumer devices, extracting data from
7 NVMEM devices whereas nvmem-provider.h is included by devices providing
8 NVMEM content.
9
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.
12
13 While we do so, we also move the kdoc associated with the function to
14 the header rather than the .c file.
15
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>
20 ---
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(-)
25
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
29 }
30
31 #if IS_ENABLED(CONFIG_OF)
32 -/**
33 - * of_nvmem_layout_get_container() - Get OF node to layout container.
34 - *
35 - * @nvmem: nvmem device.
36 - *
37 - * Return: a node pointer with refcount incremented or NULL if no
38 - * container exists. Use of_node_put() on it when done.
39 - */
40 struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
41 {
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
46 const char *id);
47 struct nvmem_device *of_nvmem_device_get(struct device_node *np,
48 const char *name);
49 -struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem);
50 #else
51 static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
52 const char *id)
53 @@ -254,12 +253,6 @@ static inline struct nvmem_device *of_nv
54 {
55 return ERR_PTR(-EOPNOTSUPP);
56 }
57 -
58 -static inline struct device_node *
59 -of_nvmem_layout_get_container(struct nvmem_device *nvmem)
60 -{
61 - return NULL;
62 -}
63 #endif /* CONFIG_NVMEM && CONFIG_OF */
64
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
69
70 #endif /* CONFIG_NVMEM */
71
72 +#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
73 +
74 +/**
75 + * of_nvmem_layout_get_container() - Get OF node of layout container
76 + *
77 + * @nvmem: nvmem device
78 + *
79 + * Return: a node pointer with refcount incremented or NULL if no
80 + * container exists. Use of_node_put() on it when done.
81 + */
82 +struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem);
83 +
84 +#else /* CONFIG_NVMEM && CONFIG_OF */
85 +
86 +static inline struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
87 +{
88 + return NULL;
89 +}
90 +
91 +#endif /* CONFIG_NVMEM && CONFIG_OF */
92 +
93 #define module_nvmem_layout_driver(__layout_driver) \
94 module_driver(__layout_driver, nvmem_layout_register, \
95 nvmem_layout_unregister)