Commit 337427f91f844ebe84442dc0b5e24577a8139600

Authored by Stanislaw Gruszka
Committed by Greg Kroah-Hartman
1 parent 04ea02f574

UEAGLE: Do not sleep when device is disconnected

Do not sleep in kernel thread when device is disconnected, this make faster
suspending and module unloading. Use one wait queue for sleeping.

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 1 changed file with 19 additions and 8 deletions Side-by-side Diff

drivers/usb/atm/ueagle-atm.c
... ... @@ -161,7 +161,6 @@
161 161 struct task_struct *kthread;
162 162 u32 data;
163 163 u32 data1;
164   - wait_queue_head_t cmv_ack_wait;
165 164  
166 165 int cmv_ack;
167 166 union cmv_dsc cmv_dsc;
... ... @@ -558,6 +557,15 @@
558 557 MODULE_PARM_DESC(annex,
559 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 569 #define UPDATE_ATM_STAT(type, val) \
562 570 do { \
563 571 if (sc->usbatm->atm_dev) \
564 572  
... ... @@ -1067,13 +1075,13 @@
1067 1075 {
1068 1076 BUG_ON(sc->cmv_ack);
1069 1077 sc->cmv_ack = 1;
1070   - wake_up(&sc->cmv_ack_wait);
  1078 + wake_up(&sc->sync_q);
1071 1079 }
1072 1080  
1073 1081 static inline int wait_cmv_ack(struct uea_softc *sc)
1074 1082 {
1075   - int ret = wait_event_interruptible_timeout(sc->cmv_ack_wait,
1076   - sc->cmv_ack, ACK_TIMEOUT);
  1083 + int ret = uea_wait(sc, sc->cmv_ack , ACK_TIMEOUT);
  1084 +
1077 1085 sc->cmv_ack = 0;
1078 1086  
1079 1087 uea_dbg(INS_TO_USBDEV(sc), "wait_event_timeout : %d ms\n",
... ... @@ -1806,7 +1814,9 @@
1806 1814 uea_request(sc, UEA_SET_MODE, UEA_START_RESET, 0, NULL);
1807 1815  
1808 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 1821 /* leave reset mode */
1812 1822 uea_request(sc, UEA_SET_MODE, UEA_END_RESET, 0, NULL);
... ... @@ -1818,7 +1828,9 @@
1818 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 1835 if (UEA_CHIP_VERSION(sc) == EAGLE_IV)
1824 1836 sc->cmv_dsc.e4.function = E4_MAKEFUNCTION(E4_ADSLDIRECTIVE, E4_MODEMREADY, 1);
... ... @@ -1868,7 +1880,7 @@
1868 1880 if (!ret)
1869 1881 ret = sc->stat(sc);
1870 1882 if (ret != -EAGAIN)
1871   - msleep_interruptible(1000);
  1883 + uea_wait(sc, 0, msecs_to_jiffies(1000));
1872 1884 if (try_to_freeze())
1873 1885 uea_err(INS_TO_USBDEV(sc), "suspend/resume not supported, "
1874 1886 "please unplug/replug your modem\n");
... ... @@ -2116,7 +2128,6 @@
2116 2128 }
2117 2129  
2118 2130 init_waitqueue_head(&sc->sync_q);
2119   - init_waitqueue_head(&sc->cmv_ack_wait);
2120 2131  
2121 2132 sc->work_q = create_workqueue("ueagle-dsp");
2122 2133 if (!sc->work_q) {