Register sysctl before doing pci registration.
authorscottr <scottr@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Thu, 26 Jun 2008 08:23:41 +0000 (08:23 +0000)
committerscottr <scottr@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Thu, 26 Jun 2008 08:23:41 +0000 (08:23 +0000)
This fixes a bug when renaming multiple wireless cards on slow devices.
The pci registration causes udev to rename the device but the sysctl is
not registered yet so the device renames but the corresponding sysctl
entries are not renamed.

git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3746 0192ed92-7a03-0410-a25b-9323aeb14dbd

ath/if_ath.c
ath/if_ath_pci.c

index 819f48ab0be9036140944314faa7fe3deca3c8c7..d863cc10579fdcd0166a2311c8b97f834ba4b0fc 100644 (file)
@@ -11024,6 +11024,10 @@ ath_dynamic_sysctl_register(struct ath_softc *sc)
        unsigned int i, space;
        char *dev_name = NULL;
 
+       /* Prevent multiple registrations */
+       if (sc->sc_sysctls)
+               return;
+
        space = 5 * sizeof(struct ctl_table) + sizeof(ath_sysctl_template);
        sc->sc_sysctls = kzalloc(space, GFP_KERNEL);
        if (sc->sc_sysctls == NULL) {
@@ -11041,6 +11045,8 @@ ath_dynamic_sysctl_register(struct ath_softc *sc)
        dev_name = kmalloc((strlen(DEV_NAME(sc->sc_dev)) + 1) * sizeof(char), GFP_KERNEL);
        if (dev_name == NULL) {
                EPRINTF(sc, "Insufficient memory for device name storage!\n");
+               kfree(sc->sc_sysctls);
+               sc->sc_sysctls = NULL;
                return;
        }
        strncpy(dev_name, DEV_NAME(sc->sc_dev), strlen(DEV_NAME(sc->sc_dev)) + 1);
index 7132607ff3408c16eefc2d5b30117a4acb5ff54e..f9ccd1ed6fad70a53c2ee4acf178a3696e7a0b59 100644 (file)
@@ -380,10 +380,12 @@ MODULE_LICENSE("Dual BSD/GPL");
 static int __init
 init_ath_pci(void)
 {
-       int status = pci_register_driver(&ath_pci_driver);
-       if (status)
-               return (status);
+       int status;
        ath_sysctl_register();
+       if ((status = pci_register_driver(&ath_pci_driver))) {
+               ath_sysctl_unregister();
+               return (status);
+       }
        return (0);
 }
 module_init(init_ath_pci);