diff options
author | Hante Meuleman <meuleman@broadcom.com> | 2012-10-22 13:36:18 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-10-29 15:28:20 -0400 |
commit | 1e271c9564132d9b5906819d7c62fbb5669ae8e9 (patch) | |
tree | c4b9f51175d88ad5587f249c8c44b5cd56f38b7a | |
parent | 348a130cebe4235937a265c4d554beb665104d77 (diff) |
brcmfmac: clean usb download code.
reuse ioctl waiting method.
Reviewed-by: Arend Van Spriel <arend@broadcom.com>
Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
Signed-off-by: Franky Lin <frankyl@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmfmac/usb.c | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c index 7a6dfdc67b6c..484a6e4f23a2 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c | |||
@@ -42,7 +42,6 @@ | |||
42 | 42 | ||
43 | #define IOCTL_RESP_TIMEOUT 2000 | 43 | #define IOCTL_RESP_TIMEOUT 2000 |
44 | 44 | ||
45 | #define BRCMF_USB_SYNC_TIMEOUT 300 /* ms */ | ||
46 | #define BRCMF_USB_DLIMAGE_SPINWAIT 100 /* in unit of ms */ | 45 | #define BRCMF_USB_DLIMAGE_SPINWAIT 100 /* in unit of ms */ |
47 | #define BRCMF_USB_DLIMAGE_LIMIT 500 /* spinwait limit (ms) */ | 46 | #define BRCMF_USB_DLIMAGE_LIMIT 500 /* spinwait limit (ms) */ |
48 | 47 | ||
@@ -116,10 +115,6 @@ struct brcmf_usbdev_info { | |||
116 | u8 *image; /* buffer for combine fw and nvram */ | 115 | u8 *image; /* buffer for combine fw and nvram */ |
117 | int image_len; | 116 | int image_len; |
118 | 117 | ||
119 | wait_queue_head_t wait; | ||
120 | bool waitdone; | ||
121 | int sync_urb_status; | ||
122 | |||
123 | struct usb_device *usbdev; | 118 | struct usb_device *usbdev; |
124 | struct device *dev; | 119 | struct device *dev; |
125 | 120 | ||
@@ -131,7 +126,6 @@ struct brcmf_usbdev_info { | |||
131 | int ctl_urb_status; | 126 | int ctl_urb_status; |
132 | int ctl_completed; | 127 | int ctl_completed; |
133 | wait_queue_head_t ioctl_resp_wait; | 128 | wait_queue_head_t ioctl_resp_wait; |
134 | wait_queue_head_t ctrl_wait; | ||
135 | ulong ctl_op; | 129 | ulong ctl_op; |
136 | 130 | ||
137 | struct urb *bulk_urb; /* used for FW download */ | 131 | struct urb *bulk_urb; /* used for FW download */ |
@@ -754,34 +748,14 @@ static void brcmf_usb_down(struct device *dev) | |||
754 | brcmf_usb_free_q(&devinfo->rx_postq, true); | 748 | brcmf_usb_free_q(&devinfo->rx_postq, true); |
755 | } | 749 | } |
756 | 750 | ||
757 | static int | ||
758 | brcmf_usb_sync_wait(struct brcmf_usbdev_info *devinfo, u16 time) | ||
759 | { | ||
760 | int ret; | ||
761 | int err = 0; | ||
762 | int ms = time; | ||
763 | |||
764 | ret = wait_event_interruptible_timeout(devinfo->wait, | ||
765 | devinfo->waitdone == true, (ms * HZ / 1000)); | ||
766 | |||
767 | if ((devinfo->waitdone == false) || (devinfo->sync_urb_status)) { | ||
768 | brcmf_dbg(ERROR, "timeout(%d) or urb err=%d\n", | ||
769 | ret, devinfo->sync_urb_status); | ||
770 | err = -EINVAL; | ||
771 | } | ||
772 | devinfo->waitdone = false; | ||
773 | return err; | ||
774 | } | ||
775 | |||
776 | static void | 751 | static void |
777 | brcmf_usb_sync_complete(struct urb *urb) | 752 | brcmf_usb_sync_complete(struct urb *urb) |
778 | { | 753 | { |
779 | struct brcmf_usbdev_info *devinfo = | 754 | struct brcmf_usbdev_info *devinfo = |
780 | (struct brcmf_usbdev_info *)urb->context; | 755 | (struct brcmf_usbdev_info *)urb->context; |
781 | 756 | ||
782 | devinfo->waitdone = true; | 757 | devinfo->ctl_completed = true; |
783 | wake_up_interruptible(&devinfo->wait); | 758 | brcmf_usb_ioctl_resp_wake(devinfo); |
784 | devinfo->sync_urb_status = urb->status; | ||
785 | } | 759 | } |
786 | 760 | ||
787 | static bool brcmf_usb_dl_cmd(struct brcmf_usbdev_info *devinfo, u8 cmd, | 761 | static bool brcmf_usb_dl_cmd(struct brcmf_usbdev_info *devinfo, u8 cmd, |
@@ -813,6 +787,7 @@ static bool brcmf_usb_dl_cmd(struct brcmf_usbdev_info *devinfo, u8 cmd, | |||
813 | (void *) tmpbuf, size, | 787 | (void *) tmpbuf, size, |
814 | (usb_complete_t)brcmf_usb_sync_complete, devinfo); | 788 | (usb_complete_t)brcmf_usb_sync_complete, devinfo); |
815 | 789 | ||
790 | devinfo->ctl_completed = false; | ||
816 | ret = usb_submit_urb(devinfo->ctl_urb, GFP_ATOMIC); | 791 | ret = usb_submit_urb(devinfo->ctl_urb, GFP_ATOMIC); |
817 | if (ret < 0) { | 792 | if (ret < 0) { |
818 | brcmf_dbg(ERROR, "usb_submit_urb failed %d\n", ret); | 793 | brcmf_dbg(ERROR, "usb_submit_urb failed %d\n", ret); |
@@ -820,11 +795,11 @@ static bool brcmf_usb_dl_cmd(struct brcmf_usbdev_info *devinfo, u8 cmd, | |||
820 | return false; | 795 | return false; |
821 | } | 796 | } |
822 | 797 | ||
823 | ret = brcmf_usb_sync_wait(devinfo, BRCMF_USB_SYNC_TIMEOUT); | 798 | ret = brcmf_usb_ioctl_resp_wait(devinfo); |
824 | memcpy(buffer, tmpbuf, buflen); | 799 | memcpy(buffer, tmpbuf, buflen); |
825 | kfree(tmpbuf); | 800 | kfree(tmpbuf); |
826 | 801 | ||
827 | return (ret == 0); | 802 | return ret; |
828 | } | 803 | } |
829 | 804 | ||
830 | static bool | 805 | static bool |
@@ -918,13 +893,14 @@ brcmf_usb_dl_send_bulk(struct brcmf_usbdev_info *devinfo, void *buffer, int len) | |||
918 | 893 | ||
919 | devinfo->bulk_urb->transfer_flags |= URB_ZERO_PACKET; | 894 | devinfo->bulk_urb->transfer_flags |= URB_ZERO_PACKET; |
920 | 895 | ||
896 | devinfo->ctl_completed = false; | ||
921 | ret = usb_submit_urb(devinfo->bulk_urb, GFP_ATOMIC); | 897 | ret = usb_submit_urb(devinfo->bulk_urb, GFP_ATOMIC); |
922 | if (ret) { | 898 | if (ret) { |
923 | brcmf_dbg(ERROR, "usb_submit_urb failed %d\n", ret); | 899 | brcmf_dbg(ERROR, "usb_submit_urb failed %d\n", ret); |
924 | return ret; | 900 | return ret; |
925 | } | 901 | } |
926 | ret = brcmf_usb_sync_wait(devinfo, BRCMF_USB_SYNC_TIMEOUT); | 902 | ret = brcmf_usb_ioctl_resp_wait(devinfo); |
927 | return ret; | 903 | return (ret == 0); |
928 | } | 904 | } |
929 | 905 | ||
930 | static int | 906 | static int |
@@ -1284,7 +1260,6 @@ struct brcmf_usbdev *brcmf_usb_attach(struct brcmf_usbdev_info *devinfo, | |||
1284 | goto error; | 1260 | goto error; |
1285 | } | 1261 | } |
1286 | 1262 | ||
1287 | init_waitqueue_head(&devinfo->wait); | ||
1288 | if (!brcmf_usb_dlneeded(devinfo)) | 1263 | if (!brcmf_usb_dlneeded(devinfo)) |
1289 | return &devinfo->bus_pub; | 1264 | return &devinfo->bus_pub; |
1290 | 1265 | ||