b43: move hwrng registration driver to wireless core initialization
authorJohn W. Linville <linville@tuxdriver.com>
Fri, 6 Aug 2010 19:31:45 +0000 (15:31 -0400)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 16 Aug 2010 18:39:48 +0000 (14:39 -0400)
...and unregistration to core shutdown.  Previously, the driver
remained registered even when the hardware was shutdown.  That
causes the driver to return -ENODEV if the b43 device is IFF_DOWN.
This change causes the driver to disappear in that case, allowing
/dev/hwrng to still function if another hwrng device is available.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/b43/main.c

index 294b6889582209d93853dbe3045f58bb82d3ad1c..a3e2f2bfe3a78f65c24f21ef4171e71593aa321a 100644 (file)
@@ -4255,6 +4255,10 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
        B43_WARN_ON(dev && b43_status(dev) > B43_STAT_INITIALIZED);
        if (!dev || b43_status(dev) != B43_STAT_INITIALIZED)
                return;
+
+       /* Unregister HW RNG driver */
+       b43_rng_exit(dev->wl);
+
        b43_set_status(dev, B43_STAT_UNINIT);
 
        /* Stop the microcode PSM. */
@@ -4384,6 +4388,9 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
 
        b43_set_status(dev, B43_STAT_INITIALIZED);
 
+       /* Register HW RNG driver */
+       b43_rng_init(dev->wl);
+
 out:
        return err;
 
@@ -4989,7 +4996,6 @@ static int b43_probe(struct ssb_device *dev, const struct ssb_device_id *id)
                if (err)
                        goto err_one_core_detach;
                b43_leds_register(wl->current_dev);
-               b43_rng_init(wl);
        }
 
       out:
@@ -5025,7 +5031,6 @@ static void b43_remove(struct ssb_device *dev)
        b43_one_core_detach(dev);
 
        if (list_empty(&wl->devlist)) {
-               b43_rng_exit(wl);
                b43_leds_unregister(wl);
                /* Last core on the chip unregistered.
                 * We can destroy common struct b43_wl.