Commit 88b3a37eaab4004cd3d26976dc3ee875bdba0b63

Authored by Simon Glass
1 parent d975ce21ce

dm: core: Use const device for the dev_read_...() interface

These functions do not modify the device so should use a const pointer to
it. Update the code accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 159 additions and 143 deletions Side-by-side Diff

... ... @@ -11,27 +11,29 @@
11 11 #include <mapmem.h>
12 12 #include <dm/of_access.h>
13 13  
14   -int dev_read_u32(struct udevice *dev, const char *propname, u32 *outp)
  14 +int dev_read_u32(const struct udevice *dev, const char *propname, u32 *outp)
15 15 {
16 16 return ofnode_read_u32(dev_ofnode(dev), propname, outp);
17 17 }
18 18  
19   -int dev_read_u32_default(struct udevice *dev, const char *propname, int def)
  19 +int dev_read_u32_default(const struct udevice *dev, const char *propname,
  20 + int def)
20 21 {
21 22 return ofnode_read_u32_default(dev_ofnode(dev), propname, def);
22 23 }
23 24  
24   -int dev_read_s32(struct udevice *dev, const char *propname, s32 *outp)
  25 +int dev_read_s32(const struct udevice *dev, const char *propname, s32 *outp)
25 26 {
26 27 return ofnode_read_u32(dev_ofnode(dev), propname, (u32 *)outp);
27 28 }
28 29  
29   -int dev_read_s32_default(struct udevice *dev, const char *propname, int def)
  30 +int dev_read_s32_default(const struct udevice *dev, const char *propname,
  31 + int def)
30 32 {
31 33 return ofnode_read_u32_default(dev_ofnode(dev), propname, def);
32 34 }
33 35  
34   -int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp)
  36 +int dev_read_u32u(const struct udevice *dev, const char *propname, uint *outp)
35 37 {
36 38 u32 val;
37 39 int ret;
38 40  
39 41  
40 42  
41 43  
42 44  
... ... @@ -44,32 +46,33 @@
44 46 return 0;
45 47 }
46 48  
47   -int dev_read_u64(struct udevice *dev, const char *propname, u64 *outp)
  49 +int dev_read_u64(const struct udevice *dev, const char *propname, u64 *outp)
48 50 {
49 51 return ofnode_read_u64(dev_ofnode(dev), propname, outp);
50 52 }
51 53  
52   -u64 dev_read_u64_default(struct udevice *dev, const char *propname, u64 def)
  54 +u64 dev_read_u64_default(const struct udevice *dev, const char *propname,
  55 + u64 def)
53 56 {
54 57 return ofnode_read_u64_default(dev_ofnode(dev), propname, def);
55 58 }
56 59  
57   -const char *dev_read_string(struct udevice *dev, const char *propname)
  60 +const char *dev_read_string(const struct udevice *dev, const char *propname)
58 61 {
59 62 return ofnode_read_string(dev_ofnode(dev), propname);
60 63 }
61 64  
62   -bool dev_read_bool(struct udevice *dev, const char *propname)
  65 +bool dev_read_bool(const struct udevice *dev, const char *propname)
63 66 {
64 67 return ofnode_read_bool(dev_ofnode(dev), propname);
65 68 }
66 69  
67   -ofnode dev_read_subnode(struct udevice *dev, const char *subnode_name)
  70 +ofnode dev_read_subnode(const struct udevice *dev, const char *subnode_name)
68 71 {
69 72 return ofnode_find_subnode(dev_ofnode(dev), subnode_name);
70 73 }
71 74  
72   -ofnode dev_read_first_subnode(struct udevice *dev)
  75 +ofnode dev_read_first_subnode(const struct udevice *dev)
73 76 {
74 77 return ofnode_first_subnode(dev_ofnode(dev));
75 78 }
76 79  
... ... @@ -79,12 +82,12 @@
79 82 return ofnode_next_subnode(node);
80 83 }
81 84  
82   -int dev_read_size(struct udevice *dev, const char *propname)
  85 +int dev_read_size(const struct udevice *dev, const char *propname)
83 86 {
84 87 return ofnode_read_size(dev_ofnode(dev), propname);
85 88 }
86 89  
87   -fdt_addr_t dev_read_addr_index(struct udevice *dev, int index)
  90 +fdt_addr_t dev_read_addr_index(const struct udevice *dev, int index)
