Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1289988
| From | Javier Martinez Canillas <javier@osg.samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v5 1/3] [media] media-device: check before unregister if mdev was registered |
| Date | 2015-12-12 00:00 +0100 |
| Message-ID | <qEEPo-2db-11@gated-at.bofh.it> (permalink) |
| References | <qEEPo-2db-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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>
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- Reword the documentation for media_device_unregister(). Suggested by Sakari.
- Added Sakari's Acked-by tag for patch #1.
drivers/media/media-device.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index c12481c753a0..11c1c7383361 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -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);
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v5 0/3] [media] Fix race between graph enumeration and entities registration Javier Martinez Canillas <javier@osg.samsung.com> - 2015-12-12 00:00 +0100
[PATCH v5 3/3] [media] media-device: set topology version 0 at media registration Javier Martinez Canillas <javier@osg.samsung.com> - 2015-12-12 00:00 +0100
[PATCH v5 1/3] [media] media-device: check before unregister if mdev was registered Javier Martinez Canillas <javier@osg.samsung.com> - 2015-12-12 00:00 +0100
Re: [PATCH v5 1/3] [media] media-device: check before unregister if mdev was registered Shuah Khan <shuahkh@osg.samsung.com> - 2015-12-12 00:40 +0100
Re: [PATCH v5 1/3] [media] media-device: check before unregister if mdev was registered Mauro Carvalho Chehab <mchehab@osg.samsung.com> - 2015-12-15 11:50 +0100
Re: [PATCH v5 1/3] [media] media-device: check before unregister if mdev was registered Javier Martinez Canillas <javier@osg.samsung.com> - 2015-12-21 13:20 +0100
[PATCH v5 2/3] [media] media-device: split media initialization and registration Javier Martinez Canillas <javier@osg.samsung.com> - 2015-12-12 00:00 +0100
Re: [PATCH v5 0/3] [media] Fix race between graph enumeration and entities registration Mauro Carvalho Chehab <mchehab@osg.samsung.com> - 2015-12-12 15:00 +0100
Re: [PATCH v5 0/3] [media] Fix race between graph enumeration and entities registration Javier Martinez Canillas <javier@osg.samsung.com> - 2015-12-21 12:30 +0100
csiph-web