]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/usb/serial/usb_wwan.c
293b460030cb2c5a67addcf2d721fac43e2e257f
[karo-tx-linux.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 void usb_wwan_dtr_rts(struct usb_serial_port *port, int on)
40 {
41         struct usb_serial *serial = port->serial;
42         struct usb_wwan_port_private *portdata;
43         struct usb_wwan_intf_private *intfdata;
44
45         intfdata = port->serial->private;
46
47         if (!intfdata->send_setup)
48                 return;
49
50         portdata = usb_get_serial_port_data(port);
51         mutex_lock(&serial->disc_mutex);
52         portdata->rts_state = on;
53         portdata->dtr_state = on;
54         if (serial->dev)
55                 intfdata->send_setup(port);
56         mutex_unlock(&serial->disc_mutex);
57 }
58 EXPORT_SYMBOL(usb_wwan_dtr_rts);
59
60 void usb_wwan_set_termios(struct tty_struct *tty,
61                           struct usb_serial_port *port,
62                           struct ktermios *old_termios)
63 {
64         struct usb_wwan_intf_private *intfdata = port->serial->private;
65
66         /* Doesn't support option setting */
67         tty_termios_copy_hw(&tty->termios, old_termios);
68
69         if (intfdata->send_setup)
70                 intfdata->send_setup(port);
71 }
72 EXPORT_SYMBOL(usb_wwan_set_termios);
73
74 int usb_wwan_tiocmget(struct tty_struct *tty)
75 {
76         struct usb_serial_port *port = tty->driver_data;
77         unsigned int value;
78         struct usb_wwan_port_private *portdata;
79
80         portdata = usb_get_serial_port_data(port);
81
82         value = ((portdata->rts_state) ? TIOCM_RTS : 0) |
83             ((portdata->dtr_state) ? TIOCM_DTR : 0) |
84             ((portdata->cts_state) ? TIOCM_CTS : 0) |
85             ((portdata->dsr_state) ? TIOCM_DSR : 0) |
86             ((portdata->dcd_state) ? TIOCM_CAR : 0) |
87             ((portdata->ri_state) ? TIOCM_RNG : 0);
88
89         return value;
90 }
91 EXPORT_SYMBOL(usb_wwan_tiocmget);
92
93 int usb_wwan_tiocmset(struct tty_struct *tty,
94                       unsigned int set, unsigned int clear)
95 {
96         struct usb_serial_port *port = tty->driver_data;
97         struct usb_wwan_port_private *portdata;
98         struct usb_wwan_intf_private *intfdata;
99
100         portdata = usb_get_serial_port_data(port);
101         intfdata = port->serial->private;
102
103         if (!intfdata->send_setup)
104                 return -EINVAL;
105
106         /* FIXME: what locks portdata fields ? */
107         if (set & TIOCM_RTS)
108                 portdata->rts_state = 1;
109         if (set & TIOCM_DTR)
110                 portdata->dtr_state = 1;
111
112         if (clear & TIOCM_RTS)
113                 portdata->rts_state = 0;
114         if (clear & TIOCM_DTR)
115                 portdata->dtr_state = 0;
116         return intfdata->send_setup(port);
117 }
118 EXPORT_SYMBOL(usb_wwan_tiocmset);
119
120 static int get_serial_info(struct usb_serial_port *port,
121                            struct serial_struct __user *retinfo)
122 {
123         struct serial_struct tmp;
124
125         if (!retinfo)
126                 return -EFAULT;
127
128         memset(&tmp, 0, sizeof(tmp));
129         tmp.line            = port->serial->minor;
130         tmp.port            = port->number;
131         tmp.baud_base       = tty_get_baud_rate(port->port.tty);
132         tmp.close_delay     = port->port.close_delay / 10;
133         tmp.closing_wait    = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
134                                  ASYNC_CLOSING_WAIT_NONE :
135                                  port->port.closing_wait / 10;
136
137         if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
138                 return -EFAULT;
139         return 0;
140 }
141
142 static int set_serial_info(struct usb_serial_port *port,
143                            struct serial_struct __user *newinfo)
144 {
145         struct serial_struct new_serial;
146         unsigned int closing_wait, close_delay;
147         int retval = 0;
148
149         if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
150                 return -EFAULT;
151
152         close_delay = new_serial.close_delay * 10;
153         closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
154                         ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
155
156         mutex_lock(&port->port.mutex);
157
158         if (!capable(CAP_SYS_ADMIN)) {
159                 if ((close_delay != port->port.close_delay) ||
160                     (closing_wait != port->port.closing_wait))
161                         retval = -EPERM;
162                 else
163                         retval = -EOPNOTSUPP;
164         } else {
165                 port->port.close_delay  = close_delay;
166                 port->port.closing_wait = closing_wait;
167         }
168
169         mutex_unlock(&port->port.mutex);
170         return retval;
171 }
172
173 int usb_wwan_ioctl(struct tty_struct *tty,
174                    unsigned int cmd, unsigned long arg)
175 {
176         struct usb_serial_port *port = tty->driver_data;
177
178         dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd);
179
180         switch (cmd) {
181         case TIOCGSERIAL:
182                 return get_serial_info(port,
183                                        (struct serial_struct __user *) arg);
184         case TIOCSSERIAL:
185                 return set_serial_info(port,
186                                        (struct serial_struct __user *) arg);
187         default:
188                 break;
189         }
190
191         dev_dbg(&port->dev, "%s arg not supported\n", __func__);
192
193         return -ENOIOCTLCMD;
194 }
195 EXPORT_SYMBOL(usb_wwan_ioctl);
196
197 /* Write */
198 int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
199                    const unsigned char *buf, int count)
200 {
201         struct usb_wwan_port_private *portdata;
202         struct usb_wwan_intf_private *intfdata;
203         int i;
204         int left, todo;
205         struct urb *this_urb = NULL;    /* spurious */
206         int err;
207         unsigned long flags;
208
209         portdata = usb_get_serial_port_data(port);
210         intfdata = port->serial->private;
211
212         dev_dbg(&port->dev, "%s: write (%d chars)\n", __func__, count);
213
214         i = 0;
215         left = count;
216         for (i = 0; left > 0 && i < N_OUT_URB; i++) {
217                 todo = left;
218                 if (todo > OUT_BUFLEN)
219                         todo = OUT_BUFLEN;
220
221                 this_urb = portdata->out_urbs[i];
222                 if (test_and_set_bit(i, &portdata->out_busy)) {
223                         if (time_before(jiffies,
224                                         portdata->tx_start_time[i] + 10 * HZ))
225                                 continue;
226                         usb_unlink_urb(this_urb);
227                         continue;
228                 }
229                 dev_dbg(&port->dev, "%s: endpoint %d buf %d\n", __func__,
230                         usb_pipeendpoint(this_urb->pipe), i);
231
232                 err = usb_autopm_get_interface_async(port->serial->interface);
233                 if (err < 0)
234                         break;
235
236                 /* send the data */
237                 memcpy(this_urb->transfer_buffer, buf, todo);
238                 this_urb->transfer_buffer_length = todo;
239
240                 spin_lock_irqsave(&intfdata->susp_lock, flags);
241                 if (intfdata->suspended) {
242                         usb_anchor_urb(this_urb, &portdata->delayed);
243                         spin_unlock_irqrestore(&intfdata->susp_lock, flags);
244                 } else {
245                         intfdata->in_flight++;
246                         spin_unlock_irqrestore(&intfdata->susp_lock, flags);
247                         err = usb_submit_urb(this_urb, GFP_ATOMIC);
248                         if (err) {
249                                 dev_dbg(&port->dev,
250                                         "usb_submit_urb %p (write bulk) failed (%d)\n",
251                                         this_urb, err);
252                                 clear_bit(i, &portdata->out_busy);
253                                 spin_lock_irqsave(&intfdata->susp_lock, flags);
254                                 intfdata->in_flight--;
255                                 spin_unlock_irqrestore(&intfdata->susp_lock,
256                                                        flags);
257                                 usb_autopm_put_interface_async(port->serial->interface);
258                                 break;
259                         }
260                 }
261
262                 portdata->tx_start_time[i] = jiffies;
263                 buf += todo;
264                 left -= todo;
265         }
266
267         count -= left;
268         dev_dbg(&port->dev, "%s: wrote (did %d)\n", __func__, count);
269         return count;
270 }
271 EXPORT_SYMBOL(usb_wwan_write);
272
273 static void usb_wwan_indat_callback(struct urb *urb)
274 {
275         int err;
276         int endpoint;
277         struct usb_serial_port *port;
278         struct tty_struct *tty;
279         struct device *dev;
280         unsigned char *data = urb->transfer_buffer;
281         int status = urb->status;
282
283         endpoint = usb_pipeendpoint(urb->pipe);
284         port = urb->context;
285         dev = &port->dev;
286
287         if (status) {
288                 dev_dbg(dev, "%s: nonzero status: %d on endpoint %02x.\n",
289                         __func__, status, endpoint);
290         } else {
291                 tty = tty_port_tty_get(&port->port);
292                 if (tty) {
293                         if (urb->actual_length) {
294                                 tty_insert_flip_string(&port->port, data,
295                                                 urb->actual_length);
296                                 tty_flip_buffer_push(tty);
297                         } else
298                                 dev_dbg(dev, "%s: empty read urb received\n", __func__);
299                         tty_kref_put(tty);
300                 }
301
302                 /* Resubmit urb so we continue receiving */
303                 err = usb_submit_urb(urb, GFP_ATOMIC);
304                 if (err) {
305                         if (err != -EPERM) {
306                                 dev_err(dev, "%s: resubmit read urb failed. (%d)\n", __func__, err);
307                                 /* busy also in error unless we are killed */
308                                 usb_mark_last_busy(port->serial->dev);
309                         }
310                 } else {
311                         usb_mark_last_busy(port->serial->dev);
312                 }
313         }
314 }
315
316 static void usb_wwan_outdat_callback(struct urb *urb)
317 {
318         struct usb_serial_port *port;
319         struct usb_wwan_port_private *portdata;
320         struct usb_wwan_intf_private *intfdata;
321         int i;
322
323         port = urb->context;
324         intfdata = port->serial->private;
325
326         usb_serial_port_softint(port);
327         usb_autopm_put_interface_async(port->serial->interface);
328         portdata = usb_get_serial_port_data(port);
329         spin_lock(&intfdata->susp_lock);
330         intfdata->in_flight--;
331         spin_unlock(&intfdata->susp_lock);
332
333         for (i = 0; i < N_OUT_URB; ++i) {
334                 if (portdata->out_urbs[i] == urb) {
335                         smp_mb__before_clear_bit();
336                         clear_bit(i, &portdata->out_busy);
337                         break;
338                 }
339         }
340 }
341
342 int usb_wwan_write_room(struct tty_struct *tty)
343 {
344         struct usb_serial_port *port = tty->driver_data;
345         struct usb_wwan_port_private *portdata;
346         int i;
347         int data_len = 0;
348         struct urb *this_urb;
349
350         portdata = usb_get_serial_port_data(port);
351
352         for (i = 0; i < N_OUT_URB; i++) {
353                 this_urb = portdata->out_urbs[i];
354                 if (this_urb && !test_bit(i, &portdata->out_busy))
355                         data_len += OUT_BUFLEN;
356         }
357
358         dev_dbg(&port->dev, "%s: %d\n", __func__, data_len);
359         return data_len;
360 }
361 EXPORT_SYMBOL(usb_wwan_write_room);
362
363 int usb_wwan_chars_in_buffer(struct tty_struct *tty)
364 {
365         struct usb_serial_port *port = tty->driver_data;
366         struct usb_wwan_port_private *portdata;
367         int i;
368         int data_len = 0;
369         struct urb *this_urb;
370
371         portdata = usb_get_serial_port_data(port);
372
373         for (i = 0; i < N_OUT_URB; i++) {
374                 this_urb = portdata->out_urbs[i];
375                 /* FIXME: This locking is insufficient as this_urb may
376                    go unused during the test */
377                 if (this_urb && test_bit(i, &portdata->out_busy))
378                         data_len += this_urb->transfer_buffer_length;
379         }
380         dev_dbg(&port->dev, "%s: %d\n", __func__, data_len);
381         return data_len;
382 }
383 EXPORT_SYMBOL(usb_wwan_chars_in_buffer);
384
385 int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port)
386 {
387         struct usb_wwan_port_private *portdata;
388         struct usb_wwan_intf_private *intfdata;
389         struct usb_serial *serial = port->serial;
390         int i, err;
391         struct urb *urb;
392
393         portdata = usb_get_serial_port_data(port);
394         intfdata = serial->private;
395
396         /* Start reading from the IN endpoint */
397         for (i = 0; i < N_IN_URB; i++) {
398                 urb = portdata->in_urbs[i];
399                 if (!urb)
400                         continue;
401                 err = usb_submit_urb(urb, GFP_KERNEL);
402                 if (err) {
403                         dev_dbg(&port->dev, "%s: submit urb %d failed (%d) %d\n",
404                                 __func__, i, err, urb->transfer_buffer_length);
405                 }
406         }
407
408         if (intfdata->send_setup)
409                 intfdata->send_setup(port);
410
411         serial->interface->needs_remote_wakeup = 1;
412         spin_lock_irq(&intfdata->susp_lock);
413         portdata->opened = 1;
414         spin_unlock_irq(&intfdata->susp_lock);
415         /* this balances a get in the generic USB serial code */
416         usb_autopm_put_interface(serial->interface);
417
418         return 0;
419 }
420 EXPORT_SYMBOL(usb_wwan_open);
421
422 void usb_wwan_close(struct usb_serial_port *port)
423 {
424         int i;
425         struct usb_serial *serial = port->serial;
426         struct usb_wwan_port_private *portdata;
427         struct usb_wwan_intf_private *intfdata = port->serial->private;
428
429         portdata = usb_get_serial_port_data(port);
430
431         if (serial->dev) {
432                 /* Stop reading/writing urbs */
433                 spin_lock_irq(&intfdata->susp_lock);
434                 portdata->opened = 0;
435                 spin_unlock_irq(&intfdata->susp_lock);
436
437                 for (i = 0; i < N_IN_URB; i++)
438                         usb_kill_urb(portdata->in_urbs[i]);
439                 for (i = 0; i < N_OUT_URB; i++)
440                         usb_kill_urb(portdata->out_urbs[i]);
441                 /* balancing - important as an error cannot be handled*/
442                 usb_autopm_get_interface_no_resume(serial->interface);
443                 serial->interface->needs_remote_wakeup = 0;
444         }
445 }
446 EXPORT_SYMBOL(usb_wwan_close);
447
448 /* Helper functions used by usb_wwan_setup_urbs */
449 static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
450                                       int endpoint,
451                                       int dir, void *ctx, char *buf, int len,
452                                       void (*callback) (struct urb *))
453 {
454         struct usb_serial *serial = port->serial;
455         struct urb *urb;
456
457         urb = usb_alloc_urb(0, GFP_KERNEL);     /* No ISO */
458         if (urb == NULL) {
459                 dev_dbg(&serial->interface->dev,
460                         "%s: alloc for endpoint %d failed.\n", __func__,
461                         endpoint);
462                 return NULL;
463         }
464
465         /* Fill URB using supplied data. */
466         usb_fill_bulk_urb(urb, serial->dev,
467                           usb_sndbulkpipe(serial->dev, endpoint) | dir,
468                           buf, len, callback, ctx);
469
470         return urb;
471 }
472
473 int usb_wwan_port_probe(struct usb_serial_port *port)
474 {
475         struct usb_wwan_port_private *portdata;
476         struct urb *urb;
477         u8 *buffer;
478         int err;
479         int i;
480
481         portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
482         if (!portdata)
483                 return -ENOMEM;
484
485         init_usb_anchor(&portdata->delayed);
486
487         for (i = 0; i < N_IN_URB; i++) {
488                 if (!port->bulk_in_size)
489                         break;
490
491                 buffer = (u8 *)__get_free_page(GFP_KERNEL);
492                 if (!buffer)
493                         goto bail_out_error;
494                 portdata->in_buffer[i] = buffer;
495
496                 urb = usb_wwan_setup_urb(port, port->bulk_in_endpointAddress,
497                                                 USB_DIR_IN, port,
498                                                 buffer, IN_BUFLEN,
499                                                 usb_wwan_indat_callback);
500                 portdata->in_urbs[i] = urb;
501         }
502
503         for (i = 0; i < N_OUT_URB; i++) {
504                 if (!port->bulk_out_size)
505                         break;
506
507                 buffer = kmalloc(OUT_BUFLEN, GFP_KERNEL);
508                 if (!buffer)
509                         goto bail_out_error2;
510                 portdata->out_buffer[i] = buffer;
511
512                 urb = usb_wwan_setup_urb(port, port->bulk_out_endpointAddress,
513                                                 USB_DIR_OUT, port,
514                                                 buffer, OUT_BUFLEN,
515                                                 usb_wwan_outdat_callback);
516                 portdata->out_urbs[i] = urb;
517         }
518
519         usb_set_serial_port_data(port, portdata);
520
521         if (port->interrupt_in_urb) {
522                 err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
523                 if (err)
524                         dev_dbg(&port->dev, "%s: submit irq_in urb failed %d\n",
525                                 __func__, err);
526         }
527
528         return 0;
529
530 bail_out_error2:
531         for (i = 0; i < N_OUT_URB; i++) {
532                 usb_free_urb(portdata->out_urbs[i]);
533                 kfree(portdata->out_buffer[i]);
534         }
535 bail_out_error:
536         for (i = 0; i < N_IN_URB; i++) {
537                 usb_free_urb(portdata->in_urbs[i]);
538                 free_page((unsigned long)portdata->in_buffer[i]);
539         }
540         kfree(portdata);
541
542         return -ENOMEM;
543 }
544 EXPORT_SYMBOL_GPL(usb_wwan_port_probe);
545
546 int usb_wwan_port_remove(struct usb_serial_port *port)
547 {
548         int i;
549         struct usb_wwan_port_private *portdata;
550
551         portdata = usb_get_serial_port_data(port);
552         usb_set_serial_port_data(port, NULL);
553
554         /* Stop reading/writing urbs and free them */
555         for (i = 0; i < N_IN_URB; i++) {
556                 usb_kill_urb(portdata->in_urbs[i]);
557                 usb_free_urb(portdata->in_urbs[i]);
558                 free_page((unsigned long)portdata->in_buffer[i]);
559         }
560         for (i = 0; i < N_OUT_URB; i++) {
561                 usb_kill_urb(portdata->out_urbs[i]);
562                 usb_free_urb(portdata->out_urbs[i]);
563                 kfree(portdata->out_buffer[i]);
564         }
565
566         /* Now free port private data */
567         kfree(portdata);
568         return 0;
569 }
570 EXPORT_SYMBOL(usb_wwan_port_remove);
571
572 #ifdef CONFIG_PM
573 static void stop_read_write_urbs(struct usb_serial *serial)
574 {
575         int i, j;
576         struct usb_serial_port *port;
577         struct usb_wwan_port_private *portdata;
578
579         /* Stop reading/writing urbs */
580         for (i = 0; i < serial->num_ports; ++i) {
581                 port = serial->port[i];
582                 portdata = usb_get_serial_port_data(port);
583                 if (!portdata)
584                         continue;
585                 for (j = 0; j < N_IN_URB; j++)
586                         usb_kill_urb(portdata->in_urbs[j]);
587                 for (j = 0; j < N_OUT_URB; j++)
588                         usb_kill_urb(portdata->out_urbs[j]);
589         }
590 }
591
592 int usb_wwan_suspend(struct usb_serial *serial, pm_message_t message)
593 {
594         struct usb_wwan_intf_private *intfdata = serial->private;
595         int b;
596
597         if (PMSG_IS_AUTO(message)) {
598                 spin_lock_irq(&intfdata->susp_lock);
599                 b = intfdata->in_flight;
600                 spin_unlock_irq(&intfdata->susp_lock);
601
602                 if (b)
603                         return -EBUSY;
604         }
605
606         spin_lock_irq(&intfdata->susp_lock);
607         intfdata->suspended = 1;
608         spin_unlock_irq(&intfdata->susp_lock);
609         stop_read_write_urbs(serial);
610
611         return 0;
612 }
613 EXPORT_SYMBOL(usb_wwan_suspend);
614
615 static void unbusy_queued_urb(struct urb *urb, struct usb_wwan_port_private *portdata)
616 {
617         int i;
618
619         for (i = 0; i < N_OUT_URB; i++) {
620                 if (urb == portdata->out_urbs[i]) {
621                         clear_bit(i, &portdata->out_busy);
622                         break;
623                 }
624         }
625 }
626
627 static void play_delayed(struct usb_serial_port *port)
628 {
629         struct usb_wwan_intf_private *data;
630         struct usb_wwan_port_private *portdata;
631         struct urb *urb;
632         int err;
633
634         portdata = usb_get_serial_port_data(port);
635         data = port->serial->private;
636         while ((urb = usb_get_from_anchor(&portdata->delayed))) {
637                 err = usb_submit_urb(urb, GFP_ATOMIC);
638                 if (!err) {
639                         data->in_flight++;
640                 } else {
641                         /* we have to throw away the rest */
642                         do {
643                                 unbusy_queued_urb(urb, portdata);
644                                 usb_autopm_put_interface_no_suspend(port->serial->interface);
645                         } while ((urb = usb_get_from_anchor(&portdata->delayed)));
646                         break;
647                 }
648         }
649 }
650
651 int usb_wwan_resume(struct usb_serial *serial)
652 {
653         int i, j;
654         struct usb_serial_port *port;
655         struct usb_wwan_intf_private *intfdata = serial->private;
656         struct usb_wwan_port_private *portdata;
657         struct urb *urb;
658         int err = 0;
659
660         /* get the interrupt URBs resubmitted unconditionally */
661         for (i = 0; i < serial->num_ports; i++) {
662                 port = serial->port[i];
663                 if (!port->interrupt_in_urb) {
664                         dev_dbg(&port->dev, "%s: No interrupt URB for port\n", __func__);
665                         continue;
666                 }
667                 err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
668                 dev_dbg(&port->dev, "Submitted interrupt URB for port (result %d)\n", err);
669                 if (err < 0) {
670                         dev_err(&port->dev, "%s: Error %d for interrupt URB\n",
671                                 __func__, err);
672                         goto err_out;
673                 }
674         }
675
676         for (i = 0; i < serial->num_ports; i++) {
677                 /* walk all ports */
678                 port = serial->port[i];
679                 portdata = usb_get_serial_port_data(port);
680
681                 /* skip closed ports */
682                 spin_lock_irq(&intfdata->susp_lock);
683                 if (!portdata || !portdata->opened) {
684                         spin_unlock_irq(&intfdata->susp_lock);
685                         continue;
686                 }
687
688                 for (j = 0; j < N_IN_URB; j++) {
689                         urb = portdata->in_urbs[j];
690                         err = usb_submit_urb(urb, GFP_ATOMIC);
691                         if (err < 0) {
692                                 dev_err(&port->dev, "%s: Error %d for bulk URB %d\n",
693                                         __func__, err, i);
694                                 spin_unlock_irq(&intfdata->susp_lock);
695                                 goto err_out;
696                         }
697                 }
698                 play_delayed(port);
699                 spin_unlock_irq(&intfdata->susp_lock);
700         }
701         spin_lock_irq(&intfdata->susp_lock);
702         intfdata->suspended = 0;
703         spin_unlock_irq(&intfdata->susp_lock);
704 err_out:
705         return err;
706 }
707 EXPORT_SYMBOL(usb_wwan_resume);
708 #endif
709
710 MODULE_AUTHOR(DRIVER_AUTHOR);
711 MODULE_DESCRIPTION(DRIVER_DESC);
712 MODULE_LICENSE("GPL");