mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
[media] media-device: check before unregister if mdev was registered
Most media functions that unregister, check if the corresponding register function succeed before. So these functions can safely be called even if a registration was never made or the component as already been unregistered. Add the same check to media_device_unregister() function for consistency. This will also allow to split the media_device_register() function in an initialization and registration functions without the need to change the generic cleanup functions and error code paths for all the media drivers. 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>
This commit is contained in:
parent
cc4a82581c
commit
223d19c566
1 changed files with 6 additions and 0 deletions
|
@ -577,6 +577,8 @@ EXPORT_SYMBOL_GPL(__media_device_register);
|
|||
* media_device_unregister - unregister a media device
|
||||
* @mdev: The media device
|
||||
*
|
||||
* It is safe to call this function on an unregistered
|
||||
* (but initialised) media device.
|
||||
*/
|
||||
void media_device_unregister(struct media_device *mdev)
|
||||
{
|
||||
|
@ -584,6 +586,10 @@ void media_device_unregister(struct media_device *mdev)
|
|||
struct media_entity *next;
|
||||
struct media_interface *intf, *tmp_intf;
|
||||
|
||||
/* Check if mdev was ever registered at all */
|
||||
if (!media_devnode_is_registered(&mdev->devnode))
|
||||
return;
|
||||
|
||||
/* Remove all entities from the media device */
|
||||
list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list)
|
||||
media_device_unregister_entity(entity);
|
||||
|
|
Loading…
Reference in a new issue