aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/siano
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javier@osg.samsung.com>2015-12-11 17:57:08 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-01-11 09:19:15 -0500
commit9832e155f1ed3030fdfaa19e72c06472dc2ecb1d (patch)
treefe787b9bd8804b7094ba797897e77ed60077a5e3 /drivers/media/usb/siano
parent821ed3662913faca0653c201fa9e36fbab81f17c (diff)
[media] media-device: split media initialization and registration
The media device node is registered and so made visible to user-space before entities are registered and links created which means that the media graph obtained by user-space could be only partially enumerated if that happens too early before all the graph has been created. To avoid this race condition, split the media init and registration in separate functions and only register the media device node when all the pending subdevices have been registered, either explicitly by the driver or asynchronously using v4l2_async_register_subdev(). The media_device_register() had a check for drivers not filling dev and model fields but all drivers in mainline set them and not doing it will be a driver bug so change the function return to void and add a BUG_ON() for dev being NULL instead. Also, add a media_device_cleanup() function that will destroy the graph_mutex that is initialized in media_device_init(). [mchehab@osg.samsung.com: Fix compilation if !CONFIG_MEDIA_CONTROLLER and remove two warnings added by this changeset] Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/usb/siano')
-rw-r--r--drivers/media/usb/siano/smsusb.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index c945e4c2fbd4..8abbd3cc8eba 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -361,10 +361,11 @@ static void *siano_media_device_register(struct smsusb_device_t *dev,
361 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); 361 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
362 mdev->driver_version = LINUX_VERSION_CODE; 362 mdev->driver_version = LINUX_VERSION_CODE;
363 363
364 media_device_init(mdev);
365
364 ret = media_device_register(mdev); 366 ret = media_device_register(mdev);
365 if (ret) { 367 if (ret) {
366 pr_err("Couldn't create a media device. Error: %d\n", 368 media_device_cleanup(mdev);
367 ret);
368 kfree(mdev); 369 kfree(mdev);
369 return NULL; 370 return NULL;
370 } 371 }