From: Vojtech Pavlik <vojtech@suse.cz>
To: torvalds@osdl.org, vojtech@ucw.cz, linux-kernel@vger.kernel.org
Subject: [PATCH 7/44] request_region() instead of check_region() in ns558.c
Date: Tue, 16 Mar 2004 15:19:36 +0100 [thread overview]
Message-ID: <10794467763238@twilight.ucw.cz> (raw)
In-Reply-To: <1079446776360@twilight.ucw.cz>
You can pull this changeset from:
bk://kernel.bkbits.net/vojtech/input
===================================================================
ChangeSet@1.1474.188.7, 2004-01-26 13:25:57+01:00, sebek64@post.cz
input: Use request_region() instead of check_region() in ns558.c
it's both safer and correct.
ns558.c | 35 ++++++++++++++++++++++++-----------
1 files changed, 24 insertions(+), 11 deletions(-)
===================================================================
diff -Nru a/drivers/input/gameport/ns558.c b/drivers/input/gameport/ns558.c
--- a/drivers/input/gameport/ns558.c Tue Mar 16 13:19:54 2004
+++ b/drivers/input/gameport/ns558.c Tue Mar 16 13:19:54 2004
@@ -77,7 +77,7 @@
* No one should be using this address.
*/
- if (check_region(io, 1))
+ if (!request_region(io, 1, "ns558-isa"))
return;
/*
@@ -89,7 +89,8 @@
outb(~c & ~3, io);
if (~(u = v = inb(io)) & 3) {
outb(c, io);
- return;
+ i = 0;
+ goto out;
}
/*
* After a trigger, there must be at least some bits changing.
@@ -99,7 +100,8 @@
if (u == v) {
outb(c, io);
- return;
+ i = 0;
+ goto out;
}
wait_ms(3);
/*
@@ -110,7 +112,8 @@
for (i = 0; i < 1000; i++)
if ((u ^ inb(io)) & 0xf) {
outb(c, io);
- return;
+ i = 0;
+ goto out;
}
/*
* And now find the number of mirrors of the port.
@@ -118,7 +121,9 @@
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;
outb(0xff, io & (-1 << i));
@@ -126,18 +131,25 @@
if (inb(io & (-1 << i)) != inb((io & (-1 << i)) + (1 << i) - 1)) b++;
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;
+ }
}
i--;
+ if (i != 4) {
+ if (!request_region(io & (-1 << i), (1 << i), "ns558-isa"))
+ return;
+ }
+
if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) {
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->size = (1 << i);
port->gameport.io = io;
@@ -148,8 +160,6 @@
sprintf(port->phys, "isa%04x/gameport0", io & (-1 << i));
sprintf(port->name, "NS558 ISA");
- request_region(io & (-1 << i), (1 << i), "ns558-isa");
-
gameport_register_port(&port->gameport);
printk(KERN_INFO "gameport: NS558 ISA at %#x", port->gameport.io);
@@ -157,6 +167,9 @@
printk(" speed %d kHz\n", port->gameport.speed);
list_add(&port->node, &ns558_list);
+ return;
+out:
+ release_region(io & (-1 << i), (1 << i));
}
#ifdef CONFIG_PNP
next prev parent reply other threads:[~2004-03-16 14:47 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-16 14:17 [44 patches] Input update Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 1/44] Fix hid-core for devices with #usages < #values Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 2/44] Add ioctl to hiddev to set multiple usages at once Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 3/44] HID quirk (badpad) for Saitek Rumblepad Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 4/44] HID quirk for another A4Tech dual-wheel mouse Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 5/44] .ko module names for acm.txt Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 6/44] Fix sunkbd.c to work with serport Vojtech Pavlik
2004-03-16 14:19 ` Vojtech Pavlik [this message]
2004-03-16 14:19 ` [PATCH 8/44] Don't reinitialize scancode map after sleep in atkbd.c Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 9/44] Support for scroll wheel on Office keyboards Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 10/44] Make enabling IBM RapidAccess special features its own option Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 11/44] Convert HP/PARISC Lasi/Dino PS/2 driver to a serio driver Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 12/44] Credit to Panagiotis Issaris for Graphire 3 support Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 13/44] Remove the obsolete busmouse.c helper driver Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 14/44] Fix a warning in i8042.c Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 15/44] Add serio entries for LK keyboards Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 16/44] Whitespace in atkbd.c Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 17/44] Automatically decide how strictly to check the protocol in synaptics Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 18/44] Whitespace fixes in psmouse.c Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 19/44] Don't fail when mouse reset doesn't work Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 20/44] Add module_parm_array() helper Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 21/44] Convert joystick drivers to new module parameters Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 22/44] Create __obsolete_setup() macro to warn users about obsolete kernel params Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 23/44] Use __obsolete_setup() in input drivers to warn " Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 24/44] Workaround i8042 chips with broken MUX mode Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 25/44] Only reprobe on PS/2 HW when the HW sends 0xaa Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 26/44] Always assume i8042 is in XLATE mode Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 27/44] Add DEC LK201/LK401 keyboard support Vojtech Pavlik
2004-03-17 19:08 ` Maciej W. Rozycki
2004-03-16 18:46 ` [PATCH 9/44] Support for scroll wheel on Office keyboards Aubin LaBrosse
2004-03-19 14:00 ` Vojtech Pavlik
2004-03-27 19:55 ` Andries Brouwer
2004-03-30 13:09 ` Pavel Machek
2004-03-30 17:05 ` Paul Wagland
2004-03-30 18:55 ` Vojtech Pavlik
2004-03-30 18:53 ` Vojtech Pavlik
2004-05-29 14:36 ` Vojtech Pavlik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10794467763238@twilight.ucw.cz \
--to=vojtech@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
--cc=vojtech@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox