Skip to content

Commit

Permalink
[media] em28xx: replug locking cleanup
Browse files Browse the repository at this point in the history
Simplifies the locking by moving the em28xx_init_extension() call until
em28xx_usb_probe() has finished with the dev->lock mutex. It therefore
makes the second and subsequent "plugging" events logically identical to
the first "plugging" event when the em28xx-dvb and em28xx-alsa modules
must be loaded (i.e. registered).

Basically, em28xx_usb_probe() requests that em28xx-dvb be loaded and
also triggers udev to initialise the V4L2 devices. These two events are
serialised by the dev->lock mutex but the order that they happen in is
undefined. But this has always been the case anyway.

Signed-off-by: Chris Rankin <rankincj@yahoo.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Chris Rankin authored and Mauro Carvalho Chehab committed Sep 26, 2011
1 parent f055815 commit 778f295
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/media/video/em28xx/em28xx-cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -3005,10 +3005,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
goto fail;
}

mutex_unlock(&dev->lock);
em28xx_init_extension(dev);
mutex_lock(&dev->lock);

/* Save some power by putting tuner to sleep */
v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0);

Expand Down Expand Up @@ -3243,6 +3239,13 @@ static int em28xx_usb_probe(struct usb_interface *interface,
*/
mutex_unlock(&dev->lock);

/*
* These extensions can be modules. If the modules are already
* loaded then we can initialise the device now, otherwise we
* will initialise it when the modules load instead.
*/
em28xx_init_extension(dev);

return 0;

err:
Expand Down

0 comments on commit 778f295

Please sign in to comment.