Commit 05fe2175 authored by Frank Schaefer's avatar Frank Schaefer Committed by Mauro Carvalho Chehab

[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: default avatarFrank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 2665c299
...@@ -3507,6 +3507,8 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) ...@@ -3507,6 +3507,8 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
if (!dev) if (!dev)
return; return;
dev->disconnected = 1;
if (dev->is_audio_only) { if (dev->is_audio_only) {
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
em28xx_close_extension(dev); em28xx_close_extension(dev);
...@@ -3518,31 +3520,25 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) ...@@ -3518,31 +3520,25 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
flush_request_modules(dev); flush_request_modules(dev);
/* wait until all current v4l2 io is finished then deallocate
resources */
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
v4l2_device_disconnect(&dev->v4l2_dev); v4l2_device_disconnect(&dev->v4l2_dev);
if (dev->users) { if (dev->users) {
em28xx_warn em28xx_warn("device %s is open! Deregistration and memory deallocation are deferred on close.\n",
("device %s is open! Deregistration and memory "
"deallocation are deferred on close.\n",
video_device_node_name(dev->vdev)); video_device_node_name(dev->vdev));
em28xx_uninit_usb_xfer(dev, dev->mode); em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE);
dev->disconnected = 1; em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE);
} else {
dev->disconnected = 1;
em28xx_release_resources(dev);
} }
/* free DVB isoc buffers */ em28xx_close_extension(dev);
em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE); /* NOTE: must be called BEFORE the resources are released */
mutex_unlock(&dev->lock); if (!dev->users)
em28xx_release_resources(dev);
em28xx_close_extension(dev); mutex_unlock(&dev->lock);
if (!dev->users) { if (!dev->users) {
kfree(dev->alt_max_pkt_size_isoc); kfree(dev->alt_max_pkt_size_isoc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment