LinuxTV Patchwork [PATCHv4,7/9] vimc: zero the media_device on probe

login
register
mail settings
Submitter Hans Verkuil
Date March 8, 2019, 1:56 p.m.
Message ID <20190308135625.11278-8-hverkuil-cisco@xs4all.nl>
Download mbox | patch
Permalink /patch/54961/
State Accepted
Delegated to: Hans Verkuil
Headers show

Comments

Hans Verkuil - March 8, 2019, 1:56 p.m.
The media_device is part of a static global vimc_device struct.
The media framework expects this to be zeroed before it is
used, however, since this is a global this is not the case if
vimc is unbound and then bound again.

So call memset to ensure any left-over values are cleared.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/platform/vimc/vimc-core.c | 2 ++
 1 file changed, 2 insertions(+)
Laurent Pinchart - March 8, 2019, 2:09 p.m.
Hi Hans,

Thank you for the patch.

On Fri, Mar 08, 2019 at 02:56:23PM +0100, Hans Verkuil wrote:
> The media_device is part of a static global vimc_device struct.
> The media framework expects this to be zeroed before it is
> used, however, since this is a global this is not the case if
> vimc is unbound and then bound again.
> 
> So call memset to ensure any left-over values are cleared.
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Do I recall correctly that you mentioned there's work in progress that
will allocate this dynamically ? If so feel free to mention it in the
commit message if you want.

> ---
>  drivers/media/platform/vimc/vimc-core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
> index 0fbb7914098f..3aa62d7e3d0e 100644
> --- a/drivers/media/platform/vimc/vimc-core.c
> +++ b/drivers/media/platform/vimc/vimc-core.c
> @@ -304,6 +304,8 @@ static int vimc_probe(struct platform_device *pdev)
>  
>  	dev_dbg(&pdev->dev, "probe");
>  
> +	memset(&vimc->mdev, 0, sizeof(vimc->mdev));
> +
>  	/* Create platform_device for each entity in the topology*/
>  	vimc->subdevs = devm_kcalloc(&vimc->pdev.dev, vimc->pipe_cfg->num_ents,
>  				     sizeof(*vimc->subdevs), GFP_KERNEL);
Hans Verkuil - March 8, 2019, 2:13 p.m.
On 3/8/19 3:09 PM, Laurent Pinchart wrote:
> Hi Hans,
> 
> Thank you for the patch.
> 
> On Fri, Mar 08, 2019 at 02:56:23PM +0100, Hans Verkuil wrote:
>> The media_device is part of a static global vimc_device struct.
>> The media framework expects this to be zeroed before it is
>> used, however, since this is a global this is not the case if
>> vimc is unbound and then bound again.
>>
>> So call memset to ensure any left-over values are cleared.
>>
>> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Do I recall correctly that you mentioned there's work in progress that
> will allocate this dynamically ? If so feel free to mention it in the
> commit message if you want.

There is, but it might take some time before that will land (it's Helen's
patch series that converts vimc to use configfs to configure all the
subdevs and topology).

Regards,

	Hans

> 
>> ---
>>  drivers/media/platform/vimc/vimc-core.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
>> index 0fbb7914098f..3aa62d7e3d0e 100644
>> --- a/drivers/media/platform/vimc/vimc-core.c
>> +++ b/drivers/media/platform/vimc/vimc-core.c
>> @@ -304,6 +304,8 @@ static int vimc_probe(struct platform_device *pdev)
>>  
>>  	dev_dbg(&pdev->dev, "probe");
>>  
>> +	memset(&vimc->mdev, 0, sizeof(vimc->mdev));
>> +
>>  	/* Create platform_device for each entity in the topology*/
>>  	vimc->subdevs = devm_kcalloc(&vimc->pdev.dev, vimc->pipe_cfg->num_ents,
>>  				     sizeof(*vimc->subdevs), GFP_KERNEL);
>

Patch

diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
index 0fbb7914098f..3aa62d7e3d0e 100644
--- a/drivers/media/platform/vimc/vimc-core.c
+++ b/drivers/media/platform/vimc/vimc-core.c
@@ -304,6 +304,8 @@  static int vimc_probe(struct platform_device *pdev)
 
 	dev_dbg(&pdev->dev, "probe");
 
+	memset(&vimc->mdev, 0, sizeof(vimc->mdev));
+
 	/* Create platform_device for each entity in the topology*/
 	vimc->subdevs = devm_kcalloc(&vimc->pdev.dev, vimc->pipe_cfg->num_ents,
 				     sizeof(*vimc->subdevs), GFP_KERNEL);

Privacy Policy