aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/timer-of.c
diff options
context:
space:
mode:
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>2017-07-17 14:00:44 -0400
committerThomas Gleixner <tglx@linutronix.de>2017-07-17 16:43:00 -0400
commit32f2fea6e77e64cd4045ec2d5deb879aada3b476 (patch)
tree8f6963fb7d9e6385bfa3e77617c9f050066a549b /drivers/clocksource/timer-of.c
parent935acd3f5ebc34984bd4de075e0f83e6ea10c28d (diff)
clocksource/drivers/timer-of: Handle of_irq_get_byname() result correctly
of_irq_get_byname() may return a negative error number as well as 0 on failure, while timer_irq_init() only checks for 0, blithely continuing with the call to request_[percpu_]irq() -- those functions expect *unsigned int*, so would probably fail anyway when a large IRQ number resulting from a conversion of a negative error number is passed to them... This, however, is incorrect behavior -- error number is not IRQ number. Filter out the negative error numbers, complain, and return them to the timer_irq_init()'s callers... Fixes: dc11bae78529 ("clocksource/drivers: Add timer-of common init routine") Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Daniel Lezcano <daniel.lezcano@linaro.org> Link: http://lkml.kernel.org/r/20170717180114.678825147@cogentembedded.com
Diffstat (limited to 'drivers/clocksource/timer-of.c')
-rw-r--r--drivers/clocksource/timer-of.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c
index f6e7491c873c..d509b500a7b5 100644
--- a/drivers/clocksource/timer-of.c
+++ b/drivers/clocksource/timer-of.c
@@ -41,8 +41,16 @@ static __init int timer_irq_init(struct device_node *np,
41 struct timer_of *to = container_of(of_irq, struct timer_of, of_irq); 41 struct timer_of *to = container_of(of_irq, struct timer_of, of_irq);
42 struct clock_event_device *clkevt = &to->clkevt; 42 struct clock_event_device *clkevt = &to->clkevt;
43 43
44 of_irq->irq = of_irq->name ? of_irq_get_byname(np, of_irq->name): 44 if (of_irq->name) {
45 irq_of_parse_and_map(np, of_irq->index); 45 of_irq->irq = ret = of_irq_get_byname(np, of_irq->name);
46 if (ret < 0) {
47 pr_err("Failed to get interrupt %s for %s\n",
48 of_irq->name, np->full_name);
49 return ret;
50 }
51 } else {
52 of_irq->irq = irq_of_parse_and_map(np, of_irq->index);
53 }
46 if (!of_irq->irq) { 54 if (!of_irq->irq) {
47 pr_err("Failed to map interrupt for %s\n", np->full_name); 55 pr_err("Failed to map interrupt for %s\n", np->full_name);
48 return -EINVAL; 56 return -EINVAL;