Handle case when firmware files are missing more gracefully.

Signed-off-by: Brett Rudley <[email protected]>
---
 drivers/staging/brcm80211/sys/wl_mac80211.c |   71 ++++++++++++++------------
 1 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/brcm80211/sys/wl_mac80211.c 
b/drivers/staging/brcm80211/sys/wl_mac80211.c
index 5400360..d718e9e 100644
--- a/drivers/staging/brcm80211/sys/wl_mac80211.c
+++ b/drivers/staging/brcm80211/sys/wl_mac80211.c
@@ -187,6 +187,7 @@ static struct pci_device_id wl_id_table[] = {
 };
 
 MODULE_DEVICE_TABLE(pci, wl_id_table);
+static void __devexit wl_remove(struct pci_dev *pdev);
 #endif                         /* !BCMSDIO */
 
 #ifdef BCMSDIO
@@ -284,7 +285,7 @@ static int wl_ops_tx_nl(struct ieee80211_hw *hw, struct 
sk_buff *skb)
                goto done;
        }
        status = wl_start(skb, wl);
- done:
+done:
        return status;
 }
 #else
@@ -299,7 +300,7 @@ static int wl_ops_tx(struct ieee80211_hw *hw, struct 
sk_buff *skb)
                goto done;
        }
        status = wl_start(skb, wl);
- done:
+done:
        WL_UNLOCK(wl);
        return status;
 }
@@ -450,7 +451,7 @@ static int wl_ops_config(struct ieee80211_hw *hw, u32 
changed)
                }
        }
 
- config_out:
+config_out:
        return err;
 }
 
@@ -902,9 +903,11 @@ static wl_info_t *wl_attach(uint16 vendor, uint16 device, 
ulong regs,
 #ifndef WLC_HIGH_ONLY
        /* prepare ucode */
        if (wl_request_fw(wl, (struct pci_dev *)btparam)) {
-               printf("%s: %s driver failed\n", KBUILD_MODNAME,
-                      EPI_VERSION_STR);
-               goto fail;
+               printf("%s: Failed to find firmware usually in %s\n",
+                       KBUILD_MODNAME, "/lib/firmware/brcm");
+               wl_release_fw(wl);
+               wl_remove((struct pci_dev *)btparam);
+               goto fail1;
        }
 #endif
 
@@ -915,8 +918,8 @@ static wl_info_t *wl_attach(uint16 vendor, uint16 device, 
ulong regs,
        wl_release_fw(wl);
 #endif
        if (!wl->wlc) {
-               printf("%s: %s driver failed with code %d\n", KBUILD_MODNAME,
-                      EPI_VERSION_STR, err);
+               printf("%s: %s wlc_attach() failed with code %d\n",
+                       KBUILD_MODNAME, EPI_VERSION_STR, err);
                goto fail;
        }
        wl->pub = wlc_pub(wl->wlc);
@@ -1016,8 +1019,9 @@ static wl_info_t *wl_attach(uint16 vendor, uint16 device, 
ulong regs,
        wl_found++;
        return wl;
 
- fail:
+fail:
        wl_free(wl);
+fail1:
        return NULL;
 }
 
@@ -1189,9 +1193,6 @@ static void wl_dbus_disconnect_cb(void *arg)
 }
 #endif                         /* WLC_HIGH_ONLY */
 
-#ifndef BCMSDIO
-static void __devexit wl_remove(struct pci_dev *pdev);
-#endif
 
 #define CHAN2GHZ(channel, freqency, chflags)  { \
        .band = IEEE80211_BAND_2GHZ, \
@@ -1510,8 +1511,13 @@ wl_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
        wl = wl_attach(pdev->vendor, pdev->device, pci_resource_start(pdev, 0),
                       PCI_BUS, pdev, pdev->irq);
 
+       if (!wl) {
+               WL_ERROR(("%s: %s: wl_attach failed!\n",
+                       KBUILD_MODNAME, __func__));
+               return -ENODEV;
+       }
        return 0;
- err_1:
+err_1:
        WL_ERROR(("%s: err_1: Major hoarkage\n", __func__));
        return 0;
 }
@@ -1594,31 +1600,28 @@ static void __devexit wl_remove(struct pci_dev *pdev)
                WL_ERROR(("wl: wl_remove: wlc_chipmatch failed\n"));
                return;
        }
-
-       ieee80211_unregister_hw(hw);
-
-       WL_LOCK(wl);
-       wl_down(wl);
-       WL_UNLOCK(wl);
-       WL_NONE(("%s: Down\n", __func__));
-
+       if (wl->wlc) {
+               ieee80211_unregister_hw(hw);
+               WL_LOCK(wl);
+               wl_down(wl);
+               WL_UNLOCK(wl);
+               WL_NONE(("%s: Down\n", __func__));
+       }
        pci_disable_device(pdev);
-
        wl_free(wl);
-
        pci_set_drvdata(pdev, NULL);
        ieee80211_free_hw(hw);
 }
 
 static struct pci_driver wl_pci_driver = {
- .name  = "brcm80211",
- .probe = wl_pci_probe,
+       .name  = "brcm80211",
+       .probe = wl_pci_probe,
 #ifdef LINUXSTA_PS
- .suspend = wl_suspend,
- .resume  = wl_resume,
+       .suspend = wl_suspend,
+       .resume  = wl_resume,
 #endif                         /* LINUXSTA_PS */
- .remove   = __devexit_p(wl_remove),
- .id_table = wl_id_table,
+       .remove   = __devexit_p(wl_remove),
+       .id_table = wl_id_table,
 };
 #endif                         /* !BCMSDIO */
 
@@ -2016,7 +2019,7 @@ static void BCMFASTPATH wl_dpc(ulong data)
                wl_intrson(wl);
        }
 
- done:
+done:
        WL_UNLOCK(wl);
 #endif                         /* WLC_LOW */
 }
@@ -2511,7 +2514,8 @@ static int wl_request_fw(wl_info_t *wl, struct pci_dev 
*pdev)
                WL_NONE(("request fw %s\n", fw_name));
                status = request_firmware(&wl->fw.fw_bin[i], fw_name, device);
                if (status) {
-                       printf("fail to request firmware %s\n", fw_name);
+                       printf("%s: fail to load firmware %s\n",
+                               KBUILD_MODNAME, fw_name);
                        wl_release_fw(wl);
                        return status;
                }
@@ -2520,7 +2524,8 @@ static int wl_request_fw(wl_info_t *wl, struct pci_dev 
*pdev)
                        UCODE_LOADER_API_VER);
                status = request_firmware(&wl->fw.fw_hdr[i], fw_name, device);
                if (status) {
-                       printf("fail to request firmware %s\n", fw_name);
+                       printf("%s: fail to load firmware %s\n",
+                               KBUILD_MODNAME, fw_name);
                        wl_release_fw(wl);
                        return status;
                }
-- 
1.6.3.3


_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to