diff mbox series

[v2] i2c: iproc: Refactor prototype and remove redundant error checks

Message ID 20250121084818.2719-1-vulab@iscas.ac.cn
State Accepted
Delegated to: Andi Shyti
Headers show
Series [v2] i2c: iproc: Refactor prototype and remove redundant error checks | expand

Commit Message

Wentao Liang Jan. 21, 2025, 8:48 a.m. UTC
The bcm_iproc_i2c_init() always returns 0. As a result, there
is no need to check its return value or handle errors.

This patch changes the prototype of bcm_iproc_i2c_init() to
return void and removes the redundant error handling code after
calls to bcm_iproc_i2c_init() in both the bcm_iproc_i2c_probe()
and bcm_iproc_i2c_resume().

Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/i2c/busses/i2c-bcm-iproc.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

Comments

Ray Jui Jan. 21, 2025, 4:36 p.m. UTC | #1
On Tue, Jan 21, 2025 at 12:49 AM Wentao Liang <vulab@iscas.ac.cn> wrote:

> The bcm_iproc_i2c_init() always returns 0. As a result, there
> is no need to check its return value or handle errors.
>
> This patch changes the prototype of bcm_iproc_i2c_init() to
> return void and removes the redundant error handling code after
> calls to bcm_iproc_i2c_init() in both the bcm_iproc_i2c_probe()
> and bcm_iproc_i2c_resume().
>
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/i2c/busses/i2c-bcm-iproc.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c
> b/drivers/i2c/busses/i2c-bcm-iproc.c
> index 15b632a146e1..59cbf8b3b025 100644
> --- a/drivers/i2c/busses/i2c-bcm-iproc.c
> +++ b/drivers/i2c/busses/i2c-bcm-iproc.c
> @@ -678,7 +678,7 @@ static irqreturn_t bcm_iproc_i2c_isr(int irq, void
> *data)
>         return IRQ_HANDLED;
>  }
>
> -static int bcm_iproc_i2c_init(struct bcm_iproc_i2c_dev *iproc_i2c)
> +static void bcm_iproc_i2c_init(struct bcm_iproc_i2c_dev *iproc_i2c)
>  {
>         u32 val;
>
> @@ -706,8 +706,6 @@ static int bcm_iproc_i2c_init(struct bcm_iproc_i2c_dev
> *iproc_i2c)
>
>         /* clear all pending interrupts */
>         iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, 0xffffffff);
> -
> -       return 0;
>  }
>
>  static void bcm_iproc_i2c_enable_disable(struct bcm_iproc_i2c_dev
> *iproc_i2c,
> @@ -1081,9 +1079,7 @@ static int bcm_iproc_i2c_probe(struct
> platform_device *pdev)
>                 bcm_iproc_algo.unreg_slave = NULL;
>         }
>
> -       ret = bcm_iproc_i2c_init(iproc_i2c);
> -       if (ret)
> -               return ret;
> +       bcm_iproc_i2c_init(iproc_i2c);
>
>         ret = bcm_iproc_i2c_cfg_speed(iproc_i2c);
>         if (ret)
> @@ -1169,9 +1165,7 @@ static int bcm_iproc_i2c_resume(struct device *dev)
>          * Power domain could have been shut off completely in system deep
>          * sleep, so re-initialize the block here
>          */
> -       ret = bcm_iproc_i2c_init(iproc_i2c);
> -       if (ret)
> -               return ret;
> +       bcm_iproc_i2c_init(iproc_i2c);
>
>         /* configure to the desired bus speed */
>         val = iproc_i2c_rd_reg(iproc_i2c, TIM_CFG_OFFSET);
> --
> 2.42.0.windows.2
>

Looks good to me. Thanks!
Acked-by: Ray Jui <ray.jui@broadcom.com>
Uwe Kleine-König Jan. 21, 2025, 5:50 p.m. UTC | #2
Hello,

On Tue, Jan 21, 2025 at 04:48:18PM +0800, Wentao Liang wrote:
> The bcm_iproc_i2c_init() always returns 0. As a result, there
> is no need to check its return value or handle errors.
> 
> This patch changes the prototype of bcm_iproc_i2c_init() to
> return void and removes the redundant error handling code after
> calls to bcm_iproc_i2c_init() in both the bcm_iproc_i2c_probe()
> and bcm_iproc_i2c_resume().
> 
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

LGTM:

Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>

Best regards
Uwe
Andi Shyti March 20, 2025, 9:29 p.m. UTC | #3
Hi Wentao,

...

> @@ -1169,9 +1165,7 @@ static int bcm_iproc_i2c_resume(struct device *dev)
>  	 * Power domain could have been shut off completely in system deep
>  	 * sleep, so re-initialize the block here
>  	 */
> -	ret = bcm_iproc_i2c_init(iproc_i2c);
> -	if (ret)
> -		return ret;
> +	bcm_iproc_i2c_init(iproc_i2c);

This caused a:

   warning: unused variable ‘ret’

Please, make sure next time to compile properly before submitting
patches. For now I fixed the warning and merged your patch to
i2c/i2c-hist.

Thanks,
Andi

>  
>  	/* configure to the desired bus speed */
>  	val = iproc_i2c_rd_reg(iproc_i2c, TIM_CFG_OFFSET);
> -- 
> 2.42.0.windows.2
>
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c
index 15b632a146e1..59cbf8b3b025 100644
--- a/drivers/i2c/busses/i2c-bcm-iproc.c
+++ b/drivers/i2c/busses/i2c-bcm-iproc.c
@@ -678,7 +678,7 @@  static irqreturn_t bcm_iproc_i2c_isr(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static int bcm_iproc_i2c_init(struct bcm_iproc_i2c_dev *iproc_i2c)
+static void bcm_iproc_i2c_init(struct bcm_iproc_i2c_dev *iproc_i2c)
 {
 	u32 val;
 
@@ -706,8 +706,6 @@  static int bcm_iproc_i2c_init(struct bcm_iproc_i2c_dev *iproc_i2c)
 
 	/* clear all pending interrupts */
 	iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, 0xffffffff);
-
-	return 0;
 }
 
 static void bcm_iproc_i2c_enable_disable(struct bcm_iproc_i2c_dev *iproc_i2c,
@@ -1081,9 +1079,7 @@  static int bcm_iproc_i2c_probe(struct platform_device *pdev)
 		bcm_iproc_algo.unreg_slave = NULL;
 	}
 
-	ret = bcm_iproc_i2c_init(iproc_i2c);
-	if (ret)
-		return ret;
+	bcm_iproc_i2c_init(iproc_i2c);
 
 	ret = bcm_iproc_i2c_cfg_speed(iproc_i2c);
 	if (ret)
@@ -1169,9 +1165,7 @@  static int bcm_iproc_i2c_resume(struct device *dev)
 	 * Power domain could have been shut off completely in system deep
 	 * sleep, so re-initialize the block here
 	 */
-	ret = bcm_iproc_i2c_init(iproc_i2c);
-	if (ret)
-		return ret;
+	bcm_iproc_i2c_init(iproc_i2c);
 
 	/* configure to the desired bus speed */
 	val = iproc_i2c_rd_reg(iproc_i2c, TIM_CFG_OFFSET);