diff options
author | Grant Likely <grant.likely@linaro.org> | 2013-11-01 13:50:50 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@linaro.org> | 2013-11-03 18:16:35 -0500 |
commit | 78119fd1068cc068f6112a57a5f6de0e5b20245a (patch) | |
tree | 8e0726dc0a7527c0e7f571c7953e3115c7bded7f /drivers/of/irq.c | |
parent | 0976c946a610d06e907335b7a3afa6db046f8e1b (diff) |
of/irq: Fix bug in interrupt parsing refactor.
Commit 2361613206e6, "of/irq: Refactor interrupt-map parsing" introduced
a bug. The irq parsing will fail for some nodes that don't have a reg
property. It is fixed by deferring the check for reg until it is
actually needed. Also adjust the testcase data to catch the bug.
Signed-off-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Ming Lei <tom.leiming@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Cc: Rob Herring <rob.herring@calxeda.com>
Diffstat (limited to 'drivers/of/irq.c')
-rw-r--r-- | drivers/of/irq.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 8cc62b4a7988..52dba6a01423 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c | |||
@@ -147,18 +147,9 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) | |||
147 | 147 | ||
148 | pr_debug(" -> addrsize=%d\n", addrsize); | 148 | pr_debug(" -> addrsize=%d\n", addrsize); |
149 | 149 | ||
150 | /* If we were passed no "reg" property and we attempt to parse | ||
151 | * an interrupt-map, then #address-cells must be 0. | ||
152 | * Fail if it's not. | ||
153 | */ | ||
154 | if (addr == NULL && addrsize != 0) { | ||
155 | pr_debug(" -> no reg passed in when needed !\n"); | ||
156 | return -EINVAL; | ||
157 | } | ||
158 | |||
159 | /* Precalculate the match array - this simplifies match loop */ | 150 | /* Precalculate the match array - this simplifies match loop */ |
160 | for (i = 0; i < addrsize; i++) | 151 | for (i = 0; i < addrsize; i++) |
161 | initial_match_array[i] = addr[i]; | 152 | initial_match_array[i] = addr ? addr[i] : 0; |
162 | for (i = 0; i < intsize; i++) | 153 | for (i = 0; i < intsize; i++) |
163 | initial_match_array[addrsize + i] = cpu_to_be32(out_irq->args[i]); | 154 | initial_match_array[addrsize + i] = cpu_to_be32(out_irq->args[i]); |
164 | 155 | ||
@@ -174,6 +165,15 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) | |||
174 | return 0; | 165 | return 0; |
175 | } | 166 | } |
176 | 167 | ||
168 | /* | ||
169 | * interrupt-map parsing does not work without a reg | ||
170 | * property when #address-cells != 0 | ||
171 | */ | ||
172 | if (addrsize && !addr) { | ||
173 | pr_debug(" -> no reg passed in when needed !\n"); | ||
174 | goto fail; | ||
175 | } | ||
176 | |||
177 | /* Now look for an interrupt-map */ | 177 | /* Now look for an interrupt-map */ |
178 | imap = of_get_property(ipar, "interrupt-map", &imaplen); | 178 | imap = of_get_property(ipar, "interrupt-map", &imaplen); |
179 | /* No interrupt map, check for an interrupt parent */ | 179 | /* No interrupt map, check for an interrupt parent */ |