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