aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2012-08-28 12:18:32 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-15 12:28:03 -0400
commit3404cb5c4dbbbac884722f418d5561d81dba969f (patch)
tree4949e3abc5be14832d2b070dc79c73f80cbbad54 /drivers
parentd9751fd02a70bbfd9868f8584c6e9fd10a713d65 (diff)
[media] ttusbir: ad support suspend and resume
While here, fix the led name: the led is green, not yellow. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/rc/ttusbir.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
index 1aee57fd2f32..fef05235234a 100644
--- a/drivers/media/rc/ttusbir.c
+++ b/drivers/media/rc/ttusbir.c
@@ -66,11 +66,11 @@ static void ttusbir_set_led(struct ttusbir *tt)
66 66
67 smp_mb(); 67 smp_mb();
68 68
69 if (tt->led_on != tt->is_led_on && 69 if (tt->led_on != tt->is_led_on && tt->udev &&
70 atomic_add_unless(&tt->led_complete, 1, 1)) { 70 atomic_add_unless(&tt->led_complete, 1, 1)) {
71 tt->bulk_buffer[4] = tt->is_led_on = tt->led_on; 71 tt->bulk_buffer[4] = tt->is_led_on = tt->led_on;
72 ret = usb_submit_urb(tt->bulk_urb, GFP_ATOMIC); 72 ret = usb_submit_urb(tt->bulk_urb, GFP_ATOMIC);
73 if (ret && ret != -ENODEV) { 73 if (ret) {
74 dev_warn(tt->dev, "failed to submit bulk urb: %d\n", 74 dev_warn(tt->dev, "failed to submit bulk urb: %d\n",
75 ret); 75 ret);
76 atomic_dec(&tt->led_complete); 76 atomic_dec(&tt->led_complete);
@@ -300,7 +300,7 @@ static int __devinit ttusbir_probe(struct usb_interface *intf,
300 tt->bulk_out_endp), tt->bulk_buffer, sizeof(tt->bulk_buffer), 300 tt->bulk_out_endp), tt->bulk_buffer, sizeof(tt->bulk_buffer),
301 ttusbir_bulk_complete, tt); 301 ttusbir_bulk_complete, tt);
302 302
303 tt->led.name = "ttusbir:yellow:power"; 303 tt->led.name = "ttusbir:green:power";
304 tt->led.brightness_set = ttusbir_brightness_set; 304 tt->led.brightness_set = ttusbir_brightness_set;
305 tt->led.brightness_get = ttusbir_brightness_get; 305 tt->led.brightness_get = ttusbir_brightness_get;
306 tt->is_led_on = tt->led_on = true; 306 tt->is_led_on = tt->led_on = true;
@@ -370,13 +370,16 @@ out:
370static void __devexit ttusbir_disconnect(struct usb_interface *intf) 370static void __devexit ttusbir_disconnect(struct usb_interface *intf)
371{ 371{
372 struct ttusbir *tt = usb_get_intfdata(intf); 372 struct ttusbir *tt = usb_get_intfdata(intf);
373 struct usb_device *udev = tt->udev;
373 int i; 374 int i;
374 375
376 tt->udev = NULL;
377
375 rc_unregister_device(tt->rc); 378 rc_unregister_device(tt->rc);
376 led_classdev_unregister(&tt->led); 379 led_classdev_unregister(&tt->led);
377 for (i = 0; i < NUM_URBS; i++) { 380 for (i = 0; i < NUM_URBS; i++) {
378 usb_kill_urb(tt->urb[i]); 381 usb_kill_urb(tt->urb[i]);
379 usb_free_coherent(tt->udev, 128, tt->urb[i]->transfer_buffer, 382 usb_free_coherent(udev, 128, tt->urb[i]->transfer_buffer,
380 tt->urb[i]->transfer_dma); 383 tt->urb[i]->transfer_dma);
381 usb_free_urb(tt->urb[i]); 384 usb_free_urb(tt->urb[i]);
382 } 385 }
@@ -386,6 +389,40 @@ static void __devexit ttusbir_disconnect(struct usb_interface *intf)
386 kfree(tt); 389 kfree(tt);
387} 390}
388 391
392static int ttusbir_suspend(struct usb_interface *intf, pm_message_t message)
393{
394 struct ttusbir *tt = usb_get_intfdata(intf);
395 int i;
396
397 for (i = 0; i < NUM_URBS; i++)
398 usb_kill_urb(tt->urb[i]);
399
400 led_classdev_suspend(&tt->led);
401 usb_kill_urb(tt->bulk_urb);
402
403 return 0;
404}
405
406static int ttusbir_resume(struct usb_interface *intf)
407{
408 struct ttusbir *tt = usb_get_intfdata(intf);
409 int i, rc;
410
411 led_classdev_resume(&tt->led);
412 tt->is_led_on = true;
413 ttusbir_set_led(tt);
414
415 for (i = 0; i < NUM_URBS; i++) {
416 rc = usb_submit_urb(tt->urb[i], GFP_KERNEL);
417 if (rc) {
418 dev_warn(tt->dev, "failed to submit urb: %d\n", rc);
419 break;
420 }
421 }
422
423 return rc;
424}
425
389static const struct usb_device_id ttusbir_table[] = { 426static const struct usb_device_id ttusbir_table[] = {
390 { USB_DEVICE(0x0b48, 0x2003) }, 427 { USB_DEVICE(0x0b48, 0x2003) },
391 { } 428 { }
@@ -395,6 +432,9 @@ static struct usb_driver ttusbir_driver = {
395 .name = DRIVER_NAME, 432 .name = DRIVER_NAME,
396 .id_table = ttusbir_table, 433 .id_table = ttusbir_table,
397 .probe = ttusbir_probe, 434 .probe = ttusbir_probe,
435 .suspend = ttusbir_suspend,
436 .resume = ttusbir_resume,
437 .reset_resume = ttusbir_resume,
398 .disconnect = __devexit_p(ttusbir_disconnect) 438 .disconnect = __devexit_p(ttusbir_disconnect)
399}; 439};
400 440