88 91 {
89 92 if (ofnode_is_np(dev_ofnode(dev)))
90 93 return ofnode_get_addr_index(dev_ofnode(dev), index);
... ... @@ -92,7 +95,7 @@
92 95 return devfdt_get_addr_index(dev, index);
93 96 }
94 97  
95   -fdt_addr_t dev_read_addr_size_index(struct udevice *dev, int index,
  98 +fdt_addr_t dev_read_addr_size_index(const struct udevice *dev, int index,
96 99 fdt_size_t *size)
97 100 {
98 101 if (ofnode_is_np(dev_ofnode(dev)))
... ... @@ -101,7 +104,7 @@
101 104 return devfdt_get_addr_size_index(dev, index, size);
102 105 }
103 106  
104   -void *dev_remap_addr_index(struct udevice *dev, int index)
  107 +void *dev_remap_addr_index(const struct udevice *dev, int index)
105 108 {
106 109 fdt_addr_t addr = dev_read_addr_index(dev, index);
107 110  
... ... @@ -111,7 +114,7 @@
111 114 return map_physmem(addr, 0, MAP_NOCACHE);
112 115 }
113 116  
114   -fdt_addr_t dev_read_addr_name(struct udevice *dev, const char *name)
  117 +fdt_addr_t dev_read_addr_name(const struct udevice *dev, const char *name)
115 118 {
116 119 int index = dev_read_stringlist_search(dev, "reg-names", name);
117 120  
... ... @@ -121,7 +124,7 @@
121 124 return dev_read_addr_index(dev, index);
122 125 }
123 126  
124   -fdt_addr_t dev_read_addr_size_name(struct udevice *dev, const char *name,
  127 +fdt_addr_t dev_read_addr_size_name(const struct udevice *dev, const char *name,
125 128 fdt_size_t *size)
126 129 {
127 130 int index = dev_read_stringlist_search(dev, "reg-names", name);
... ... @@ -132,7 +135,7 @@
132 135 return dev_read_addr_size_index(dev, index, size);
133 136 }
134 137  
135   -void *dev_remap_addr_name(struct udevice *dev, const char *name)
  138 +void *dev_remap_addr_name(const struct udevice *dev, const char *name)
136 139 {
137 140 fdt_addr_t addr = dev_read_addr_name(dev, name);
138 141  
139 142  
140 143  
141 144  
142 145  
143 146  
144 147  
145 148  
146 149  
... ... @@ -142,52 +145,52 @@
142 145 return map_physmem(addr, 0, MAP_NOCACHE);
143 146 }
144 147  
145   -fdt_addr_t dev_read_addr(struct udevice *dev)
  148 +fdt_addr_t dev_read_addr(const struct udevice *dev)
146 149 {
147 150 return dev_read_addr_index(dev, 0);
148 151 }
149 152  
150   -void *dev_read_addr_ptr(struct udevice *dev)
  153 +void *dev_read_addr_ptr(const struct udevice *dev)
151 154 {
152 155 fdt_addr_t addr = dev_read_addr(dev);
153 156  
154 157 return (addr == FDT_ADDR_T_NONE) ? NULL : map_sysmem(addr, 0);
155 158 }
156 159  
157   -void *dev_remap_addr(struct udevice *dev)
  160 +void *dev_remap_addr(const struct udevice *dev)
158 161 {
159 162 return dev_remap_addr_index(dev, 0);
160 163 }
161 164  
162   -fdt_addr_t dev_read_addr_size(struct udevice *dev, const char *property,
  165 +fdt_addr_t dev_read_addr_size(const struct udevice *dev, const char *property,
163 166 fdt_size_t *sizep)
164 167 {
165 168 return ofnode_get_addr_size(dev_ofnode(dev), property, sizep);
166 169 }
167 170  
168   -const char *dev_read_name(struct udevice *dev)
  171 +const char *dev_read_name(const struct udevice *dev)
169 172 {
170 173 return ofnode_get_name(dev_ofnode(dev));
171 174 }
172 175  
173   -int dev_read_stringlist_search(struct udevice *dev, const char *property,
  176 +int dev_read_stringlist_search(const struct udevice *dev, const char *property,
174 177 const char *string)
175 178 {
176 179 return ofnode_stringlist_search(dev_ofnode(dev), property, string);
177 180 }
178 181  
179   -int dev_read_string_index(struct udevice *dev, const char *propname, int index,
180   - const char **outp)
  182 +int dev_read_string_index(const struct udevice *dev, const char *propname,
  183 + int index, const char **outp)
181 184 {
182 185 return ofnode_read_string_index(dev_ofnode(dev), propname, index, outp);
183 186 }
184 187  
185   -int dev_read_string_count(struct udevice *dev, const char *propname)
  188 +int dev_read_string_count(const struct udevice *dev, const char *propname)
186 189 {
187 190 return ofnode_read_string_count(dev_ofnode(dev), propname);
188 191 }
189 192  
190   -int dev_read_phandle_with_args(struct udevice *dev, const char *list_name,
  193 +int dev_read_phandle_with_args(const struct udevice *dev, const char *list_name,
191 194 const char *cells_name, int cell_count,
192 195 int index, struct ofnode_phandle_args *out_args)
193 196 {
194 197  
195 198  
196 199  
197 200  
198 201  
... ... @@ -196,34 +199,34 @@
196 199 out_args);
197 200 }
198 201  
199   -int dev_count_phandle_with_args(struct udevice *dev, const char *list_name,
200   - const char *cells_name)
  202 +int dev_count_phandle_with_args(const struct udevice *dev,
  203 + const char *list_name, const char *cells_name)
201 204 {
202 205 return ofnode_count_phandle_with_args(dev_ofnode(dev), list_name,
203 206 cells_name);
204 207 }
205 208  
206   -int dev_read_addr_cells(struct udevice *dev)
  209 +int dev_read_addr_cells(const struct udevice *dev)
207 210 {
208 211 return ofnode_read_addr_cells(dev_ofnode(dev));
209 212 }
210 213  
211   -int dev_read_size_cells(struct udevice *dev)
  214 +int dev_read_size_cells(const struct udevice *dev)
212 215 {
213 216 return ofnode_read_size_cells(dev_ofnode(dev));
214 217 }
215 218  
216   -int dev_read_simple_addr_cells(struct udevice *dev)
  219 +int dev_read_simple_addr_cells(const struct udevice *dev)
217 220 {
218 221 return ofnode_read_simple_addr_cells(dev_ofnode(dev));
219 222 }
220 223  
221   -int dev_read_simple_size_cells(struct udevice *dev)
  224 +int dev_read_simple_size_cells(const struct udevice *dev)
222 225 {
223 226 return ofnode_read_simple_size_cells(dev_ofnode(dev));
224 227 }
225 228  
226   -int dev_read_phandle(struct udevice *dev)
  229 +int dev_read_phandle(const struct udevice *dev)
227 230 {
228 231 ofnode node = dev_ofnode(dev);
229 232  
230 233  
... ... @@ -233,12 +236,13 @@
233 236 return fdt_get_phandle(gd->fdt_blob, ofnode_to_offset(node));
234 237 }
235 238  
236   -const void *dev_read_prop(struct udevice *dev, const char *propname, int *lenp)
  239 +const void *dev_read_prop(const struct udevice *dev, const char *propname,
  240 + int *lenp)
237 241 {
238 242 return ofnode_get_property(dev_ofnode(dev), propname, lenp);
239 243 }
240 244  
241   -int dev_read_alias_seq(struct udevice *dev, int *devnump)
  245 +int dev_read_alias_seq(const struct udevice *dev, int *devnump)
242 246 {
243 247 ofnode node = dev_ofnode(dev);
244 248 const char *uc_name = dev->uclass->uc_drv->name;
245 249  
246 250  
... ... @@ -256,19 +260,19 @@
256 260 return ret;
257 261 }
258 262  
259   -int dev_read_u32_array(struct udevice *dev, const char *propname,
  263 +int dev_read_u32_array(const struct udevice *dev, const char *propname,
260 264 u32 *out_values, size_t sz)
261 265 {
262 266 return ofnode_read_u32_array(dev_ofnode(dev), propname, out_values, sz);
263 267 }
264 268  
265   -const uint8_t *dev_read_u8_array_ptr(struct udevice *dev, const char *propname,
266   - size_t sz)
  269 +const uint8_t *dev_read_u8_array_ptr(const struct udevice *dev,
  270 + const char *propname, size_t sz)
267 271 {
268 272 return ofnode_read_u8_array_ptr(dev_ofnode(dev), propname, sz);
269 273 }
270 274  
271   -int dev_read_enabled(struct udevice *dev)
  275 +int dev_read_enabled(const struct udevice *dev)
272 276 {
273 277 ofnode node = dev_ofnode(dev);
274 278  
275 279  
276 280  
277 281  
... ... @@ -279,23 +283,24 @@
279 283 ofnode_to_offset(node));
280 284 }
281 285  
282   -int dev_read_resource(struct udevice *dev, uint index, struct resource *res)
  286 +int dev_read_resource(const struct udevice *dev, uint index,
  287 + struct resource *res)
283 288 {
284 289 return ofnode_read_resource(dev_ofnode(dev), index, res);
285 290 }
286 291  
287   -int dev_read_resource_byname(struct udevice *dev, const char *name,
  292 +int dev_read_resource_byname(const struct udevice *dev, const char *name,
288 293 struct resource *res)
289 294 {
290 295 return ofnode_read_resource_byname(dev_ofnode(dev), name, res);
291 296 }
292 297  
293   -u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr)
  298 +u64 dev_translate_address(const struct udevice *dev, const fdt32_t *in_addr)
294 299 {
295 300 return ofnode_translate_address(dev_ofnode(dev), in_addr);
296 301 }
297 302  
298   -u64 dev_translate_dma_address(struct udevice *dev, const fdt32_t *in_addr)
  303 +u64 dev_translate_dma_address(const struct udevice *dev, const fdt32_t *in_addr)
299 304 {
300 305 return ofnode_translate_dma_address(dev_ofnode(dev), in_addr);
301 306 }
... ... @@ -308,7 +313,7 @@
308 313 return fdtdec_get_alias_highest_id(gd->fdt_blob, stem);
309 314 }
310 315  
311   -fdt_addr_t dev_read_addr_pci(struct udevice *dev)
  316 +fdt_addr_t dev_read_addr_pci(const struct udevice *dev)
312 317 {
313 318 ulong addr;
314 319  
... ... @@ -16,12 +16,12 @@
16 16 struct resource;
17 17  
18 18 #if CONFIG_IS_ENABLED(OF_LIVE)
19   -static inline const struct device_node *dev_np(struct udevice *dev)
  19 +static inline const struct device_node *dev_np(const struct udevice *dev)
20 20 {
21 21 return ofnode_to_np(dev->node);
22 22 }
23 23 #else
24   -static inline const struct device_node *dev_np(struct udevice *dev)
  24 +static inline const struct device_node *dev_np(const struct udevice *dev)
25 25 {
26 26 return NULL;
27 27 }
... ... @@ -53,7 +53,7 @@
53 53 * @outp: place to put value (if found)
54 54 * @return 0 if OK, -ve on error
55 55 */
56   -int dev_read_u32(struct udevice *dev, const char *propname, u32 *outp);
  56 +int dev_read_u32(const struct udevice *dev, const char *propname, u32 *outp);
57 57  
58 58 /**
59 59 * dev_read_u32_default() - read a 32-bit integer from a device's DT property
... ... @@ -63,7 +63,8 @@
63 63 * @def: default value to return if the property has no value
64 64 * @return property value, or @def if not found
65 65 */
66   -int dev_read_u32_default(struct udevice *dev, const char *propname, int def);
  66 +int dev_read_u32_default(const struct udevice *dev, const char *propname,
  67 + int def);
67 68  
68 69 /**
69 70 * dev_read_s32() - read a signed 32-bit integer from a device's DT property
... ... @@ -73,7 +74,7 @@
73 74 * @outp: place to put value (if found)
74 75 * @return 0 if OK, -ve on error
75 76 */
76   -int dev_read_s32(struct udevice *dev, const char *propname, s32 *outp);
  77 +int dev_read_s32(const struct udevice *dev, const char *propname, s32 *outp);
77 78  
78 79 /**
79 80 * dev_read_s32_default() - read a signed 32-bit int from a device's DT property
... ... @@ -83,7 +84,8 @@
83 84 * @def: default value to return if the property has no value
84 85 * @return property value, or @def if not found
85 86 */
86   -int dev_read_s32_default(struct udevice *dev, const char *propname, int def);
  87 +int dev_read_s32_default(const struct udevice *dev, const char *propname,
  88 + int def);
87 89  
88 90 /**
89 91 * dev_read_u32u() - read a 32-bit integer from a device's DT property
... ... @@ -95,7 +97,7 @@
95 97 * @outp: place to put value (if found)
96 98 * @return 0 if OK, -ve on error
97 99 */
98   -int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp);
  100 +int dev_read_u32u(const struct udevice *dev, const char *propname, uint *outp);
99 101  
100 102 /**
101 103 * dev_read_u64() - read a 64-bit integer from a device's DT property
... ... @@ -105,7 +107,7 @@
105 107 * @outp: place to put value (if found)
106 108 * @return 0 if OK, -ve on error
107 109 */
108   -int dev_read_u64(struct udevice *dev, const char *propname, u64 *outp);
  110 +int dev_read_u64(const struct udevice *dev, const char *propname, u64 *outp);
109 111  
110 112 /**
111 113 * dev_read_u64_default() - read a 64-bit integer from a device's DT property
... ... @@ -115,7 +117,8 @@
115 117 * @def: default value to return if the property has no value
116 118 * @return property value, or @def if not found
117 119 */
118   -u64 dev_read_u64_default(struct udevice *dev, const char *propname, u64 def);
  120 +u64 dev_read_u64_default(const struct udevice *dev, const char *propname,
  121 + u64 def);
119 122  
120 123 /**
121 124 * dev_read_string() - Read a string from a device's DT property
... ... @@ -124,7 +127,7 @@
124 127 * @propname: name of the property to read
125 128 * @return string from property value, or NULL if there is no such property
126 129 */
127   -const char *dev_read_string(struct udevice *dev, const char *propname);
  130 +const char *dev_read_string(const struct udevice *dev, const char *propname);
128 131  
129 132 /**
130 133 * dev_read_bool() - read a boolean value from a device's DT property
... ... @@ -133,7 +136,7 @@
133 136 * @propname: name of property to read
134 137 * @return true if property is present (meaning true), false if not present
135 138 */
136   -bool dev_read_bool(struct udevice *dev, const char *propname);
  139 +bool dev_read_bool(const struct udevice *dev, const char *propname);
137 140  
138 141 /**
139 142 * dev_read_subnode() - find a named subnode of a device
... ... @@ -143,7 +146,7 @@
143 146 * @return reference to subnode (which can be invalid if there is no such
144 147 * subnode)
145 148 */
146   -ofnode dev_read_subnode(struct udevice *dev, const char *subbnode_name);
  149 +ofnode dev_read_subnode(const struct udevice *dev, const char *subbnode_name);
147 150  
148 151 /**
149 152 * dev_read_size() - read the size of a property
... ... @@ -152,7 +155,7 @@
152 155 * @propname: property to check
153 156 * @return size of property if present, or -EINVAL if not
154 157 */
155   -int dev_read_size(struct udevice *dev, const char *propname);
  158 +int dev_read_size(const struct udevice *dev, const char *propname);
156 159  
157 160 /**
158 161 * dev_read_addr_index() - Get the indexed reg property of a device
... ... @@ -163,7 +166,7 @@
163 166 *
164 167 * @return address or FDT_ADDR_T_NONE if not found
165 168 */
166   -fdt_addr_t dev_read_addr_index(struct udevice *dev, int index);
  169 +fdt_addr_t dev_read_addr_index(const struct udevice *dev, int index);
167 170  
168 171 /**
169 172 * dev_read_addr_size_index() - Get the indexed reg property of a device
... ... @@ -175,7 +178,7 @@
175 178 *
176 179 * @return address or FDT_ADDR_T_NONE if not found
177 180 */
178   -fdt_addr_t dev_read_addr_size_index(struct udevice *dev, int index,
  181 +fdt_addr_t dev_read_addr_size_index(const struct udevice *dev, int index,
179 182 fdt_size_t *size);
180 183  
181 184 /**
... ... @@ -188,7 +191,7 @@
188 191 *
189 192 * @return pointer or NULL if not found
190 193 */
191   -void *dev_remap_addr_index(struct udevice *dev, int index);
  194 +void *dev_remap_addr_index(const struct udevice *dev, int index);
192 195  
193 196 /**
194 197 * dev_read_addr_name() - Get the reg property of a device, indexed by name
... ... @@ -200,7 +203,7 @@
200 203 *
201 204 * @return address or FDT_ADDR_T_NONE if not found
202 205 */
203   -fdt_addr_t dev_read_addr_name(struct udevice *dev, const char* name);
  206 +fdt_addr_t dev_read_addr_name(const struct udevice *dev, const char *name);
204 207  
205 208 /**
206 209 * dev_read_addr_size_name() - Get the reg property of a device, indexed by name
... ... @@ -213,7 +216,7 @@
213 216 *
214 217 * @return address or FDT_ADDR_T_NONE if not found
215 218 */
216   -fdt_addr_t dev_read_addr_size_name(struct udevice *dev, const char *name,
  219 +fdt_addr_t dev_read_addr_size_name(const struct udevice *dev, const char *name,
217 220 fdt_size_t *size);
218 221  
219 222 /**
... ... @@ -227,7 +230,7 @@
227 230 *
228 231 * @return pointer or NULL if not found
229 232 */
230   -void *dev_remap_addr_name(struct udevice *dev, const char* name);
  233 +void *dev_remap_addr_name(const struct udevice *dev, const char *name);
231 234  
232 235 /**
233 236 * dev_read_addr() - Get the reg property of a device
... ... @@ -236,7 +239,7 @@
236 239 *
237 240 * @return address or FDT_ADDR_T_NONE if not found
238 241 */
239   -fdt_addr_t dev_read_addr(struct udevice *dev);
  242 +fdt_addr_t dev_read_addr(const struct udevice *dev);
240 243  
241 244 /**
242 245 * dev_read_addr_ptr() - Get the reg property of a device
... ... @@ -246,7 +249,7 @@
246 249 *
247 250 * @return pointer or NULL if not found
248 251 */
249   -void *dev_read_addr_ptr(struct udevice *dev);
  252 +void *dev_read_addr_ptr(const struct udevice *dev);
250 253  
251 254 /**
252 255 * dev_read_addr_pci() - Read an address and handle PCI address translation
... ... @@ -266,7 +269,7 @@
266 269 * @dev: Device to read from
267 270 * @return address or FDT_ADDR_T_NONE if not found
268 271 */
269   -fdt_addr_t dev_read_addr_pci(struct udevice *dev);
  272 +fdt_addr_t dev_read_addr_pci(const struct udevice *dev);
270 273  
271 274 /**
272 275 * dev_remap_addr() - Get the reg property of a device as a
... ... @@ -276,7 +279,7 @@
276 279 *
277 280 * @return pointer or NULL if not found
278 281 */
279   -void *dev_remap_addr(struct udevice *dev);
  282 +void *dev_remap_addr(const struct udevice *dev);
280 283  
281 284 /**
282 285 * dev_read_addr_size() - get address and size from a device property
... ... @@ -289,8 +292,8 @@
289 292 * @sizep: place to put size value (on success)
290 293 * @return address value, or FDT_ADDR_T_NONE on error
291 294 */
292   -fdt_addr_t dev_read_addr_size(struct udevice *dev, const char *propname,
293   - fdt_size_t *sizep);
  295 +fdt_addr_t dev_read_addr_size(const struct udevice *dev, const char *propname,
  296 + fdt_size_t *sizep);
294 297  
295 298 /**
296 299 * dev_read_name() - get the name of a device's node
... ... @@ -298,7 +301,7 @@
298 301 * @dev: Device to read from
299 302 * @return name of node
300 303 */
301   -const char *dev_read_name(struct udevice *dev);
  304 +const char *dev_read_name(const struct udevice *dev);
302 305  
303 306 /**
304 307 * dev_read_stringlist_search() - find string in a string list and return index
... ... @@ -318,8 +321,8 @@
318 321 * -ENODATA if the property is not found
319 322 * -EINVAL on some other error
320 323 */
321   -int dev_read_stringlist_search(struct udevice *dev, const char *property,
322   - const char *string);
  324 +int dev_read_stringlist_search(const struct udevice *dev, const char *property,
  325 + const char *string);
323 326  
324 327 /**
325 328 * dev_read_string_index() - obtain an indexed string from a string list
... ... @@ -332,8 +335,8 @@
332 335 * @return:
333 336 * length of string, if found or -ve error value if not found
334 337 */
335   -int dev_read_string_index(struct udevice *dev, const char *propname, int index,
336   - const char **outp);
  338 +int dev_read_string_index(const struct udevice *dev, const char *propname,
  339 + int index, const char **outp);
337 340  
338 341 /**
339 342 * dev_read_string_count() - find the number of strings in a string list
... ... @@ -343,7 +346,7 @@
343 346 * @return:
344 347 * number of strings in the list, or -ve error value if not found
345 348 */
346   -int dev_read_string_count(struct udevice *dev, const char *propname);
  349 +int dev_read_string_count(const struct udevice *dev, const char *propname);
347 350 /**
348 351 * dev_read_phandle_with_args() - Find a node pointed by phandle in a list
349 352 *
... ... @@ -382,10 +385,9 @@
382 385 * @cells_name could not be found, the arguments were truncated or there
383 386 * were too many arguments.
384 387 */
385   -int dev_read_phandle_with_args(struct udevice *dev, const char *list_name,
386   - const char *cells_name, int cell_count,
387   - int index,
388   - struct ofnode_phandle_args *out_args);
  388 +int dev_read_phandle_with_args(const struct udevice *dev, const char *list_name,
  389 + const char *cells_name, int cell_count,
  390 + int index, struct ofnode_phandle_args *out_args);
389 391  
390 392 /**
391 393 * dev_count_phandle_with_args() - Return phandle number in a list
... ... @@ -402,8 +404,8 @@
402 404 * errno value.
403 405 */
404 406  
405   -int dev_count_phandle_with_args(struct udevice *dev, const char *list_name,
406   - const char *cells_name);
  407 +int dev_count_phandle_with_args(const struct udevice *dev,
  408 + const char *list_name, const char *cells_name);
407 409  
408 410 /**
409 411 * dev_read_addr_cells() - Get the number of address cells for a device's node
... ... @@ -414,7 +416,7 @@
414 416 * @dev: device to check
415 417 * @return number of address cells this node uses
416 418 */
417   -int dev_read_addr_cells(struct udevice *dev);
  419 +int dev_read_addr_cells(const struct udevice *dev);
418 420  
419 421 /**
420 422 * dev_read_size_cells() - Get the number of size cells for a device's node
... ... @@ -425,7 +427,7 @@
425 427 * @dev: device to check
426 428 * @return number of size cells this node uses
427 429 */
428   -int dev_read_size_cells(struct udevice *dev);
  430 +int dev_read_size_cells(const struct udevice *dev);
429 431  
430 432 /**
431 433 * dev_read_addr_cells() - Get the address cells property in a node
... ... @@ -435,7 +437,7 @@
435 437 * @dev: device to check
436 438 * @return number of address cells this node uses
437 439 */
438   -int dev_read_simple_addr_cells(struct udevice *dev);
  440 +int dev_read_simple_addr_cells(const struct udevice *dev);
439 441  
440 442 /**
441 443 * dev_read_size_cells() - Get the size cells property in a node
... ... @@ -445,7 +447,7 @@
445 447 * @dev: device to check
446 448 * @return number of size cells this node uses
447 449 */
448   -int dev_read_simple_size_cells(struct udevice *dev);
  450 +int dev_read_simple_size_cells(const struct udevice *dev);
449 451  
450 452 /**
451 453 * dev_read_phandle() - Get the phandle from a device
... ... @@ -453,7 +455,7 @@
453 455 * @dev: device to check
454 456 * @return phandle (1 or greater), or 0 if no phandle or other error
455 457 */
456   -int dev_read_phandle(struct udevice *dev);
  458 +int dev_read_phandle(const struct udevice *dev);
457 459  
458 460 /**
459 461 * dev_read_prop()- - read a property from a device's node
... ... @@ -463,7 +465,8 @@
463 465 * @lenp: place to put length on success
464 466 * @return pointer to property, or NULL if not found
465 467 */
466   -const void *dev_read_prop(struct udevice *dev, const char *propname, int *lenp);
  468 +const void *dev_read_prop(const struct udevice *dev, const char *propname,
  469 + int *lenp);
467 470  
468 471 /**
469 472 * dev_read_alias_seq() - Get the alias sequence number of a node
... ... @@ -476,7 +479,7 @@
476 479 * @devnump: set to the sequence number if one is found
477 480 * @return 0 if a sequence was found, -ve if not
478 481 */
479   -int dev_read_alias_seq(struct udevice *dev, int *devnump);
  482 +int dev_read_alias_seq(const struct udevice *dev, int *devnump);
480 483  
481 484 /**
482 485 * dev_read_u32_array() - Find and read an array of 32 bit integers
... ... @@ -494,7 +497,7 @@
494 497 * property does not have a value, and -EOVERFLOW if the property data isn't
495 498 * large enough.
496 499 */
497   -int dev_read_u32_array(struct udevice *dev, const char *propname,
  500 +int dev_read_u32_array(const struct udevice *dev, const char *propname,
498 501 u32 *out_values, size_t sz);
499 502  
500 503 /**
... ... @@ -504,7 +507,7 @@
504 507 * @return reference to the first subnode (which can be invalid if the device's
505 508 * node has no subnodes)
506 509 */
507   -ofnode dev_read_first_subnode(struct udevice *dev);
  510 +ofnode dev_read_first_subnode(const struct udevice *dev);
508 511  
509 512 /**
510 513 * ofnode_next_subnode() - find the next sibling of a subnode
... ... @@ -529,8 +532,8 @@
529 532 * @return pointer to byte array if found, or NULL if the property is not
530 533 * found or there is not enough data
531 534 */
532   -const uint8_t *dev_read_u8_array_ptr(struct udevice *dev, const char *propname,
533   - size_t sz);
  535 +const uint8_t *dev_read_u8_array_ptr(const struct udevice *dev,
  536 + const char *propname, size_t sz);
534 537  
535 538 /**
536 539 * dev_read_enabled() - check whether a node is enabled
... ... @@ -543,7 +546,7 @@
543 546 * @dev: device to examine
544 547 * @return integer value 0 (not enabled) or 1 (enabled)
545 548 */
546   -int dev_read_enabled(struct udevice *dev);
  549 +int dev_read_enabled(const struct udevice *dev);
547 550  
548 551 /**
549 552 * dev_read_resource() - obtain an indexed resource from a device.
... ... @@ -553,7 +556,8 @@
553 556 * @res returns the resource
554 557 * @return 0 if ok, negative on error
555 558 */
556   -int dev_read_resource(struct udevice *dev, uint index, struct resource *res);
  559 +int dev_read_resource(const struct udevice *dev, uint index,
  560 + struct resource *res);
557 561  
558 562 /**
559 563 * dev_read_resource_byname() - obtain a named resource from a device.
... ... @@ -563,7 +567,7 @@
563 567 * @res: returns the resource
564 568 * @return 0 if ok, negative on error
565 569 */
566   -int dev_read_resource_byname(struct udevice *dev, const char *name,
  570 +int dev_read_resource_byname(const struct udevice *dev, const char *name,
567 571 struct resource *res);
568 572  
569 573 /**
... ... @@ -577,7 +581,7 @@
577 581 * @in_addr: pointer to the address to translate
578 582 * @return the translated address; OF_BAD_ADDR on error
579 583 */
580   -u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr);
  584 +u64 dev_translate_address(const struct udevice *dev, const fdt32_t *in_addr);
581 585  
582 586 /**
583 587 * dev_translate_dma_address() - Translate a device-tree DMA address
... ... @@ -590,7 +594,8 @@
590 594 * @in_addr: pointer to the DMA address to translate
591 595 * @return the translated DMA address; OF_BAD_ADDR on error
592 596 */
593   -u64 dev_translate_dma_address(struct udevice *dev, const fdt32_t *in_addr);
  597 +u64 dev_translate_dma_address(const struct udevice *dev,
  598 + const fdt32_t *in_addr);
594 599  
595 600 /**
596 601 * dev_read_alias_highest_id - Get highest alias id for the given stem
597 602  
598 603  
599 604  
600 605  
... ... @@ -604,31 +609,31 @@
604 609  
605 610 #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
606 611  
607   -static inline int dev_read_u32(struct udevice *dev,
  612 +static inline int dev_read_u32(const struct udevice *dev,
608 613 const char *propname, u32 *outp)
609 614 {
610 615 return ofnode_read_u32(dev_ofnode(dev), propname, outp);
611 616 }
612 617  
613   -static inline int dev_read_u32_default(struct udevice *dev,
  618 +static inline int dev_read_u32_default(const struct udevice *dev,
614 619 const char *propname, int def)
615 620 {
616 621 return ofnode_read_u32_default(dev_ofnode(dev), propname, def);
617 622 }
618 623  
619   -static inline int dev_read_s32(struct udevice *dev,
  624 +static inline int dev_read_s32(const struct udevice *dev,
620 625 const char *propname, s32 *outp)
621 626 {
622 627 return ofnode_read_s32(dev_ofnode(dev), propname, outp);
623 628 }
624 629  
625   -static inline int dev_read_s32_default(struct udevice *dev,
  630 +static inline int dev_read_s32_default(const struct udevice *dev,
626 631 const char *propname, int def)
627 632 {
628 633 return ofnode_read_s32_default(dev_ofnode(dev), propname, def);
629 634 }
630 635  
631   -static inline int dev_read_u32u(struct udevice *dev,
  636 +static inline int dev_read_u32u(const struct udevice *dev,
632 637 const char *propname, uint *outp)
633 638 {
634 639 u32 val;
635 640  
636 641  
637 642  
638 643  
639 644  
640 645  
641 646  
642 647  
643 648  
644 649  
645 650  
646 651  
647 652  
648 653  
649 654  
650 655  
651 656  
652 657  
653 658  
654 659  
655 660  
... ... @@ -642,128 +647,131 @@
642 647 return 0;
643 648 }
644 649  
645   -static inline int dev_read_u64(struct udevice *dev,
  650 +static inline int dev_read_u64(const struct udevice *dev,
646 651 const char *propname, u64 *outp)
647 652 {
648 653 return ofnode_read_u64(dev_ofnode(dev), propname, outp);
649 654 }
650 655  
651   -static inline u64 dev_read_u64_default(struct udevice *dev,
  656 +static inline u64 dev_read_u64_default(const struct udevice *dev,
652 657 const char *propname, u64 def)
653 658 {
654 659 return ofnode_read_u64_default(dev_ofnode(dev), propname, def);
655 660 }
656 661  
657   -static inline const char *dev_read_string(struct udevice *dev,
  662 +static inline const char *dev_read_string(const struct udevice *dev,
658 663 const char *propname)
659 664 {
660 665 return ofnode_read_string(dev_ofnode(dev), propname);
661 666 }
662 667  
663   -static inline bool dev_read_bool(struct udevice *dev, const char *propname)
  668 +static inline bool dev_read_bool(const struct udevice *dev,
  669 + const char *propname)
664 670 {
665 671 return ofnode_read_bool(dev_ofnode(dev), propname);
666 672 }
667 673  
668   -static inline ofnode dev_read_subnode(struct udevice *dev,
  674 +static inline ofnode dev_read_subnode(const struct udevice *dev,
669 675 const char *subbnode_name)
670 676 {
671 677 return ofnode_find_subnode(dev_ofnode(dev), subbnode_name);
672 678 }
673 679  
674   -static inline int dev_read_size(struct udevice *dev, const char *propname)
  680 +static inline int dev_read_size(const struct udevice *dev, const char *propname)
675 681 {
676 682 return ofnode_read_size(dev_ofnode(dev), propname);
677 683 }
678 684  
679   -static inline fdt_addr_t dev_read_addr_index(struct udevice *dev, int index)
  685 +static inline fdt_addr_t dev_read_addr_index(const struct udevice *dev,
  686 + int index)
680 687 {
681 688 return devfdt_get_addr_index(dev, index);
682 689 }
683 690  
684   -static inline fdt_addr_t dev_read_addr_size_index(struct udevice *dev,
  691 +static inline fdt_addr_t dev_read_addr_size_index(const struct udevice *dev,
685 692 int index,
686 693 fdt_size_t *size)
687 694 {
688 695 return devfdt_get_addr_size_index(dev, index, size);
689 696 }
690 697  
691   -static inline fdt_addr_t dev_read_addr_name(struct udevice *dev,
  698 +static inline fdt_addr_t dev_read_addr_name(const struct udevice *dev,
692 699 const char *name)
693 700 {
694 701 return devfdt_get_addr_name(dev, name);
695 702 }
696 703  
697   -static inline fdt_addr_t dev_read_addr_size_name(struct udevice *dev,
  704 +static inline fdt_addr_t dev_read_addr_size_name(const struct udevice *dev,
698 705 const char *name,
699 706 fdt_size_t *size)
700 707 {
701 708 return devfdt_get_addr_size_name(dev, name, size);
702 709 }
703 710  
704   -static inline fdt_addr_t dev_read_addr(struct udevice *dev)
  711 +static inline fdt_addr_t dev_read_addr(const struct udevice *dev)
705 712 {
706 713 return devfdt_get_addr(dev);
707 714 }
708 715  
709   -static inline void *dev_read_addr_ptr(struct udevice *dev)
  716 +static inline void *dev_read_addr_ptr(const struct udevice *dev)
710 717 {
711 718 return devfdt_get_addr_ptr(dev);
712 719 }
713 720  
714   -static inline fdt_addr_t dev_read_addr_pci(struct udevice *dev)
  721 +static inline fdt_addr_t dev_read_addr_pci(const struct udevice *dev)
715 722 {
716 723 return devfdt_get_addr_pci(dev);
717 724 }
718 725  
719   -static inline void *dev_remap_addr(struct udevice *dev)
  726 +static inline void *dev_remap_addr(const struct udevice *dev)
720 727 {
721 728 return devfdt_remap_addr(dev);
722 729 }
723 730  
724   -static inline void *dev_remap_addr_index(struct udevice *dev, int index)
  731 +static inline void *dev_remap_addr_index(const struct udevice *dev, int index)
725 732 {
726 733 return devfdt_remap_addr_index(dev, index);
727 734 }
728 735  
729   -static inline void *dev_remap_addr_name(struct udevice *dev, const char *name)
  736 +static inline void *dev_remap_addr_name(const struct udevice *dev,
  737 + const char *name)
730 738 {
731 739 return devfdt_remap_addr_name(dev, name);
732 740 }
733 741  
734   -static inline fdt_addr_t dev_read_addr_size(struct udevice *dev,
  742 +static inline fdt_addr_t dev_read_addr_size(const struct udevice *dev,
735 743 const char *propname,
736 744 fdt_size_t *sizep)
737 745 {
738 746 return ofnode_get_addr_size(dev_ofnode(dev), propname, sizep);
739 747 }
740 748  
741   -static inline const char *dev_read_name(struct udevice *dev)
  749 +static inline const char *dev_read_name(const struct udevice *dev)
742 750 {
743 751 return ofnode_get_name(dev_ofnode(dev));
744 752 }
745 753  
746   -static inline int dev_read_stringlist_search(struct udevice *dev,
  754 +static inline int dev_read_stringlist_search(const struct udevice *dev,
747 755 const char *propname,
748 756 const char *string)
749 757 {
750 758 return ofnode_stringlist_search(dev_ofnode(dev), propname, string);
751 759 }
752 760  
753   -static inline int dev_read_string_index(struct udevice *dev,
  761 +static inline int dev_read_string_index(const struct udevice *dev,
754 762 const char *propname, int index,
755 763 const char **outp)
756 764 {
757 765 return ofnode_read_string_index(dev_ofnode(dev), propname, index, outp);
758 766 }
759 767  
760   -static inline int dev_read_string_count(struct udevice *dev,
  768 +static inline int dev_read_string_count(const struct udevice *dev,
761 769 const char *propname)
762 770 {
763 771 return ofnode_read_string_count(dev_ofnode(dev), propname);
764 772 }
765 773  
766   -static inline int dev_read_phandle_with_args(struct udevice *dev,
  774 +static inline int dev_read_phandle_with_args(const struct udevice *dev,
767 775 const char *list_name, const char *cells_name, int cell_count,
768 776 int index, struct ofnode_phandle_args *out_args)
769 777 {
770 778  
771 779  
772 780  
773 781  
774 782  
775 783  
776 784  
777 785  
778 786  
... ... @@ -772,59 +780,60 @@
772 780 out_args);
773 781 }
774 782  
775   -static inline int dev_count_phandle_with_args(struct udevice *dev,
  783 +static inline int dev_count_phandle_with_args(const struct udevice *dev,
776 784 const char *list_name, const char *cells_name)
777 785 {
778 786 return ofnode_count_phandle_with_args(dev_ofnode(dev), list_name,
779 787 cells_name);
780 788 }
781 789  
782   -static inline int dev_read_addr_cells(struct udevice *dev)
  790 +static inline int dev_read_addr_cells(const struct udevice *dev)
783 791 {
784 792 /* NOTE: this call should walk up the parent stack */
785 793 return fdt_address_cells(gd->fdt_blob, dev_of_offset(dev));
786 794 }
787 795  
788   -static inline int dev_read_size_cells(struct udevice *dev)
  796 +static inline int dev_read_size_cells(const struct udevice *dev)
789 797 {
790 798 /* NOTE: this call should walk up the parent stack */
791 799 return fdt_size_cells(gd->fdt_blob, dev_of_offset(dev));
792 800 }
793 801  
794   -static inline int dev_read_simple_addr_cells(struct udevice *dev)
  802 +static inline int dev_read_simple_addr_cells(const struct udevice *dev)
795 803 {
796 804 return fdt_address_cells(gd->fdt_blob, dev_of_offset(dev));
797 805 }
798 806  
799   -static inline int dev_read_simple_size_cells(struct udevice *dev)
  807 +static inline int dev_read_simple_size_cells(const struct udevice *dev)
800 808 {
801 809 return fdt_size_cells(gd->fdt_blob, dev_of_offset(dev));
802 810 }
803 811  
804   -static inline int dev_read_phandle(struct udevice *dev)
  812 +static inline int dev_read_phandle(const struct udevice *dev)
805 813 {
806 814 return fdt_get_phandle(gd->fdt_blob, dev_of_offset(dev));
807 815 }
808 816  
809   -static inline const void *dev_read_prop(struct udevice *dev,
  817 +static inline const void *dev_read_prop(const struct udevice *dev,
810 818 const char *propname, int *lenp)
811 819 {
812 820 return ofnode_get_property(dev_ofnode(dev), propname, lenp);
813 821 }
814 822  
815   -static inline int dev_read_alias_seq(struct udevice *dev, int *devnump)
  823 +static inline int dev_read_alias_seq(const struct udevice *dev, int *devnump)
816 824 {
817 825 return fdtdec_get_alias_seq(gd->fdt_blob, dev->uclass->uc_drv->name,
818 826 dev_of_offset(dev), devnump);
819 827 }
820 828  
821   -static inline int dev_read_u32_array(struct udevice *dev, const char *propname,
822   - u32 *out_values, size_t sz)
  829 +static inline int dev_read_u32_array(const struct udevice *dev,
  830 + const char *propname, u32 *out_values,
  831 + size_t sz)
823 832 {
824 833 return ofnode_read_u32_array(dev_ofnode(dev), propname, out_values, sz);
825 834 }
826 835  
827   -static inline ofnode dev_read_first_subnode(struct udevice *dev)
  836 +static inline ofnode dev_read_first_subnode(const struct udevice *dev)
828 837 {
829 838 return ofnode_first_subnode(dev_ofnode(dev));
830 839 }
831 840  
832 841  
833 842  
834 843  
835 844  
... ... @@ -834,36 +843,38 @@
834 843 return ofnode_next_subnode(node);
835 844 }
836 845  
837   -static inline const uint8_t *dev_read_u8_array_ptr(struct udevice *dev,
  846 +static inline const uint8_t *dev_read_u8_array_ptr(const struct udevice *dev,
838 847 const char *propname, size_t sz)
839 848 {
840 849 return ofnode_read_u8_array_ptr(dev_ofnode(dev), propname, sz);
841 850 }
842 851  
843   -static inline int dev_read_enabled(struct udevice *dev)
  852 +static inline int dev_read_enabled(const struct udevice *dev)
844 853 {
845 854 return fdtdec_get_is_enabled(gd->fdt_blob, dev_of_offset(dev));
846 855 }
847 856  
848   -static inline int dev_read_resource(struct udevice *dev, uint index,
  857 +static inline int dev_read_resource(const struct udevice *dev, uint index,
849 858 struct resource *res)
850 859 {
851 860 return ofnode_read_resource(dev_ofnode(dev), index, res);
852 861 }
853 862  
854   -static inline int dev_read_resource_byname(struct udevice *dev,
  863 +static inline int dev_read_resource_byname(const struct udevice *dev,
855 864 const char *name,
856 865 struct resource *res)
857 866 {
858 867 return ofnode_read_resource_byname(dev_ofnode(dev), name, res);
859 868 }
860 869  
861   -static inline u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr)
  870 +static inline u64 dev_translate_address(const struct udevice *dev,
  871 + const fdt32_t *in_addr)
862 872 {
863 873 return ofnode_translate_address(dev_ofnode(dev), in_addr);
864 874 }
865 875  
866   -static inline u64 dev_translate_dma_address(struct udevice *dev, const fdt32_t *in_addr)
  876 +static inline u64 dev_translate_dma_address(const struct udevice *dev,
  877 + const fdt32_t *in_addr)
867 878 {
868 879 return ofnode_translate_dma_address(dev_ofnode(dev), in_addr);
869 880 }