Skip to content

Commit b5dc784

Browse files
Roman ZippelLinus Torvalds
authored andcommitted
[PATCH] m68k: introduce irq controller
Introduce irq controller and use it to manage auto vector interrupts. Introduce setup_irq() which can be used for irq setup. Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 1d174cf commit b5dc784

12 files changed

Lines changed: 148 additions & 99 deletions

File tree

‎arch/m68k/amiga/amiints.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <linux/sched.h>
4141
#include <linux/kernel_stat.h>
4242
#include <linux/init.h>
43+
#include <linux/interrupt.h>
4344
#include <linux/errno.h>
4445
#include <linux/seq_file.h>
4546

@@ -484,13 +485,10 @@ static irqreturn_t ami_int7(int irq, void *dev_id, struct pt_regs *fp)
484485
}
485486

486487
irqreturn_t (*amiga_default_handler[SYS_IRQS])(int, void *, struct pt_regs *) = {
487-
[0] = ami_badint,
488488
[1] = ami_int1,
489-
[2] = ami_badint,
490489
[3] = ami_int3,
491490
[4] = ami_int4,
492491
[5] = ami_int5,
493-
[6] = ami_badint,
494492
[7] = ami_int7
495493
};
496494

‎arch/m68k/bvme6000/bvmeints.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/types.h>
1515
#include <linux/kernel.h>
1616
#include <linux/errno.h>
17+
#include <linux/interrupt.h>
1718
#include <linux/seq_file.h>
1819

1920
#include <asm/ptrace.h>

‎arch/m68k/kernel/ints.c‎

Lines changed: 123 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,15 @@
4545
#endif
4646

4747
/* table for system interrupt handlers */
48-
static irq_handler_t irq_list[SYS_IRQS];
48+
static struct irq_node *irq_list[SYS_IRQS];
49+
static struct irq_controller *irq_controller[SYS_IRQS];
50+
51+
static struct irq_controller auto_irq_controller = {
52+
.name = "auto",
53+
.lock = SPIN_LOCK_UNLOCKED,
54+
.startup = m68k_irq_startup,
55+
.shutdown = m68k_irq_shutdown,
56+
};
4957

5058
static const char *default_names[SYS_IRQS] = {
5159
[0] = "spurious int",
@@ -101,17 +109,13 @@ void __init init_IRQ(void)
101109
hardirq_mask_is_broken();
102110
}
103111

104-
for (i = 0; i < SYS_IRQS; i++) {
105-
if (mach_default_handler)
106-
irq_list[i].handler = (*mach_default_handler)[i];
107-
irq_list[i].flags = 0;
108-
irq_list[i].dev_id = NULL;
109-
irq_list[i].devname = default_names[i];
112+
for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++) {
113+
irq_controller[i] = &auto_irq_controller;
114+
if (mach_default_handler && (*mach_default_handler)[i])
115+
cpu_request_irq(i, (*mach_default_handler)[i],
116+
0, default_names[i], NULL);
110117
}
111118

112-
for (i = 0; i < NUM_IRQ_NODES; i++)
113-
nodes[i].handler = NULL;
114-
115119
mach_init_IRQ ();
116120
}
117121

@@ -120,9 +124,12 @@ irq_node_t *new_irq_node(void)
120124
irq_node_t *node;
121125
short i;
122126

123-
for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
124-
if (!node->handler)
127+
for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--) {
128+
if (!node->handler) {
129+
memset(node, 0, sizeof(*node));
125130
return node;
131+
}
132+
}
126133

127134
printk ("new_irq_node: out of nodes\n");
128135
return NULL;
@@ -149,55 +156,115 @@ void free_irq(unsigned int irq, void *dev_id)
149156

150157
EXPORT_SYMBOL(free_irq);
151158

152-
int cpu_request_irq(unsigned int irq,
153-
irqreturn_t (*handler)(int, void *, struct pt_regs *),
154-
unsigned long flags, const char *devname, void *dev_id)
159+
int setup_irq(unsigned int irq, struct irq_node *node)
155160
{
156-
if (irq < IRQ_AUTO_1 || irq > IRQ_AUTO_7) {
161+
struct irq_controller *contr;
162+
struct irq_node **prev;
163+
unsigned long flags;
164+
165+
if (irq >= SYS_IRQS || !(contr = irq_controller[irq])) {
157166
printk("%s: Incorrect IRQ %d from %s\n",
158-
__FUNCTION__, irq, devname);
167+
__FUNCTION__, irq, node->devname);
159168
return -ENXIO;
160169
}
161170

162-
#if 0
163-
if (!(irq_list[irq].flags & IRQ_FLG_STD)) {
164-
if (irq_list[irq].flags & IRQ_FLG_LOCK) {
165-
printk("%s: IRQ %d from %s is not replaceable\n",
166-
__FUNCTION__, irq, irq_list[irq].devname);
167-
return -EBUSY;
168-
}
169-
if (!(flags & IRQ_FLG_REPLACE)) {
170-
printk("%s: %s can't replace IRQ %d from %s\n",
171-
__FUNCTION__, devname, irq, irq_list[irq].devname);
171+
spin_lock_irqsave(&contr->lock, flags);
172+
173+
prev = irq_list + irq;
174+
if (*prev) {
175+
/* Can't share interrupts unless both agree to */
176+
if (!((*prev)->flags & node->flags & SA_SHIRQ)) {
177+
spin_unlock_irqrestore(&contr->lock, flags);
172178
return -EBUSY;
173179
}
180+
while (*prev)
181+
prev = &(*prev)->next;
174182
}
175-
#endif
176183

177-
irq_list[irq].handler = handler;
178-
irq_list[irq].flags = flags;
179-
irq_list[irq].dev_id = dev_id;
180-
irq_list[irq].devname = devname;
184+
if (!irq_list[irq]) {
185+
if (contr->startup)
186+
contr->startup(irq);
187+
else
188+
contr->enable(irq);
189+
}
190+
node->next = NULL;
191+
*prev = node;
192+
193+
spin_unlock_irqrestore(&contr->lock, flags);
194+
181195
return 0;
182196
}
183197

198+
int cpu_request_irq(unsigned int irq,
199+
irqreturn_t (*handler)(int, void *, struct pt_regs *),
200+
unsigned long flags, const char *devname, void *dev_id)
201+
{
202+
struct irq_node *node;
203+
int res;
204+
205+
node = new_irq_node();
206+
if (!node)
207+
return -ENOMEM;
208+
209+
node->handler = handler;
210+
node->flags = flags;
211+
node->dev_id = dev_id;
212+
node->devname = devname;
213+
214+
res = setup_irq(irq, node);
215+
if (res)
216+
node->handler = NULL;
217+
218+
return res;
219+
}
220+
184221
void cpu_free_irq(unsigned int irq, void *dev_id)
185222
{
186-
if (irq < IRQ_AUTO_1 || irq > IRQ_AUTO_7) {
223+
struct irq_controller *contr;
224+
struct irq_node **p, *node;
225+
unsigned long flags;
226+
227+
if (irq >= SYS_IRQS || !(contr = irq_controller[irq])) {
187228
printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
188229
return;
189230
}
190231

191-
if (irq_list[irq].dev_id != dev_id)
192-
printk("%s: Removing probably wrong IRQ %d from %s\n",
193-
__FUNCTION__, irq, irq_list[irq].devname);
232+
spin_lock_irqsave(&contr->lock, flags);
233+
234+
p = irq_list + irq;
235+
while ((node = *p)) {
236+
if (node->dev_id == dev_id)
237+
break;
238+
p = &node->next;
239+
}
240+
241+
if (node) {
242+
*p = node->next;
243+
node->handler = NULL;
244+
} else
245+
printk("%s: Removing probably wrong IRQ %d\n",
246+
__FUNCTION__, irq);
247+
248+
if (!irq_list[irq])
249+
contr->shutdown(irq);
194250

195-
irq_list[irq].handler = (*mach_default_handler)[irq];
196-
irq_list[irq].flags = 0;
197-
irq_list[irq].dev_id = NULL;
198-
irq_list[irq].devname = default_names[irq];
251+
spin_unlock_irqrestore(&contr->lock, flags);
199252
}
200253

254+
int m68k_irq_startup(unsigned int irq)
255+
{
256+
if (irq <= IRQ_AUTO_7)
257+
vectors[VEC_SPUR + irq] = auto_inthandler;
258+
return 0;
259+
}
260+
261+
void m68k_irq_shutdown(unsigned int irq)
262+
{
263+
if (irq <= IRQ_AUTO_7)
264+
vectors[VEC_SPUR + irq] = bad_inthandler;
265+
}
266+
267+
201268
/*
202269
* Do we need these probe functions on the m68k?
203270
*
@@ -250,8 +317,14 @@ static void dummy_free_irq(unsigned int irq, void *dev_id)
250317

251318
asmlinkage void m68k_handle_int(unsigned int irq, struct pt_regs *regs)
252319
{
320+
struct irq_node *node;
321+
253322
kstat_cpu(0).irqs[irq]++;
254-
irq_list[irq].handler(irq, irq_list[irq].dev_id, regs);
323+
node = irq_list[irq];
324+
do {
325+
node->handler(irq, node->dev_id, regs);
326+
node = node->next;
327+
} while (node);
255328
}
256329

257330
asmlinkage void handle_badint(struct pt_regs *regs)
@@ -262,16 +335,18 @@ asmlinkage void handle_badint(struct pt_regs *regs)
262335

263336
int show_interrupts(struct seq_file *p, void *v)
264337
{
338+
struct irq_controller *contr;
339+
struct irq_node *node;
265340
int i = *(loff_t *) v;
266341

267342
/* autovector interrupts */
268-
if (i < SYS_IRQS) {
269-
if (mach_default_handler) {
270-
seq_printf(p, "auto %2d: %10u ", i,
271-
i ? kstat_cpu(0).irqs[i] : num_spurious);
272-
seq_puts(p, " ");
273-
seq_printf(p, "%s\n", irq_list[i].devname);
274-
}
343+
if (i < SYS_IRQS && irq_list[i]) {
344+
contr = irq_controller[i];
345+
node = irq_list[i];
346+
seq_printf(p, "%s %u: %10u %s", contr->name, i, kstat_cpu(0).irqs[i], node->devname);
347+
while ((node = node->next))
348+
seq_printf(p, ", %s", node->devname);
349+
seq_puts(p, "\n");
275350
} else if (i == SYS_IRQS)
276351
mach_get_irq_list(p, v);
277352
return 0;

‎arch/m68k/mac/config.c‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,6 @@ static void mac_sched_init(irqreturn_t (*vector)(int, void *, struct pt_regs *))
9494
via_init_clock(vector);
9595
}
9696

97-
extern irqreturn_t mac_default_handler(int, void *, struct pt_regs *);
98-
99-
irqreturn_t (*mac_handlers[8])(int, void *, struct pt_regs *)=
100-
{
101-
mac_default_handler,
102-
mac_default_handler,
103-
mac_default_handler,
104-
mac_default_handler,
105-
mac_default_handler,
106-
mac_default_handler,
107-
mac_default_handler,
108-
mac_default_handler
109-
};
110-
11197
/*
11298
* Parse a Macintosh-specific record in the bootinfo
11399
*/
@@ -188,7 +174,6 @@ void __init config_mac(void)
188174
enable_irq = mac_enable_irq;
189175
disable_irq = mac_disable_irq;
190176
mach_get_model = mac_get_model;
191-
mach_default_handler = &mac_handlers;
192177
mach_get_irq_list = show_mac_interrupts;
193178
mach_gettimeoffset = mac_gettimeoffset;
194179
#warning move to adb/via init

‎arch/m68k/mac/macints.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,13 +637,6 @@ int show_mac_interrupts(struct seq_file *p, void *v)
637637
return 0;
638638
}
639639

640-
void mac_default_handler(int irq, void *dev_id, struct pt_regs *regs)
641-
{
642-
#ifdef DEBUG_SPURIOUS
643-
printk("Unexpected IRQ %d on device %p\n", irq, dev_id);
644-
#endif
645-
}
646-
647640
static int num_debug[8];
648641

649642
irqreturn_t mac_debug_handler(int irq, void *dev_id, struct pt_regs *regs)

‎arch/m68k/mvme147/147ints.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/types.h>
1515
#include <linux/kernel.h>
1616
#include <linux/errno.h>
17+
#include <linux/interrupt.h>
1718
#include <linux/seq_file.h>
1819

1920
#include <asm/ptrace.h>

‎arch/m68k/mvme16x/16xints.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/types.h>
1515
#include <linux/kernel.h>
1616
#include <linux/errno.h>
17+
#include <linux/interrupt.h>
1718
#include <linux/seq_file.h>
1819

1920
#include <asm/system.h>

‎arch/m68k/q40/config.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include <asm/q40_master.h>
3838

3939
extern irqreturn_t q40_process_int (int level, struct pt_regs *regs);
40-
extern irqreturn_t (*q40_default_handler[]) (int, void *, struct pt_regs *); /* added just for debugging */
4140
extern void q40_init_IRQ (void);
4241
extern void q40_free_irq (unsigned int, void *);
4342
extern int show_q40_interrupts (struct seq_file *, void *);
@@ -181,7 +180,6 @@ void __init config_q40(void)
181180
mach_request_irq = q40_request_irq;
182181
enable_irq = q40_enable_irq;
183182
disable_irq = q40_disable_irq;
184-
mach_default_handler = &q40_default_handler;
185183
mach_get_model = q40_get_model;
186184
mach_get_hardware_list = q40_get_hardware_list;
187185

‎arch/m68k/q40/q40ints.c‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ irqreturn_t q40_irq2_handler (int, void *, struct pt_regs *fp);
4646

4747

4848
static irqreturn_t q40_defhand (int irq, void *dev_id, struct pt_regs *fp);
49-
static irqreturn_t default_handler(int lev, void *dev_id, struct pt_regs *regs);
5049

5150

5251
#define DEVNAME_SIZE 24
@@ -415,22 +414,6 @@ static irqreturn_t q40_defhand (int irq, void *dev_id, struct pt_regs *fp)
415414
else master_outb(-1,KEYBOARD_UNLOCK_REG);
416415
return IRQ_NONE;
417416
}
418-
static irqreturn_t default_handler(int lev, void *dev_id, struct pt_regs *regs)
419-
{
420-
printk ("Uninitialised interrupt level %d\n", lev);
421-
return IRQ_NONE;
422-
}
423-
424-
irqreturn_t (*q40_default_handler[SYS_IRQS])(int, void *, struct pt_regs *) = {
425-
[0] = default_handler,
426-
[1] = default_handler,
427-
[2] = default_handler,
428-
[3] = default_handler,
429-
[4] = default_handler,
430-
[5] = default_handler,
431-
[6] = default_handler,
432-
[7] = default_handler
433-
};
434417

435418

436419
void q40_enable_irq (unsigned int irq)

‎drivers/block/amiflop.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include <linux/buffer_head.h>
6565
#include <linux/blkdev.h>
6666
#include <linux/elevator.h>
67+
#include <linux/interrupt.h>
6768

6869
#include <asm/setup.h>
6970
#include <asm/uaccess.h>

0 commit comments

Comments
 (0)