]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] rio_linux.c misc_register patch
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 1 Apr 2003 11:47:14 +0000 (03:47 -0800)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Tue, 1 Apr 2003 11:47:14 +0000 (03:47 -0800)
From:  Chris Wilson <chris@qwirx.com>

  This function did check misc_register's return code, but made no effort to
  clean up if it failed, leaving a large amount of potential crud lying
  around. I moved the registration to the start of the function, so that the
  cleanup is trivial, and made sure the device gets unregistered in the
  cases where it would not have been registered at all before.

drivers/char/rio/rio_linux.c

index 1fc1180be81ca6868baddef79b196df39d14c694..5b6f5b0fda194c60ff44ba54d5e6d8ff11da1f12 100644 (file)
@@ -1139,7 +1139,6 @@ static int __init rio_init(void)
   struct vpd_prom *vpdp;
   int okboard;
 
-
 #ifdef CONFIG_PCI
 #ifndef TWO_ZERO
   struct pci_dev *pdev = NULL;
@@ -1161,8 +1160,16 @@ static int __init rio_init(void)
     rio_debug=-1;
   }
 
+  if (misc_register(&rio_fw_device) < 0) {
+    printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n");
+    return -EIO;
+  }
+
   retval = rio_init_datastructures ();
-  if (retval < 0) return retval;
+  if (retval < 0) {
+    misc_deregister(&rio_fw_device);
+    return retval;
+  }
 
 #ifdef CONFIG_PCI
   if (pci_present ()) {
@@ -1400,12 +1407,10 @@ static int __init rio_init(void)
 
   if (found) {
     rio_dprintk (RIO_DEBUG_INIT, "rio: total of %d boards detected.\n", found);
-
-    if (misc_register(&rio_fw_device) < 0) {
-      printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n");
-      return -EIO;
-    }
     rio_init_drivers ();
+  } else {
+    /* deregister the misc device we created earlier */
+    misc_deregister(&rio_fw_device);
   }
 
   func_exit();