of: base: use of_property_read_u32()
PATCH 1/2 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...
--- drivers/of/base.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/of/base.c +6 -8
@@ -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 ;
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Sergei Shtylyov
of_n_{addr|size}_cells(() predate
of_property_read_u32(), so they have to
Oops,. double open paren. Rob, could you please fxi while applying?
Quoted 4 lines
basically open-code it. Using the modern DT API saves several LoCs and also adds some prop sanity checks as a bonus...
[...]
MNR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html