diff mbox

[v10,15/21] V4L2: add a device pointer to struct v4l2_subdev

Message ID 1370939028-8352-16-git-send-email-g.liakhovetski@gmx.de (mailing list archive)
State New, archived
Headers show

Commit Message

Guennadi Liakhovetski June 11, 2013, 8:23 a.m. UTC
It is often useful to have simple means to get from a subdevice to the
underlying physical device. This patch adds such a pointer to struct
v4l2_subdev and sets it accordingly in the I2C and SPI cases.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/media/v4l2-core/v4l2-common.c |    2 ++
 include/media/v4l2-subdev.h           |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

Comments

Lad, Prabhakar June 12, 2013, 5:16 p.m. UTC | #1
On Tue, Jun 11, 2013 at 1:53 PM, Guennadi Liakhovetski
<g.liakhovetski@gmx.de> wrote:
> It is often useful to have simple means to get from a subdevice to the
> underlying physical device. This patch adds such a pointer to struct
> v4l2_subdev and sets it accordingly in the I2C and SPI cases.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Regards,
--Prabhakar Lad
--
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 13, 2013, 10:32 a.m. UTC | #2
On Tue 11 June 2013 10:23:42 Guennadi Liakhovetski wrote:
> It is often useful to have simple means to get from a subdevice to the
> underlying physical device. This patch adds such a pointer to struct
> v4l2_subdev and sets it accordingly in the I2C and SPI cases.
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
>  drivers/media/v4l2-core/v4l2-common.c |    2 ++
>  include/media/v4l2-subdev.h           |    2 ++
>  2 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index 3fed63f..accfec6 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -291,6 +291,7 @@ void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
>  	sd->flags |= V4L2_SUBDEV_FL_IS_I2C;
>  	/* the owner is the same as the i2c_client's driver owner */
>  	sd->owner = client->driver->driver.owner;
> +	sd->dev = &client->dev;
>  	/* i2c_client and v4l2_subdev point to one another */
>  	v4l2_set_subdevdata(sd, client);
>  	i2c_set_clientdata(client, sd);
> @@ -426,6 +427,7 @@ void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
>  	sd->flags |= V4L2_SUBDEV_FL_IS_SPI;
>  	/* the owner is the same as the spi_device's driver owner */
>  	sd->owner = spi->dev.driver->owner;
> +	sd->dev = &spi->dev;
>  	/* spi_device and v4l2_subdev point to one another */
>  	v4l2_set_subdevdata(sd, spi);
>  	spi_set_drvdata(spi, sd);
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index 5298d67..d8756fa 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -585,6 +585,8 @@ struct v4l2_subdev {
>  	void *host_priv;
>  	/* subdev device node */
>  	struct video_device *devnode;
> +	/* pointer to the physical device */

Can you change this comment to:

	/* pointer to the physical device, if any */

It's a small change, but this makes it clear that it's OK to leave it to
NULL for subdevs that don't have an underlying device struct.

Thanks!

	Hans

> +	struct device *dev;
>  };
>  
>  #define media_entity_to_v4l2_subdev(ent) \
> 
--
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
diff mbox

Patch

diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index 3fed63f..accfec6 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -291,6 +291,7 @@  void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_IS_I2C;
 	/* the owner is the same as the i2c_client's driver owner */
 	sd->owner = client->driver->driver.owner;
+	sd->dev = &client->dev;
 	/* i2c_client and v4l2_subdev point to one another */
 	v4l2_set_subdevdata(sd, client);
 	i2c_set_clientdata(client, sd);
@@ -426,6 +427,7 @@  void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
 	sd->flags |= V4L2_SUBDEV_FL_IS_SPI;
 	/* the owner is the same as the spi_device's driver owner */
 	sd->owner = spi->dev.driver->owner;
+	sd->dev = &spi->dev;
 	/* spi_device and v4l2_subdev point to one another */
 	v4l2_set_subdevdata(sd, spi);
 	spi_set_drvdata(spi, sd);
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 5298d67..d8756fa 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -585,6 +585,8 @@  struct v4l2_subdev {
 	void *host_priv;
 	/* subdev device node */
 	struct video_device *devnode;
+	/* pointer to the physical device */
+	struct device *dev;
 };
 
 #define media_entity_to_v4l2_subdev(ent) \