[2/2] media: i2c: adv748x: Remove PAGE_WAIT
diff mbox series

Message ID 20190111174141.12594-3-kieran.bingham+renesas@ideasonboard.com
State Superseded
Delegated to: Kieran Bingham
Headers show
Series
  • media: i2c: adv748x: Refactor sw_reset handling
Related show

Commit Message

Kieran Bingham Jan. 11, 2019, 5:41 p.m. UTC
The ADV748X_PAGE_WAIT is a fake page to insert arbitrary delays in the
register tables.

Its only usage was removed, so we can remove the handling and simplify
the code.

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
---
 drivers/media/i2c/adv748x/adv748x-core.c | 17 ++++++-----------
 drivers/media/i2c/adv748x/adv748x.h      |  1 -
 2 files changed, 6 insertions(+), 12 deletions(-)

Comments

Laurent Pinchart Jan. 11, 2019, 8:23 p.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Friday, 11 January 2019 19:41:41 EET Kieran Bingham wrote:
> The ADV748X_PAGE_WAIT is a fake page to insert arbitrary delays in the
> register tables.
> 
> Its only usage was removed, so we can remove the handling and simplify
> the code.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> ---
>  drivers/media/i2c/adv748x/adv748x-core.c | 17 ++++++-----------
>  drivers/media/i2c/adv748x/adv748x.h      |  1 -
>  2 files changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv748x/adv748x-core.c
> b/drivers/media/i2c/adv748x/adv748x-core.c index 252bdb28b18b..8199e0b20790
> 100644
> --- a/drivers/media/i2c/adv748x/adv748x-core.c
> +++ b/drivers/media/i2c/adv748x/adv748x-core.c
> @@ -219,18 +219,13 @@ static int adv748x_write_regs(struct adv748x_state
> *state, int ret;
> 
>  	while (regs->page != ADV748X_PAGE_EOR) {

While at it you could write this as

	for (; regs->page != ADV748X_PAGE_EOR; ++regs)

and remove the regs++ below.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> -		if (regs->page == ADV748X_PAGE_WAIT) {
> -			msleep(regs->value);
> -		} else {
> -			ret = adv748x_write(state, regs->page, regs->reg,
> -				      regs->value);
> -			if (ret < 0) {
> -				adv_err(state,
> -					"Error regs page: 0x%02x reg: 0x%02x\n",
> -					regs->page, regs->reg);
> -				return ret;
> -			}
> +		ret = adv748x_write(state, regs->page, regs->reg, regs->value);
> +		if (ret < 0) {
> +			adv_err(state, "Error regs page: 0x%02x reg: 0x%02x\n",
> +				regs->page, regs->reg);
> +			return ret;
>  		}
> +
>  		regs++;
>  	}
> 
> diff --git a/drivers/media/i2c/adv748x/adv748x.h
> b/drivers/media/i2c/adv748x/adv748x.h index 2f8d751cfbb0..5042f9e94aee
> 100644
> --- a/drivers/media/i2c/adv748x/adv748x.h
> +++ b/drivers/media/i2c/adv748x/adv748x.h
> @@ -39,7 +39,6 @@ enum adv748x_page {
>  	ADV748X_PAGE_MAX,
> 
>  	/* Fake pages for register sequences */
> -	ADV748X_PAGE_WAIT,		/* Wait x msec */
>  	ADV748X_PAGE_EOR,		/* End Mark */
>  };
Kieran Bingham Jan. 12, 2019, 4:51 p.m. UTC | #2
Hi Laurent,

On 11/01/2019 20:23, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Friday, 11 January 2019 19:41:41 EET Kieran Bingham wrote:
>> The ADV748X_PAGE_WAIT is a fake page to insert arbitrary delays in the
>> register tables.
>>
>> Its only usage was removed, so we can remove the handling and simplify
>> the code.
>>
>> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>> ---
>>  drivers/media/i2c/adv748x/adv748x-core.c | 17 ++++++-----------
>>  drivers/media/i2c/adv748x/adv748x.h      |  1 -
>>  2 files changed, 6 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/media/i2c/adv748x/adv748x-core.c
>> b/drivers/media/i2c/adv748x/adv748x-core.c index 252bdb28b18b..8199e0b20790
>> 100644
>> --- a/drivers/media/i2c/adv748x/adv748x-core.c
>> +++ b/drivers/media/i2c/adv748x/adv748x-core.c
>> @@ -219,18 +219,13 @@ static int adv748x_write_regs(struct adv748x_state
>> *state, int ret;
>>
>>  	while (regs->page != ADV748X_PAGE_EOR) {
> 
> While at it you could write this as
> 
> 	for (; regs->page != ADV748X_PAGE_EOR; ++regs)
> 
> and remove the regs++ below.

ah yes - good idea. I'll update this.

--
Kieran


> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
>> -		if (regs->page == ADV748X_PAGE_WAIT) {
>> -			msleep(regs->value);
>> -		} else {
>> -			ret = adv748x_write(state, regs->page, regs->reg,
>> -				      regs->value);
>> -			if (ret < 0) {
>> -				adv_err(state,
>> -					"Error regs page: 0x%02x reg: 0x%02x\n",
>> -					regs->page, regs->reg);
>> -				return ret;
>> -			}
>> +		ret = adv748x_write(state, regs->page, regs->reg, regs->value);
>> +		if (ret < 0) {
>> +			adv_err(state, "Error regs page: 0x%02x reg: 0x%02x\n",
>> +				regs->page, regs->reg);
>> +			return ret;
>>  		}
>> +
>>  		regs++;
>>  	}
>>
>> diff --git a/drivers/media/i2c/adv748x/adv748x.h
>> b/drivers/media/i2c/adv748x/adv748x.h index 2f8d751cfbb0..5042f9e94aee
>> 100644
>> --- a/drivers/media/i2c/adv748x/adv748x.h
>> +++ b/drivers/media/i2c/adv748x/adv748x.h
>> @@ -39,7 +39,6 @@ enum adv748x_page {
>>  	ADV748X_PAGE_MAX,
>>
>>  	/* Fake pages for register sequences */
>> -	ADV748X_PAGE_WAIT,		/* Wait x msec */
>>  	ADV748X_PAGE_EOR,		/* End Mark */
>>  };
>
Niklas Söderlund Jan. 14, 2019, 2:44 p.m. UTC | #3
Hi Kieran,

Thanks for your patch.

On 2019-01-11 17:41:41 +0000, Kieran Bingham wrote:
> The ADV748X_PAGE_WAIT is a fake page to insert arbitrary delays in the
> register tables.
> 
> Its only usage was removed, so we can remove the handling and simplify
> the code.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

With the change Laurent points out,

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  drivers/media/i2c/adv748x/adv748x-core.c | 17 ++++++-----------
>  drivers/media/i2c/adv748x/adv748x.h      |  1 -
>  2 files changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
> index 252bdb28b18b..8199e0b20790 100644
> --- a/drivers/media/i2c/adv748x/adv748x-core.c
> +++ b/drivers/media/i2c/adv748x/adv748x-core.c
> @@ -219,18 +219,13 @@ static int adv748x_write_regs(struct adv748x_state *state,
>  	int ret;
>  
>  	while (regs->page != ADV748X_PAGE_EOR) {
> -		if (regs->page == ADV748X_PAGE_WAIT) {
> -			msleep(regs->value);
> -		} else {
> -			ret = adv748x_write(state, regs->page, regs->reg,
> -				      regs->value);
> -			if (ret < 0) {
> -				adv_err(state,
> -					"Error regs page: 0x%02x reg: 0x%02x\n",
> -					regs->page, regs->reg);
> -				return ret;
> -			}
> +		ret = adv748x_write(state, regs->page, regs->reg, regs->value);
> +		if (ret < 0) {
> +			adv_err(state, "Error regs page: 0x%02x reg: 0x%02x\n",
> +				regs->page, regs->reg);
> +			return ret;
>  		}
> +
>  		regs++;
>  	}
>  
> diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h
> index 2f8d751cfbb0..5042f9e94aee 100644
> --- a/drivers/media/i2c/adv748x/adv748x.h
> +++ b/drivers/media/i2c/adv748x/adv748x.h
> @@ -39,7 +39,6 @@ enum adv748x_page {
>  	ADV748X_PAGE_MAX,
>  
>  	/* Fake pages for register sequences */
> -	ADV748X_PAGE_WAIT,		/* Wait x msec */
>  	ADV748X_PAGE_EOR,		/* End Mark */
>  };
>  
> -- 
> 2.17.1
>

Patch
diff mbox series

diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
index 252bdb28b18b..8199e0b20790 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -219,18 +219,13 @@  static int adv748x_write_regs(struct adv748x_state *state,
 	int ret;
 
 	while (regs->page != ADV748X_PAGE_EOR) {
-		if (regs->page == ADV748X_PAGE_WAIT) {
-			msleep(regs->value);
-		} else {
-			ret = adv748x_write(state, regs->page, regs->reg,
-				      regs->value);
-			if (ret < 0) {
-				adv_err(state,
-					"Error regs page: 0x%02x reg: 0x%02x\n",
-					regs->page, regs->reg);
-				return ret;
-			}
+		ret = adv748x_write(state, regs->page, regs->reg, regs->value);
+		if (ret < 0) {
+			adv_err(state, "Error regs page: 0x%02x reg: 0x%02x\n",
+				regs->page, regs->reg);
+			return ret;
 		}
+
 		regs++;
 	}
 
diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h
index 2f8d751cfbb0..5042f9e94aee 100644
--- a/drivers/media/i2c/adv748x/adv748x.h
+++ b/drivers/media/i2c/adv748x/adv748x.h
@@ -39,7 +39,6 @@  enum adv748x_page {
 	ADV748X_PAGE_MAX,
 
 	/* Fake pages for register sequences */
-	ADV748X_PAGE_WAIT,		/* Wait x msec */
 	ADV748X_PAGE_EOR,		/* End Mark */
 };