diff options
Diffstat (limited to 'drivers/usb/class')
-rw-r--r-- | drivers/usb/class/cdc-acm.c | 29 | ||||
-rw-r--r-- | drivers/usb/class/usblp.c | 78 |
2 files changed, 86 insertions, 21 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index ec4d1d756725..9a9012fd284b 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -325,7 +325,7 @@ static void acm_rx_tasklet(unsigned long _acm) | |||
325 | struct acm_rb *buf; | 325 | struct acm_rb *buf; |
326 | struct tty_struct *tty = acm->tty; | 326 | struct tty_struct *tty = acm->tty; |
327 | struct acm_ru *rcv; | 327 | struct acm_ru *rcv; |
328 | //unsigned long flags; | 328 | unsigned long flags; |
329 | int i = 0; | 329 | int i = 0; |
330 | dbg("Entering acm_rx_tasklet"); | 330 | dbg("Entering acm_rx_tasklet"); |
331 | 331 | ||
@@ -333,15 +333,15 @@ static void acm_rx_tasklet(unsigned long _acm) | |||
333 | return; | 333 | return; |
334 | 334 | ||
335 | next_buffer: | 335 | next_buffer: |
336 | spin_lock(&acm->read_lock); | 336 | spin_lock_irqsave(&acm->read_lock, flags); |
337 | if (list_empty(&acm->filled_read_bufs)) { | 337 | if (list_empty(&acm->filled_read_bufs)) { |
338 | spin_unlock(&acm->read_lock); | 338 | spin_unlock_irqrestore(&acm->read_lock, flags); |
339 | goto urbs; | 339 | goto urbs; |
340 | } | 340 | } |
341 | buf = list_entry(acm->filled_read_bufs.next, | 341 | buf = list_entry(acm->filled_read_bufs.next, |
342 | struct acm_rb, list); | 342 | struct acm_rb, list); |
343 | list_del(&buf->list); | 343 | list_del(&buf->list); |
344 | spin_unlock(&acm->read_lock); | 344 | spin_unlock_irqrestore(&acm->read_lock, flags); |
345 | 345 | ||
346 | dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d", buf, buf->size); | 346 | dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d", buf, buf->size); |
347 | 347 | ||
@@ -356,29 +356,29 @@ next_buffer: | |||
356 | memmove(buf->base, buf->base + i, buf->size - i); | 356 | memmove(buf->base, buf->base + i, buf->size - i); |
357 | buf->size -= i; | 357 | buf->size -= i; |
358 | spin_unlock(&acm->throttle_lock); | 358 | spin_unlock(&acm->throttle_lock); |
359 | spin_lock(&acm->read_lock); | 359 | spin_lock_irqsave(&acm->read_lock, flags); |
360 | list_add(&buf->list, &acm->filled_read_bufs); | 360 | list_add(&buf->list, &acm->filled_read_bufs); |
361 | spin_unlock(&acm->read_lock); | 361 | spin_unlock_irqrestore(&acm->read_lock, flags); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | spin_unlock(&acm->throttle_lock); | 364 | spin_unlock(&acm->throttle_lock); |
365 | 365 | ||
366 | spin_lock(&acm->read_lock); | 366 | spin_lock_irqsave(&acm->read_lock, flags); |
367 | list_add(&buf->list, &acm->spare_read_bufs); | 367 | list_add(&buf->list, &acm->spare_read_bufs); |
368 | spin_unlock(&acm->read_lock); | 368 | spin_unlock_irqrestore(&acm->read_lock, flags); |
369 | goto next_buffer; | 369 | goto next_buffer; |
370 | 370 | ||
371 | urbs: | 371 | urbs: |
372 | while (!list_empty(&acm->spare_read_bufs)) { | 372 | while (!list_empty(&acm->spare_read_bufs)) { |
373 | spin_lock(&acm->read_lock); | 373 | spin_lock_irqsave(&acm->read_lock, flags); |
374 | if (list_empty(&acm->spare_read_urbs)) { | 374 | if (list_empty(&acm->spare_read_urbs)) { |
375 | spin_unlock(&acm->read_lock); | 375 | spin_unlock_irqrestore(&acm->read_lock, flags); |
376 | return; | 376 | return; |
377 | } | 377 | } |
378 | rcv = list_entry(acm->spare_read_urbs.next, | 378 | rcv = list_entry(acm->spare_read_urbs.next, |
379 | struct acm_ru, list); | 379 | struct acm_ru, list); |
380 | list_del(&rcv->list); | 380 | list_del(&rcv->list); |
381 | spin_unlock(&acm->read_lock); | 381 | spin_unlock_irqrestore(&acm->read_lock, flags); |
382 | 382 | ||
383 | buf = list_entry(acm->spare_read_bufs.next, | 383 | buf = list_entry(acm->spare_read_bufs.next, |
384 | struct acm_rb, list); | 384 | struct acm_rb, list); |
@@ -400,9 +400,9 @@ urbs: | |||
400 | free-urbs-pool and resubmited ASAP */ | 400 | free-urbs-pool and resubmited ASAP */ |
401 | if (usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) { | 401 | if (usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) { |
402 | list_add(&buf->list, &acm->spare_read_bufs); | 402 | list_add(&buf->list, &acm->spare_read_bufs); |
403 | spin_lock(&acm->read_lock); | 403 | spin_lock_irqsave(&acm->read_lock, flags); |
404 | list_add(&rcv->list, &acm->spare_read_urbs); | 404 | list_add(&rcv->list, &acm->spare_read_urbs); |
405 | spin_unlock(&acm->read_lock); | 405 | spin_unlock_irqrestore(&acm->read_lock, flags); |
406 | return; | 406 | return; |
407 | } | 407 | } |
408 | } | 408 | } |
@@ -1083,6 +1083,9 @@ static struct usb_device_id acm_ids[] = { | |||
1083 | { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */ | 1083 | { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */ |
1084 | .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ | 1084 | .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ |
1085 | }, | 1085 | }, |
1086 | { USB_DEVICE(0x079b, 0x000f), /* BT On-Air USB MODEM */ | ||
1087 | .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ | ||
1088 | }, | ||
1086 | { USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */ | 1089 | { USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */ |
1087 | .driver_info = SINGLE_RX_URB, /* firmware bug */ | 1090 | .driver_info = SINGLE_RX_URB, /* firmware bug */ |
1088 | }, | 1091 | }, |
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index a161d70e1e42..6303970e93c1 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c | |||
@@ -154,6 +154,7 @@ struct usblp { | |||
154 | unsigned char used; /* True if open */ | 154 | unsigned char used; /* True if open */ |
155 | unsigned char present; /* True if not disconnected */ | 155 | unsigned char present; /* True if not disconnected */ |
156 | unsigned char bidir; /* interface is bidirectional */ | 156 | unsigned char bidir; /* interface is bidirectional */ |
157 | unsigned char sleeping; /* interface is suspended */ | ||
157 | unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string (ptr) */ | 158 | unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string (ptr) */ |
158 | /* first 2 bytes are (big-endian) length */ | 159 | /* first 2 bytes are (big-endian) length */ |
159 | }; | 160 | }; |
@@ -183,6 +184,7 @@ static void usblp_dump(struct usblp *usblp) { | |||
183 | dbg("quirks=%d", usblp->quirks); | 184 | dbg("quirks=%d", usblp->quirks); |
184 | dbg("used=%d", usblp->used); | 185 | dbg("used=%d", usblp->used); |
185 | dbg("bidir=%d", usblp->bidir); | 186 | dbg("bidir=%d", usblp->bidir); |
187 | dbg("sleeping=%d", usblp->sleeping); | ||
186 | dbg("device_id_string=\"%s\"", | 188 | dbg("device_id_string=\"%s\"", |
187 | usblp->device_id_string ? | 189 | usblp->device_id_string ? |
188 | usblp->device_id_string + 2 : | 190 | usblp->device_id_string + 2 : |
@@ -338,6 +340,20 @@ static int usblp_check_status(struct usblp *usblp, int err) | |||
338 | return newerr; | 340 | return newerr; |
339 | } | 341 | } |
340 | 342 | ||
343 | static int handle_bidir (struct usblp *usblp) | ||
344 | { | ||
345 | if (usblp->bidir && usblp->used && !usblp->sleeping) { | ||
346 | usblp->readcount = 0; | ||
347 | usblp->readurb->dev = usblp->dev; | ||
348 | if (usb_submit_urb(usblp->readurb, GFP_KERNEL) < 0) { | ||
349 | usblp->used = 0; | ||
350 | return -EIO; | ||
351 | } | ||
352 | } | ||
353 | |||
354 | return 0; | ||
355 | } | ||
356 | |||
341 | /* | 357 | /* |
342 | * File op functions. | 358 | * File op functions. |
343 | */ | 359 | */ |
@@ -390,14 +406,9 @@ static int usblp_open(struct inode *inode, struct file *file) | |||
390 | usblp->writeurb->status = 0; | 406 | usblp->writeurb->status = 0; |
391 | usblp->readurb->status = 0; | 407 | usblp->readurb->status = 0; |
392 | 408 | ||
393 | if (usblp->bidir) { | 409 | if (handle_bidir(usblp) < 0) { |
394 | usblp->readcount = 0; | 410 | file->private_data = NULL; |
395 | usblp->readurb->dev = usblp->dev; | 411 | retval = -EIO; |
396 | if (usb_submit_urb(usblp->readurb, GFP_KERNEL) < 0) { | ||
397 | retval = -EIO; | ||
398 | usblp->used = 0; | ||
399 | file->private_data = NULL; | ||
400 | } | ||
401 | } | 412 | } |
402 | out: | 413 | out: |
403 | mutex_unlock (&usblp_mutex); | 414 | mutex_unlock (&usblp_mutex); |
@@ -460,6 +471,11 @@ static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
460 | goto done; | 471 | goto done; |
461 | } | 472 | } |
462 | 473 | ||
474 | if (usblp->sleeping) { | ||
475 | retval = -ENODEV; | ||
476 | goto done; | ||
477 | } | ||
478 | |||
463 | dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd), | 479 | dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd), |
464 | _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd) ); | 480 | _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd) ); |
465 | 481 | ||
@@ -658,6 +674,11 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t | |||
658 | return -ENODEV; | 674 | return -ENODEV; |
659 | } | 675 | } |
660 | 676 | ||
677 | if (usblp->sleeping) { | ||
678 | up (&usblp->sem); | ||
679 | return writecount ? writecount : -ENODEV; | ||
680 | } | ||
681 | |||
661 | if (usblp->writeurb->status != 0) { | 682 | if (usblp->writeurb->status != 0) { |
662 | if (usblp->quirks & USBLP_QUIRK_BIDIR) { | 683 | if (usblp->quirks & USBLP_QUIRK_BIDIR) { |
663 | if (!usblp->wcomplete) | 684 | if (!usblp->wcomplete) |
@@ -701,6 +722,7 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t | |||
701 | usblp->wcomplete = 0; | 722 | usblp->wcomplete = 0; |
702 | err = usb_submit_urb(usblp->writeurb, GFP_KERNEL); | 723 | err = usb_submit_urb(usblp->writeurb, GFP_KERNEL); |
703 | if (err) { | 724 | if (err) { |
725 | usblp->wcomplete = 1; | ||
704 | if (err != -ENOMEM) | 726 | if (err != -ENOMEM) |
705 | count = -EIO; | 727 | count = -EIO; |
706 | else | 728 | else |
@@ -749,6 +771,11 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count, | |||
749 | goto done; | 771 | goto done; |
750 | } | 772 | } |
751 | 773 | ||
774 | if (usblp->sleeping) { | ||
775 | count = -ENODEV; | ||
776 | goto done; | ||
777 | } | ||
778 | |||
752 | if (usblp->readurb->status) { | 779 | if (usblp->readurb->status) { |
753 | err("usblp%d: error %d reading from printer", | 780 | err("usblp%d: error %d reading from printer", |
754 | usblp->minor, usblp->readurb->status); | 781 | usblp->minor, usblp->readurb->status); |
@@ -1167,6 +1194,39 @@ static void usblp_disconnect(struct usb_interface *intf) | |||
1167 | mutex_unlock (&usblp_mutex); | 1194 | mutex_unlock (&usblp_mutex); |
1168 | } | 1195 | } |
1169 | 1196 | ||
1197 | static int usblp_suspend (struct usb_interface *intf, pm_message_t message) | ||
1198 | { | ||
1199 | struct usblp *usblp = usb_get_intfdata (intf); | ||
1200 | |||
1201 | /* this races against normal access and open */ | ||
1202 | mutex_lock (&usblp_mutex); | ||
1203 | down (&usblp->sem); | ||
1204 | /* we take no more IO */ | ||
1205 | usblp->sleeping = 1; | ||
1206 | usblp_unlink_urbs(usblp); | ||
1207 | up (&usblp->sem); | ||
1208 | mutex_unlock (&usblp_mutex); | ||
1209 | |||
1210 | return 0; | ||
1211 | } | ||
1212 | |||
1213 | static int usblp_resume (struct usb_interface *intf) | ||
1214 | { | ||
1215 | struct usblp *usblp = usb_get_intfdata (intf); | ||
1216 | int r; | ||
1217 | |||
1218 | mutex_lock (&usblp_mutex); | ||
1219 | down (&usblp->sem); | ||
1220 | |||
1221 | usblp->sleeping = 0; | ||
1222 | r = handle_bidir (usblp); | ||
1223 | |||
1224 | up (&usblp->sem); | ||
1225 | mutex_unlock (&usblp_mutex); | ||
1226 | |||
1227 | return r; | ||
1228 | } | ||
1229 | |||
1170 | static struct usb_device_id usblp_ids [] = { | 1230 | static struct usb_device_id usblp_ids [] = { |
1171 | { USB_DEVICE_INFO(7, 1, 1) }, | 1231 | { USB_DEVICE_INFO(7, 1, 1) }, |
1172 | { USB_DEVICE_INFO(7, 1, 2) }, | 1232 | { USB_DEVICE_INFO(7, 1, 2) }, |
@@ -1183,6 +1243,8 @@ static struct usb_driver usblp_driver = { | |||
1183 | .name = "usblp", | 1243 | .name = "usblp", |
1184 | .probe = usblp_probe, | 1244 | .probe = usblp_probe, |
1185 | .disconnect = usblp_disconnect, | 1245 | .disconnect = usblp_disconnect, |
1246 | .suspend = usblp_suspend, | ||
1247 | .resume = usblp_resume, | ||
1186 | .id_table = usblp_ids, | 1248 | .id_table = usblp_ids, |
1187 | }; | 1249 | }; |
1188 | 1250 | ||