[RFC,05/13] soc_camera: replace vdev->parent by vdev->v4l2_dev.

Message ID 1370252210-4994-6-git-send-email-hverkuil@xs4all.nl (mailing list archive)
State Rejected, archived
Delegated to: Guennadi Liakhovetski
Headers

Commit Message

Hans Verkuil June 3, 2013, 9:36 a.m. UTC
  From: Hans Verkuil <hans.verkuil@cisco.com>

The parent field will eventually disappear to be replaced by v4l2_dev.
soc_camera does provide a v4l2_device struct but did not point to it in
struct video_device. This is now fixed.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/media/platform/soc_camera/soc_camera.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Guennadi Liakhovetski June 7, 2013, 9:33 a.m. UTC | #1
On Mon, 3 Jun 2013, Hans Verkuil wrote:

> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> The parent field will eventually disappear to be replaced by v4l2_dev.
> soc_camera does provide a v4l2_device struct but did not point to it in
> struct video_device. This is now fixed.
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
>  drivers/media/platform/soc_camera/soc_camera.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index 96645e9..ea951ec 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -524,7 +524,7 @@ static int soc_camera_open(struct file *file)
>  		return -ENODEV;
>  	}
>  
> -	icd = dev_get_drvdata(vdev->parent);
> +	icd = dev_get_drvdata(vdev->v4l2_dev->dev);
>  	ici = to_soc_camera_host(icd->parent);
>  
>  	ret = try_module_get(ici->ops->owner) ? 0 : -ENODEV;
> @@ -1511,7 +1511,7 @@ static int video_dev_create(struct soc_camera_device *icd)
>  
>  	strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name));
>  
> -	vdev->parent		= icd->pdev;
> +	vdev->v4l2_dev		= &ici->v4l2_dev;
>  	vdev->fops		= &soc_camera_fops;
>  	vdev->ioctl_ops		= &soc_camera_ioctl_ops;
>  	vdev->release		= video_device_release;

Doesn't it break soc-camera?... I think those are 2 absolutely different 
devices, so, you're not getting icd from 
dev_get_drvdata(vdev->v4l2_dev->dev).

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Hans Verkuil June 7, 2013, 9:41 a.m. UTC | #2
On Fri June 7 2013 11:33:16 Guennadi Liakhovetski wrote:
> On Mon, 3 Jun 2013, Hans Verkuil wrote:
> 
> > From: Hans Verkuil <hans.verkuil@cisco.com>
> > 
> > The parent field will eventually disappear to be replaced by v4l2_dev.
> > soc_camera does provide a v4l2_device struct but did not point to it in
> > struct video_device. This is now fixed.
> > 
> > Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> > Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> > ---
> >  drivers/media/platform/soc_camera/soc_camera.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> > index 96645e9..ea951ec 100644
> > --- a/drivers/media/platform/soc_camera/soc_camera.c
> > +++ b/drivers/media/platform/soc_camera/soc_camera.c
> > @@ -524,7 +524,7 @@ static int soc_camera_open(struct file *file)
> >  		return -ENODEV;
> >  	}
> >  
> > -	icd = dev_get_drvdata(vdev->parent);
> > +	icd = dev_get_drvdata(vdev->v4l2_dev->dev);
> >  	ici = to_soc_camera_host(icd->parent);
> >  
> >  	ret = try_module_get(ici->ops->owner) ? 0 : -ENODEV;
> > @@ -1511,7 +1511,7 @@ static int video_dev_create(struct soc_camera_device *icd)
> >  
> >  	strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name));
> >  
> > -	vdev->parent		= icd->pdev;
> > +	vdev->v4l2_dev		= &ici->v4l2_dev;
> >  	vdev->fops		= &soc_camera_fops;
> >  	vdev->ioctl_ops		= &soc_camera_ioctl_ops;
> >  	vdev->release		= video_device_release;
> 
> Doesn't it break soc-camera?... I think those are 2 absolutely different 
> devices, so, you're not getting icd from 
> dev_get_drvdata(vdev->v4l2_dev->dev).

I'm looking into this today. I managed to get my renesas board up and running
again yesterday, so I have a decent soc-camera test environment.

This was the one patch that I wasn't sure about, so it definitely needs more
analysis. I'll remove it from the patch series anyway, since it is unrelated
to the current_norm changes.

Regards,

	Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Hans Verkuil June 7, 2013, 10:29 a.m. UTC | #3
