diff mbox series

[v3,7/7] imx214: Use v4l2_ctrl_new_area helper

Message ID 20190823123737.7774-7-ribalda@kernel.org (mailing list archive)
State New, archived
Headers show
Series [v3,1/7] media: add V4L2_CID_UNIT_CELL_SIZE control | expand

Commit Message

Ricardo Ribalda Delgado Aug. 23, 2019, 12:37 p.m. UTC
Instead of creating manually the V4L2_CID_UNIT_CELL_SIZE control, lets
use the helper.

Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org>
---
 drivers/media/i2c/imx214.c | 29 ++++++++---------------------
 1 file changed, 8 insertions(+), 21 deletions(-)

Comments

Jacopo Mondi Aug. 26, 2019, 7:54 a.m. UTC | #1
Hi Ricardo,

On Fri, Aug 23, 2019 at 02:37:37PM +0200, Ricardo Ribalda Delgado wrote:
> Instead of creating manually the V4L2_CID_UNIT_CELL_SIZE control, lets
> use the helper.
>

I think you should drop 4/7 and use directly the new helper here.

Thanks
  j

> Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org>
> ---
>  drivers/media/i2c/imx214.c | 29 ++++++++---------------------
>  1 file changed, 8 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c
> index cc0a013ba7da..625617d4c81a 100644
> --- a/drivers/media/i2c/imx214.c
> +++ b/drivers/media/i2c/imx214.c
> @@ -942,26 +942,6 @@ static int __maybe_unused imx214_resume(struct device *dev)
>  	return ret;
>  }
>
> -static void unit_size_init(const struct v4l2_ctrl *ctrl, u32 idx,
> -		     union v4l2_ctrl_ptr ptr)
> -{
> -	ptr.p_area->width = 1120;
> -	ptr.p_area->height = 1120;
> -}
> -
> -static const struct v4l2_ctrl_type_ops unit_size_ops = {
> -	.init = unit_size_init,
> -};
> -
> -static struct v4l2_ctrl *new_unit_size_ctrl(struct v4l2_ctrl_handler *handler)
> -{
> -	static struct v4l2_ctrl_config ctrl = {
> -		.id = V4L2_CID_UNIT_CELL_SIZE,
> -		.type_ops = &unit_size_ops,
> -	};
> -
> -	return v4l2_ctrl_new_custom(handler, &ctrl, NULL);
> -}
>  static int imx214_probe(struct i2c_client *client)
>  {
>  	struct device *dev = &client->dev;
> @@ -969,6 +949,10 @@ static int imx214_probe(struct i2c_client *client)
>  	static const s64 link_freq[] = {
>  		IMX214_DEFAULT_LINK_FREQ,
>  	};
> +	struct v4l2_area unit_size = {
> +		.width = 1120,
> +		.height = 1120,
> +	};
>  	int ret;
>
>  	ret = imx214_parse_fwnode(dev);
> @@ -1050,7 +1034,10 @@ static int imx214_probe(struct i2c_client *client)
>  					     V4L2_CID_EXPOSURE,
>  					     0, 3184, 1, 0x0c70);
>
> -	imx214->unit_size = new_unit_size_ctrl(&imx214->ctrls);
> +	imx214->unit_size = v4l2_ctrl_new_area(&imx214->ctrls,
> +					       &imx214_ctrl_ops,
> +					       V4L2_CID_UNIT_CELL_SIZE,
> +					       &unit_size);
>
>  	ret = imx214->ctrls.error;
>  	if (ret) {
> --
> 2.23.0.rc1
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c
index cc0a013ba7da..625617d4c81a 100644
--- a/drivers/media/i2c/imx214.c
+++ b/drivers/media/i2c/imx214.c
@@ -942,26 +942,6 @@  static int __maybe_unused imx214_resume(struct device *dev)
 	return ret;
 }
 
-static void unit_size_init(const struct v4l2_ctrl *ctrl, u32 idx,
-		     union v4l2_ctrl_ptr ptr)
-{
-	ptr.p_area->width = 1120;
-	ptr.p_area->height = 1120;
-}
-
-static const struct v4l2_ctrl_type_ops unit_size_ops = {
-	.init = unit_size_init,
-};
-
-static struct v4l2_ctrl *new_unit_size_ctrl(struct v4l2_ctrl_handler *handler)
-{
-	static struct v4l2_ctrl_config ctrl = {
-		.id = V4L2_CID_UNIT_CELL_SIZE,
-		.type_ops = &unit_size_ops,
-	};
-
-	return v4l2_ctrl_new_custom(handler, &ctrl, NULL);
-}
 static int imx214_probe(struct i2c_client *client)
 {
 	struct device *dev = &client->dev;
@@ -969,6 +949,10 @@  static int imx214_probe(struct i2c_client *client)
 	static const s64 link_freq[] = {
 		IMX214_DEFAULT_LINK_FREQ,
 	};
+	struct v4l2_area unit_size = {
+		.width = 1120,
+		.height = 1120,
+	};
 	int ret;
 
 	ret = imx214_parse_fwnode(dev);
@@ -1050,7 +1034,10 @@  static int imx214_probe(struct i2c_client *client)
 					     V4L2_CID_EXPOSURE,
 					     0, 3184, 1, 0x0c70);
 
-	imx214->unit_size = new_unit_size_ctrl(&imx214->ctrls);
+	imx214->unit_size = v4l2_ctrl_new_area(&imx214->ctrls,
+					       &imx214_ctrl_ops,
+					       V4L2_CID_UNIT_CELL_SIZE,
+					       &unit_size);
 
 	ret = imx214->ctrls.error;
 	if (ret) {