usb_wwan.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. /*
  2. USB Driver layer for GSM modems
  3. Copyright (C) 2005 Matthias Urlichs <smurf@smurf.noris.de>
  4. This driver is free software; you can redistribute it and/or modify
  5. it under the terms of Version 2 of the GNU General Public License as
  6. published by the Free Software Foundation.
  7. Portions copied from the Keyspan driver by Hugh Blemings <hugh@blemings.org>
  8. History: see the git log.
  9. Work sponsored by: Sigos GmbH, Germany <info@sigos.de>
  10. This driver exists because the "normal" serial driver doesn't work too well
  11. with GSM modems. Issues:
  12. - data loss -- one single Receive URB is not nearly enough
  13. - controlling the baud rate doesn't make sense
  14. */
  15. #define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>"
  16. #define DRIVER_DESC "USB Driver for GSM modems"
  17. #include <linux/kernel.h>
  18. #include <linux/jiffies.h>
  19. #include <linux/errno.h>
  20. #include <linux/slab.h>
  21. #include <linux/tty.h>
  22. #include <linux/tty_flip.h>
  23. #include <linux/module.h>
  24. #include <linux/bitops.h>
  25. #include <linux/uaccess.h>
  26. #include <linux/usb.h>
  27. #include <linux/usb/serial.h>
  28. #include <linux/serial.h>
  29. #include "usb-wwan.h"
  30. void usb_wwan_dtr_rts(struct usb_serial_port *port, int on)
  31. {
  32. struct usb_wwan_port_private *portdata;
  33. struct usb_wwan_intf_private *intfdata;
  34. intfdata = usb_get_serial_data(port->serial);
  35. if (!intfdata->send_setup)
  36. return;
  37. portdata = usb_get_serial_port_data(port);
  38. /* FIXME: locking */
  39. portdata->rts_state = on;
  40. portdata->dtr_state = on;
  41. intfdata->send_setup(port);
  42. }
  43. EXPORT_SYMBOL(usb_wwan_dtr_rts);
  44. int usb_wwan_tiocmget(struct tty_struct *tty)
  45. {
  46. struct usb_serial_port *port = tty->driver_data;
  47. unsigned int value;
  48. struct usb_wwan_port_private *portdata;
  49. portdata = usb_get_serial_port_data(port);
  50. value = ((portdata->rts_state) ? TIOCM_RTS : 0) |
  51. ((portdata->dtr_state) ? TIOCM_DTR : 0) |
  52. ((portdata->cts_state) ? TIOCM_CTS : 0) |
  53. ((portdata->dsr_state) ? TIOCM_DSR : 0) |
  54. ((portdata->dcd_state) ? TIOCM_CAR : 0) |
  55. ((portdata->ri_state) ? TIOCM_RNG : 0);
  56. return value;
  57. }
  58. EXPORT_SYMBOL(usb_wwan_tiocmget);
  59. int usb_wwan_tiocmset(struct tty_struct *tty,
  60. unsigned int set, unsigned int clear)
  61. {
  62. struct usb_serial_port *port = tty->driver_data;
  63. struct usb_wwan_port_private *portdata;
  64. struct usb_wwan_intf_private *intfdata;
  65. portdata = usb_get_serial_port_data(port);
  66. intfdata = usb_get_serial_data(port->serial);
  67. if (!intfdata->send_setup)
  68. return -EINVAL;
  69. /* FIXME: what locks portdata fields ? */
  70. if (set & TIOCM_RTS)
  71. portdata->rts_state = 1;
  72. if (set & TIOCM_DTR)
  73. portdata->dtr_state = 1;
  74. if (clear & TIOCM_RTS)
  75. portdata->rts_state = 0;
  76. if (clear & TIOCM_DTR)
  77. portdata->dtr_state = 0;
  78. return intfdata->send_setup(port);
  79. }
  80. EXPORT_SYMBOL(usb_wwan_tiocmset);
  81. static int get_serial_info(struct usb_serial_port *port,
  82. struct serial_struct __user *retinfo)
  83. {
  84. struct serial_struct tmp;
  85. if (!retinfo)
  86. return -EFAULT;
  87. memset(&tmp, 0, sizeof(tmp));
  88. tmp.line = port->minor;
  89. tmp.port = port->port_number;
  90. tmp.baud_base = tty_get_baud_rate(port->port.tty);
  91. tmp.close_delay = port->port.close_delay / 10;
  92. tmp.closing_wait = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
  93. ASYNC_CLOSING_WAIT_NONE :
  94. port->port.closing_wait / 10;
  95. if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
  96. return -EFAULT;
  97. return 0;
  98. }
  99. static int set_serial_info(struct usb_serial_port *port,
  100. struct serial_struct __user *newinfo)
  101. {
  102. struct serial_struct new_serial;
  103. unsigned int closing_wait, close_delay;
  104. int retval = 0;
  105. if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
  106. return -EFAULT;
  107. close_delay = new_serial.close_delay * 10;
  108. closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
  109. ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
  110. mutex_lock(&port->port.mutex);
  111. if (!capable(CAP_SYS_ADMIN)) {
  112. if ((close_delay != port->port.close_delay) ||
  113. (closing_wait != port->port.closing_wait))
  114. retval = -EPERM;
  115. else
  116. retval = -EOPNOTSUPP;
  117. } else {
  118. port->port.close_delay = close_delay;
  119. port->port.closing_wait = closing_wait;
  120. }
  121. mutex_unlock(&port->port.mutex);
  122. return retval;
  123. }
  124. int usb_wwan_ioctl(struct tty_struct *tty,
  125. unsigned int cmd, unsigned long arg)
  126. {
  127. struct usb_serial_port *port = tty->driver_data;
  128. dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd);
  129. switch (cmd) {
  130. case TIOCGSERIAL:
  131. return get_serial_info(port,
  132. (struct serial_struct __user *) arg);
  133. case TIOCSSERIAL:
  134. return set_serial_info(port,
  135. (struct serial_struct __user *) arg);
  136. default:
  137. break;
  138. }
  139. dev_dbg(&port->dev, "%s arg not supported\n", __func__);
  140. return -ENOIOCTLCMD;
  141. }
  142. EXPORT_SYMBOL(usb_wwan_ioctl);
  143. int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
  144. const unsigned char *buf, int count)
  145. {
  146. struct usb_wwan_port_private *portdata;
  147. struct usb_wwan_intf_private *intfdata;
  148. int i;
  149. int left, todo;
  150. struct urb *this_urb = NULL; /* spurious */
  151. int err;
  152. unsigned long flags;
  153. portdata = usb_get_serial_port_data(port);
  154. intfdata = usb_get_serial_data(port->serial);
  155. dev_dbg(&port->dev, "%s: write (%d chars)\n", __func__, count);
  156. i = 0;
  157. left = count;
  158. for (i = 0; left > 0 && i < N_OUT_URB; i++) {
  159. todo = left;
  160. if (todo > OUT_BUFLEN)
  161. todo = OUT_BUFLEN;
  162. this_urb = portdata->out_urbs[i];
  163. if (test_and_set_bit(i, &portdata->out_busy)) {
  164. if (time_before(jiffies,
  165. portdata->tx_start_time[i] + 10 * HZ))
  166. continue;
  167. usb_unlink_urb(this_urb);
  168. continue;
  169. }
  170. dev_dbg(&port->dev, "%s: endpoint %d buf %d\n", __func__,
  171. usb_pipeendpoint(this_urb->pipe), i);
  172. err = usb_autopm_get_interface_async(port->serial->interface);
  173. if (err < 0) {
  174. clear_bit(i, &portdata->out_busy);
  175. break;
  176. }
  177. /* send the data */
  178. memcpy(this_urb->transfer_buffer, buf, todo);
  179. this_urb->transfer_buffer_length = todo;
  180. spin_lock_irqsave(&intfdata->susp_lock, flags);
  181. if (intfdata->suspended) {
  182. usb_anchor_urb(this_urb, &portdata->delayed);
  183. spin_unlock_irqrestore(&intfdata->susp_lock, flags);
  184. } else {
  185. intfdata->in_flight++;
  186. spin_unlock_irqrestore(&intfdata->susp_lock, flags);
  187. err = usb_submit_urb(this_urb, GFP_ATOMIC);
  188. if (err) {
  189. dev_err(&port->dev,
  190. "%s: submit urb %d failed: %d\n",
  191. __func__, i, err);
  192. clear_bit(i, &portdata->out_busy);
  193. spin_lock_irqsave(&intfdata->susp_lock, flags);
  194. intfdata->in_flight--;
  195. spin_unlock_irqrestore(&intfdata->susp_lock,
  196. flags);
  197. usb_autopm_put_interface_async(port->serial->interface);
  198. break;
  199. }
  200. }
  201. portdata->tx_start_time[i] = jiffies;
  202. buf += todo;
  203. left -= todo;
  204. }
  205. count -= left;
  206. dev_dbg(&port->dev, "%s: wrote (did %d)\n", __func__, count);
  207. return count;
  208. }
  209. EXPORT_SYMBOL(usb_wwan_write);
  210. static void usb_wwan_indat_callback(struct urb *urb)
  211. {
  212. int err;
  213. int endpoint;
  214. struct usb_serial_port *port;
  215. struct device *dev;
  216. unsigned char *data = urb->transfer_buffer;
  217. int status = urb->status;
  218. endpoint = usb_pipeendpoint(urb->pipe);
  219. port = urb->context;
  220. dev = &port->dev;
  221. if (status) {
  222. dev_dbg(dev, "%s: nonzero status: %d on endpoint %02x.\n",
  223. __func__, status, endpoint);
  224. } else {
  225. if (urb->actual_length) {
  226. tty_insert_flip_string(&port->port, data,
  227. urb->actual_length);
  228. tty_flip_buffer_push(&port->port);
  229. } else
  230. dev_dbg(dev, "%s: empty read urb received\n", __func__);
  231. }
  232. /* Resubmit urb so we continue receiving */
  233. err = usb_submit_urb(urb, GFP_ATOMIC);
  234. if (err) {
  235. if (err != -EPERM) {
  236. dev_err(dev, "%s: resubmit read urb failed. (%d)\n",
  237. __func__, err);
  238. /* busy also in error unless we are killed */
  239. usb_mark_last_busy(port->serial->dev);
  240. }
  241. } else {
  242. usb_mark_last_busy(port->serial->dev);
  243. }
  244. }
  245. static void usb_wwan_outdat_callback(struct urb *urb)
  246. {
  247. struct usb_serial_port *port;
  248. struct usb_wwan_port_private *portdata;
  249. struct usb_wwan_intf_private *intfdata;
  250. int i;
  251. port = urb->context;
  252. intfdata = usb_get_serial_data(port->serial);
  253. usb_serial_port_softint(port);
  254. usb_autopm_put_interface_async(port->serial->interface);
  255. portdata = usb_get_serial_port_data(port);
  256. spin_lock(&intfdata->susp_lock);
  257. intfdata->in_flight--;
  258. spin_unlock(&intfdata->susp_lock);
  259. for (i = 0; i < N_OUT_URB; ++i) {
  260. if (portdata->out_urbs[i] == urb) {
  261. smp_mb__before_atomic();
  262. clear_bit(i, &portdata->out_busy);
  263. break;
  264. }
  265. }
  266. }
  267. int usb_wwan_write_room(struct tty_struct *tty)
  268. {
  269. struct usb_serial_port *port = tty->driver_data;
  270. struct usb_wwan_port_private *portdata;
  271. int i;
  272. int data_len = 0;
  273. struct urb *this_urb;
  274. portdata = usb_get_serial_port_data(port);
  275. for (i = 0; i < N_OUT_URB; i++) {
  276. this_urb = portdata->out_urbs[i];
  277. if (this_urb && !test_bit(i, &portdata->out_busy))
  278. data_len += OUT_BUFLEN;
  279. }
  280. dev_dbg(&port->dev, "%s: %d\n", __func__, data_len);
  281. return data_len;
  282. }
  283. EXPORT_SYMBOL(usb_wwan_write_room);
  284. int usb_wwan_chars_in_buffer(struct tty_struct *tty)
  285. {
  286. struct usb_serial_port *port = tty->driver_data;
  287. struct usb_wwan_port_private *portdata;
  288. int i;
  289. int data_len = 0;
  290. struct urb *this_urb;
  291. portdata = usb_get_serial_port_data(port);
  292. for (i = 0; i < N_OUT_URB; i++) {
  293. this_urb = portdata->out_urbs[i];
  294. /* FIXME: This locking is insufficient as this_urb may
  295. go unused during the test */
  296. if (this_urb && test_bit(i, &portdata->out_busy))
  297. data_len += this_urb->transfer_buffer_length;
  298. }
  299. dev_dbg(&port->dev, "%s: %d\n", __func__, data_len);
  300. return data_len;
  301. }
  302. EXPORT_SYMBOL(usb_wwan_chars_in_buffer);
  303. int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port)
  304. {
  305. struct usb_wwan_port_private *portdata;
  306. struct usb_wwan_intf_private *intfdata;
  307. struct usb_serial *serial = port->serial;
  308. int i, err;
  309. struct urb *urb;
  310. portdata = usb_get_serial_port_data(port);
  311. intfdata = usb_get_serial_data(serial);
  312. if (port->interrupt_in_urb) {
  313. err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
  314. if (err) {
  315. dev_err(&port->dev, "%s: submit int urb failed: %d\n",
  316. __func__, err);
  317. }
  318. }
  319. /* Start reading from the IN endpoint */
  320. for (i = 0; i < N_IN_URB; i++) {
  321. urb = portdata->in_urbs[i];
  322. if (!urb)
  323. continue;
  324. err = usb_submit_urb(urb, GFP_KERNEL);
  325. if (err) {
  326. dev_err(&port->dev,
  327. "%s: submit read urb %d failed: %d\n",
  328. __func__, i, err);
  329. }
  330. }
  331. spin_lock_irq(&intfdata->susp_lock);
  332. if (++intfdata->open_ports == 1)
  333. serial->interface->needs_remote_wakeup = 1;
  334. spin_unlock_irq(&intfdata->susp_lock);
  335. /* this balances a get in the generic USB serial code */
  336. usb_autopm_put_interface(serial->interface);
  337. return 0;
  338. }
  339. EXPORT_SYMBOL(usb_wwan_open);
  340. static void unbusy_queued_urb(struct urb *urb,
  341. struct usb_wwan_port_private *portdata)
  342. {
  343. int i;
  344. for (i = 0; i < N_OUT_URB; i++) {
  345. if (urb == portdata->out_urbs[i]) {
  346. clear_bit(i, &portdata->out_busy);
  347. break;
  348. }
  349. }
  350. }
  351. void usb_wwan_close(struct usb_serial_port *port)
  352. {
  353. int i;
  354. struct usb_serial *serial = port->serial;
  355. struct usb_wwan_port_private *portdata;
  356. struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
  357. struct urb *urb;
  358. portdata = usb_get_serial_port_data(port);
  359. /*
  360. * Need to take susp_lock to make sure port is not already being
  361. * resumed, but no need to hold it due to ASYNC_INITIALIZED.
  362. */
  363. spin_lock_irq(&intfdata->susp_lock);
  364. if (--intfdata->open_ports == 0)
  365. serial->interface->needs_remote_wakeup = 0;
  366. spin_unlock_irq(&intfdata->susp_lock);
  367. for (;;) {
  368. urb = usb_get_from_anchor(&portdata->delayed);
  369. if (!urb)
  370. break;
  371. unbusy_queued_urb(urb, portdata);
  372. usb_autopm_put_interface_async(serial->interface);
  373. }
  374. for (i = 0; i < N_IN_URB; i++)
  375. usb_kill_urb(portdata->in_urbs[i]);
  376. for (i = 0; i < N_OUT_URB; i++)
  377. usb_kill_urb(portdata->out_urbs[i]);
  378. usb_kill_urb(port->interrupt_in_urb);
  379. usb_autopm_get_interface_no_resume(serial->interface);
  380. }
  381. EXPORT_SYMBOL(usb_wwan_close);
  382. static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
  383. int endpoint,
  384. int dir, void *ctx, char *buf, int len,
  385. void (*callback) (struct urb *))
  386. {
  387. struct usb_serial *serial = port->serial;
  388. struct urb *urb;
  389. urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
  390. if (!urb)
  391. return NULL;
  392. usb_fill_bulk_urb(urb, serial->dev,
  393. usb_sndbulkpipe(serial->dev, endpoint) | dir,
  394. buf, len, callback, ctx);
  395. return urb;
  396. }
  397. int usb_wwan_port_probe(struct usb_serial_port *port)
  398. {
  399. struct usb_wwan_port_private *portdata;
  400. struct urb *urb;
  401. u8 *buffer;
  402. int i;
  403. if (!port->bulk_in_size || !port->bulk_out_size)
  404. return -ENODEV;
  405. portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
  406. if (!portdata)
  407. return -ENOMEM;
  408. init_usb_anchor(&portdata->delayed);
  409. for (i = 0; i < N_IN_URB; i++) {
  410. buffer = (u8 *)__get_free_page(GFP_KERNEL);
  411. if (!buffer)
  412. goto bail_out_error;
  413. portdata->in_buffer[i] = buffer;
  414. urb = usb_wwan_setup_urb(port, port->bulk_in_endpointAddress,
  415. USB_DIR_IN, port,
  416. buffer, IN_BUFLEN,
  417. usb_wwan_indat_callback);
  418. portdata->in_urbs[i] = urb;
  419. }
  420. for (i = 0; i < N_OUT_URB; i++) {
  421. buffer = kmalloc(OUT_BUFLEN, GFP_KERNEL);
  422. if (!buffer)
  423. goto bail_out_error2;
  424. portdata->out_buffer[i] = buffer;
  425. urb = usb_wwan_setup_urb(port, port->bulk_out_endpointAddress,
  426. USB_DIR_OUT, port,
  427. buffer, OUT_BUFLEN,
  428. usb_wwan_outdat_callback);
  429. portdata->out_urbs[i] = urb;
  430. }
  431. usb_set_serial_port_data(port, portdata);
  432. return 0;
  433. bail_out_error2:
  434. for (i = 0; i < N_OUT_URB; i++) {
  435. usb_free_urb(portdata->out_urbs[i]);
  436. kfree(portdata->out_buffer[i]);
  437. }
  438. bail_out_error:
  439. for (i = 0; i < N_IN_URB; i++) {
  440. usb_free_urb(portdata->in_urbs[i]);
  441. free_page((unsigned long)portdata->in_buffer[i]);
  442. }
  443. kfree(portdata);
  444. return -ENOMEM;
  445. }
  446. EXPORT_SYMBOL_GPL(usb_wwan_port_probe);
  447. int usb_wwan_port_remove(struct usb_serial_port *port)
  448. {
  449. int i;
  450. struct usb_wwan_port_private *portdata;
  451. portdata = usb_get_serial_port_data(port);
  452. usb_set_serial_port_data(port, NULL);
  453. for (i = 0; i < N_IN_URB; i++) {
  454. usb_free_urb(portdata->in_urbs[i]);
  455. free_page((unsigned long)portdata->in_buffer[i]);
  456. }
  457. for (i = 0; i < N_OUT_URB; i++) {
  458. usb_free_urb(portdata->out_urbs[i]);
  459. kfree(portdata->out_buffer[i]);
  460. }
  461. kfree(portdata);
  462. return 0;
  463. }
  464. EXPORT_SYMBOL(usb_wwan_port_remove);
  465. #ifdef CONFIG_PM
  466. static void stop_urbs(struct usb_serial *serial)
  467. {
  468. int i, j;
  469. struct usb_serial_port *port;
  470. struct usb_wwan_port_private *portdata;
  471. for (i = 0; i < serial->num_ports; ++i) {
  472. port = serial->port[i];
  473. portdata = usb_get_serial_port_data(port);
  474. if (!portdata)
  475. continue;
  476. for (j = 0; j < N_IN_URB; j++)
  477. usb_kill_urb(portdata->in_urbs[j]);
  478. for (j = 0; j < N_OUT_URB; j++)
  479. usb_kill_urb(portdata->out_urbs[j]);
  480. usb_kill_urb(port->interrupt_in_urb);
  481. }
  482. }
  483. int usb_wwan_suspend(struct usb_serial *serial, pm_message_t message)
  484. {
  485. struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
  486. spin_lock_irq(&intfdata->susp_lock);
  487. if (PMSG_IS_AUTO(message)) {
  488. if (intfdata->in_flight) {
  489. spin_unlock_irq(&intfdata->susp_lock);
  490. return -EBUSY;
  491. }
  492. }
  493. intfdata->suspended = 1;
  494. spin_unlock_irq(&intfdata->susp_lock);
  495. stop_urbs(serial);
  496. return 0;
  497. }
  498. EXPORT_SYMBOL(usb_wwan_suspend);
  499. /* Caller must hold susp_lock. */
  500. static int usb_wwan_submit_delayed_urbs(struct usb_serial_port *port)
  501. {
  502. struct usb_serial *serial = port->serial;
  503. struct usb_wwan_intf_private *data = usb_get_serial_data(serial);
  504. struct usb_wwan_port_private *portdata;
  505. struct urb *urb;
  506. int err_count = 0;
  507. int err;
  508. portdata = usb_get_serial_port_data(port);
  509. for (;;) {
  510. urb = usb_get_from_anchor(&portdata->delayed);
  511. if (!urb)
  512. break;
  513. err = usb_submit_urb(urb, GFP_ATOMIC);
  514. if (err) {
  515. dev_err(&port->dev, "%s: submit urb failed: %d\n",
  516. __func__, err);
  517. err_count++;
  518. unbusy_queued_urb(urb, portdata);
  519. usb_autopm_put_interface_async(serial->interface);
  520. continue;
  521. }
  522. data->in_flight++;
  523. }
  524. if (err_count)
  525. return -EIO;
  526. return 0;
  527. }
  528. int usb_wwan_resume(struct usb_serial *serial)
  529. {
  530. int i, j;
  531. struct usb_serial_port *port;
  532. struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
  533. struct usb_wwan_port_private *portdata;
  534. struct urb *urb;
  535. int err;
  536. int err_count = 0;
  537. spin_lock_irq(&intfdata->susp_lock);
  538. for (i = 0; i < serial->num_ports; i++) {
  539. port = serial->port[i];
  540. if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
  541. continue;
  542. portdata = usb_get_serial_port_data(port);
  543. if (port->interrupt_in_urb) {
  544. err = usb_submit_urb(port->interrupt_in_urb,
  545. GFP_ATOMIC);
  546. if (err) {
  547. dev_err(&port->dev,
  548. "%s: submit int urb failed: %d\n",
  549. __func__, err);
  550. err_count++;
  551. }
  552. }
  553. err = usb_wwan_submit_delayed_urbs(port);
  554. if (err)
  555. err_count++;
  556. for (j = 0; j < N_IN_URB; j++) {
  557. urb = portdata->in_urbs[j];
  558. err = usb_submit_urb(urb, GFP_ATOMIC);
  559. if (err < 0) {
  560. dev_err(&port->dev,
  561. "%s: submit read urb %d failed: %d\n",
  562. __func__, i, err);
  563. err_count++;
  564. }
  565. }
  566. }
  567. intfdata->suspended = 0;
  568. spin_unlock_irq(&intfdata->susp_lock);
  569. if (err_count)
  570. return -EIO;
  571. return 0;
  572. }
  573. EXPORT_SYMBOL(usb_wwan_resume);
  574. #endif
  575. MODULE_AUTHOR(DRIVER_AUTHOR);
  576. MODULE_DESCRIPTION(DRIVER_DESC);
  577. MODULE_LICENSE("GPL");