@@ -158,6 +158,17 @@ static inline int acm_set_control(struct acm *acm, int control)
158
158
#define acm_send_break (acm , ms ) \
159
159
acm_ctrl_msg(acm, USB_CDC_REQ_SEND_BREAK, ms, NULL, 0)
160
160
161
+ static void acm_kill_urbs (struct acm * acm )
162
+ {
163
+ int i ;
164
+
165
+ usb_kill_urb (acm -> ctrlurb );
166
+ for (i = 0 ; i < ACM_NW ; i ++ )
167
+ usb_kill_urb (acm -> wb [i ].urb );
168
+ for (i = 0 ; i < acm -> rx_buflimit ; i ++ )
169
+ usb_kill_urb (acm -> read_urbs [i ]);
170
+ }
171
+
161
172
/*
162
173
* Write buffer management.
163
174
* All of these assume proper locks taken by the caller.
@@ -607,7 +618,6 @@ static void acm_port_shutdown(struct tty_port *port)
607
618
struct acm * acm = container_of (port , struct acm , port );
608
619
struct urb * urb ;
609
620
struct acm_wb * wb ;
610
- int i ;
611
621
612
622
/*
613
623
* Need to grab write_lock to prevent race with resume, but no need to
@@ -629,11 +639,7 @@ static void acm_port_shutdown(struct tty_port *port)
629
639
usb_autopm_put_interface_async (acm -> control );
630
640
}
631
641
632
- usb_kill_urb (acm -> ctrlurb );
633
- for (i = 0 ; i < ACM_NW ; i ++ )
634
- usb_kill_urb (acm -> wb [i ].urb );
635
- for (i = 0 ; i < acm -> rx_buflimit ; i ++ )
636
- usb_kill_urb (acm -> read_urbs [i ]);
642
+ acm_kill_urbs (acm );
637
643
}
638
644
639
645
static void acm_tty_cleanup (struct tty_struct * tty )
@@ -1506,24 +1512,10 @@ static int acm_probe(struct usb_interface *intf,
1506
1512
return rv ;
1507
1513
}
1508
1514
1509
- static void stop_data_traffic (struct acm * acm )
1510
- {
1511
- int i ;
1512
-
1513
- usb_kill_urb (acm -> ctrlurb );
1514
- for (i = 0 ; i < ACM_NW ; i ++ )
1515
- usb_kill_urb (acm -> wb [i ].urb );
1516
- for (i = 0 ; i < acm -> rx_buflimit ; i ++ )
1517
- usb_kill_urb (acm -> read_urbs [i ]);
1518
-
1519
- cancel_work_sync (& acm -> work );
1520
- }
1521
-
1522
1515
static void acm_disconnect (struct usb_interface * intf )
1523
1516
{
1524
1517
struct acm * acm = usb_get_intfdata (intf );
1525
1518
struct tty_struct * tty ;
1526
- int i ;
1527
1519
1528
1520
/* sibling interface is already cleaning up */
1529
1521
if (!acm )
@@ -1549,15 +1541,11 @@ static void acm_disconnect(struct usb_interface *intf)
1549
1541
tty_kref_put (tty );
1550
1542
}
1551
1543
1552
- stop_data_traffic (acm );
1544
+ acm_kill_urbs (acm );
1545
+ cancel_work_sync (& acm -> work );
1553
1546
1554
1547
tty_unregister_device (acm_tty_driver , acm -> minor );
1555
1548
1556
- usb_free_urb (acm -> ctrlurb );
1557
- for (i = 0 ; i < ACM_NW ; i ++ )
1558
- usb_free_urb (acm -> wb [i ].urb );
1559
- for (i = 0 ; i < acm -> rx_buflimit ; i ++ )
1560
- usb_free_urb (acm -> read_urbs [i ]);
1561
1549
acm_write_buffers_free (acm );
1562
1550
usb_free_coherent (acm -> dev , acm -> ctrlsize , acm -> ctrl_buffer , acm -> ctrl_dma );
1563
1551
acm_read_buffers_free (acm );
@@ -1588,7 +1576,8 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message)
1588
1576
if (cnt )
1589
1577
return 0 ;
1590
1578
1591
- stop_data_traffic (acm );
1579
+ acm_kill_urbs (acm );
1580
+ cancel_work_sync (& acm -> work );
1592
1581
1593
1582
return 0 ;
1594
1583
}
0 commit comments