diff options
Diffstat (limited to 'drivers/usb/serial/usb_wwan.c')
-rw-r--r-- | drivers/usb/serial/usb_wwan.c | 68 |
1 files changed, 29 insertions, 39 deletions
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index f35971dff4a5..6855d5ed0331 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c | |||
@@ -565,62 +565,52 @@ bail_out_error: | |||
565 | } | 565 | } |
566 | EXPORT_SYMBOL(usb_wwan_startup); | 566 | EXPORT_SYMBOL(usb_wwan_startup); |
567 | 567 | ||
568 | static void stop_read_write_urbs(struct usb_serial *serial) | 568 | int usb_wwan_port_remove(struct usb_serial_port *port) |
569 | { | 569 | { |
570 | int i, j; | 570 | int i; |
571 | struct usb_serial_port *port; | ||
572 | struct usb_wwan_port_private *portdata; | 571 | struct usb_wwan_port_private *portdata; |
573 | 572 | ||
574 | /* Stop reading/writing urbs */ | 573 | portdata = usb_get_serial_port_data(port); |
575 | for (i = 0; i < serial->num_ports; ++i) { | 574 | usb_set_serial_port_data(port, NULL); |
576 | port = serial->port[i]; | 575 | |
577 | portdata = usb_get_serial_port_data(port); | 576 | /* Stop reading/writing urbs and free them */ |
578 | for (j = 0; j < N_IN_URB; j++) | 577 | for (i = 0; i < N_IN_URB; i++) { |
579 | usb_kill_urb(portdata->in_urbs[j]); | 578 | usb_kill_urb(portdata->in_urbs[i]); |
580 | for (j = 0; j < N_OUT_URB; j++) | 579 | usb_free_urb(portdata->in_urbs[i]); |
581 | usb_kill_urb(portdata->out_urbs[j]); | 580 | free_page((unsigned long)portdata->in_buffer[i]); |
581 | } | ||
582 | for (i = 0; i < N_OUT_URB; i++) { | ||
583 | usb_kill_urb(portdata->out_urbs[i]); | ||
584 | usb_free_urb(portdata->out_urbs[i]); | ||
585 | kfree(portdata->out_buffer[i]); | ||
582 | } | 586 | } |
583 | } | ||
584 | 587 | ||
585 | void usb_wwan_disconnect(struct usb_serial *serial) | 588 | /* Now free port private data */ |
586 | { | 589 | kfree(portdata); |
587 | stop_read_write_urbs(serial); | 590 | return 0; |
588 | } | 591 | } |
589 | EXPORT_SYMBOL(usb_wwan_disconnect); | 592 | EXPORT_SYMBOL(usb_wwan_port_remove); |
590 | 593 | ||
591 | void usb_wwan_release(struct usb_serial *serial) | 594 | #ifdef CONFIG_PM |
595 | static void stop_read_write_urbs(struct usb_serial *serial) | ||
592 | { | 596 | { |
593 | int i, j; | 597 | int i, j; |
594 | struct usb_serial_port *port; | 598 | struct usb_serial_port *port; |
595 | struct usb_wwan_port_private *portdata; | 599 | struct usb_wwan_port_private *portdata; |
596 | 600 | ||
597 | /* Now free them */ | 601 | /* Stop reading/writing urbs */ |
598 | for (i = 0; i < serial->num_ports; ++i) { | 602 | for (i = 0; i < serial->num_ports; ++i) { |
599 | port = serial->port[i]; | 603 | port = serial->port[i]; |
600 | portdata = usb_get_serial_port_data(port); | 604 | portdata = usb_get_serial_port_data(port); |
601 | 605 | if (!portdata) | |
602 | for (j = 0; j < N_IN_URB; j++) { | 606 | continue; |
603 | usb_free_urb(portdata->in_urbs[j]); | 607 | for (j = 0; j < N_IN_URB; j++) |
604 | free_page((unsigned long) | 608 | usb_kill_urb(portdata->in_urbs[j]); |
605 | portdata->in_buffer[j]); | 609 | for (j = 0; j < N_OUT_URB; j++) |
606 | portdata->in_urbs[j] = NULL; | 610 | usb_kill_urb(portdata->out_urbs[j]); |
607 | } | ||
608 | for (j = 0; j < N_OUT_URB; j++) { | ||
609 | usb_free_urb(portdata->out_urbs[j]); | ||
610 | kfree(portdata->out_buffer[j]); | ||
611 | portdata->out_urbs[j] = NULL; | ||
612 | } | ||
613 | } | ||
614 | |||
615 | /* Now free per port private data */ | ||
616 | for (i = 0; i < serial->num_ports; i++) { | ||
617 | port = serial->port[i]; | ||
618 | kfree(usb_get_serial_port_data(port)); | ||
619 | } | 611 | } |
620 | } | 612 | } |
621 | EXPORT_SYMBOL(usb_wwan_release); | ||
622 | 613 | ||
623 | #ifdef CONFIG_PM | ||
624 | int usb_wwan_suspend(struct usb_serial *serial, pm_message_t message) | 614 | int usb_wwan_suspend(struct usb_serial *serial, pm_message_t message) |
625 | { | 615 | { |
626 | struct usb_wwan_intf_private *intfdata = serial->private; | 616 | struct usb_wwan_intf_private *intfdata = serial->private; |
@@ -712,7 +702,7 @@ int usb_wwan_resume(struct usb_serial *serial) | |||
712 | 702 | ||
713 | /* skip closed ports */ | 703 | /* skip closed ports */ |
714 | spin_lock_irq(&intfdata->susp_lock); | 704 | spin_lock_irq(&intfdata->susp_lock); |
715 | if (!portdata->opened) { | 705 | if (!portdata || !portdata->opened) { |
716 | spin_unlock_irq(&intfdata->susp_lock); | 706 | spin_unlock_irq(&intfdata->susp_lock); |
717 | continue; | 707 | continue; |
718 | } | 708 | } |