]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] check_region elimination
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 22 May 2002 05:24:57 +0000 (22:24 -0700)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Wed, 22 May 2002 05:24:57 +0000 (22:24 -0700)
Trivial patch update against 2.5.17:
johnpol@2ka.mipt.ru: Re: 47) request_region check, 41-50:

drivers/char/pcwd.c

index 791c15d52f1170704e38132fc028f4d85f4f79cf..7820fe87143837c62372e1979a8fe3088957ccf2 100644 (file)
@@ -114,12 +114,6 @@ static int __init pcwd_checkcard(void)
 {
        int card_dat, prev_card_dat, found = 0, count = 0, done = 0;
 
-       /* As suggested by Alan Cox - this is a safety measure. */
-       if (check_region(current_readport, 4)) {
-               printk("pcwd: Port 0x%x unavailable.\n", current_readport);
-               return 0;
-       }
-
        card_dat = 0x00;
        prev_card_dat = 0x00;
 
@@ -628,15 +622,31 @@ static int __init pcwatchdog_init(void)
                outb_p(0xA5, current_readport + 3);
        }
 
-       if (revision == PCWD_REVISION_A)
-               request_region(current_readport, 2, "PCWD Rev.A (Berkshire)");
-       else
-               request_region(current_readport, 4, "PCWD Rev.C (Berkshire)");
+       if (misc_register(&pcwd_miscdev))
+               return -ENODEV;
+       
+       if (supports_temp)
+               if (misc_register(&temp_miscdev)) {
+                       misc_deregister(&pcwd_miscdev);
+                       return -ENODEV;         
+               }
 
-       misc_register(&pcwd_miscdev);
 
-       if (supports_temp)
-               misc_register(&temp_miscdev);
+       if (revision == PCWD_REVISION_A) {
+               if (!request_region(current_readport, 2, "PCWD Rev.A (Berkshire)")) {
+                       misc_deregister(&pcwd_miscdev);
+                       if (supports_temp)
+                               misc_deregister(&pcwd_miscdev);
+                       return -EIO;            
+               }
+       }
+       else 
+               if (!request_region(current_readport, 4, "PCWD Rev.C (Berkshire)")) {
+                       misc_deregister(&pcwd_miscdev);
+                       if (supports_temp)
+                               misc_deregister(&pcwd_miscdev);
+                       return -EIO;
+               }
 
        return 0;
 }