mtd: fix build with GCC 14
[openwrt/openwrt.git] / target / linux / generic / backport-5.15 / 834-v6.8-0004-nvmem-Move-and-rename-fixup_cell_info.patch
1 From 1172460e716784ac7e1049a537bdca8edbf97360 Mon Sep 17 00:00:00 2001
2 From: Miquel Raynal <miquel.raynal@bootlin.com>
3 Date: Fri, 15 Dec 2023 11:15:31 +0000
4 Subject: [PATCH] nvmem: Move and rename ->fixup_cell_info()
5
6 This hook is meant to be used by any provider and instantiating a layout
7 just for this is useless. Let's instead move this hook to the nvmem
8 device and add it to the config structure to be easily shared by the
9 providers.
10
11 While at moving this hook, rename it ->fixup_dt_cell_info() to clarify
12 its main intended purpose.
13
14 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
15 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
16 Link: https://lore.kernel.org/r/20231215111536.316972-6-srinivas.kandagatla@linaro.org
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 ---
19 drivers/nvmem/core.c | 6 +++---
20 drivers/nvmem/imx-ocotp.c | 11 +++--------
21 drivers/nvmem/internals.h | 2 ++
22 drivers/nvmem/mtk-efuse.c | 11 +++--------
23 include/linux/nvmem-provider.h | 9 ++++-----
24 5 files changed, 15 insertions(+), 24 deletions(-)
25
26 --- a/drivers/nvmem/core.c
27 +++ b/drivers/nvmem/core.c
28 @@ -676,7 +676,6 @@ static int nvmem_validate_keepouts(struc
29
30 static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np)
31 {
32 - struct nvmem_layout *layout = nvmem->layout;
33 struct device *dev = &nvmem->dev;
34 struct device_node *child;
35 const __be32 *addr;
36 @@ -706,8 +705,8 @@ static int nvmem_add_cells_from_dt(struc
37
38 info.np = of_node_get(child);
39
40 - if (layout && layout->fixup_cell_info)
41 - layout->fixup_cell_info(nvmem, layout, &info);
42 + if (nvmem->fixup_dt_cell_info)
43 + nvmem->fixup_dt_cell_info(nvmem, &info);
44
45 ret = nvmem_add_one_cell(nvmem, &info);
46 kfree(info.name);
47 @@ -896,6 +895,7 @@ struct nvmem_device *nvmem_register(cons
48
49 kref_init(&nvmem->refcnt);
50 INIT_LIST_HEAD(&nvmem->cells);
51 + nvmem->fixup_dt_cell_info = config->fixup_dt_cell_info;
52
53 nvmem->owner = config->owner;
54 if (!nvmem->owner && config->dev->driver)
55 --- a/drivers/nvmem/imx-ocotp.c
56 +++ b/drivers/nvmem/imx-ocotp.c
57 @@ -584,17 +584,12 @@ static const struct of_device_id imx_oco
58 };
59 MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids);
60
61 -static void imx_ocotp_fixup_cell_info(struct nvmem_device *nvmem,
62 - struct nvmem_layout *layout,
63 - struct nvmem_cell_info *cell)
64 +static void imx_ocotp_fixup_dt_cell_info(struct nvmem_device *nvmem,
65 + struct nvmem_cell_info *cell)
66 {
67 cell->read_post_process = imx_ocotp_cell_pp;
68 }
69
70 -static struct nvmem_layout imx_ocotp_layout = {
71 - .fixup_cell_info = imx_ocotp_fixup_cell_info,
72 -};
73 -
74 static int imx_ocotp_probe(struct platform_device *pdev)
75 {
76 struct device *dev = &pdev->dev;
77 @@ -620,7 +615,7 @@ static int imx_ocotp_probe(struct platfo
78 imx_ocotp_nvmem_config.size = 4 * priv->params->nregs;
79 imx_ocotp_nvmem_config.dev = dev;
80 imx_ocotp_nvmem_config.priv = priv;
81 - imx_ocotp_nvmem_config.layout = &imx_ocotp_layout;
82 + imx_ocotp_nvmem_config.fixup_dt_cell_info = &imx_ocotp_fixup_dt_cell_info;
83
84 priv->config = &imx_ocotp_nvmem_config;
85
86 --- a/drivers/nvmem/internals.h
87 +++ b/drivers/nvmem/internals.h
88 @@ -23,6 +23,8 @@ struct nvmem_device {
89 struct bin_attribute eeprom;
90 struct device *base_dev;
91 struct list_head cells;
92 + void (*fixup_dt_cell_info)(struct nvmem_device *nvmem,
93 + struct nvmem_cell_info *cell);
94 const struct nvmem_keepout *keepout;
95 unsigned int nkeepout;
96 nvmem_reg_read_t reg_read;
97 --- a/drivers/nvmem/mtk-efuse.c
98 +++ b/drivers/nvmem/mtk-efuse.c
99 @@ -45,9 +45,8 @@ static int mtk_efuse_gpu_speedbin_pp(voi
100 return 0;
101 }
102
103 -static void mtk_efuse_fixup_cell_info(struct nvmem_device *nvmem,
104 - struct nvmem_layout *layout,
105 - struct nvmem_cell_info *cell)
106 +static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
107 + struct nvmem_cell_info *cell)
108 {
109 size_t sz = strlen(cell->name);
110
111 @@ -61,10 +60,6 @@ static void mtk_efuse_fixup_cell_info(st
112 cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
113 }
114
115 -static struct nvmem_layout mtk_efuse_layout = {
116 - .fixup_cell_info = mtk_efuse_fixup_cell_info,
117 -};
118 -
119 static int mtk_efuse_probe(struct platform_device *pdev)
120 {
121 struct device *dev = &pdev->dev;
122 @@ -91,7 +86,7 @@ static int mtk_efuse_probe(struct platfo
123 econfig.priv = priv;
124 econfig.dev = dev;
125 if (pdata->uses_post_processing)
126 - econfig.layout = &mtk_efuse_layout;
127 + econfig.fixup_dt_cell_info = &mtk_efuse_fixup_dt_cell_info;
128 nvmem = devm_nvmem_register(dev, &econfig);
129
130 return PTR_ERR_OR_ZERO(nvmem);
131 --- a/include/linux/nvmem-provider.h
132 +++ b/include/linux/nvmem-provider.h
133 @@ -83,6 +83,8 @@ struct nvmem_cell_info {
134 * @cells: Optional array of pre-defined NVMEM cells.
135 * @ncells: Number of elements in cells.
136 * @add_legacy_fixed_of_cells: Read fixed NVMEM cells from old OF syntax.
137 + * @fixup_dt_cell_info: Will be called before a cell is added. Can be
138 + * used to modify the nvmem_cell_info.
139 * @keepout: Optional array of keepout ranges (sorted ascending by start).
140 * @nkeepout: Number of elements in the keepout array.
141 * @type: Type of the nvmem storage
142 @@ -113,6 +115,8 @@ struct nvmem_config {
143 const struct nvmem_cell_info *cells;
144 int ncells;
145 bool add_legacy_fixed_of_cells;
146 + void (*fixup_dt_cell_info)(struct nvmem_device *nvmem,
147 + struct nvmem_cell_info *cell);
148 const struct nvmem_keepout *keepout;
149 unsigned int nkeepout;
150 enum nvmem_type type;
151 @@ -158,8 +162,6 @@ struct nvmem_cell_table {
152 * @of_match_table: Open firmware match table.
153 * @add_cells: Called to populate the layout using
154 * nvmem_add_one_cell().
155 - * @fixup_cell_info: Will be called before a cell is added. Can be
156 - * used to modify the nvmem_cell_info.
157 * @owner: Pointer to struct module.
158 * @node: List node.
159 *
160 @@ -172,9 +174,6 @@ struct nvmem_layout {
161 const char *name;
162 const struct of_device_id *of_match_table;
163 int (*add_cells)(struct device *dev, struct nvmem_device *nvmem);
164 - void (*fixup_cell_info)(struct nvmem_device *nvmem,
165 - struct nvmem_layout *layout,
166 - struct nvmem_cell_info *cell);
167
168 /* private */
169 struct module *owner;