Hi Sakari, Thank you for the patch. On Wed, Dec 20, 2023 at 12:36:58PM +0200, Sakari Ailus wrote: > Refactor clearing media devnode minor bit in media devnode bitmap. Note > that number is used instead of struct media_devnode as argument since the > minor number will also be stored in a different structure soon. > > Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@xxxxxxxxxxxxxxxx> > --- > drivers/media/mc/mc-devnode.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) > > diff --git a/drivers/media/mc/mc-devnode.c b/drivers/media/mc/mc-devnode.c > index 7b17419050fb..717408791a7c 100644 > --- a/drivers/media/mc/mc-devnode.c > +++ b/drivers/media/mc/mc-devnode.c > @@ -44,17 +44,22 @@ static dev_t media_dev_t; > static DEFINE_MUTEX(media_devnode_lock); > static DECLARE_BITMAP(media_devnode_nums, MEDIA_NUM_DEVICES); > > -/* Called when the last user of the media device exits. */ > -static void media_devnode_release(struct device *cd) > +static void media_devnode_free_minor(unsigned int minor) > { > - struct media_devnode *devnode = to_media_devnode(cd); > - > mutex_lock(&media_devnode_lock); > > /* Mark device node number as free */ > - clear_bit(devnode->minor, media_devnode_nums); > + clear_bit(minor, media_devnode_nums); > > mutex_unlock(&media_devnode_lock); > +} > + > +/* Called when the last user of the media device exits. */ > +static void media_devnode_release(struct device *cd) > +{ > + struct media_devnode *devnode = to_media_devnode(cd); > + > + media_devnode_free_minor(devnode->minor); > > /* Release media_devnode and perform other cleanups as needed. */ > if (devnode->release) > @@ -254,9 +259,7 @@ int __must_check media_devnode_register(struct media_devnode *devnode, > return 0; > > cdev_add_error: > - mutex_lock(&media_devnode_lock); > - clear_bit(devnode->minor, media_devnode_nums); > - mutex_unlock(&media_devnode_lock); > + media_devnode_free_minor(devnode->minor); > > return ret; > } -- Regards, Laurent Pinchart