aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>2017-07-23 12:55:47 -0400
committerRob Herring <robh@kernel.org>2017-07-24 10:50:07 -0400
commit8832963d89f09e4cef6c1ec62f0082a545baf69d (patch)
tree7a9031d163fa5b854339b055d304b4d020796c59
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>
-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);
60 60
61int of_n_addr_cells(struct device_node *np) 61int of_n_addr_cells(struct device_node *np)
62{ 62{
63 const __be32 *ip; 63 u32 cells;
64 64
65 do { 65 do {
66 if (np->parent) 66 if (np->parent)
67 np = np->parent; 67 np = np->parent;
68 ip = of_get_property(np, "#address-cells", NULL); 68 if (!of_property_read_u32(np, "#address-cells", &cells))
69 if (ip) 69 return cells;
70 return be32_to_cpup(ip);
71 } while (np->parent); 70 } while (np->parent);
72 /* No #address-cells property for the root node */ 71 /* No #address-cells property for the root node */
73 return OF_ROOT_NODE_ADDR_CELLS_DEFAULT; 72 return OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
@@ -76,14 +75,13 @@ EXPORT_SYMBOL(of_n_addr_cells);
76 75
77int of_n_size_cells(struct device_node *np) 76int of_n_size_cells(struct device_node *np)
78{ 77{
79 const __be32 *ip; 78 u32 cells;
80 79
81 do { 80 do {
82 if (np->parent) 81 if (np->parent)
83 np = np->parent; 82 np = np->parent;
84 ip = of_get_property(np, "#size-cells", NULL); 83 if (!of_property_read_u32(np, "#size-cells", &cells))
85 if (ip) 84 return cells;
86 return be32_to_cpup(ip);
87 } while (np->parent); 85 } while (np->parent);
88 /* No #size-cells property for the root node */ 86 /* No #size-cells property for the root node */
89 return OF_ROOT_NODE_SIZE_CELLS_DEFAULT; 87 return OF_ROOT_NODE_SIZE_CELLS_DEFAULT;