mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: OMAP: syslib: Optimize wait_on_value() function
@ 2022-06-06  6:40 Alexander Shiyan
  2022-06-07  7:17 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Shiyan @ 2022-06-06  6:40 UTC (permalink / raw)
  To: barebox; +Cc: Alexander Shiyan

Saves up to 8 bytes in THUMB mode.

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 arch/arm/mach-omap/syslib.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap/syslib.c b/arch/arm/mach-omap/syslib.c
index 42da348c5a..488f0ab859 100644
--- a/arch/arm/mach-omap/syslib.c
+++ b/arch/arm/mach-omap/syslib.c
@@ -52,19 +52,16 @@ void sdelay(unsigned long loops)
  * @param[in] read_addr  address to read from
  * @param[in] bound max iterations
  *
- * @return 1 if match_value is found, else if bound iterations reached,
+ * @return non zero if match_value is found, else if bound iterations reached,
  *         returns 0
  */
 u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
 {
-	u32 i = 0, val;
 	do {
-		++i;
-		val = readl(read_addr) & read_bit_mask;
+		u32 val = readl(read_addr) & read_bit_mask;
 		if (val == match_value)
-			return 1;
-		if (i == bound)
-			return 0;
-	} while (1);
-}
+			break;
+	} while (--bound);
 
+	return bound;
+}
-- 
2.32.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ARM: OMAP: syslib: Optimize wait_on_value() function
  2022-06-06  6:40 [PATCH] ARM: OMAP: syslib: Optimize wait_on_value() function Alexander Shiyan
@ 2022-06-07  7:17 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2022-06-07  7:17 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: barebox

On Mon, Jun 06, 2022 at 09:40:34AM +0300, Alexander Shiyan wrote:
> Saves up to 8 bytes in THUMB mode.
> 
> Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
> ---
>  arch/arm/mach-omap/syslib.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/mach-omap/syslib.c b/arch/arm/mach-omap/syslib.c
> index 42da348c5a..488f0ab859 100644
> --- a/arch/arm/mach-omap/syslib.c
> +++ b/arch/arm/mach-omap/syslib.c
> @@ -52,19 +52,16 @@ void sdelay(unsigned long loops)
>   * @param[in] read_addr  address to read from
>   * @param[in] bound max iterations
>   *
> - * @return 1 if match_value is found, else if bound iterations reached,
> + * @return non zero if match_value is found, else if bound iterations reached,
>   *         returns 0
>   */
>  u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
>  {
> -	u32 i = 0, val;
>  	do {
> -		++i;
> -		val = readl(read_addr) & read_bit_mask;
> +		u32 val = readl(read_addr) & read_bit_mask;
>  		if (val == match_value)
> -			return 1;
> -		if (i == bound)
> -			return 0;
> -	} while (1);
> -}
> +			break;
> +	} while (--bound);
>  
> +	return bound;
> +}
> -- 
> 2.32.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-07  7:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-06  6:40 [PATCH] ARM: OMAP: syslib: Optimize wait_on_value() function Alexander Shiyan
2022-06-07  7:17 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox