summaryrefslogtreecommitdiff
path: root/drivers/of/base.c
diff options
context:
space:
mode:
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>2017-07-23 19:55:47 +0300
committerRob Herring <robh@kernel.org>2017-07-24 09:50:07 -0500
commit8832963d89f09e4cef6c1ec62f0082a545baf69d (patch)
tree7a9031d163fa5b854339b055d304b4d020796c59 /drivers/of/base.c
parentfda9f5d4a97cedba3174641263a49d82ff3c3469 (diff)
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: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r--drivers/of/base.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 5551ac2a9d4c..830f8d2f3594 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -60,14 +60,13 @@ DEFINE_RAW_SPINLOCK(devtree_lock);
int of_n_addr_cells(struct device_node *np)
{
- const __be32 *ip;
+ u32 cells;
do {
if (np->parent)
np = np->parent;
- ip = of_get_property(np, "#address-cells", NULL);
- if (ip)
- return be32_to_cpup(ip);
+ if (!of_property_read_u32(np, "#address-cells", &cells))
+ return cells;
} while (np->parent);
/* No #address-cells property for the root node */
return OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
@@ -76,14 +75,13 @@ EXPORT_SYMBOL(of_n_addr_cells);
int of_n_size_cells(struct device_node *np)
{
- const __be32 *ip;
+ u32 cells;
do {
if (np->parent)
np = np->parent;
- ip = of_get_property(np, "#size-cells", NULL);
- if (ip)
- return be32_to_cpup(ip);
+ if (!of_property_read_u32(np, "#size-cells", &cells))
+ return cells;
} while (np->parent);
/* No #size-cells property for the root node */
return OF_ROOT_NODE_SIZE_CELLS_DEFAULT;