Commit 1aada6313ca9b9e9123a4118c78558ef413e1039
1 parent
a8167d8ee2
Exists in
smarc_8mq_lf_v2020.04
and in
9 other branches
dm: core: Reimplement ofnode_read_size()
Now that we have ofnode_read_prop() we can rewrite this function using that one, reducing the amount of duplicated code. Update ofnode_read_size() and move it up next to the other similar functions. Signed-off-by: Simon Glass <sjg@chromium.org>
Showing 1 changed file with 10 additions and 19 deletions Side-by-side Diff
drivers/core/ofnode.c
... | ... | @@ -151,6 +151,16 @@ |
151 | 151 | return str; |
152 | 152 | } |
153 | 153 | |
154 | +int ofnode_read_size(ofnode node, const char *propname) | |
155 | +{ | |
156 | + int len; | |
157 | + | |
158 | + if (!ofnode_read_prop(node, propname, &len)) | |
159 | + return -EINVAL; | |
160 | + | |
161 | + return len; | |
162 | +} | |
163 | + | |
154 | 164 | ofnode ofnode_find_subnode(ofnode node, const char *subnode_name) |
155 | 165 | { |
156 | 166 | ofnode subnode; |
... | ... | @@ -251,25 +261,6 @@ |
251 | 261 | phandle); |
252 | 262 | |
253 | 263 | return node; |
254 | -} | |
255 | - | |
256 | -int ofnode_read_size(ofnode node, const char *propname) | |
257 | -{ | |
258 | - int len; | |
259 | - | |
260 | - if (ofnode_is_np(node)) { | |
261 | - struct property *prop = of_find_property( | |
262 | - ofnode_to_np(node), propname, NULL); | |
263 | - | |
264 | - if (prop) | |
265 | - return prop->length; | |
266 | - } else { | |
267 | - if (fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname, | |
268 | - &len)) | |
269 | - return len; | |
270 | - } | |
271 | - | |
272 | - return -EINVAL; | |
273 | 264 | } |
274 | 265 | |
275 | 266 | fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size) |