From 668773b84604926519e2baf444f382f88d799d41 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 10 Jun 2013 15:07:35 -0300 Subject: [PATCH] [media] V4L2: add a device pointer to struct v4l2_subdev 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 Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Tested-by: Lad, Prabhakar Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-common.c | 2 ++ include/media/v4l2-subdev.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 3b2a7606bc84..a95e5e23403f 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -237,6 +237,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); @@ -370,6 +371,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 21fc9e16d7be..5fbb266405f9 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -583,6 +583,8 @@ struct v4l2_subdev { void *host_priv; /* subdev device node */ struct video_device *devnode; + /* pointer to the physical device, if any */ + struct device *dev; }; #define media_entity_to_v4l2_subdev(ent) \ -- 2.39.5