Skip to content

Commit cc2550b

Browse files
afzalmamdlezcano
authored andcommitted
clocksource: Replace setup_irq() by request_irq()
request_irq() is preferred over setup_irq(). The early boot setup_irq() invocations happen either via 'init_IRQ()' or 'time_init()', while memory allocators are ready by 'mm_init()'. Per tglx[1], setup_irq() existed in olden days when allocators were not ready by the time early interrupts were initialized. Hence replace setup_irq() by request_irq(). Seldom remove_irq() usage has been observed coupled with setup_irq(), wherever that has been found, it too has been replaced by free_irq(). A build error that was reported by kbuild test robot <lkp@intel.com> in the previous version of the patch also has been fixed. [1] https://lkml.kernel.org/r/alpine.DEB.2.20.1710191609480.1971@nanos Signed-off-by: afzal mohammed <afzal.mohd.ma@gmail.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/91961c77c1cf93d41523f5e1ac52043f32f97077.1582799709.git.afzal.mohd.ma@gmail.com
1 parent a7cd395 commit cc2550b

23 files changed

+83
-191
lines changed

drivers/clocksource/bcm2835_timer.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ struct bcm2835_timer {
3131
void __iomem *compare;
3232
int match_mask;
3333
struct clock_event_device evt;
34-
struct irqaction act;
3534
};
3635

3736
static void __iomem *system_clock __read_mostly;
@@ -113,12 +112,9 @@ static int __init bcm2835_timer_init(struct device_node *node)
113112
timer->evt.features = CLOCK_EVT_FEAT_ONESHOT;
114113
timer->evt.set_next_event = bcm2835_time_set_next_event;
115114
timer->evt.cpumask = cpumask_of(0);
116-
timer->act.name = node->name;
117-
timer->act.flags = IRQF_TIMER | IRQF_SHARED;
118-
timer->act.dev_id = timer;
119-
timer->act.handler = bcm2835_time_interrupt;
120115

121-
ret = setup_irq(irq, &timer->act);
116+
ret = request_irq(irq, bcm2835_time_interrupt, IRQF_TIMER | IRQF_SHARED,
117+
node->name, timer);
122118
if (ret) {
123119
pr_err("Can't set up timer IRQ\n");
124120
goto err_timer_free;

drivers/clocksource/bcm_kona_timer.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,6 @@ static irqreturn_t kona_timer_interrupt(int irq, void *dev_id)
160160
return IRQ_HANDLED;
161161
}
162162

