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