On Fri June 7 2013 11:41:30 Hans Verkuil wrote:
> On Fri June 7 2013 11:33:16 Guennadi Liakhovetski wrote:
> > On Mon, 3 Jun 2013, Hans Verkuil wrote:
> > 
> > > From: Hans Verkuil <hans.verkuil@cisco.com>
> > > 
> > > The parent field will eventually disappear to be replaced by v4l2_dev.
> > > soc_camera does provide a v4l2_device struct but did not point to it in
> > > struct video_device. This is now fixed.
> > > 
> > > Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> > > Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> > > ---
> > >  drivers/media/platform/soc_camera/soc_camera.c |    4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> > > index 96645e9..ea951ec 100644
> > > --- a/drivers/media/platform/soc_camera/soc_camera.c
> > > +++ b/drivers/media/platform/soc_camera/soc_camera.c
> > > @@ -524,7 +524,7 @@ static int soc_camera_open(struct file *file)
> > >  		return -ENODEV;
> > >  	}
> > >  
> > > -	icd = dev_get_drvdata(vdev->parent);
> > > +	icd = dev_get_drvdata(vdev->v4l2_dev->dev);
> > >  	ici = to_soc_camera_host(icd->parent);
> > >  
> > >  	ret = try_module_get(ici->ops->owner) ? 0 : -ENODEV;
> > > @@ -1511,7 +1511,7 @@ static int video_dev_create(struct soc_camera_device *icd)
> > >  
> > >  	strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name));
> > >  
> > > -	vdev->parent		= icd->pdev;
> > > +	vdev->v4l2_dev		= &ici->v4l2_dev;
> > >  	vdev->fops		= &soc_camera_fops;
> > >  	vdev->ioctl_ops		= &soc_camera_ioctl_ops;
> > >  	vdev->release		= video_device_release;
> > 
> > Doesn't it break soc-camera?... I think those are 2 absolutely different 
> > devices, so, you're not getting icd from 
> > dev_get_drvdata(vdev->v4l2_dev->dev).
> 
> I'm looking into this today. I managed to get my renesas board up and running
> again yesterday, so I have a decent soc-camera test environment.
> 
> This was the one patch that I wasn't sure about, so it definitely needs more
> analysis. I'll remove it from the patch series anyway, since it is unrelated
> to the current_norm changes.

Yes, it breaks soc_camera. I have a proper fix for this, but I'm postponing
this.

Stupid question perhaps, but why is soc_camera_device a platform_device?
It's weird. The camera host device is definitely a platform_device, and
the video nodes are childs of that platform_device, but soc_camera_device
doesn't map to any hardware.

Regards,

	Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Guennadi Liakhovetski June 7, 2013, 10:49 a.m. UTC | #4
On Fri, 7 Jun 2013, Hans Verkuil wrote:

> Stupid question perhaps, but why is soc_camera_device a platform_device?

Partially that's historic.

> It's weird. The camera host device is definitely a platform_device, and
> the video nodes are childs of that platform_device, but soc_camera_device
> doesn't map to any hardware.

Using platform devices for camera sensors etc. is a way to inform the 
soc-camera core about them. Soc-camera core registers a platform driver, 
which probes those devices, and then, once soc-camera hosts register with 
the soc-camera core, they are matched against those platform devices. Yes, 
this could also be done differently - hosts could just pass lists of 
respective camera sensor descriptors, but soc-camera is currently using a 
different approach. This anyway is going to disappear once we convert to 
asynchronous probing...

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Patch

diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 96645e9..ea951ec 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -524,7 +524,7 @@  static int soc_camera_open(struct file *file)
 		return -ENODEV;
 	}
 
-	icd = dev_get_drvdata(vdev->parent);
+	icd = dev_get_drvdata(vdev->v4l2_dev->dev);
 	ici = to_soc_camera_host(icd->parent);
 
 	ret = try_module_get(ici->ops->owner) ? 0 : -ENODEV;
@@ -1511,7 +1511,7 @@  static int video_dev_create(struct soc_camera_device *icd)
 
 	strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name));
 
-	vdev->parent		= icd->pdev;
+	vdev->v4l2_dev		= &ici->v4l2_dev;
 	vdev->fops		= &soc_camera_fops;
 	vdev->ioctl_ops		= &soc_camera_ioctl_ops;
 	vdev->release		= video_device_release;