diff mbox series

[v3,06/20] media: i2c: ov4689: Refactor ov4689_set_ctrl

Message ID 20240229165333.227484-7-mike.rudenko@gmail.com (mailing list archive)
State New, archived
Headers show
Series Omnivision OV4689 refactoring and improvements | expand

Commit Message

Mikhail Rudenko Feb. 29, 2024, 4:53 p.m. UTC
Introduce local variable for regmap within the ov4689_set_ctrl
function. This adjustment eliminates repetition within the function.

Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com>
---
 drivers/media/i2c/ov4689.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Kieran Bingham March 4, 2024, 4:49 p.m. UTC | #1
Hi Mikhail,

I love this series. ;-)

Quoting Mikhail Rudenko (2024-02-29 16:53:19)
> Introduce local variable for regmap within the ov4689_set_ctrl
> function. This adjustment eliminates repetition within the function.
> 
> Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  drivers/media/i2c/ov4689.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c
> index 56bf1d964e43..1bc00404f3fb 100644
> --- a/drivers/media/i2c/ov4689.c
> +++ b/drivers/media/i2c/ov4689.c
> @@ -580,10 +580,11 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl)
>  {
>         struct ov4689 *ov4689 =
>                 container_of(ctrl->handler, struct ov4689, ctrl_handler);
> +       struct regmap *regmap = ov4689->regmap;
>         struct device *dev = ov4689->dev;
>         int sensor_gain;
>         s64 max_expo;
> -       int ret;
> +       int ret = 0;
>  
>         /* Propagate change of current control to all related controls */
>         switch (ctrl->id) {
> @@ -603,16 +604,15 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl)
>         switch (ctrl->id) {
>         case V4L2_CID_EXPOSURE:
>                 /* 4 least significant bits of exposure are fractional part */
> -               ret = cci_write(ov4689->regmap, OV4689_REG_EXPOSURE,
> -                               ctrl->val << 4, NULL);
> +               cci_write(regmap, OV4689_REG_EXPOSURE, ctrl->val << 4, &ret);
>                 break;
>         case V4L2_CID_ANALOGUE_GAIN:
>                 ret = ov4689_map_gain(ov4689, ctrl->val, &sensor_gain);
> -               cci_write(ov4689->regmap, OV4689_REG_GAIN, sensor_gain, &ret);
> +               cci_write(regmap, OV4689_REG_GAIN, sensor_gain, &ret);
>                 break;
>         case V4L2_CID_VBLANK:
> -               ret = cci_write(ov4689->regmap, OV4689_REG_VTS,
> -                               ctrl->val + ov4689->cur_mode->height, NULL);
> +               cci_write(regmap, OV4689_REG_VTS,
> +                         ctrl->val + ov4689->cur_mode->height, &ret);
>                 break;
>         case V4L2_CID_TEST_PATTERN:
>                 ret = ov4689_enable_test_pattern(ov4689, ctrl->val);
> -- 
> 2.43.0
>
Mikhail Rudenko March 4, 2024, 8:17 p.m. UTC | #2
Hi Kieran,

On 2024-03-04 at 16:49 GMT, Kieran Bingham <kieran.bingham@ideasonboard.com> wrote:

> Hi Mikhail,
>
> I love this series. ;-)

Thanks! :)

> Quoting Mikhail Rudenko (2024-02-29 16:53:19)
>> Introduce local variable for regmap within the ov4689_set_ctrl
>> function. This adjustment eliminates repetition within the function.
>>
>> Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com>
>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>
>> ---
>>  drivers/media/i2c/ov4689.c | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c
>> index 56bf1d964e43..1bc00404f3fb 100644
>> --- a/drivers/media/i2c/ov4689.c
>> +++ b/drivers/media/i2c/ov4689.c
>> @@ -580,10 +580,11 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl)
>>  {
>>         struct ov4689 *ov4689 =
>>                 container_of(ctrl->handler, struct ov4689, ctrl_handler);
>> +       struct regmap *regmap = ov4689->regmap;
>>         struct device *dev = ov4689->dev;
>>         int sensor_gain;
>>         s64 max_expo;
>> -       int ret;
>> +       int ret = 0;
>>
>>         /* Propagate change of current control to all related controls */
>>         switch (ctrl->id) {
>> @@ -603,16 +604,15 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl)
>>         switch (ctrl->id) {
>>         case V4L2_CID_EXPOSURE:
>>                 /* 4 least significant bits of exposure are fractional part */
>> -               ret = cci_write(ov4689->regmap, OV4689_REG_EXPOSURE,
>> -                               ctrl->val << 4, NULL);
>> +               cci_write(regmap, OV4689_REG_EXPOSURE, ctrl->val << 4, &ret);
>>                 break;
>>         case V4L2_CID_ANALOGUE_GAIN:
>>                 ret = ov4689_map_gain(ov4689, ctrl->val, &sensor_gain);
>> -               cci_write(ov4689->regmap, OV4689_REG_GAIN, sensor_gain, &ret);
>> +               cci_write(regmap, OV4689_REG_GAIN, sensor_gain, &ret);
>>                 break;
>>         case V4L2_CID_VBLANK:
>> -               ret = cci_write(ov4689->regmap, OV4689_REG_VTS,
>> -                               ctrl->val + ov4689->cur_mode->height, NULL);
>> +               cci_write(regmap, OV4689_REG_VTS,
>> +                         ctrl->val + ov4689->cur_mode->height, &ret);
>>                 break;
>>         case V4L2_CID_TEST_PATTERN:
>>                 ret = ov4689_enable_test_pattern(ov4689, ctrl->val);
>> --
>> 2.43.0
>>


--
Best regards,
Mikhail Rudenko
diff mbox series

Patch

diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c
index 56bf1d964e43..1bc00404f3fb 100644
--- a/drivers/media/i2c/ov4689.c
+++ b/drivers/media/i2c/ov4689.c
@@ -580,10 +580,11 @@  static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl)
 {
 	struct ov4689 *ov4689 =
 		container_of(ctrl->handler, struct ov4689, ctrl_handler);
+	struct regmap *regmap = ov4689->regmap;
 	struct device *dev = ov4689->dev;
 	int sensor_gain;
 	s64 max_expo;
-	int ret;
+	int ret = 0;
 
 	/* Propagate change of current control to all related controls */
 	switch (ctrl->id) {
@@ -603,16 +604,15 @@  static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl)
 	switch (ctrl->id) {
 	case V4L2_CID_EXPOSURE:
 		/* 4 least significant bits of exposure are fractional part */
-		ret = cci_write(ov4689->regmap, OV4689_REG_EXPOSURE,
-				ctrl->val << 4, NULL);
+		cci_write(regmap, OV4689_REG_EXPOSURE, ctrl->val << 4, &ret);
 		break;
 	case V4L2_CID_ANALOGUE_GAIN:
 		ret = ov4689_map_gain(ov4689, ctrl->val, &sensor_gain);
-		cci_write(ov4689->regmap, OV4689_REG_GAIN, sensor_gain, &ret);
+		cci_write(regmap, OV4689_REG_GAIN, sensor_gain, &ret);
 		break;
 	case V4L2_CID_VBLANK:
-		ret = cci_write(ov4689->regmap, OV4689_REG_VTS,
-				ctrl->val + ov4689->cur_mode->height, NULL);
+		cci_write(regmap, OV4689_REG_VTS,
+			  ctrl->val + ov4689->cur_mode->height, &ret);
 		break;
 	case V4L2_CID_TEST_PATTERN:
 		ret = ov4689_enable_test_pattern(ov4689, ctrl->val);