[PATCH v3 06/25] i2c: designware: Replace a while-loop by for-loop

Andy Shevchenko posted 25 patches 2 years, 1 month ago
There is a newer version of this series
[PATCH v3 06/25] i2c: designware: Replace a while-loop by for-loop
Posted by Andy Shevchenko 2 years, 1 month ago
Replace a while-loop by for-loop in i2c_dw_probe_lock_support() to
save a few lines of code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-designware-platdrv.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 63cc3cdca2c7..cb954f11540e 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -260,11 +260,9 @@ static int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
 	int i = 0;
 	int ret;
 
-	ptr = i2c_dw_semaphore_cb_table;
-
 	dev->semaphore_idx = -1;
 
-	while (ptr->probe) {
+	for (ptr = i2c_dw_semaphore_cb_table; ptr->probe; ptr++) {
 		ret = ptr->probe(dev);
 		if (ret) {
 			/*
@@ -276,7 +274,6 @@ static int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
 				return ret;
 
 			i++;
-			ptr++;
 			continue;
 		}
 
-- 
2.43.0.rc1.1.gbec44491f096
Re: [PATCH v3 06/25] i2c: designware: Replace a while-loop by for-loop
Posted by Jarkko Nikula 2 years ago
On 11/10/23 20:11, Andy Shevchenko wrote:
> Replace a while-loop by for-loop in i2c_dw_probe_lock_support() to
> save a few lines of code.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/i2c/busses/i2c-designware-platdrv.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Re: [PATCH v3 06/25] i2c: designware: Replace a while-loop by for-loop
Posted by Mario Limonciello 2 years, 1 month ago
On 11/10/2023 12:11, Andy Shevchenko wrote:
> Replace a while-loop by for-loop in i2c_dw_probe_lock_support() to
> save a few lines of code.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   drivers/i2c/busses/i2c-designware-platdrv.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> index 63cc3cdca2c7..cb954f11540e 100644
> --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> @@ -260,11 +260,9 @@ static int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
>   	int i = 0;
>   	int ret;
>   
> -	ptr = i2c_dw_semaphore_cb_table;
> -
>   	dev->semaphore_idx = -1;
>   
> -	while (ptr->probe) {
> +	for (ptr = i2c_dw_semaphore_cb_table; ptr->probe; ptr++) {
>   		ret = ptr->probe(dev);
>   		if (ret) {
>   			/*
> @@ -276,7 +274,6 @@ static int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
>   				return ret;
>   
>   			i++;
> -			ptr++;
>   			continue;
>   		}
>