diff mbox series

[v4,17/33] crypto: rockchip: use read_poll_timeout

Message ID 20220401201804.2867154-18-clabbe@baylibre.com (mailing list archive)
State New, archived
Headers show
Series crypto: rockchip: permit to pass self-tests | expand

Commit Message

Corentin LABBE April 1, 2022, 8:17 p.m. UTC
Use read_poll_timeout instead of open coding it

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 drivers/crypto/rockchip/rk3288_crypto_ahash.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

John Keeping April 4, 2022, 11:38 a.m. UTC | #1
On Fri, Apr 01, 2022 at 08:17:48PM +0000, Corentin Labbe wrote:
> Use read_poll_timeout instead of open coding it
> 
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---
>  drivers/crypto/rockchip/rk3288_crypto_ahash.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/crypto/rockchip/rk3288_crypto_ahash.c b/drivers/crypto/rockchip/rk3288_crypto_ahash.c
> index 137013bd4410..21c9a0327ddf 100644
> --- a/drivers/crypto/rockchip/rk3288_crypto_ahash.c
> +++ b/drivers/crypto/rockchip/rk3288_crypto_ahash.c
> @@ -10,6 +10,7 @@
>   */
>  #include <linux/device.h>
>  #include <asm/unaligned.h>
> +#include <linux/iopoll.h>
>  #include "rk3288_crypto.h"
>  
>  /*
> @@ -305,8 +306,8 @@ static int rk_hash_run(struct crypto_engine *engine, void *breq)
>  		 * efficiency, and make it response quickly when dma
>  		 * complete.
>  		 */
> -	while (!CRYPTO_READ(tctx->dev, RK_CRYPTO_HASH_STS))
> -		udelay(10);
> +	read_poll_timeout(readl, v, v == 0, 10, 1000, false,
> +			  tctx->dev->dev + RK_CRYPTO_HASH_STS);

This can be simplified to:

	readl_poll_timeout(tctx->dev->dev + RK_CRYPTO_HASH_STS,
			   v, v == 0, 10, 1000);

But shouldn't this be tctx->dev->reg ?!
Corentin LABBE April 11, 2022, 8:33 a.m. UTC | #2
Le Mon, Apr 04, 2022 at 12:38:27PM +0100, John Keeping a écrit :
> On Fri, Apr 01, 2022 at 08:17:48PM +0000, Corentin Labbe wrote:
> > Use read_poll_timeout instead of open coding it
> > 
> > Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> > ---
> >  drivers/crypto/rockchip/rk3288_crypto_ahash.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/crypto/rockchip/rk3288_crypto_ahash.c b/drivers/crypto/rockchip/rk3288_crypto_ahash.c
> > index 137013bd4410..21c9a0327ddf 100644
> > --- a/drivers/crypto/rockchip/rk3288_crypto_ahash.c
> > +++ b/drivers/crypto/rockchip/rk3288_crypto_ahash.c
> > @@ -10,6 +10,7 @@
> >   */
> >  #include <linux/device.h>
> >  #include <asm/unaligned.h>
> > +#include <linux/iopoll.h>
> >  #include "rk3288_crypto.h"
> >  
> >  /*
> > @@ -305,8 +306,8 @@ static int rk_hash_run(struct crypto_engine *engine, void *breq)
> >  		 * efficiency, and make it response quickly when dma
> >  		 * complete.
> >  		 */
> > -	while (!CRYPTO_READ(tctx->dev, RK_CRYPTO_HASH_STS))
> > -		udelay(10);
> > +	read_poll_timeout(readl, v, v == 0, 10, 1000, false,
> > +			  tctx->dev->dev + RK_CRYPTO_HASH_STS);
> 
> This can be simplified to:
> 
> 	readl_poll_timeout(tctx->dev->dev + RK_CRYPTO_HASH_STS,
> 			   v, v == 0, 10, 1000);

Thanks, this is better.

> 
> But shouldn't this be tctx->dev->reg ?!

Yes, I will fix it.

Thanks
Regards
diff mbox series

Patch

diff --git a/drivers/crypto/rockchip/rk3288_crypto_ahash.c b/drivers/crypto/rockchip/rk3288_crypto_ahash.c
index 137013bd4410..21c9a0327ddf 100644
--- a/drivers/crypto/rockchip/rk3288_crypto_ahash.c
+++ b/drivers/crypto/rockchip/rk3288_crypto_ahash.c
@@ -10,6 +10,7 @@ 
  */
 #include <linux/device.h>
 #include <asm/unaligned.h>
+#include <linux/iopoll.h>
 #include "rk3288_crypto.h"
 
 /*
@@ -305,8 +306,8 @@  static int rk_hash_run(struct crypto_engine *engine, void *breq)
 		 * efficiency, and make it response quickly when dma
 		 * complete.
 		 */
-	while (!CRYPTO_READ(tctx->dev, RK_CRYPTO_HASH_STS))
-		udelay(10);
+	read_poll_timeout(readl, v, v == 0, 10, 1000, false,
+			  tctx->dev->dev + RK_CRYPTO_HASH_STS);
 
 	for (i = 0; i < crypto_ahash_digestsize(tfm) / 4; i++) {
 		v = readl(tctx->dev->reg + RK_CRYPTO_HASH_DOUT_0 + i * 4);