All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: ccree - Remove a useless dma_supported() call
@ 2022-07-19 20:27 Christophe JAILLET
  2022-07-20  5:21 ` Christoph Hellwig
  2022-07-20  9:24 ` Gilad Ben-Yossef
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-07-19 20:27 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S. Miller
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-crypto

There is no point in calling dma_supported() before calling
dma_set_coherent_mask(). This function already calls dma_supported() and
returns an error (-EIO) if it fails.

So remove the superfluous dma_supported() call.

While at it, fix the name of the function reported in a dev_err().

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
I guess that the whole while loop could be removed, but I don't remind the
thread with the corresponding explanation, so leave it as-is :(
---
 drivers/crypto/ccree/cc_driver.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index 7d1bee86d581..99f8bda718fe 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -373,16 +373,16 @@ static int init_cc_resources(struct platform_device *plat_dev)
 
 	dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
 	while (dma_mask > 0x7fffffffUL) {
-		if (dma_supported(dev, dma_mask)) {
-			rc = dma_set_coherent_mask(dev, dma_mask);
-			if (!rc)
-				break;
-		}
+		rc = dma_set_coherent_mask(dev, dma_mask);
+		if (!rc)
+			break;
+
 		dma_mask >>= 1;
 	}
 
 	if (rc) {
-		dev_err(dev, "Failed in dma_set_mask, mask=%llx\n", dma_mask);
+		dev_err(dev, "Failed in dma_set_coherent_mask, mask=%llx\n",
+			dma_mask);
 		return rc;
 	}
 
-- 
2.34.1


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

* Re: [PATCH] crypto: ccree - Remove a useless dma_supported() call
  2022-07-19 20:27 [PATCH] crypto: ccree - Remove a useless dma_supported() call Christophe JAILLET
@ 2022-07-20  5:21 ` Christoph Hellwig
  2022-07-20  9:24 ` Gilad Ben-Yossef
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2022-07-20  5:21 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Gilad Ben-Yossef, Herbert Xu, David S. Miller, linux-kernel,
	kernel-janitors, linux-crypto

On Tue, Jul 19, 2022 at 10:27:50PM +0200, Christophe JAILLET wrote:
> There is no point in calling dma_supported() before calling
> dma_set_coherent_mask(). This function already calls dma_supported() and
> returns an error (-EIO) if it fails.
> 
> So remove the superfluous dma_supported() call.
> 
> While at it, fix the name of the function reported in a dev_err().
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> I guess that the whole while loop could be removed, but I don't remind the
> thread with the corresponding explanation, so leave it as-is :(

The loop should go away.  Setting a larger DMA mask will never fail when
setting a smaller one will succeed.

Also after this patch dma_supported can be marked static (Yay!)

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

* Re: [PATCH] crypto: ccree - Remove a useless dma_supported() call
  2022-07-19 20:27 [PATCH] crypto: ccree - Remove a useless dma_supported() call Christophe JAILLET
  2022-07-20  5:21 ` Christoph Hellwig
@ 2022-07-20  9:24 ` Gilad Ben-Yossef
  2022-07-20  9:36   ` Christophe JAILLET
  1 sibling, 1 reply; 4+ messages in thread
From: Gilad Ben-Yossef @ 2022-07-20  9:24 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Herbert Xu, David S. Miller, Linux kernel mailing list,
	kernel-janitors, Linux Crypto Mailing List

Hi Christophe,

Thank you for the patch!


On Tue, Jul 19, 2022 at 11:27 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> There is no point in calling dma_supported() before calling
> dma_set_coherent_mask(). This function already calls dma_supported() and
> returns an error (-EIO) if it fails.
>
> So remove the superfluous dma_supported() call.
>
> While at it, fix the name of the function reported in a dev_err().
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>

> ---
> I guess that the whole while loop could be removed, but I don't remind the
> thread with the corresponding explanation, so leave it as-is :(

I would be happy to ack a patch that does this if you care to write it...

Gilad

> ---
>  drivers/crypto/ccree/cc_driver.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
> index 7d1bee86d581..99f8bda718fe 100644
> --- a/drivers/crypto/ccree/cc_driver.c
> +++ b/drivers/crypto/ccree/cc_driver.c
> @@ -373,16 +373,16 @@ static int init_cc_resources(struct platform_device *plat_dev)
>
>         dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
>         while (dma_mask > 0x7fffffffUL) {
> -               if (dma_supported(dev, dma_mask)) {
> -                       rc = dma_set_coherent_mask(dev, dma_mask);
> -                       if (!rc)
> -                               break;
> -               }
> +               rc = dma_set_coherent_mask(dev, dma_mask);
> +               if (!rc)
> +                       break;
> +
>                 dma_mask >>= 1;
>         }
>
>         if (rc) {
> -               dev_err(dev, "Failed in dma_set_mask, mask=%llx\n", dma_mask);
> +               dev_err(dev, "Failed in dma_set_coherent_mask, mask=%llx\n",
> +                       dma_mask);
>                 return rc;
>         }
>
> --
> 2.34.1
>


-- 
Gilad Ben-Yossef
Chief Coffee Drinker

values of β will give rise to dom!

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

* Re: [PATCH] crypto: ccree - Remove a useless dma_supported() call
  2022-07-20  9:24 ` Gilad Ben-Yossef
@ 2022-07-20  9:36   ` Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-07-20  9:36 UTC (permalink / raw)
  To: Gilad Ben-Yossef
  Cc: Herbert Xu, David S. Miller, Linux kernel mailing list,
	kernel-janitors, Linux Crypto Mailing List, Christoph Hellwig

Le 20/07/2022 à 11:24, Gilad Ben-Yossef a écrit :
> Hi Christophe,
> 
> Thank you for the patch!
> 
> 
> On Tue, Jul 19, 2022 at 11:27 PM Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
>>
>> There is no point in calling dma_supported() before calling
>> dma_set_coherent_mask(). This function already calls dma_supported() and
>> returns an error (-EIO) if it fails.
>>
>> So remove the superfluous dma_supported() call.
>>
>> While at it, fix the name of the function reported in a dev_err().
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> 
> Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
> 
>> ---
>> I guess that the whole while loop could be removed, but I don't remind the
>> thread with the corresponding explanation, so leave it as-is :(
> 
> I would be happy to ack a patch that does this if you care to write it...

I will send a v2.

Don't bother with this patch.

CJ

> 
> Gilad
> 
>> ---
>>   drivers/crypto/ccree/cc_driver.c | 12 ++++++------
>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
>> index 7d1bee86d581..99f8bda718fe 100644
>> --- a/drivers/crypto/ccree/cc_driver.c
>> +++ b/drivers/crypto/ccree/cc_driver.c
>> @@ -373,16 +373,16 @@ static int init_cc_resources(struct platform_device *plat_dev)
>>
>>          dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
>>          while (dma_mask > 0x7fffffffUL) {
>> -               if (dma_supported(dev, dma_mask)) {
>> -                       rc = dma_set_coherent_mask(dev, dma_mask);
>> -                       if (!rc)
>> -                               break;
>> -               }
>> +               rc = dma_set_coherent_mask(dev, dma_mask);
>> +               if (!rc)
>> +                       break;
>> +
>>                  dma_mask >>= 1;
>>          }
>>
>>          if (rc) {
>> -               dev_err(dev, "Failed in dma_set_mask, mask=%llx\n", dma_mask);
>> +               dev_err(dev, "Failed in dma_set_coherent_mask, mask=%llx\n",
>> +                       dma_mask);
>>                  return rc;
>>          }
>>
>> --
>> 2.34.1
>>
> 
> 


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

end of thread, other threads:[~2022-07-20  9:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19 20:27 [PATCH] crypto: ccree - Remove a useless dma_supported() call Christophe JAILLET
2022-07-20  5:21 ` Christoph Hellwig
2022-07-20  9:24 ` Gilad Ben-Yossef
2022-07-20  9:36   ` Christophe JAILLET

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.