Skip to contentSkip to conversation

media: i2c: ths7303 cleanup

PATCH In review Prabhakar Lad 4 participants 14 messages May 25, 2013 – Jun 8, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover media: i2c: ths7303 cleanup

From: Lad, Prabhakar <[email protected]>

Trivial cleanup of the driver.

Changes for v2:
1: Dropped the asynchronous probing and, OF
support patches will be handling them independently because of dependencies.
2: Arranged the patches logically so that git bisect
succeeds.

Lad, Prabhakar (4):
ARM: davinci: dm365 evm: remove init_enable from ths7303 pdata
media: i2c: ths7303: remove init_enable option from pdata
media: i2c: ths7303: remove unnecessary function ths7303_setup()
media: i2c: ths7303: make the pdata as a constant pointer

 arch/arm/mach-davinci/board-dm365-evm.c |    1 -
 drivers/media/i2c/ths7303.c             |   48 ++++++++-----------------------
 include/media/ths7303.h                 |    2 -
 3 files changed, 12 insertions(+), 39 deletions(-)
#1 lore raw

PATCH v2 1/4 ARM: davinci: dm365 evm: remove init_enable from ths7303 pdata

From: Lad, Prabhakar <[email protected]>

remove init_enable from ths7303 pdata as it is being dropped from ths7303_platform_data.

Cc Sekhar Nori <[email protected]>
Cc Hans Verkuil <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
---
 arch/arm/mach-davinci/board-dm365-evm.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
