diff options
author | John W. Linville <linville@tuxdriver.com> | 2010-08-25 14:51:42 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-08-25 14:51:42 -0400 |
commit | e569aa78ba01f7f66e016a4d57310fd041524d17 (patch) | |
tree | eaedc03d42ee2bf6200fc07b080a99bad103def3 /drivers/net/wireless/libertas/if_usb.c | |
parent | 4562487a00445eab96311365ba15c41dc4d043cd (diff) | |
parent | 268bae0b6879f238ba57f5f801958d1254e136f7 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6 into for-davem
Conflicts:
drivers/net/wireless/libertas/if_sdio.c
Diffstat (limited to 'drivers/net/wireless/libertas/if_usb.c')
-rw-r--r-- | drivers/net/wireless/libertas/if_usb.c | 60 |
1 files changed, 53 insertions, 7 deletions
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index 3ff61063671a..e906616232a2 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 | ||
29 | static char *lbs_fw_name = "usb8388.bin"; | 29 | static char *lbs_fw_name = NULL; |
30 | module_param_named(fw_name, lbs_fw_name, charp, 0644); | 30 | module_param_named(fw_name, lbs_fw_name, charp, 0644); |
31 | 31 | ||
32 | MODULE_FIRMWARE("libertas/usb8388_v9.bin"); | ||
33 | MODULE_FIRMWARE("libertas/usb8388_v5.bin"); | ||
34 | MODULE_FIRMWARE("libertas/usb8388.bin"); | ||
35 | MODULE_FIRMWARE("libertas/usb8682.bin"); | ||
32 | MODULE_FIRMWARE("usb8388.bin"); | 36 | MODULE_FIRMWARE("usb8388.bin"); |
33 | 37 | ||
38 | enum { | ||
39 | MODEL_UNKNOWN = 0x0, | ||
40 | MODEL_8388 = 0x1, | ||
41 | MODEL_8682 = 0x2 | ||
42 | }; | ||
43 | |||
34 | static struct usb_device_id if_usb_table[] = { | 44 | static 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" |
@@ -924,6 +939,38 @@ static int if_usb_prog_firmware(struct if_usb_card *cardp, | |||
924 | return ret; | 939 | return ret; |
925 | } | 940 | } |
926 | 941 | ||
942 | /* table of firmware file names */ | ||
943 | static const struct { | ||
944 | u32 model; | ||
945 | const char *fwname; | ||
946 | } fw_table[] = { | ||
947 | { MODEL_8388, "libertas/usb8388_v9.bin" }, | ||
948 | { MODEL_8388, "libertas/usb8388_v5.bin" }, | ||
949 | { MODEL_8388, "libertas/usb8388.bin" }, | ||
950 | { MODEL_8388, "usb8388.bin" }, | ||
951 | { MODEL_8682, "libertas/usb8682.bin" } | ||
952 | }; | ||
953 | |||
954 | static int get_fw(struct if_usb_card *cardp, const char *fwname) | ||
955 | { | ||
956 | int i; | ||
957 | |||
958 | /* Try user-specified firmware first */ | ||
959 | if (fwname) | ||
960 | return request_firmware(&cardp->fw, fwname, &cardp->udev->dev); | ||
961 | |||
962 | /* Otherwise search for firmware to use */ | ||
963 | for (i = 0; i < ARRAY_SIZE(fw_table); i++) { | ||
964 | if (fw_table[i].model != cardp->model) | ||
965 | continue; | ||
966 | if (request_firmware(&cardp->fw, fw_table[i].fwname, | ||
967 | &cardp->udev->dev) == 0) | ||
968 | return 0; | ||
969 | } | ||
970 | |||
971 | return -ENOENT; | ||
972 | } | ||
973 | |||
927 | static int __if_usb_prog_firmware(struct if_usb_card *cardp, | 974 | static int __if_usb_prog_firmware(struct if_usb_card *cardp, |
928 | const char *fwname, int cmd) | 975 | const char *fwname, int cmd) |
929 | { | 976 | { |
@@ -933,10 +980,9 @@ static int __if_usb_prog_firmware(struct if_usb_card *cardp, | |||
933 | 980 | ||
934 | lbs_deb_enter(LBS_DEB_USB); | 981 | lbs_deb_enter(LBS_DEB_USB); |
935 | 982 | ||
936 | ret = request_firmware(&cardp->fw, fwname, &cardp->udev->dev); | 983 | ret = get_fw(cardp, fwname); |
937 | if (ret < 0) { | 984 | if (ret) { |
938 | lbs_pr_err("request_firmware() failed with %#x\n", ret); | 985 | lbs_pr_err("failed to find firmware (%d)\n", ret); |
939 | lbs_pr_err("firmware %s not found\n", fwname); | ||
940 | goto done; | 986 | goto done; |
941 | } | 987 | } |
942 | 988 | ||