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