aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/if_usb.c
diff options
context:
space:
mode:
authorHolger Schurig <hs4233@mail.mn-solutions.de>2007-08-02 11:45:12 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:49:48 -0400
commit1df4e8fe91d5bab3fd7ae7f115e43c52010cd4ad (patch)
tree62a9e58760fe8021adf62f745316a265c2d7dca4 /drivers/net/wireless/libertas/if_usb.c
parent8c5127657549d055ac9d709cdea73902a6ef392c (diff)
[PATCH] libertas: remove fw.c
Firmware download is quite different for different hardware. The SDIO and CF cards have two flat files that need to be downloaded, whereas the USB driver needs only one file, but with an internal structure. The code that handles this (USB only) structured file is currently in fw.c. This patch moves this code into if_usb.c. The remaining functions in fw.c have not much to do with firmware, they are various card- and network-stack initialisation functions. I've moved them into main.c. Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/if_usb.c')
-rw-r--r--drivers/net/wireless/libertas/if_usb.c78
1 files changed, 76 insertions, 2 deletions
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index e38fce73cf7..ac1cfc253fd 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -216,7 +216,7 @@ static int if_usb_probe(struct usb_interface *intf,
216 priv->hw_get_int_status = if_usb_get_int_status; 216 priv->hw_get_int_status = if_usb_get_int_status;
217 priv->hw_read_event_cause = if_usb_read_event_cause; 217 priv->hw_read_event_cause = if_usb_read_event_cause;
218 218
219 if (libertas_activate_card(priv, libertas_fw_name)) 219 if (libertas_activate_card(priv))
220 goto err_activate_card; 220 goto err_activate_card;
221 221
222 list_add_tail(&cardp->list, &usb_devices); 222 list_add_tail(&cardp->list, &usb_devices);
@@ -819,7 +819,7 @@ static int if_usb_issue_boot_command(wlan_private *priv, int ivalue)
819} 819}
820 820
821 821
822static int if_usb_prog_firmware(wlan_private * priv) 822static int if_usb_do_prog_firmware(wlan_private * priv)
823{ 823{
824 struct usb_card_rec *cardp = priv->card; 824 struct usb_card_rec *cardp = priv->card;
825 int i = 0; 825 int i = 0;
@@ -903,6 +903,80 @@ done:
903 return ret; 903 return ret;
904} 904}
905 905
906/**
907 * @brief This function checks the validity of Boot2/FW image.
908 *
909 * @param data pointer to image
910 * len image length
911 * @return 0 or -1
912 */
913static int check_fwfile_format(u8 *data, u32 totlen)
914{
915 u32 bincmd, exit;
916 u32 blksize, offset, len;
917 int ret;
918
919 ret = 1;
920 exit = len = 0;
921
922 do {
923 struct fwheader *fwh = (void *)data;
924
925 bincmd = le32_to_cpu(fwh->dnldcmd);
926 blksize = le32_to_cpu(fwh->datalength);
927 switch (bincmd) {
928 case FW_HAS_DATA_TO_RECV:
929 offset = sizeof(struct fwheader) + blksize;
930 data += offset;
931 len += offset;
932 if (len >= totlen)
933 exit = 1;
934 break;
935 case FW_HAS_LAST_BLOCK:
936 exit = 1;
937 ret = 0;
938 break;
939 default:
940 exit = 1;
941 break;
942 }
943 } while (!exit);
944
945 if (ret)
946 lbs_pr_err("firmware file format check FAIL\n");
947 else
948 lbs_deb_fw("firmware file format check PASS\n");
949
950 return ret;
951}
952
953
954static int if_usb_prog_firmware(wlan_private *priv)
955{
956 int ret = -1;
957
958 lbs_deb_enter(LBS_DEB_FW);
959
960 if ((ret = request_firmware(&priv->firmware, libertas_fw_name,
961 priv->hotplug_device)) < 0) {
962 lbs_pr_err("request_firmware() failed with %#x\n", ret);
963 lbs_pr_err("firmware %s not found\n", libertas_fw_name);
964 goto done;
965 }
966
967 if (check_fwfile_format(priv->firmware->data, priv->firmware->size)) {
968 release_firmware(priv->firmware);
969 goto done;
970 }
971
972 ret = if_usb_do_prog_firmware(priv);
973
974 release_firmware(priv->firmware);
975done:
976 return ret;
977}
978
979
906#ifdef CONFIG_PM 980#ifdef CONFIG_PM
907static int if_usb_suspend(struct usb_interface *intf, pm_message_t message) 981static int if_usb_suspend(struct usb_interface *intf, pm_message_t message)
908{ 982{