[v4,09/26] media: mc: Delete character device early

Message ID 20240610100530.1107771-10-sakari.ailus@linux.intel.com (mailing list archive)
State New
Series Media device lifetime management |

Commit Message

Sakari Ailus June 10, 2024, 10:05 a.m. UTC
  The parent of the character device related to the media devnode is the
media devnode. Thus the character device needs to be released before the
media devnode's release function. Move it to unregistering of the media
devnode, which mirrors adding the character device in conjunction with
registering the media devnode.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
 drivers/media/mc/mc-devnode.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)


diff --git a/drivers/media/mc/mc-devnode.c b/drivers/media/mc/mc-devnode.c
index 707593d127a7..38c472498f9e 100644
--- a/drivers/media/mc/mc-devnode.c
+++ b/drivers/media/mc/mc-devnode.c
@@ -51,9 +51,6 @@  static void media_devnode_release(struct device *cd)
-	/* Delete the cdev on this minor as well */
-	cdev_del(&devnode->cdev);
 	/* Mark device node number as free */
 	clear_bit(devnode->minor, media_devnode_nums);
@@ -269,6 +266,7 @@  void media_devnode_unregister(struct media_devnode *devnode)
 	clear_bit(MEDIA_FLAG_REGISTERED, &devnode->flags);
+	cdev_del(&devnode->cdev);