Commit 8832963d authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by Rob Herring

of: base: use of_property_read_u32()

of_n_{addr|size}_cells() predate of_property_read_u32(), so they have to
basically open-code it. Using the modern DT API saves several LoCs and also
adds some prop sanity checks as a bonus...
Signed-off-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent fda9f5d4
...@@ -60,14 +60,13 @@ DEFINE_RAW_SPINLOCK(devtree_lock); ...@@ -60,14 +60,13 @@ DEFINE_RAW_SPINLOCK(devtree_lock);
int of_n_addr_cells(struct device_node *np) int of_n_addr_cells(struct device_node *np)
{ {
const __be32 *ip; u32 cells;
do { do {
if (np->parent) if (np->parent)
np = np->parent; np = np->parent;
ip = of_get_property(np, "#address-cells", NULL); if (!of_property_read_u32(np, "#address-cells", &cells))
if (ip) return cells;
return be32_to_cpup(ip);
} while (np->parent); } while (np->parent);
/* No #address-cells property for the root node */ /* No #address-cells property for the root node */
return OF_ROOT_NODE_ADDR_CELLS_DEFAULT; return OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
...@@ -76,14 +75,13 @@ EXPORT_SYMBOL(of_n_addr_cells); ...@@ -76,14 +75,13 @@ EXPORT_SYMBOL(of_n_addr_cells);
int of_n_size_cells(struct device_node *np) int of_n_size_cells(struct device_node *np)
{ {
const __be32 *ip; u32 cells;
do { do {
if (np->parent) if (np->parent)
np = np->parent; np = np->parent;
ip = of_get_property(np, "#size-cells", NULL); if (!of_property_read_u32(np, "#size-cells", &cells))
if (ip) return cells;
return be32_to_cpup(ip);
} while (np->parent); } while (np->parent);
/* No #size-cells property for the root node */ /* No #size-cells property for the root node */
return OF_ROOT_NODE_SIZE_CELLS_DEFAULT; return OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment