[media] media-device: split media initialization and registration
authorJavier Martinez Canillas <javier@osg.samsung.com>
Fri, 11 Dec 2015 22:57:08 +0000 (20:57 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 11 Jan 2016 14:19:15 +0000 (12:19 -0200)
commit9832e155f1ed3030fdfaa19e72c06472dc2ecb1d
treefe787b9bd8804b7094ba797897e77ed60077a5e3
parent821ed3662913faca0653c201fa9e36fbab81f17c
[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>
14 files changed:
drivers/media/common/siano/smsdvb-main.c
drivers/media/media-device.c
drivers/media/platform/exynos4-is/media-dev.c
drivers/media/platform/omap3isp/isp.c
drivers/media/platform/s3c-camif/camif-core.c
drivers/media/platform/vsp1/vsp1_drv.c
drivers/media/platform/xilinx/xilinx-vipp.c
drivers/media/usb/au0828/au0828-core.c
drivers/media/usb/cx231xx/cx231xx-cards.c
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
drivers/media/usb/dvb-usb/dvb-usb-dvb.c
drivers/media/usb/siano/smsusb.c
drivers/media/usb/uvc/uvc_driver.c
include/media/media-device.h