diff mbox

[RFC,v2,1/4] media: i2c: adv7343: add support for asynchronous probing

Message ID 1366625848-743-2-git-send-email-prabhakar.csengg@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lad, Prabhakar April 22, 2013, 10:17 a.m. UTC
From: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Both synchronous and asynchronous adv7343 subdevice probing is supported by
this patch.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Sakari Ailus <sakari.ailus@iki.fi>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/i2c/adv7343.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

Comments

Guennadi Liakhovetski April 22, 2013, 10:38 a.m. UTC | #1
Hi Prabhakar

On Mon, 22 Apr 2013, Prabhakar Lad wrote:

> From: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> 
> Both synchronous and asynchronous adv7343 subdevice probing is supported by
> this patch.
> 
> Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Hans Verkuil <hverkuil@xs4all.nl>
> Cc: Sakari Ailus <sakari.ailus@iki.fi>
> Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
> ---
>  drivers/media/i2c/adv7343.c |   17 +++++++++++++----
>  1 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
> index 9fc2b98..5b1417b 100644
> --- a/drivers/media/i2c/adv7343.c
> +++ b/drivers/media/i2c/adv7343.c
> @@ -27,6 +27,7 @@
>  #include <linux/uaccess.h>
>  
>  #include <media/adv7343.h>
> +#include <media/v4l2-async.h>
>  #include <media/v4l2-device.h>
>  #include <media/v4l2-chip-ident.h>
>  #include <media/v4l2-ctrls.h>
> @@ -44,6 +45,7 @@ struct adv7343_state {
>  	struct v4l2_subdev sd;
>  	struct v4l2_ctrl_handler hdl;
>  	const struct adv7343_platform_data *pdata;
> +	struct v4l2_async_subdev_list	asdl;

Do you still need this? Don't think it's needed any more with the latest 
V4L2-async version.

Thanks
Guennadi

>  	u8 reg00;
>  	u8 reg01;
>  	u8 reg02;
> @@ -455,16 +457,22 @@ static int adv7343_probe(struct i2c_client *client,
>  				       ADV7343_GAIN_DEF);
>  	state->sd.ctrl_handler = &state->hdl;
>  	if (state->hdl.error) {
> -		int err = state->hdl.error;
> -
> -		v4l2_ctrl_handler_free(&state->hdl);
> -		return err;
> +		err = state->hdl.error;
> +		goto done;
>  	}
>  	v4l2_ctrl_handler_setup(&state->hdl);
>  
>  	err = adv7343_initialize(&state->sd);
>  	if (err)
> +		goto done;
> +
> +	state->sd.dev = &client->dev;
> +	err = v4l2_async_register_subdev(&state->sd);
> +
> +done:
> +	if (err < 0)
>  		v4l2_ctrl_handler_free(&state->hdl);
> +
>  	return err;
>  }
>  
> @@ -473,6 +481,7 @@ static int adv7343_remove(struct i2c_client *client)
>  	struct v4l2_subdev *sd = i2c_get_clientdata(client);
>  	struct adv7343_state *state = to_state(sd);
>  
> +	v4l2_async_unregister_subdev(&state->sd);
>  	v4l2_device_unregister_subdev(sd);
>  	v4l2_ctrl_handler_free(&state->hdl);
>  
> -- 
> 1.7.4.1
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
Lad, Prabhakar April 22, 2013, 10:41 a.m. UTC | #2
Hi Guennadi,

Thanks for the quick review.

On Mon, Apr 22, 2013 at 4:08 PM, Guennadi Liakhovetski
<g.liakhovetski@gmx.de> wrote:
> Hi Prabhakar
>
> On Mon, 22 Apr 2013, Prabhakar Lad wrote:
>
>> From: Lad, Prabhakar <prabhakar.csengg@gmail.com>
>>
>> Both synchronous and asynchronous adv7343 subdevice probing is supported by
>> this patch.
>>
>> Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
>> Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> Cc: Hans Verkuil <hverkuil@xs4all.nl>
>> Cc: Sakari Ailus <sakari.ailus@iki.fi>
>> Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
>> ---
>>  drivers/media/i2c/adv7343.c |   17 +++++++++++++----
>>  1 files changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
>> index 9fc2b98..5b1417b 100644
>> --- a/drivers/media/i2c/adv7343.c
>> +++ b/drivers/media/i2c/adv7343.c
>> @@ -27,6 +27,7 @@
>>  #include <linux/uaccess.h>
>>
>>  #include <media/adv7343.h>
>> +#include <media/v4l2-async.h>
>>  #include <media/v4l2-device.h>
>>  #include <media/v4l2-chip-ident.h>
>>  #include <media/v4l2-ctrls.h>
>> @@ -44,6 +45,7 @@ struct adv7343_state {
>>       struct v4l2_subdev sd;
>>       struct v4l2_ctrl_handler hdl;
>>       const struct adv7343_platform_data *pdata;
>> +     struct v4l2_async_subdev_list   asdl;
>
> Do you still need this? Don't think it's needed any more with the latest
> V4L2-async version.
>
Yes not required missed to remove :)

