diff options
-rw-r--r-- | drivers/usb/atm/ueagle-atm.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index 648c6b79ff41..4aa41a97bf6f 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c | |||
@@ -161,7 +161,6 @@ struct uea_softc { | |||
161 | struct task_struct *kthread; | 161 | struct task_struct *kthread; |
162 | u32 data; | 162 | u32 data; |
163 | u32 data1; | 163 | u32 data1; |
164 | wait_queue_head_t cmv_ack_wait; | ||
165 | 164 | ||
166 | int cmv_ack; | 165 | int cmv_ack; |
167 | union cmv_dsc cmv_dsc; | 166 | union cmv_dsc cmv_dsc; |
@@ -558,6 +557,15 @@ module_param_array(annex, uint, NULL, 0644); | |||
558 | MODULE_PARM_DESC(annex, | 557 | MODULE_PARM_DESC(annex, |
559 | "manually set annex a/b (0=auto, 1=annex a, 2=annex b)"); | 558 | "manually set annex a/b (0=auto, 1=annex a, 2=annex b)"); |
560 | 559 | ||
560 | #define uea_wait(sc, cond, timeo) \ | ||
561 | ({ \ | ||
562 | int _r = wait_event_interruptible_timeout(sc->sync_q, \ | ||
563 | (cond) || kthread_should_stop(), timeo); \ | ||
564 | if (kthread_should_stop()) \ | ||
565 | _r = -ENODEV; \ | ||
566 | _r; \ | ||
567 | }) | ||
568 | |||
561 | #define UPDATE_ATM_STAT(type, val) \ | 569 | #define UPDATE_ATM_STAT(type, val) \ |
562 | do { \ | 570 | do { \ |
563 | if (sc->usbatm->atm_dev) \ | 571 | if (sc->usbatm->atm_dev) \ |
@@ -1067,13 +1075,13 @@ static inline void wake_up_cmv_ack(struct uea_softc *sc) | |||
1067 | { | 1075 | { |
1068 | BUG_ON(sc->cmv_ack); | 1076 | BUG_ON(sc->cmv_ack); |
1069 | sc->cmv_ack = 1; | 1077 | sc->cmv_ack = 1; |
1070 | wake_up(&sc->cmv_ack_wait); | 1078 | wake_up(&sc->sync_q); |
1071 | } | 1079 | } |
1072 | 1080 | ||
1073 | static inline int wait_cmv_ack(struct uea_softc *sc) | 1081 | static inline int wait_cmv_ack(struct uea_softc *sc) |
1074 | { | 1082 | { |
1075 | int ret = wait_event_interruptible_timeout(sc->cmv_ack_wait, | 1083 | int ret = uea_wait(sc, sc->cmv_ack , ACK_TIMEOUT); |
1076 | sc->cmv_ack, ACK_TIMEOUT); | 1084 | |
1077 | sc->cmv_ack = 0; | 1085 | sc->cmv_ack = 0; |
1078 | 1086 | ||
1079 | uea_dbg(INS_TO_USBDEV(sc), "wait_event_timeout : %d ms\n", | 1087 | uea_dbg(INS_TO_USBDEV(sc), "wait_event_timeout : %d ms\n", |
@@ -1806,7 +1814,9 @@ static int uea_start_reset(struct uea_softc *sc) | |||
1806 | uea_request(sc, UEA_SET_MODE, UEA_START_RESET, 0, NULL); | 1814 | uea_request(sc, UEA_SET_MODE, UEA_START_RESET, 0, NULL); |
1807 | 1815 | ||
1808 | /* original driver use 200ms, but windows driver use 100ms */ | 1816 | /* original driver use 200ms, but windows driver use 100ms */ |
1809 | msleep(100); | 1817 | ret = uea_wait(sc, 0, msecs_to_jiffies(100)); |
1818 | if (ret < 0) | ||
1819 | return ret; | ||
1810 | 1820 | ||
1811 | /* leave reset mode */ | 1821 | /* leave reset mode */ |
1812 | uea_request(sc, UEA_SET_MODE, UEA_END_RESET, 0, NULL); | 1822 | uea_request(sc, UEA_SET_MODE, UEA_END_RESET, 0, NULL); |
@@ -1818,7 +1828,9 @@ static int uea_start_reset(struct uea_softc *sc) | |||
1818 | uea_request(sc, UEA_SET_2183_DATA, UEA_SWAP_MAILBOX, 2, &zero); | 1828 | uea_request(sc, UEA_SET_2183_DATA, UEA_SWAP_MAILBOX, 2, &zero); |
1819 | } | 1829 | } |
1820 | 1830 | ||
1821 | msleep(1000); | 1831 | ret = uea_wait(sc, 0, msecs_to_jiffies(1000)); |
1832 | if (ret < 0) | ||
1833 | return ret; | ||
1822 | 1834 | ||
1823 | if (UEA_CHIP_VERSION(sc) == EAGLE_IV) | 1835 | if (UEA_CHIP_VERSION(sc) == EAGLE_IV) |
1824 | sc->cmv_dsc.e4.function = E4_MAKEFUNCTION(E4_ADSLDIRECTIVE, E4_MODEMREADY, 1); | 1836 | sc->cmv_dsc.e4.function = E4_MAKEFUNCTION(E4_ADSLDIRECTIVE, E4_MODEMREADY, 1); |
@@ -1868,7 +1880,7 @@ static int uea_kthread(void *data) | |||
1868 | if (!ret) | 1880 | if (!ret) |
1869 | ret = sc->stat(sc); | 1881 | ret = sc->stat(sc); |
1870 | if (ret != -EAGAIN) | 1882 | if (ret != -EAGAIN) |
1871 | msleep_interruptible(1000); | 1883 | uea_wait(sc, 0, msecs_to_jiffies(1000)); |
1872 | if (try_to_freeze()) | 1884 | if (try_to_freeze()) |
1873 | uea_err(INS_TO_USBDEV(sc), "suspend/resume not supported, " | 1885 | uea_err(INS_TO_USBDEV(sc), "suspend/resume not supported, " |
1874 | "please unplug/replug your modem\n"); | 1886 | "please unplug/replug your modem\n"); |
@@ -2116,7 +2128,6 @@ static int uea_boot(struct uea_softc *sc) | |||
2116 | } | 2128 | } |
2117 | 2129 | ||
2118 | init_waitqueue_head(&sc->sync_q); | 2130 | init_waitqueue_head(&sc->sync_q); |
2119 | init_waitqueue_head(&sc->cmv_ack_wait); | ||
2120 | 2131 | ||
2121 | sc->work_q = create_workqueue("ueagle-dsp"); | 2132 | sc->work_q = create_workqueue("ueagle-dsp"); |
2122 | if (!sc->work_q) { | 2133 | if (!sc->work_q) { |