linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: Delete redundant variable definition
@ 2020-04-19  7:12 Tang Bin
  2020-04-19 11:44 ` Joe Perches
  2020-04-24  7:47 ` Herbert Xu
  0 siblings, 2 replies; 4+ messages in thread
From: Tang Bin @ 2020-04-19  7:12 UTC (permalink / raw)
  To: davem, herbert; +Cc: linux-crypto, linux-kernel, Tang Bin, Shengju Zhang

The variable "i" is redundant to be assigned a value
of zero,because it's assigned in the for loop, so remove
redundant one here.

Signed-off-by: Shengju Zhang <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>

---
 drivers/crypto/bcm/cipher.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index c8b940854..5db23c18c 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -4724,7 +4724,6 @@ static int spu_dt_read(struct platform_device *pdev)
 	spu->spu_type = matched_spu_type->type;
 	spu->spu_subtype = matched_spu_type->subtype;
 
-	i = 0;
 	for (i = 0; (i < MAX_SPUS) && ((spu_ctrl_regs =
 		platform_get_resource(pdev, IORESOURCE_MEM, i)) != NULL); i++) {
 
-- 
2.20.1.windows.1




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

* Re: [PATCH] crypto: Delete redundant variable definition
  2020-04-19  7:12 [PATCH] crypto: Delete redundant variable definition Tang Bin
@ 2020-04-19 11:44 ` Joe Perches
  2020-04-21 11:22   ` Tang Bin
  2020-04-24  7:47 ` Herbert Xu
  1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2020-04-19 11:44 UTC (permalink / raw)
  To: Tang Bin, davem, herbert; +Cc: linux-crypto, linux-kernel, Shengju Zhang

On Sun, 2020-04-19 at 15:12 +0800, Tang Bin wrote:
> The variable "i" is redundant to be assigned a value
> of zero,because it's assigned in the for loop, so remove
> redundant one here.
> 
> Signed-off-by: Shengju Zhang <zhangshengju@cmss.chinamobile.com>
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> 
> ---
>  drivers/crypto/bcm/cipher.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
> index c8b940854..5db23c18c 100644
> --- a/drivers/crypto/bcm/cipher.c
> +++ b/drivers/crypto/bcm/cipher.c
> @@ -4724,7 +4724,6 @@ static int spu_dt_read(struct platform_device *pdev)
>  	spu->spu_type = matched_spu_type->type;
>  	spu->spu_subtype = matched_spu_type->subtype;
>  
> -	i = 0;
>  	for (i = 0; (i < MAX_SPUS) && ((spu_ctrl_regs =
>  		platform_get_resource(pdev, IORESOURCE_MEM, i)) != NULL); i++) {

Maybe the for loop could be simplified too by
moving the assignment inside the loop.

Also, the %pe extension could be used.

Perhaps:
---
 drivers/crypto/bcm/cipher.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index c8b940..7d6afa4 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -4707,7 +4707,6 @@ static int spu_dt_read(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct spu_hw *spu = &iproc_priv.spu;
-	struct resource *spu_ctrl_regs;
 	const struct spu_type_subtype *matched_spu_type;
 	struct device_node *dn = pdev->dev.of_node;
 	int err, i;
@@ -4724,19 +4723,23 @@ static int spu_dt_read(struct platform_device *pdev)
 	spu->spu_type = matched_spu_type->type;
 	spu->spu_subtype = matched_spu_type->subtype;
 
-	i = 0;
-	for (i = 0; (i < MAX_SPUS) && ((spu_ctrl_regs =
-		platform_get_resource(pdev, IORESOURCE_MEM, i)) != NULL); i++) {
+	for (i = 0; i < MAX_SPUS; i++) {
+		struct resource *spu_ctrl_regs;
+
+		spu_ctrl_regs = platform_get_resource(pdev, IORESOURCE_MEM, i);
+		if (!spu_ctrl_regs)
+			break;
 
 		spu->reg_vbase[i] = devm_ioremap_resource(dev, spu_ctrl_regs);
 		if (IS_ERR(spu->reg_vbase[i])) {
 			err = PTR_ERR(spu->reg_vbase[i]);
-			dev_err(&pdev->dev, "Failed to map registers: %d\n",
-				err);
+			dev_err(&pdev->dev, "Failed to map registers: %pe\n",
+				spu->reg_vbase[i]);
 			spu->reg_vbase[i] = NULL;
 			return err;
 		}
 	}
+
 	spu->num_spu = i;
 	dev_dbg(dev, "Device has %d SPUs", spu->num_spu);
 


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

* Re: [PATCH] crypto: Delete redundant variable definition
  2020-04-19 11:44 ` Joe Perches
@ 2020-04-21 11:22   ` Tang Bin
  0 siblings, 0 replies; 4+ messages in thread
From: Tang Bin @ 2020-04-21 11:22 UTC (permalink / raw)
  To: Joe Perches, davem, herbert; +Cc: linux-crypto, linux-kernel, Shengju Zhang

Hi, Joe:

On 2020/4/19 19:44, Joe Perches wrote:
> On Sun, 2020-04-19 at 15:12 +0800, Tang Bin wrote:
>> The variable "i" is redundant to be assigned a value
>> of zero,because it's assigned in the for loop, so remove
>> redundant one here.
>>
>> Signed-off-by: Shengju Zhang <zhangshengju@cmss.chinamobile.com>
>> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
>>
>> ---
>>   drivers/crypto/bcm/cipher.c | 1 -
>>   1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
>> index c8b940854..5db23c18c 100644
>> --- a/drivers/crypto/bcm/cipher.c
>> +++ b/drivers/crypto/bcm/cipher.c
>> @@ -4724,7 +4724,6 @@ static int spu_dt_read(struct platform_device *pdev)
>>   	spu->spu_type = matched_spu_type->type;
>>   	spu->spu_subtype = matched_spu_type->subtype;
>>   
>> -	i = 0;
>>   	for (i = 0; (i < MAX_SPUS) && ((spu_ctrl_regs =
>>   		platform_get_resource(pdev, IORESOURCE_MEM, i)) != NULL); i++) {
> Maybe the for loop could be simplified too by
> moving the assignment inside the loop.
>
> Also, the %pe extension could be used.

Sorry for the delay. Thank you for your advice, I was already thinking 
about optimizing this place.

Thanks,

Tang Bin


>



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

* Re: [PATCH] crypto: Delete redundant variable definition
  2020-04-19  7:12 [PATCH] crypto: Delete redundant variable definition Tang Bin
  2020-04-19 11:44 ` Joe Perches
@ 2020-04-24  7:47 ` Herbert Xu
  1 sibling, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2020-04-24  7:47 UTC (permalink / raw)
  To: Tang Bin; +Cc: davem, linux-crypto, linux-kernel, Shengju Zhang

On Sun, Apr 19, 2020 at 03:12:45PM +0800, Tang Bin wrote:
> The variable "i" is redundant to be assigned a value
> of zero,because it's assigned in the for loop, so remove
> redundant one here.
> 
> Signed-off-by: Shengju Zhang <zhangshengju@cmss.chinamobile.com>
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> 
> ---
>  drivers/crypto/bcm/cipher.c | 1 -
>  1 file changed, 1 deletion(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2020-04-24  7:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-19  7:12 [PATCH] crypto: Delete redundant variable definition Tang Bin
2020-04-19 11:44 ` Joe Perches
2020-04-21 11:22   ` Tang Bin
2020-04-24  7:47 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).