Commit fa976ff7 authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by Rob Herring

of: irq: use of_property_read_u32()

The DT interrupt parsing code predates of_property_read_u32(), so it has 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 6a245d95
...@@ -59,20 +59,19 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map); ...@@ -59,20 +59,19 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
struct device_node *of_irq_find_parent(struct device_node *child) struct device_node *of_irq_find_parent(struct device_node *child)
{ {
struct device_node *p; struct device_node *p;
const __be32 *parp; phandle parent;
if (!of_node_get(child)) if (!of_node_get(child))
return NULL; return NULL;
do { do {
parp = of_get_property(child, "interrupt-parent", NULL); if (of_property_read_u32(child, "interrupt-parent", &parent)) {
if (parp == NULL)
p = of_get_parent(child); p = of_get_parent(child);
else { } else {
if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
p = of_node_get(of_irq_dflt_pic); p = of_node_get(of_irq_dflt_pic);
else else
p = of_find_node_by_phandle(be32_to_cpup(parp)); p = of_find_node_by_phandle(parent);
} }
of_node_put(child); of_node_put(child);
child = p; child = p;
...@@ -117,11 +116,8 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) ...@@ -117,11 +116,8 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
* is none, we are nice and just walk up the tree * is none, we are nice and just walk up the tree
*/ */
do { do {
tmp = of_get_property(ipar, "#interrupt-cells", NULL); if (!of_property_read_u32(ipar, "#interrupt-cells", &intsize))
if (tmp != NULL) {
intsize = be32_to_cpu(*tmp);
break; break;
}
tnode = ipar; tnode = ipar;
ipar = of_irq_find_parent(ipar); ipar = of_irq_find_parent(ipar);
of_node_put(tnode); of_node_put(tnode);
...@@ -228,14 +224,14 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) ...@@ -228,14 +224,14 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
/* Get #interrupt-cells and #address-cells of new /* Get #interrupt-cells and #address-cells of new
* parent * parent
*/ */
tmp = of_get_property(newpar, "#interrupt-cells", NULL); if (of_property_read_u32(newpar, "#interrupt-cells",
if (tmp == NULL) { &newintsize)) {
pr_debug(" -> parent lacks #interrupt-cells!\n"); pr_debug(" -> parent lacks #interrupt-cells!\n");
goto fail; goto fail;
} }
newintsize = be32_to_cpu(*tmp); if (of_property_read_u32(newpar, "#address-cells",
tmp = of_get_property(newpar, "#address-cells", NULL); &newaddrsize))
newaddrsize = (tmp == NULL) ? 0 : be32_to_cpu(*tmp); newaddrsize = 0;
pr_debug(" -> newintsize=%d, newaddrsize=%d\n", pr_debug(" -> newintsize=%d, newaddrsize=%d\n",
newintsize, newaddrsize); newintsize, newaddrsize);
...@@ -296,7 +292,7 @@ EXPORT_SYMBOL_GPL(of_irq_parse_raw); ...@@ -296,7 +292,7 @@ EXPORT_SYMBOL_GPL(of_irq_parse_raw);
int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_args *out_irq) int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_args *out_irq)
{ {
struct device_node *p; struct device_node *p;
const __be32 *intspec, *tmp, *addr; const __be32 *intspec, *addr;
u32 intsize, intlen; u32 intsize, intlen;
int i, res; int i, res;
...@@ -330,12 +326,10 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar ...@@ -330,12 +326,10 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
return -EINVAL; return -EINVAL;
/* Get size of interrupt specifier */ /* Get size of interrupt specifier */
tmp = of_get_property(p, "#interrupt-cells", NULL); if (of_property_read_u32(p, "#interrupt-cells", &intsize)) {
if (tmp == NULL) {
res = -EINVAL; res = -EINVAL;
goto out; goto out;
} }
intsize = be32_to_cpu(*tmp);
pr_debug(" intsize=%d intlen=%d\n", intsize, intlen); pr_debug(" intsize=%d intlen=%d\n", intsize, intlen);
......
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