Re: [PATCH v4 25/26] media: mc: Enforce one-time registration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/06/2024 12:05, Sakari Ailus wrote:
> A media devnode may be registered only once. Enforce this by setting the
> minor to -1 in init.
> 
> Registration initialises the character device and sets up the device name.
> These should take place only once during the lifetime of the media device.

This has nothing to do with patch 23/26, right?

I would move this to before that patch.

> 
> Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>

Acked-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>

Regards,

	Hans

> ---
>  drivers/media/mc/mc-devnode.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/media/mc/mc-devnode.c b/drivers/media/mc/mc-devnode.c
> index 8cb4e0eec17f..758971f310c3 100644
> --- a/drivers/media/mc/mc-devnode.c
> +++ b/drivers/media/mc/mc-devnode.c
> @@ -240,6 +240,7 @@ void media_devnode_init(struct media_devnode *devnode)
>  {
>  	device_initialize(&devnode->dev);
>  	devnode->dev.release = media_devnode_release;
> +	devnode->minor = -1;
>  }
>  
>  int __must_check media_devnode_register(struct media_devnode *devnode,
> @@ -251,6 +252,9 @@ int __must_check media_devnode_register(struct media_devnode *devnode,
>  	int minor;
>  	int ret;
>  
> +	if (devnode->minor != -1)
> +		return -EINVAL;
> +
>  	/* Part 1: Find a free minor number */
>  	mutex_lock(&media_devnode_lock);
>  	minor = find_first_zero_bit(media_devnode_nums, MEDIA_NUM_DEVICES);





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux