Commit 97d35f95552c9a0ee4777a7f04431a9fd1260478

Authored by Oliver Neukum
Committed by Greg Kroah-Hartman
1 parent 1f141ca2b1

USB: cdc-acm: Update to new autopm API

Update cdc-acm to the async methods eliminating the workqueue

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 2 changed files with 22 additions and 22 deletions Side-by-side Diff

drivers/usb/class/cdc-acm.c
... ... @@ -170,6 +170,7 @@
170 170 {
171 171 wb->use = 0;
172 172 acm->transmitting--;
  173 + usb_autopm_put_interface_async(acm->control);
173 174 }
174 175  
175 176 /*
176 177  
... ... @@ -211,9 +212,12 @@
211 212 }
212 213  
213 214 dbg("%s susp_count: %d", __func__, acm->susp_count);
  215 + usb_autopm_get_interface_async(acm->control);
214 216 if (acm->susp_count) {
215   - acm->delayed_wb = wb;
216   - schedule_work(&acm->waker);
  217 + if (!acm->delayed_wb)
  218 + acm->delayed_wb = wb;
  219 + else
  220 + usb_autopm_put_interface_async(acm->control);
217 221 spin_unlock_irqrestore(&acm->write_lock, flags);
218 222 return 0; /* A white lie */
219 223 }
... ... @@ -534,23 +538,6 @@
534 538 tty_kref_put(tty);
535 539 }
536 540  
537   -static void acm_waker(struct work_struct *waker)
538   -{
539   - struct acm *acm = container_of(waker, struct acm, waker);
540   - int rv;
541   -
542   - rv = usb_autopm_get_interface(acm->control);
543   - if (rv < 0) {
544   - dev_err(&acm->dev->dev, "Autopm failure in %s\n", __func__);
545   - return;
546   - }
547   - if (acm->delayed_wb) {
548   - acm_start_wb(acm, acm->delayed_wb);
549   - acm->delayed_wb = NULL;
550   - }
551   - usb_autopm_put_interface(acm->control);
552   -}
553   -
554 541 /*
555 542 * TTY handlers
556 543 */
... ... @@ -1178,7 +1165,6 @@
1178 1165 acm->urb_task.func = acm_rx_tasklet;
1179 1166 acm->urb_task.data = (unsigned long) acm;
1180 1167 INIT_WORK(&acm->work, acm_softint);
1181   - INIT_WORK(&acm->waker, acm_waker);
1182 1168 init_waitqueue_head(&acm->drain_wait);
1183 1169 spin_lock_init(&acm->throttle_lock);
1184 1170 spin_lock_init(&acm->write_lock);
... ... @@ -1343,7 +1329,6 @@
1343 1329 tasklet_enable(&acm->urb_task);
1344 1330  
1345 1331 cancel_work_sync(&acm->work);
1346   - cancel_work_sync(&acm->waker);
1347 1332 }
1348 1333  
1349 1334 static void acm_disconnect(struct usb_interface *intf)
... ... @@ -1435,6 +1420,7 @@
1435 1420 static int acm_resume(struct usb_interface *intf)
1436 1421 {
1437 1422 struct acm *acm = usb_get_intfdata(intf);
  1423 + struct acm_wb *wb;
1438 1424 int rv = 0;
1439 1425 int cnt;
1440 1426  
... ... @@ -1449,6 +1435,21 @@
1449 1435 mutex_lock(&acm->mutex);
1450 1436 if (acm->port.count) {
1451 1437 rv = usb_submit_urb(acm->ctrlurb, GFP_NOIO);
  1438 +
  1439 + spin_lock_irq(&acm->write_lock);
  1440 + if (acm->delayed_wb) {
  1441 + wb = acm->delayed_wb;
  1442 + acm->delayed_wb = NULL;
  1443 + spin_unlock_irq(&acm->write_lock);
  1444 + acm_start_wb(acm, acm->delayed_wb);
  1445 + } else {
  1446 + spin_unlock_irq(&acm->write_lock);
  1447 + }
  1448 +
  1449 + /*
  1450 + * delayed error checking because we must
  1451 + * do the write path at all cost
  1452 + */
1452 1453 if (rv < 0)
1453 1454 goto err_out;
1454 1455  
drivers/usb/class/cdc-acm.h
... ... @@ -112,7 +112,6 @@
112 112 struct mutex mutex;
113 113 struct usb_cdc_line_coding line; /* bits, stop, parity */
114 114 struct work_struct work; /* work queue entry for line discipline waking up */
115   - struct work_struct waker;
116 115 wait_queue_head_t drain_wait; /* close processing */
117 116 struct tasklet_struct urb_task; /* rx processing */
118 117 spinlock_t throttle_lock; /* synchronize throtteling and read callback */