aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Schaefer <fschaefer.oss@googlemail.com>2012-12-27 17:02:44 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-01-04 22:10:13 -0500
commit05fe2175cf87da8a5475aed422bd636475ab0412 (patch)
tree05e45951c6771bf6ebd614ec92bda62d3c5dc11e
parent2665c2995d6a6026cfc9ec118908dfccb74fb5e0 (diff)
[media] em28xx: refactor the code in em28xx_usb_disconnect()
The main purpose of this patch is to move the call of em28xx_release_resources() after the call of em28xx_close_extension(). This is necessary, because some resources might be needed/used by the extensions fini() functions when they get closed. Also mark the device as disconnected earlier in this function and unify the em28xx_uninit_usb_xfer() calls for analog and digital mode. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/usb/em28xx/em28xx-cards.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index 99f2da661c32..4d849bfa2db3 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -3507,6 +3507,8 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
3507 if (!dev) 3507 if (!dev)
3508 return; 3508 return;
3509 3509
3510 dev->disconnected = 1;
3511
3510 if (dev->is_audio_only) { 3512 if (dev->is_audio_only) {
3511 mutex_lock(&dev->lock); 3513 mutex_lock(&dev->lock);
3512 em28xx_close_extension(dev); 3514 em28xx_close_extension(dev);
@@ -3518,32 +3520,26 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
3518 3520
3519 flush_request_modules(dev); 3521 flush_request_modules(dev);
3520 3522
3521 /* wait until all current v4l2 io is finished then deallocate
3522 resources */
3523 mutex_lock(&dev->lock); 3523 mutex_lock(&dev->lock);
3524 3524
3525 v4l2_device_disconnect(&dev->v4l2_dev); 3525 v4l2_device_disconnect(&dev->v4l2_dev);
3526 3526
3527 if (dev->users) { 3527 if (dev->users) {
3528 em28xx_warn 3528 em28xx_warn("device %s is open! Deregistration and memory deallocation are deferred on close.\n",
3529 ("device %s is open! Deregistration and memory " 3529 video_device_node_name(dev->vdev));
3530 "deallocation are deferred on close.\n",
3531 video_device_node_name(dev->vdev));
3532 3530
3533 em28xx_uninit_usb_xfer(dev, dev->mode); 3531 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE);
3534 dev->disconnected = 1; 3532 em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE);
3535 } else {
3536 dev->disconnected = 1;
3537 em28xx_release_resources(dev);
3538 } 3533 }
3539 3534
3540 /* free DVB isoc buffers */ 3535 em28xx_close_extension(dev);
3541 em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE); 3536 /* NOTE: must be called BEFORE the resources are released */
3537
3538 if (!dev->users)
3539 em28xx_release_resources(dev);
3542 3540
3543 mutex_unlock(&dev->lock); 3541 mutex_unlock(&dev->lock);
3544 3542
3545 em28xx_close_extension(dev);
3546
3547 if (!dev->users) { 3543 if (!dev->users) {
3548 kfree(dev->alt_max_pkt_size_isoc); 3544 kfree(dev->alt_max_pkt_size_isoc);
3549 kfree(dev); 3545 kfree(dev);