Commit c5b529b3 authored by Marcel Sebek's avatar Marcel Sebek Committed by Vojtech Pavlik

input: Use request_region() instead of check_region() in ns558.c

       it's both safer and correct.
parent e2bf29ee
...@@ -77,7 +77,7 @@ static void ns558_isa_probe(int io) ...@@ -77,7 +77,7 @@ static void ns558_isa_probe(int io)
* No one should be using this address. * No one should be using this address.
*/ */
if (check_region(io, 1)) if (!request_region(io, 1, "ns558-isa"))
return; return;
/* /*
...@@ -89,7 +89,8 @@ static void ns558_isa_probe(int io) ...@@ -89,7 +89,8 @@ static void ns558_isa_probe(int io)
outb(~c & ~3, io); outb(~c & ~3, io);
if (~(u = v = inb(io)) & 3) { if (~(u = v = inb(io)) & 3) {
outb(c, io); outb(c, io);
return; i = 0;
goto out;
} }
/* /*
* After a trigger, there must be at least some bits changing. * After a trigger, there must be at least some bits changing.
...@@ -99,7 +100,8 @@ static void ns558_isa_probe(int io) ...@@ -99,7 +100,8 @@ static void ns558_isa_probe(int io)
if (u == v) { if (u == v) {
outb(c, io); outb(c, io);
return; i = 0;
goto out;
} }
wait_ms(3); wait_ms(3);
/* /*
...@@ -110,7 +112,8 @@ static void ns558_isa_probe(int io) ...@@ -110,7 +112,8 @@ static void ns558_isa_probe(int io)
for (i = 0; i < 1000; i++) for (i = 0; i < 1000; i++)
if ((u ^ inb(io)) & 0xf) { if ((u ^ inb(io)) & 0xf) {
outb(c, io); outb(c, io);
return; i = 0;
goto out;
} }
/* /*
* And now find the number of mirrors of the port. * And now find the number of mirrors of the port.
...@@ -118,7 +121,9 @@ static void ns558_isa_probe(int io) ...@@ -118,7 +121,9 @@ static void ns558_isa_probe(int io)
for (i = 1; i < 5; i++) { for (i = 1; i < 5; i++) {
if (check_region(io & (-1 << i), (1 << i))) /* Don't disturb anyone */ release_region(io & (-1 << (i-1)), (1 << (i-1)));
if (!request_region(io & (-1 << i), (1 << i), "ns558-isa")) /* Don't disturb anyone */
break; break;
outb(0xff, io & (-1 << i)); outb(0xff, io & (-1 << i));
...@@ -126,18 +131,25 @@ static void ns558_isa_probe(int io) ...@@ -126,18 +131,25 @@ static void ns558_isa_probe(int io)
if (inb(io & (-1 << i)) != inb((io & (-1 << i)) + (1 << i) - 1)) b++; if (inb(io & (-1 << i)) != inb((io & (-1 << i)) + (1 << i) - 1)) b++;
wait_ms(3); wait_ms(3);
if (b > 300) /* We allow 30% difference */ if (b > 300) { /* We allow 30% difference */
release_region(io & (-1 << i), (1 << i));
break; break;
}
} }
i--; i--;
if (i != 4) {
if (!request_region(io & (-1 << i), (1 << i), "ns558-isa"))
return;
}
if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) { if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) {
printk(KERN_ERR "ns558: Memory allocation failed.\n"); printk(KERN_ERR "ns558: Memory allocation failed.\n");
return; goto out;
} }
memset(port, 0, sizeof(struct ns558)); memset(port, 0, sizeof(struct ns558));
port->type = NS558_ISA; port->type = NS558_ISA;
port->size = (1 << i); port->size = (1 << i);
port->gameport.io = io; port->gameport.io = io;
...@@ -148,8 +160,6 @@ static void ns558_isa_probe(int io) ...@@ -148,8 +160,6 @@ static void ns558_isa_probe(int io)
sprintf(port->phys, "isa%04x/gameport0", io & (-1 << i)); sprintf(port->phys, "isa%04x/gameport0", io & (-1 << i));
sprintf(port->name, "NS558 ISA"); sprintf(port->name, "NS558 ISA");
request_region(io & (-1 << i), (1 << i), "ns558-isa");
gameport_register_port(&port->gameport); gameport_register_port(&port->gameport);
printk(KERN_INFO "gameport: NS558 ISA at %#x", port->gameport.io); printk(KERN_INFO "gameport: NS558 ISA at %#x", port->gameport.io);
...@@ -157,6 +167,9 @@ static void ns558_isa_probe(int io) ...@@ -157,6 +167,9 @@ static void ns558_isa_probe(int io)
printk(" speed %d kHz\n", port->gameport.speed); printk(" speed %d kHz\n", port->gameport.speed);
list_add(&port->node, &ns558_list); list_add(&port->node, &ns558_list);
return;
out:
release_region(io & (-1 << i), (1 << i));
} }
#ifdef CONFIG_PNP #ifdef CONFIG_PNP
......
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