Skip to content

Commit a9ecdc0

Browse files
ffainelliglikely
authored andcommitted
of/irq: Fix lookup to use 'interrupts-extended' property first
In case the Device Tree blob passed by the boot agent supplies both an 'interrupts-extended' and an 'interrupts' property in order to allow for older kernels to be usable, prefer the new-style 'interrupts-extended' property which conveys a lot more information. This allows us to have bootloaders willingly maintaining backwards compatibility with older kernels without entirely deprecating the 'interrupts' property. Update the bindings documentation to describe a situation where both the 'interrupts-extended' and the 'interrupts' property are present, and which one takes precedence over the other. Cc: [email protected] # 3.13+ Acked-by: Rob Herring <[email protected]> Signed-off-by: Brian Norris <[email protected]> Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: Grant Likely <[email protected]>
1 parent b951f9d commit a9ecdc0

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Documentation/devicetree/bindings/interrupt-controller/interrupts.txt

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ Specifying interrupt information for devices
44
1) Interrupt client nodes
55
-------------------------
66

7-
Nodes that describe devices which generate interrupts must contain an either an
8-
"interrupts" property or an "interrupts-extended" property. These properties
9-
contain a list of interrupt specifiers, one per output interrupt. The format of
10-
the interrupt specifier is determined by the interrupt controller to which the
11-
interrupts are routed; see section 2 below for details.
7+
Nodes that describe devices which generate interrupts must contain an
8+
"interrupts" property, an "interrupts-extended" property, or both. If both are
9+
present, the latter should take precedence; the former may be provided simply
10+
for compatibility with software that does not recognize the latter. These
11+
properties contain a list of interrupt specifiers, one per output interrupt. The
12+
format of the interrupt specifier is determined by the interrupt controller to
13+
which the interrupts are routed; see section 2 below for details.
1214

1315
Example:
1416
interrupt-parent = <&intc1>;

drivers/of/irq.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -301,16 +301,17 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
301301
/* Get the reg property (if any) */
302302
addr = of_get_property(device, "reg", NULL);
303303

304+
/* Try the new-style interrupts-extended first */
305+
res = of_parse_phandle_with_args(device, "interrupts-extended",
306+
"#interrupt-cells", index, out_irq);
307+
if (!res)
308+
return of_irq_parse_raw(addr, out_irq);
309+
304310
/* Get the interrupts property */
305311
intspec = of_get_property(device, "interrupts", &intlen);
306-
if (intspec == NULL) {
307-
/* Try the new-style interrupts-extended */
308-
res = of_parse_phandle_with_args(device, "interrupts-extended",
309-
"#interrupt-cells", index, out_irq);
310-
if (res)
311-
return -EINVAL;
312-
return of_irq_parse_raw(addr, out_irq);
313-
}
312+
if (intspec == NULL)
313+
return -EINVAL;
314+
314315
intlen /= sizeof(*intspec);
315316

316317
pr_debug(" intspec=%d intlen=%d\n", be32_to_cpup(intspec), intlen);

0 commit comments

Comments
 (0)