163-
static struct irqaction kona_timer_irq = {
164-
.name = "Kona Timer Tick",
165-
.flags = IRQF_TIMER,
166-
.handler = kona_timer_interrupt,
167-
};
168-
169163
static int __init kona_timer_init(struct device_node *node)
170164
{
171165
u32 freq;
@@ -192,7 +186,9 @@ static int __init kona_timer_init(struct device_node *node)
192186
kona_timer_disable_and_clear(timers.tmr_regs);
193187

194188
kona_timer_clockevents_init();
195-
setup_irq(timers.tmr_irq, &kona_timer_irq);
189+
if (request_irq(timers.tmr_irq, kona_timer_interrupt, IRQF_TIMER,
190+
"Kona Timer Tick", NULL))
191+
pr_err("%s: request_irq() failed\n", "Kona Timer Tick");
196192
kona_timer_set_next_event((arch_timer_rate / HZ), NULL);
197193

198194
return 0;

drivers/clocksource/dw_apb_timer.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,10 @@ dw_apb_clockevent_init(int cpu, const char *name, unsigned rating,
270270
dw_ced->ced.rating = rating;
271271
dw_ced->ced.name = name;
272272

273-
dw_ced->irqaction.name = dw_ced->ced.name;
274-
dw_ced->irqaction.handler = dw_apb_clockevent_irq;
275-
dw_ced->irqaction.dev_id = &dw_ced->ced;
276-
dw_ced->irqaction.irq = irq;
277-
dw_ced->irqaction.flags = IRQF_TIMER | IRQF_IRQPOLL |
278-
IRQF_NOBALANCING;
279-
280273
dw_ced->eoi = apbt_eoi;
281-
err = setup_irq(irq, &dw_ced->irqaction);
274+
err = request_irq(irq, dw_apb_clockevent_irq,
275+
IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
276+
dw_ced->ced.name, &dw_ced->ced);
282277
if (err) {
283278
pr_err("failed to request timer irq\n");
284279
kfree(dw_ced);

drivers/clocksource/exynos_mct.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,19 +329,15 @@ static irqreturn_t exynos4_mct_comp_isr(int irq, void *dev_id)
329329
return IRQ_HANDLED;
330330
}
331331

332-
static struct irqaction mct_comp_event_irq = {
333-
.name = "mct_comp_irq",
334-
.flags = IRQF_TIMER | IRQF_IRQPOLL,
335-
.handler = exynos4_mct_comp_isr,
336-
.dev_id = &mct_comp_device,
337-
};
338-
339332
static int exynos4_clockevent_init(void)
340333
{
341334
mct_comp_device.cpumask = cpumask_of(0);
342335
clockevents_config_and_register(&mct_comp_device, clk_rate,
343336
0xf, 0xffffffff);
344-
setup_irq(mct_irqs[MCT_G0_IRQ], &mct_comp_event_irq);
337+
if (request_irq(mct_irqs[MCT_G0_IRQ], exynos4_mct_comp_isr,
338+
IRQF_TIMER | IRQF_IRQPOLL, "mct_comp_irq",
339+
&mct_comp_device))
340+
pr_err("%s: request_irq() failed\n", "mct_comp_irq");
345341

346342
return 0;
347343
}

drivers/clocksource/mxs_timer.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,6 @@ static irqreturn_t mxs_timer_interrupt(int irq, void *dev_id)
117117
return IRQ_HANDLED;
118118
}
119119

120-
static struct irqaction mxs_timer_irq = {
121-
.name = "MXS Timer Tick",
122-
.dev_id = &mxs_clockevent_device,
123-
.flags = IRQF_TIMER | IRQF_IRQPOLL,
124-
.handler = mxs_timer_interrupt,
125-
};
126-
127120
static void mxs_irq_clear(char *state)
128121
{
129122
/* Disable interrupt in timer module */
@@ -277,6 +270,7 @@ static int __init mxs_timer_init(struct device_node *np)
277270
if (irq <= 0)
278271
return -EINVAL;
279272

280-
return setup_irq(irq, &mxs_timer_irq);
273+
return request_irq(irq, mxs_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL,
274+
"MXS Timer Tick", &mxs_clockevent_device);
281275
}
282276
TIMER_OF_DECLARE(mxs, "fsl,timrot", mxs_timer_init);

drivers/clocksource/nomadik-mtu.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,6 @@ static irqreturn_t nmdk_timer_interrupt(int irq, void *dev_id)
181181
return IRQ_HANDLED;
182182
}
183183