Regards,
--Prabhakar

> Thanks
> Guennadi
>
>>       u8 reg00;
>>       u8 reg01;
>>       u8 reg02;
>> @@ -455,16 +457,22 @@ static int adv7343_probe(struct i2c_client *client,
>>                                      ADV7343_GAIN_DEF);
>>       state->sd.ctrl_handler = &state->hdl;
>>       if (state->hdl.error) {
>> -             int err = state->hdl.error;
>> -
>> -             v4l2_ctrl_handler_free(&state->hdl);
>> -             return err;
>> +             err = state->hdl.error;
>> +             goto done;
>>       }
>>       v4l2_ctrl_handler_setup(&state->hdl);
>>
>>       err = adv7343_initialize(&state->sd);
>>       if (err)
>> +             goto done;
>> +
>> +     state->sd.dev = &client->dev;
>> +     err = v4l2_async_register_subdev(&state->sd);
>> +
>> +done:
>> +     if (err < 0)
>>               v4l2_ctrl_handler_free(&state->hdl);
>> +
>>       return err;
>>  }
>>
>> @@ -473,6 +481,7 @@ static int adv7343_remove(struct i2c_client *client)
>>       struct v4l2_subdev *sd = i2c_get_clientdata(client);
>>       struct adv7343_state *state = to_state(sd);
>>
>> +     v4l2_async_unregister_subdev(&state->sd);
>>       v4l2_device_unregister_subdev(sd);
>>       v4l2_ctrl_handler_free(&state->hdl);
>>
>> --
>> 1.7.4.1
>>
>
> ---
> Guennadi Liakhovetski, Ph.D.
> Freelance Open-Source Software Developer
> http://www.open-technology.de/
diff mbox

Patch

diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
index 9fc2b98..5b1417b 100644
--- a/drivers/media/i2c/adv7343.c
+++ b/drivers/media/i2c/adv7343.c
@@ -27,6 +27,7 @@ 
 #include <linux/uaccess.h>
 
 #include <media/adv7343.h>
+#include <media/v4l2-async.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
 #include <media/v4l2-ctrls.h>
@@ -44,6 +45,7 @@  struct adv7343_state {
 	struct v4l2_subdev sd;
 	struct v4l2_ctrl_handler hdl;
 	const struct adv7343_platform_data *pdata;
+	struct v4l2_async_subdev_list	asdl;
 	u8 reg00;
 	u8 reg01;
 	u8 reg02;
@@ -455,16 +457,22 @@  static int adv7343_probe(struct i2c_client *client,
 				       ADV7343_GAIN_DEF);
 	state->sd.ctrl_handler = &state->hdl;
 	if (state->hdl.error) {
-		int err = state->hdl.error;
-
-		v4l2_ctrl_handler_free(&state->hdl);
-		return err;
+		err = state->hdl.error;
+		goto done;
 	}
 	v4l2_ctrl_handler_setup(&state->hdl);
 
 	err = adv7343_initialize(&state->sd);
 	if (err)
+		goto done;
+
+	state->sd.dev = &client->dev;
+	err = v4l2_async_register_subdev(&state->sd);
+
+done:
+	if (err < 0)
 		v4l2_ctrl_handler_free(&state->hdl);
+
 	return err;
 }
 
@@ -473,6 +481,7 @@  static int adv7343_remove(struct i2c_client *client)
 	struct v4l2_subdev *sd = i2c_get_clientdata(client);
 	struct adv7343_state *state = to_state(sd);
 
+	v4l2_async_unregister_subdev(&state->sd);
 	v4l2_device_unregister_subdev(sd);
 	v4l2_ctrl_handler_free(&state->hdl);