arch/arm/mach-davinci/board-dm365-evm.c +0 -1
index fd38c8d..afbc439 100644
@@ -509,7 +509,6 @@ struct ths7303_platform_data ths7303_pdata = {
 	.ch_1 = 3,
 	.ch_2 = 3,
 	.ch_3 = 3,
-	.init_enable = 1,
 };
 
 static struct amp_config_info vpbe_amp = {
Signature · 1 line
1.7.0.4
#7 lore raw

PATCH v2 2/4 media: i2c: ths7303: remove init_enable option from pdata

In reply to Prabhakar Lad

From: Lad, Prabhakar <[email protected]>

This patch removes init_enable option from pdata, the init_enable was intended that the device should start streaming video immediately but ideally the bridge drivers should call s_stream explicitly for such devices to start video.

Cc Hans Verkuil <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
---
 drivers/media/i2c/ths7303.c |    4 +---
 include/media/ths7303.h     |    2 --
 2 files changed, 1 insertions(+), 5 deletions(-)
drivers/media/i2c/ths7303.c +1 -3
index 65853ee..8cddcd0 100644
@@ -356,9 +356,7 @@ static int ths7303_setup(struct v4l2_subdev *sd)
 	int ret;
 	u8 mask;
 
-	state->stream_on = pdata->init_enable;
-
-	mask = state->stream_on ? 0xff : 0xf8;
+	mask = 0xf8;
 
 	ret = ths7303_write(sd, THS7303_CHANNEL_1, pdata->ch_1 & mask);
 	if (ret)
include/media/ths7303.h +0 -2
index 980ec51..a7b4929 100644
@@ -30,13 +30,11 @@
  * @ch_1: Bias value for channel one.
  * @ch_2: Bias value for channel two.
  * @ch_3: Bias value for channel three.
- * @init_enable: initalize on init.
  */
 struct ths7303_platform_data {
 	u8 ch_1;
 	u8 ch_2;
 	u8 ch_3;
-	u8 init_enable;
 };
 
 #endif
Signature · 1 line
1.7.0.4
#8 lore raw

PATCH v2 3/4 media: i2c: ths7303: remove unnecessary function ths7303_setup()

In reply to Prabhakar Lad

From: Lad, Prabhakar <[email protected]>

the ths7303_setup() was doing the same thing as ths7303_setval() except that ths7303_setval() sets it to some particular mode. This patch removes ths7303_setup() function and calls ths7303_setval() in the probe setting the device to 480I_576I filter mode in the probe.

Cc Hans Verkuil <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
---
 drivers/media/i2c/ths7303.c |   31 ++++---------------------------
 1 files changed, 4 insertions(+), 27 deletions(-)
drivers/media/i2c/ths7303.c +4 -27
index 8cddcd0..af06187 100644
@@ -349,30 +349,6 @@ static const struct v4l2_subdev_ops ths7303_ops = {
 	.video 	= &ths7303_video_ops,
 };
 
-static int ths7303_setup(struct v4l2_subdev *sd)
-{
-	struct ths7303_state *state = to_state(sd);
-	struct ths7303_platform_data *pdata = &state->pdata;
-	int ret;
-	u8 mask;
-
-	mask = 0xf8;
-
-	ret = ths7303_write(sd, THS7303_CHANNEL_1, pdata->ch_1 & mask);
-	if (ret)
-		return ret;
-
-	ret = ths7303_write(sd, THS7303_CHANNEL_2, pdata->ch_2 & mask);
-	if (ret)
-		return ret;
-
-	ret = ths7303_write(sd, THS7303_CHANNEL_3, pdata->ch_3 & mask);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
 static int ths7303_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
@@ -402,9 +378,10 @@ static int ths7303_probe(struct i2c_client *client,
 	/* store the driver data to differntiate the chip */
 	state->driver_data = (int)id->driver_data;
 
-	if (ths7303_setup(sd) < 0) {
-		v4l_err(client, "init failed\n");
-		return -EIO;
+	/* set to default 480I_576I filter mode */
+	if (ths7303_setval(sd, THS7303_FILTER_MODE_480I_576I) < 0) {
+		v4l_err(client, "Setting to 480I_576I filter mode failed!\n");
+		return -EINVAL;
 	}
 
 	return 0;
Signature · 1 line
1.7.0.4
#9 lore raw

PATCH v2 4/4 media: i2c: ths7303: make the pdata as a constant pointer

In reply to Prabhakar Lad

From: Lad, Prabhakar <[email protected]>

generally the pdata needs to be a constant pointer in the device state structure. This patch makes the pdata as a constant pointer and alongside returns -EINVAL when pdata is NULL.

Cc Hans Verkuil <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
---
 drivers/media/i2c/ths7303.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
drivers/media/i2c/ths7303.c +8 -7
index af06187..b954195 100644
@@ -35,7 +35,7 @@
 
 struct ths7303_state {
 	struct v4l2_subdev		sd;
-	struct ths7303_platform_data	pdata;
+	const struct ths7303_platform_data *pdata;
 	struct v4l2_bt_timings		bt;
 	int std_id;
 	int stream_on;
@@ -89,7 +89,7 @@ int ths7303_setval(struct v4l2_subdev *sd, enum ths7303_filter_mode mode)
 {
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
 	struct ths7303_state *state = to_state(sd);
-	struct ths7303_platform_data *pdata = &state->pdata;
+	const struct ths7303_platform_data *pdata = state->pdata;
 	u8 val, sel = 0;
 	int err, disable = 0;
 
@@ -356,6 +356,11 @@ static int ths7303_probe(struct i2c_client *client,
 	struct ths7303_state *state;
 	struct v4l2_subdev *sd;
 
+	if (pdata == NULL) {
+		dev_err(&client->dev, "No platform data\n");
+		return -EINVAL;
+	}
+
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
 		return -ENODEV;
 
@@ -367,11 +372,7 @@ static int ths7303_probe(struct i2c_client *client,
 	if (!state)
 		return -ENOMEM;
 
-	if (!pdata)
-		v4l_warn(client, "No platform data, using default data!\n");
-	else
-		state->pdata = *pdata;
-
+	state->pdata = pdata;
 	sd = &state->sd;
 	v4l2_i2c_subdev_init(sd, client, &ths7303_ops);
 
Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH v2 1/4] ARM: davinci: dm365 evm: remove init_enable from ths7303 pdata

In reply to Prabhakar Lad

Hi Sekhar,

Quoted 5 lines · Prabhakar Lad

From: Lad, Prabhakar <[email protected]>

remove init_enable from ths7303 pdata as it is being dropped from ths7303_platform_data.

Can you please ack this patch as I intend to take this patch via media tree.

Regards,
--Prabhakar Lad

Acked-by on the v2 series
#10 lore raw
In reply to Prabhakar Lad
Quoted 16 lines · On Saturday 25 May 2013 23:09:32 Prabhakar Lad wrote:

From: Lad, Prabhakar <[email protected]>

Trivial cleanup of the driver.

Changes for v2:
1: Dropped the asynchronous probing and, OF
support patches will be handling them independently because of
dependencies. 2: Arranged the patches logically so that git bisect
succeeds.

Lad, Prabhakar (4):
ARM: davinci: dm365 evm: remove init_enable from ths7303 pdata
media: i2c: ths7303: remove init_enable option from pdata
media: i2c: ths7303: remove unnecessary function ths7303_setup()
media: i2c: ths7303: make the pdata as a constant pointer

Quoted 4 lines
 arch/arm/mach-davinci/board-dm365-evm.c |    1 -
 drivers/media/i2c/ths7303.c             |   48 ++++++++--------------------
 include/media/ths7303.h                 |    2 -
 3 files changed, 12 insertions(+), 39 deletions(-)

For the whole series,

Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

Re: [PATCH v2 1/4] ARM: davinci: dm365 evm: remove init_enable from ths7303 pdata

In reply to Prabhakar Lad

Hi Sekhar,

Quoted 11 lines · Prabhakar Lad

Hi Sekhar,

Quoted 5 lines · Prabhakar Lad

From: Lad, Prabhakar <[email protected]>

remove init_enable from ths7303 pdata as it is being dropped from ths7303_platform_data.

Can you please ack this patch as I intend to take this patch via media tree.

gentle ping.

Regards,
--Prabhakar

Acked-by on v2 1/4
#4 lore raw

Re: [PATCH v2 1/4] ARM: davinci: dm365 evm: remove init_enable from ths7303 pdata

In reply to Prabhakar Lad
Quoted 5 lines · Prabhakar Lad

From: Lad, Prabhakar <[email protected]>

remove init_enable from ths7303 pdata as it is being dropped from ths7303_platform_data.

Quoted 7 lines
Cc Sekhar Nori <[email protected]>
Cc Hans Verkuil <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>

I would prefer this be squashed into 2/4 but I leave it to you.

Thanks,
Sekhar

#5 lore raw

Re: [PATCH v2 1/4] ARM: davinci: dm365 evm: remove init_enable from ths7303 pdata

Hi Sekhar,

Quoted 14 lines · Sekhar Nori
Quoted 5 lines · Prabhakar Lad

From: Lad, Prabhakar <[email protected]>

remove init_enable from ths7303 pdata as it is being dropped from ths7303_platform_data.

Quoted 7 lines
Cc Sekhar Nori <[email protected]>
Cc Hans Verkuil <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Quoted 2 lines

Thanks for the ack.

Quoted 2 lines

I would prefer this be squashed into 2/4 but I leave it to you.

I would like to go as is :)

Regards,
--Prabhakar Lad

#11 lore raw
In reply to Laurent Pinchart

Hi Hans,

Quoted 11 lines · Laurent Pinchart
Quoted 10 lines · On Saturday 25 May 2013 23:09:32 Prabhakar Lad wrote:

From: Lad, Prabhakar <[email protected]>

Trivial cleanup of the driver.

Changes for v2:
1: Dropped the asynchronous probing and, OF
support patches will be handling them independently because of
dependencies. 2: Arranged the patches logically so that git bisect
succeeds.

Quoted 6 lines
Quoted 6 lines

Lad, Prabhakar (4):
ARM: davinci: dm365 evm: remove init_enable from ths7303 pdata
media: i2c: ths7303: remove init_enable option from pdata
media: i2c: ths7303: remove unnecessary function ths7303_setup()
media: i2c: ths7303: make the pdata as a constant pointer

Can you pick up this series or do you want me to issue a pull for it ?

Regards,
--Prabhakar Lad

#6 lore raw

Re: [PATCH v2 1/4] ARM: davinci: dm365 evm: remove init_enable from ths7303 pdata

In reply to Prabhakar Lad
Quoted 17 lines · Prabhakar Lad

Hi Sekhar,

Quoted 14 lines · Sekhar Nori
Quoted 12 lines · Prabhakar Lad

From: Lad, Prabhakar <[email protected]>

remove init_enable from ths7303 pdata as it is being dropped from ths7303_platform_data.

Cc Sekhar Nori <[email protected]>
Cc Hans Verkuil <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Quoted 7 lines
Quoted 2 lines

Thanks for the ack.

Quoted 2 lines

I would prefer this be squashed into 2/4 but I leave it to you.

I would like to go as is :)

If you go this path, then may be repeat some of the explanation of why init_enable is not needed from 2/4 here as well. Without that the description above makes little sense.

Thanks,
Sekhar

#12 lore raw
In reply to Prabhakar Lad
Quoted 15 lines · On Thu June 6 2013 12:05:38 Prabhakar Lad wrote:

Hi Hans,

Quoted 11 lines · Laurent Pinchart
Quoted 10 lines · On Saturday 25 May 2013 23:09:32 Prabhakar Lad wrote:

From: Lad, Prabhakar <[email protected]>

Trivial cleanup of the driver.

Changes for v2:
1: Dropped the asynchronous probing and, OF
support patches will be handling them independently because of
dependencies. 2: Arranged the patches logically so that git bisect
succeeds.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

Lad, Prabhakar (4):
ARM: davinci: dm365 evm: remove init_enable from ths7303 pdata
media: i2c: ths7303: remove init_enable option from pdata
media: i2c: ths7303: remove unnecessary function ths7303_setup()
media: i2c: ths7303: make the pdata as a constant pointer

Can you pick up this series or do you want me to issue a pull for it ?

I've picked it up. I kept the dm365 patch separate, but I did improve the commit log a bit.

Regards,

Hans

#13 lore raw

Hi Hans,

Quoted 22 lines · Hans Verkuil
Quoted 21 lines · On Thu June 6 2013 12:05:38 Prabhakar Lad wrote:

Hi Hans,

Quoted 17 lines · Laurent Pinchart
Quoted 16 lines · On Saturday 25 May 2013 23:09:32 Prabhakar Lad wrote:

From: Lad, Prabhakar <[email protected]>

Trivial cleanup of the driver.

Changes for v2:
1: Dropped the asynchronous probing and, OF
support patches will be handling them independently because of
dependencies. 2: Arranged the patches logically so that git bisect
succeeds.

Lad, Prabhakar (4):
ARM: davinci: dm365 evm: remove init_enable from ths7303 pdata
media: i2c: ths7303: remove init_enable option from pdata
media: i2c: ths7303: remove unnecessary function ths7303_setup()
media: i2c: ths7303: make the pdata as a constant pointer

Quoted 5 lines
Quoted 1 line

Can you pick up this series or do you want me to issue a pull for it ?

I've picked it up. I kept the dm365 patch separate, but I did improve the commit log a bit.

Thanks for fixing it.

Regards,
--Prabhakar Lad