184-
static struct irqaction nmdk_timer_irq = {
185-
.name = "Nomadik Timer Tick",
186-
.flags = IRQF_TIMER,
187-
.handler = nmdk_timer_interrupt,
188-
.dev_id = &nmdk_clkevt,
189-
};
190-
191184
static int __init nmdk_timer_init(void __iomem *base, int irq,
192185
struct clk *pclk, struct clk *clk)
193186
{
@@ -232,7 +225,9 @@ static int __init nmdk_timer_init(void __iomem *base, int irq,
232225
sched_clock_register(nomadik_read_sched_clock, 32, rate);
233226

234227
/* Timer 1 is used for events, register irq and clockevents */
235-
setup_irq(irq, &nmdk_timer_irq);
228+
if (request_irq(irq, nmdk_timer_interrupt, IRQF_TIMER,
229+
"Nomadik Timer Tick", &nmdk_clkevt))
230+
pr_err("%s: request_irq() failed\n", "Nomadik Timer Tick");
236231
nmdk_clkevt.cpumask = cpumask_of(0);
237232
nmdk_clkevt.irq = irq;
238233
clockevents_config_and_register(&nmdk_clkevt, rate, 2, 0xffffffffU);

drivers/clocksource/samsung_pwm_timer.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,6 @@ static irqreturn_t samsung_clock_event_isr(int irq, void *dev_id)
256256
return IRQ_HANDLED;
257257
}
258258

259-
static struct irqaction samsung_clock_event_irq = {
260-
.name = "samsung_time_irq",
261-
.flags = IRQF_TIMER | IRQF_IRQPOLL,
262-
.handler = samsung_clock_event_isr,
263-
.dev_id = &time_event_device,
264-
};
265-
266259
static void __init samsung_clockevent_init(void)
267260
{
268261
unsigned long pclk;
@@ -282,7 +275,10 @@ static void __init samsung_clockevent_init(void)
282275
clock_rate, 1, pwm.tcnt_max);
283276

284277
irq_number = pwm.irq[pwm.event_id];
285-
setup_irq(irq_number, &samsung_clock_event_irq);
278+
if (request_irq(irq_number, samsung_clock_event_isr,
279+
IRQF_TIMER | IRQF_IRQPOLL, "samsung_time_irq",
280+
&time_event_device))
281+
pr_err("%s: request_irq() failed\n", "samsung_time_irq");
286282

287283
if (pwm.variant.has_tint_cstat) {
288284
u32 mask = (1 << pwm.event_id);

drivers/clocksource/timer-atlas7.c

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -159,29 +159,23 @@ static struct clocksource sirfsoc_clocksource = {
159159
.resume = sirfsoc_clocksource_resume,
160160
};
161161

162-
static struct irqaction sirfsoc_timer_irq = {
163-
.name = "sirfsoc_timer0",
164-
.flags = IRQF_TIMER | IRQF_NOBALANCING,
165-
.handler = sirfsoc_timer_interrupt,
166-
};
167-
168-
static struct irqaction sirfsoc_timer1_irq = {
169-
.name = "sirfsoc_timer1",
170-
.flags = IRQF_TIMER | IRQF_NOBALANCING,
171-
.handler = sirfsoc_timer_interrupt,
172-
};
162+
static unsigned int sirfsoc_timer_irq, sirfsoc_timer1_irq;
173163

174164
static int sirfsoc_local_timer_starting_cpu(unsigned int cpu)
175165
{
176166
struct clock_event_device *ce = per_cpu_ptr(sirfsoc_clockevent, cpu);
177-
struct irqaction *action;
178-
179-
if (cpu == 0)
180-
action = &sirfsoc_timer_irq;
181-
else
182-
action = &sirfsoc_timer1_irq;
167+
unsigned int irq;
168+
const char *name;
169+
170+
if (cpu == 0) {
171+
irq = sirfsoc_timer_irq;
172+
name = "sirfsoc_timer0";
173+
} else {
174+
irq = sirfsoc_timer1_irq;
175+
name = "sirfsoc_timer1";
176+
}
183177

184-
ce->irq = action->irq;
178+
ce->irq = irq;
185179
ce->name = "local_timer";
186180
ce->features = CLOCK_EVT_FEAT_ONESHOT;
187181
ce->rating = 200;
@@ -196,22 +190,24 @@ static int sirfsoc_local_timer_starting_cpu(unsigned int cpu)
196190
ce->min_delta_ticks = 2;
197191
ce->cpumask = cpumask_of(cpu);
198192

199-
action->dev_id = ce;
200-
BUG_ON(setup_irq(ce->irq, action));
201-
irq_force_affinity(action->irq, cpumask_of(cpu));
193+
BUG_ON(request_irq(ce->irq, sirfsoc_timer_interrupt,
194+
IRQF_TIMER | IRQF_NOBALANCING, name, ce));
195+
irq_force_affinity(ce->irq, cpumask_of(cpu));
202196

203197
clockevents_register_device(ce);
204198
return 0;
205199
}
206200

207201
static int sirfsoc_local_timer_dying_cpu(unsigned int cpu)
208202
{
203+
struct clock_event_device *ce = per_cpu_ptr(sirfsoc_clockevent, cpu);
204+
209205
sirfsoc_timer_count_disable(1);
210206

211207
if (cpu == 0)
212-
remove_irq(sirfsoc_timer_irq.irq, &sirfsoc_timer_irq);
208+
free_irq(sirfsoc_timer_irq, ce);
213209
else
214-
remove_irq(sirfsoc_timer1_irq.irq, &sirfsoc_timer1_irq);
210+
free_irq(sirfsoc_timer1_irq, ce);
215211
return 0;
216212
}
217213

@@ -268,14 +264,14 @@ static int __init sirfsoc_of_timer_init(struct device_node *np)
268264
return -ENXIO;
269265
}
270266

271-
sirfsoc_timer_irq.irq = irq_of_parse_and_map(np, 0);
272-
if (!sirfsoc_timer_irq.irq) {
267+
sirfsoc_timer_irq = irq_of_parse_and_map(np, 0);
268+
if (!sirfsoc_timer_irq) {
273269
pr_err("No irq passed for timer0 via DT\n");
274270
return -EINVAL;
275271
}
276272

277-
sirfsoc_timer1_irq.irq = irq_of_parse_and_map(np, 1);
278-
if (!sirfsoc_timer1_irq.irq) {
273+
sirfsoc_timer1_irq = irq_of_parse_and_map(np, 1);
274+
if (!sirfsoc_timer1_irq) {
279275
pr_err("No irq passed for timer1 via DT\n");
280276
return -EINVAL;
281277
}

drivers/clocksource/timer-cs5535.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ static irqreturn_t mfgpt_tick(int irq, void *dev_id)
131131
return IRQ_HANDLED;
132132
}
133133

134-
static struct irqaction mfgptirq = {
135-
.handler = mfgpt_tick,
136-
.flags = IRQF_NOBALANCING | IRQF_TIMER | IRQF_SHARED,
137-
.name = DRV_NAME,
138-
};
139-
140134
static int __init cs5535_mfgpt_init(void)
141135
{
142136
struct cs5535_mfgpt_timer *timer;
@@ -158,7 +152,9 @@ static int __init cs5535_mfgpt_init(void)
158152
}
159153

160154
/* And register it with the kernel */
161-
ret = setup_irq(timer_irq, &mfgptirq);
155+
ret = request_irq(timer_irq, mfgpt_tick,
156+
IRQF_NOBALANCING | IRQF_TIMER | IRQF_SHARED,
157+
DRV_NAME, NULL);
162158
if (ret) {
163159
printk(KERN_ERR DRV_NAME ": Unable to set up the interrupt.\n");
164160
goto err_irq;

drivers/clocksource/timer-efm32.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,6 @@ static struct efm32_clock_event_ddata clock_event_ddata = {
119119
},
120120
};
121121

122-
static struct irqaction efm32_clock_event_irq = {
123-
.name = "efm32 clockevent",
124-
.flags = IRQF_TIMER,
125-
.handler = efm32_clock_event_handler,
126-
.dev_id = &clock_event_ddata,
127-
};
128-
129122
static int __init efm32_clocksource_init(struct device_node *np)
130123
{
131124
struct clk *clk;
@@ -230,7 +223,8 @@ static int __init efm32_clockevent_init(struct device_node *np)
230223
DIV_ROUND_CLOSEST(rate, 1024),
231224
0xf, 0xffff);
232225

233-
ret = setup_irq(irq, &efm32_clock_event_irq);
226+
ret = request_irq(irq, efm32_clock_event_handler, IRQF_TIMER,
227+
"efm32 clockevent", &clock_event_ddata);
234228
if (ret) {
235229
pr_err("Failed setup irq\n");
236230
goto err_setup_irq;

0 commit comments

Comments
 (0)