aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-08-07 22:13:57 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-08-16 15:26:43 -0400
commit5cddea816eec8b5f6ab76d3fafcbb1533c8c2b9d (patch)
treef8c2c1a9afec14bfc3ef0ca53cd73394433072a5
parente5ef5bad345f97f1fef7ccdc01a88c298629a5d9 (diff)
libertas: [usb] use new firmware locations
Look for firmware where the linux-firmware tree actually puts it, but fall back to original firmware name & location when the new location doesn't exist. Signed-off-by: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/libertas/if_usb.c60
-rw-r--r--drivers/net/wireless/libertas/if_usb.h1
2 files changed, 54 insertions, 7 deletions
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index 07ece9d26c6..238de10a4b5 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -26,15 +26,25 @@
26 26
27#define MESSAGE_HEADER_LEN 4 27#define MESSAGE_HEADER_LEN 4
28 28
29static char *lbs_fw_name = "usb8388.bin"; 29static char *lbs_fw_name = NULL;
30module_param_named(fw_name, lbs_fw_name, charp, 0644); 30module_param_named(fw_name, lbs_fw_name, charp, 0644);
31 31
32MODULE_FIRMWARE("libertas/usb8388_v9.bin");
33MODULE_FIRMWARE("libertas/usb8388_v5.bin");
34MODULE_FIRMWARE("libertas/usb8388.bin");
35MODULE_FIRMWARE("libertas/usb8682.bin");
32MODULE_FIRMWARE("usb8388.bin"); 36MODULE_FIRMWARE("usb8388.bin");
33 37
38enum {
39 MODEL_UNKNOWN = 0x0,
40 MODEL_8388 = 0x1,
41 MODEL_8682 = 0x2
42};
43
34static struct usb_device_id if_usb_table[] = { 44static struct usb_device_id if_usb_table[] = {
35 /* Enter the device signature inside */ 45 /* Enter the device signature inside */
36 { USB_DEVICE(0x1286, 0x2001) }, 46 { USB_DEVICE(0x1286, 0x2001), .driver_info = MODEL_8388 },
37 { USB_DEVICE(0x05a3, 0x8388) }, 47 { USB_DEVICE(0x05a3, 0x8388), .driver_info = MODEL_8388 },
38 {} /* Terminating entry */ 48 {} /* Terminating entry */
39}; 49};
40 50
@@ -66,6 +76,8 @@ static ssize_t if_usb_firmware_set(struct device *dev,
66 struct if_usb_card *cardp = priv->card; 76 struct if_usb_card *cardp = priv->card;
67 int ret; 77 int ret;
68 78
79 BUG_ON(buf == NULL);
80
69 ret = if_usb_prog_firmware(cardp, buf, BOOT_CMD_UPDATE_FW); 81 ret = if_usb_prog_firmware(cardp, buf, BOOT_CMD_UPDATE_FW);
70 if (ret == 0) 82 if (ret == 0)
71 return count; 83 return count;
@@ -91,6 +103,8 @@ static ssize_t if_usb_boot2_set(struct device *dev,
91 struct if_usb_card *cardp = priv->card; 103 struct if_usb_card *cardp = priv->card;
92 int ret; 104 int ret;
93 105
106 BUG_ON(buf == NULL);
107
94 ret = if_usb_prog_firmware(cardp, buf, BOOT_CMD_UPDATE_BOOT2); 108 ret = if_usb_prog_firmware(cardp, buf, BOOT_CMD_UPDATE_BOOT2);
95 if (ret == 0) 109 if (ret == 0)
96 return count; 110 return count;
@@ -244,6 +258,7 @@ static int if_usb_probe(struct usb_interface *intf,
244 init_waitqueue_head(&cardp->fw_wq); 258 init_waitqueue_head(&cardp->fw_wq);
245 259
246 cardp->udev = udev; 260 cardp->udev = udev;
261 cardp->model = (uint32_t) id->driver_info;
247 iface_desc = intf->cur_altsetting; 262 iface_desc = intf->cur_altsetting;
248 263
249 lbs_deb_usbd(&udev->dev, "bcdUSB = 0x%X bDeviceClass = 0x%X" 264 lbs_deb_usbd(&udev->dev, "bcdUSB = 0x%X bDeviceClass = 0x%X"
@@ -921,6 +936,38 @@ static int if_usb_prog_firmware(struct if_usb_card *cardp,
921 return ret; 936 return ret;
922} 937}
923 938
939/* table of firmware file names */
940static const struct {
941 u32 model;
942 const char *fwname;
943} fw_table[] = {
944 { MODEL_8388, "libertas/usb8388_v9.bin" },
945 { MODEL_8388, "libertas/usb8388_v5.bin" },
946 { MODEL_8388, "libertas/usb8388.bin" },
947 { MODEL_8388, "usb8388.bin" },
948 { MODEL_8682, "libertas/usb8682.bin" }
949};
950
951static int get_fw(struct if_usb_card *cardp, const char *fwname)
952{
953 int i;
954
955 /* Try user-specified firmware first */
956 if (fwname)
957 return request_firmware(&cardp->fw, fwname, &cardp->udev->dev);
958
959 /* Otherwise search for firmware to use */
960 for (i = 0; i < ARRAY_SIZE(fw_table); i++) {
961 if (fw_table[i].model != cardp->model)
962 continue;
963 if (request_firmware(&cardp->fw, fw_table[i].fwname,
964 &cardp->udev->dev) == 0)
965 return 0;
966 }
967
968 return -ENOENT;
969}
970
924static int __if_usb_prog_firmware(struct if_usb_card *cardp, 971static int __if_usb_prog_firmware(struct if_usb_card *cardp,
925 const char *fwname, int cmd) 972 const char *fwname, int cmd)
926{ 973{
@@ -930,10 +977,9 @@ static int __if_usb_prog_firmware(struct if_usb_card *cardp,
930 977
931 lbs_deb_enter(LBS_DEB_USB); 978 lbs_deb_enter(LBS_DEB_USB);
932 979
933 ret = request_firmware(&cardp->fw, fwname, &cardp->udev->dev); 980 ret = get_fw(cardp, fwname);
934 if (ret < 0) { 981 if (ret) {
935 lbs_pr_err("request_firmware() failed with %#x\n", ret); 982 lbs_pr_err("failed to find firmware (%d)\n", ret);
936 lbs_pr_err("firmware %s not found\n", fwname);
937 goto done; 983 goto done;
938 } 984 }
939 985
diff --git a/drivers/net/wireless/libertas/if_usb.h b/drivers/net/wireless/libertas/if_usb.h
index 5ba0aee0eb2..d819e7e3c9a 100644
--- a/drivers/net/wireless/libertas/if_usb.h
+++ b/drivers/net/wireless/libertas/if_usb.h
@@ -43,6 +43,7 @@ struct bootcmdresp
43/** USB card description structure*/ 43/** USB card description structure*/
44struct if_usb_card { 44struct if_usb_card {
45 struct usb_device *udev; 45 struct usb_device *udev;
46 uint32_t model; /* MODEL_* */
46 struct urb *rx_urb, *tx_urb; 47 struct urb *rx_urb, *tx_urb;
47 struct lbs_private *priv; 48 struct lbs_private *priv;
48 49