Skip to contentSkip to conversation

clocksource/drivers/moxart: Replace setup_irq by request_irq

PATCH In review Daniel Lezcano 2 participants 4 messages Sep 8, 2016 – Sep 12, 2016 Clocksource, clockevent drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 clocksource/drivers/moxart: Replace setup_irq by request_irq

Save memory space and line of code by replacing setup_irq by request_irq.

---
 drivers/clocksource/moxart_timer.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/clocksource/moxart_timer.c +2 -6
index ad2bead9..cba25b7 100644
@@ -79,7 +79,6 @@ struct moxart_timer {
 	unsigned int t1_enable_val;
 	unsigned int count_per_tick;
 	struct clock_event_device clkevt;
-	struct irqaction act;
 };
 
 static inline struct moxart_timer *to_moxart(struct clock_event_device *evt)
@@ -201,10 +200,6 @@ static int __init moxart_timer_init(struct device_node *node)
 	timer->clkevt.set_next_event = moxart_clkevt_next_event;
 	timer->clkevt.cpumask = cpumask_of(0);
 	timer->clkevt.irq = irq;
-	timer->act.name = node->name;
-	timer->act.flags = IRQF_TIMER;
-	timer->act.handler = moxart_timer_interrupt;
-	timer->act.dev_id = &timer->clkevt;
 
 	ret = clocksource_mmio_init(timer->base + TIMER2_BASE + REG_COUNT,
 				    "moxart_timer", pclk, 200, 32,
@@ -214,7 +209,8 @@ static int __init moxart_timer_init(struct device_node *node)
 		return ret;
 	}
 
-	ret = setup_irq(irq, &timer->act);
+	ret = request_irq(irq, moxart_timer_interrupt, IRQF_TIMER,
+			  node->name, &timer->clkevt);
 	if (ret) {
 		pr_err("%s: setup_irq failed\n", node->full_name);
 		return ret;
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 clocksource/drivers/moxart: Replace panic by pr_err

The clksrc-of code is supposed to catch the return code and fail gracefully.

Don't panic on error, but print the error and exit with a relevant error code.

---
 drivers/clocksource/moxart_timer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clocksource/moxart_timer.c +4 -2
index cba25b7..2a8f470 100644
@@ -184,8 +184,10 @@ static int __init moxart_timer_init(struct device_node *node)
 	} else if (of_device_is_compatible(node, "aspeed,ast2400-timer")) {
 		timer->t1_enable_val = ASPEED_TIMER1_ENABLE;
 		timer->t1_disable_val = ASPEED_TIMER1_DISABLE;
-	} else
-		panic("%s: unknown platform\n", node->full_name);
+	} else {
+		pr_err("%s: unknown platform\n", node->full_name);
+		return -EINVAL;
+	}
 
 	timer->count_per_tick = DIV_ROUND_CLOSEST(pclk, HZ);
 
Signature · 1 line
1.9.1
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] clocksource/drivers/moxart: Replace panic by pr_err

Quoted 6 lines · Daniel Lezcano

The clksrc-of code is supposed to catch the return code and fail gracefully.

Don't panic on error, but print the error and exit with a relevant error code.

Quoted 24 lines
---
 drivers/clocksource/moxart_timer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clocksource/moxart_timer.c +4 -3
index cba25b7..2a8f470 100644
@@ -184,8 +184,10 @@ static int __init moxart_timer_init(struct device_node *node)
        } else if (of_device_is_compatible(node, "aspeed,ast2400-timer")) {
                timer->t1_enable_val = ASPEED_TIMER1_ENABLE;
                timer->t1_disable_val = ASPEED_TIMER1_DISABLE;
-       } else
-               panic("%s: unknown platform\n", node->full_name);
+       } else {
+               pr_err("%s: unknown platform\n", node->full_name);
+               return -EINVAL;
+       }
 
        timer->count_per_tick = DIV_ROUND_CLOSEST(pclk, HZ);
 
--

1.9.1

Acked-by on v1 1/2
#3 lore raw
In reply to Daniel Lezcano
Quoted 1 line · Daniel Lezcano

Save memory space and line of code by replacing setup_irq by request_irq.

Thanks. I also gave it a spin on our hardware to be sure.

Quoted 1 line
Quoted 40 lines
---
 drivers/clocksource/moxart_timer.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/clocksource/moxart_timer.c +2 -7
index ad2bead9..cba25b7 100644
@@ -79,7 +79,6 @@ struct moxart_timer {
        unsigned int t1_enable_val;
        unsigned int count_per_tick;
        struct clock_event_device clkevt;
-       struct irqaction act;
 };
 
 static inline struct moxart_timer *to_moxart(struct clock_event_device *evt)
@@ -201,10 +200,6 @@ static int __init moxart_timer_init(struct device_node *node)
        timer->clkevt.set_next_event = moxart_clkevt_next_event;
        timer->clkevt.cpumask = cpumask_of(0);
        timer->clkevt.irq = irq;
-       timer->act.name = node->name;
-       timer->act.flags = IRQF_TIMER;
-       timer->act.handler = moxart_timer_interrupt;
-       timer->act.dev_id = &timer->clkevt;
 
        ret = clocksource_mmio_init(timer->base + TIMER2_BASE + REG_COUNT,
                                    "moxart_timer", pclk, 200, 32,
@@ -214,7 +209,8 @@ static int __init moxart_timer_init(struct device_node *node)
                return ret;
        }
 
-       ret = setup_irq(irq, &timer->act);
+       ret = request_irq(irq, moxart_timer_interrupt, IRQF_TIMER,
+                         node->name, &timer->clkevt);
        if (ret) {
                pr_err("%s: setup_irq failed\n", node->full_name);
                return ret;
--

1.9.1