Commit fd390a57 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Remove check_region and MOD_*_USE_COUNT from

From: Bob Miller <rem@osdl.org>

- Replace the call to MOD_INC_USE_COUNT with a __module_get() when
  forcing the module to not be unloadable.

- Remove the check_region() calls and restructured things to only use
  request_region().
parent b019b5ee
...@@ -95,7 +95,12 @@ static int mixcomwd_open(struct inode *inode, struct file *file) ...@@ -95,7 +95,12 @@ static int mixcomwd_open(struct inode *inode, struct file *file)
mixcomwd_ping(); mixcomwd_ping();
if (nowayout) { if (nowayout) {
MOD_INC_USE_COUNT; /*
* fops_get() code via open() has already done
* a try_module_get() so it is safe to do the
* __module_get().
*/
__module_get(THIS_MODULE);
} else { } else {
if(mixcomwd_timer_alive) { if(mixcomwd_timer_alive) {
del_timer(&mixcomwd_timer); del_timer(&mixcomwd_timer);
...@@ -211,30 +216,34 @@ static int __init mixcomwd_checkcard(int port) ...@@ -211,30 +216,34 @@ static int __init mixcomwd_checkcard(int port)
{ {
int id; int id;
if(check_region(port+MIXCOM_WATCHDOG_OFFSET,1)) { port += MIXCOM_WATCHDOG_OFFSET;
if (!request_region(port, 1, "MixCOM watchdog")) {
return 0; return 0;
} }
id=inb_p(port + MIXCOM_WATCHDOG_OFFSET) & 0x3f; id=inb_p(port) & 0x3f;
if(id!=MIXCOM_ID) { if(id!=MIXCOM_ID) {
release_region(port, 1);
return 0; return 0;
} }
return 1; return port;
} }
static int __init flashcom_checkcard(int port) static int __init flashcom_checkcard(int port)
{ {
int id; int id;
if(check_region(port + FLASHCOM_WATCHDOG_OFFSET,1)) { port += FLASHCOM_WATCHDOG_OFFSET;
if (!request_region(port, 1, "MixCOM watchdog")) {
return 0; return 0;
} }
id=inb_p(port + FLASHCOM_WATCHDOG_OFFSET); id=inb_p(port);
if(id!=FLASHCOM_ID) { if(id!=FLASHCOM_ID) {
release_region(port, 1);
return 0; return 0;
} }
return 1; return port;
} }
static int __init mixcomwd_init(void) static int __init mixcomwd_init(void)
...@@ -244,17 +253,17 @@ static int __init mixcomwd_init(void) ...@@ -244,17 +253,17 @@ static int __init mixcomwd_init(void)
int found=0; int found=0;
for (i = 0; !found && mixcomwd_ioports[i] != 0; i++) { for (i = 0; !found && mixcomwd_ioports[i] != 0; i++) {
if (mixcomwd_checkcard(mixcomwd_ioports[i])) { watchdog_port = mixcomwd_checkcard(mixcomwd_ioports[i]);
if (watchdog_port) {
found = 1; found = 1;
watchdog_port = mixcomwd_ioports[i] + MIXCOM_WATCHDOG_OFFSET;
} }
} }
/* The FlashCOM card can be set up at 0x300 -> 0x378, in 0x8 jumps */ /* The FlashCOM card can be set up at 0x300 -> 0x378, in 0x8 jumps */
for (i = 0x300; !found && i < 0x380; i+=0x8) { for (i = 0x300; !found && i < 0x380; i+=0x8) {
if (flashcom_checkcard(i)) { watchdog_port = flashcom_checkcard(i);
if (watchdog_port) {
found = 1; found = 1;
watchdog_port = i + FLASHCOM_WATCHDOG_OFFSET;
} }
} }
...@@ -263,9 +272,6 @@ static int __init mixcomwd_init(void) ...@@ -263,9 +272,6 @@ static int __init mixcomwd_init(void)
return -ENODEV; return -ENODEV;
} }
if (!request_region(watchdog_port,1,"MixCOM watchdog"))
return -EIO;
ret = misc_register(&mixcomwd_miscdev); ret = misc_register(&mixcomwd_miscdev);
if (ret) if (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