Update of /cvsroot/alsa/alsa-kernel/drivers
In directory sc8-pr-cvs1:/tmp/cvs-serv11054
Modified Files:
serial-u16550.c
Log Message:
Fixed port allocation race as suggested by william stinson <[EMAIL PROTECTED]>
Index: serial-u16550.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/drivers/serial-u16550.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- serial-u16550.c 19 Nov 2002 17:21:58 -0000 1.18
+++ serial-u16550.c 26 Dec 2002 10:31:57 -0000 1.19
@@ -322,17 +322,20 @@
* return 0 if found
* return negative error if not found
*/
-static int __init snd_uart16550_detect(unsigned int io_base)
+static int __init snd_uart16550_detect(snd_uart16550_t *uart)
{
+ unsigned long io_base = uart->base;
int ok;
unsigned char c;
- if (check_region(io_base, 8))
- return -EBUSY;
-
/* Do some vague tests for the presence of the uart */
- if (io_base == 0)
+ if (io_base == 0) {
return -ENODEV; /* Not configured */
+ }
+
+ uart->res_base = request_region(io_base, 8, "Serial MIDI");
+ if (uart->res_base == NULL)
+ return -EBUSY;
ok = 1; /* uart detected unless one of the following tests
should fail */
/* 8 data-bits, 1 stop-bit, parity off, DLAB = 0 */
@@ -766,11 +769,13 @@
uart->card = card;
spin_lock_init(&uart->open_lock);
uart->irq = -1;
- if ((uart->res_base = request_region(iobase, 8, "Serial MIDI")) == NULL) {
- snd_printk("unable to grab ports 0x%lx-0x%lx\n", iobase, iobase + 8 -
1);
- return -EBUSY;
- }
uart->base = iobase;
+
+ if ((err = snd_uart16550_detect(uart)) <= 0) {
+ printk(KERN_ERR "no UART detected at 0x%lx\n", iobase);
+ return err;
+ }
+
if (irq >= 0) {
if (request_irq(irq, snd_uart16550_interrupt,
SA_INTERRUPT, "Serial MIDI", (void *) uart)) {
@@ -887,12 +892,6 @@
strcpy(card->driver, "Serial");
strcpy(card->shortname, "Serial midi (uart16550A)");
-
- if ((err = snd_uart16550_detect(port[dev])) <= 0) {
- snd_card_free(card);
- printk(KERN_ERR "no UART detected at 0x%lx\n", (long)port[dev]);
- return err;
- }
if ((err = snd_uart16550_create(card,
port[dev],
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog