Commit 25db8ad5 authored by Alan Cox's avatar Alan Cox Committed by Ingo Molnar

serial, 8250: remove NR_IRQ usage

Works on my test box with a quick test.
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 5fef06e8
...@@ -66,7 +66,6 @@ ...@@ -66,7 +66,6 @@
#endif #endif
static struct m68k_serial m68k_soft[NR_PORTS]; static struct m68k_serial m68k_soft[NR_PORTS];
struct m68k_serial *IRQ_ports[NR_IRQS];
static unsigned int uart_irqs[NR_PORTS] = UART_IRQ_DEFNS; static unsigned int uart_irqs[NR_PORTS] = UART_IRQ_DEFNS;
...@@ -375,15 +374,11 @@ clear_and_return: ...@@ -375,15 +374,11 @@ clear_and_return:
*/ */
irqreturn_t rs_interrupt(int irq, void *dev_id) irqreturn_t rs_interrupt(int irq, void *dev_id)
{ {
struct m68k_serial * info; struct m68k_serial *info = dev_id;
m68328_uart *uart; m68328_uart *uart;
unsigned short rx; unsigned short rx;
unsigned short tx; unsigned short tx;
info = IRQ_ports[irq];
if(!info)
return IRQ_NONE;
uart = &uart_addr[info->line]; uart = &uart_addr[info->line];
rx = uart->urx.w; rx = uart->urx.w;
...@@ -1383,8 +1378,6 @@ rs68328_init(void) ...@@ -1383,8 +1378,6 @@ rs68328_init(void)
info->port, info->irq); info->port, info->irq);
printk(" is a builtin MC68328 UART\n"); printk(" is a builtin MC68328 UART\n");
IRQ_ports[info->irq] = info; /* waste of space */
#ifdef CONFIG_M68VZ328 #ifdef CONFIG_M68VZ328
if (i > 0 ) if (i > 0 )
PJSEL &= 0xCF; /* PSW enable second port output */ PJSEL &= 0xCF; /* PSW enable second port output */
...@@ -1393,7 +1386,7 @@ rs68328_init(void) ...@@ -1393,7 +1386,7 @@ rs68328_init(void)
if (request_irq(uart_irqs[i], if (request_irq(uart_irqs[i],
rs_interrupt, rs_interrupt,
IRQF_DISABLED, IRQF_DISABLED,
"M68328_UART", NULL)) "M68328_UART", info))
panic("Unable to attach 68328 serial interrupt\n"); panic("Unable to attach 68328 serial interrupt\n");
} }
local_irq_restore(flags); local_irq_restore(flags);
......
...@@ -156,11 +156,15 @@ struct uart_8250_port { ...@@ -156,11 +156,15 @@ struct uart_8250_port {
}; };
struct irq_info { struct irq_info {
spinlock_t lock; struct hlist_node node;
int irq;
spinlock_t lock; /* Protects list not the hash */
struct list_head *head; struct list_head *head;
}; };
static struct irq_info irq_lists[NR_IRQS]; #define NR_IRQ_HASH 32 /* Can be adjusted later */
static struct hlist_head irq_lists[NR_IRQ_HASH];
static DEFINE_MUTEX(hash_mutex); /* Used to walk the hash */
/* /*
* Here we define the default xmit fifo size used for each type of UART. * Here we define the default xmit fifo size used for each type of UART.
...@@ -1545,15 +1549,43 @@ static void serial_do_unlink(struct irq_info *i, struct uart_8250_port *up) ...@@ -1545,15 +1549,43 @@ static void serial_do_unlink(struct irq_info *i, struct uart_8250_port *up)
BUG_ON(i->head != &up->list); BUG_ON(i->head != &up->list);
i->head = NULL; i->head = NULL;
} }
spin_unlock_irq(&i->lock); spin_unlock_irq(&i->lock);
/* List empty so throw away the hash node */
if (i->head == NULL) {
hlist_del(&i->node);
kfree(i);
}
} }
static int serial_link_irq_chain(struct uart_8250_port *up) static int serial_link_irq_chain(struct uart_8250_port *up)
{ {
struct irq_info *i = irq_lists + up->port.irq; struct hlist_head *h;
struct hlist_node *n;
struct irq_info *i;
int ret, irq_flags = up->port.flags & UPF_SHARE_IRQ ? IRQF_SHARED : 0; int ret, irq_flags = up->port.flags & UPF_SHARE_IRQ ? IRQF_SHARED : 0;
mutex_lock(&hash_mutex);
h = &irq_lists[up->port.irq % NR_IRQ_HASH];
hlist_for_each(n, h) {
i = hlist_entry(n, struct irq_info, node);
if (i->irq == up->port.irq)
break;
}
if (n == NULL) {
i = kzalloc(sizeof(struct irq_info), GFP_KERNEL);
if (i == NULL) {
mutex_unlock(&hash_mutex);
return -ENOMEM;
}
spin_lock_init(&i->lock);
i->irq = up->port.irq;
hlist_add_head(&i->node, h);
}
mutex_unlock(&hash_mutex);
spin_lock_irq(&i->lock); spin_lock_irq(&i->lock);
if (i->head) { if (i->head) {
...@@ -1577,14 +1609,28 @@ static int serial_link_irq_chain(struct uart_8250_port *up) ...@@ -1577,14 +1609,28 @@ static int serial_link_irq_chain(struct uart_8250_port *up)
static void serial_unlink_irq_chain(struct uart_8250_port *up) static void serial_unlink_irq_chain(struct uart_8250_port *up)
{ {
struct irq_info *i = irq_lists + up->port.irq; struct irq_info *i;
struct hlist_node *n;
struct hlist_head *h;
mutex_lock(&hash_mutex);
h = &irq_lists[up->port.irq % NR_IRQ_HASH];
hlist_for_each(n, h) {
i = hlist_entry(n, struct irq_info, node);
if (i->irq == up->port.irq)
break;
}
BUG_ON(n == NULL);
BUG_ON(i->head == NULL); BUG_ON(i->head == NULL);
if (list_empty(i->head)) if (list_empty(i->head))
free_irq(up->port.irq, i); free_irq(up->port.irq, i);
serial_do_unlink(i, up); serial_do_unlink(i, up);
mutex_unlock(&hash_mutex);
} }
/* Base timer interval for polling */ /* Base timer interval for polling */
...@@ -2960,7 +3006,7 @@ EXPORT_SYMBOL(serial8250_unregister_port); ...@@ -2960,7 +3006,7 @@ EXPORT_SYMBOL(serial8250_unregister_port);
static int __init serial8250_init(void) static int __init serial8250_init(void)
{ {
int ret, i; int ret;
if (nr_uarts > UART_NR) if (nr_uarts > UART_NR)
nr_uarts = UART_NR; nr_uarts = UART_NR;
...@@ -2969,9 +3015,6 @@ static int __init serial8250_init(void) ...@@ -2969,9 +3015,6 @@ static int __init serial8250_init(void)
"%d ports, IRQ sharing %sabled\n", nr_uarts, "%d ports, IRQ sharing %sabled\n", nr_uarts,
share_irqs ? "en" : "dis"); share_irqs ? "en" : "dis");
for (i = 0; i < NR_IRQS; i++)
spin_lock_init(&irq_lists[i].lock);
#ifdef CONFIG_SPARC #ifdef CONFIG_SPARC
ret = sunserial_register_minors(&serial8250_reg, UART_NR); ret = sunserial_register_minors(&serial8250_reg, UART_NR);
#else #else
...@@ -2999,15 +3042,15 @@ static int __init serial8250_init(void) ...@@ -2999,15 +3042,15 @@ static int __init serial8250_init(void)
goto out; goto out;
platform_device_del(serial8250_isa_devs); platform_device_del(serial8250_isa_devs);
put_dev: put_dev:
platform_device_put(serial8250_isa_devs); platform_device_put(serial8250_isa_devs);
unreg_uart_drv: unreg_uart_drv:
#ifdef CONFIG_SPARC #ifdef CONFIG_SPARC
sunserial_unregister_minors(&serial8250_reg, UART_NR); sunserial_unregister_minors(&serial8250_reg, UART_NR);
#else #else
uart_unregister_driver(&serial8250_reg); uart_unregister_driver(&serial8250_reg);
#endif #endif
out: out:
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment