Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1271338 > unrolled thread

[PATCH v2 0/3] crypto-ixp4xx: Deletion of a few unnecessary checks

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2015-11-17 16:40 +0100
Last post2015-11-18 08:30 +0100
Articles 6 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 0/3] crypto-ixp4xx: Deletion of a few unnecessary checks SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-17 16:40 +0100
    [PATCH v2 2/3] crypto-ixp4xx: Reduce assignment for a variable in  init_ixp_crypto() SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-17 16:50 +0100
    [PATCH v2 3/3] crypto-ixp4xx: Less function calls in  init_ixp_crypto() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-17 16:50 +0100
    [PATCH v2 1/3] crypto-ixp4xx: Delete unnecessary checks before the  function call "dma_pool_destroy" SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-17 16:50 +0100
    Re: [PATCH v2 0/3] crypto-ixp4xx: Deletion of a few unnecessary  checks Herbert Xu <herbert@gondor.apana.org.au> - 2015-11-18 01:10 +0100
      Re: crypto-ixp4xx: Deletion of a few unnecessary checks SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-18 08:30 +0100

#1271338 — [PATCH v2 0/3] crypto-ixp4xx: Deletion of a few unnecessary checks

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2015-11-17 16:40 +0100
Subject[PATCH v2 0/3] crypto-ixp4xx: Deletion of a few unnecessary checks
Message-ID<qvQwr-6RR-45@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 17 Nov 2015 16:26:01 +0100
Subject: [PATCH 0/3] crypto-ixp4xx: Deletion of a few unnecessary checks

Further update suggestions were taken into account after a patch
was applied from static source code analysis.

Markus Elfring (3):
  Delete unnecessary checks before the function call "dma_pool_destroy"
  Reduce assignment for a variable in init_ixp_crypto()
  crypto-ixp4xx: Less function calls in init_ixp_crypto() after error detection

 drivers/crypto/ixp4xx_crypto.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

-- 
2.6.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1271348 — [PATCH v2 2/3] crypto-ixp4xx: Reduce assignment for a variable in init_ixp_crypto()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2015-11-17 16:50 +0100
Subject[PATCH v2 2/3] crypto-ixp4xx: Reduce assignment for a variable in init_ixp_crypto()
Message-ID<qvQG5-6Vs-13@gated-at.bofh.it>
In reply to#1271338
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 17 Nov 2015 15:45:32 +0100

The variable "ret" was set more often than necessary by the
init_ixp_crypto() function.

* Omit its initialisation at the beginning.

* Use an error return code in two cases directly.

* Improve compliance with the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/ixp4xx_crypto.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index e52496a..79b6958 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -433,17 +433,17 @@ static void crypto_done_action(unsigned long arg)
 
 static int init_ixp_crypto(struct device *dev)
 {
-	int ret = -ENODEV;
+	int ret;
 	u32 msg[2] = { 0, 0 };
 
 	if (! ( ~(*IXP4XX_EXP_CFG2) & (IXP4XX_FEATURE_HASH |
 				IXP4XX_FEATURE_AES | IXP4XX_FEATURE_DES))) {
 		printk(KERN_ERR "ixp_crypto: No HW crypto available\n");
-		return ret;
+		return -ENODEV;
 	}
 	npe_c = npe_request(NPE_ID);
 	if (!npe_c)
-		return ret;
+		return -ENODEV;
 
 	if (!npe_running(npe_c)) {
 		ret = npe_load_firmware(npe_c, npe_name(npe_c), dev);
@@ -481,13 +481,14 @@ static int init_ixp_crypto(struct device *dev)
 	BUILD_BUG_ON(SHA1_DIGEST_SIZE > sizeof(struct buffer_desc));
 	buffer_pool = dma_pool_create("buffer", dev,
 			sizeof(struct buffer_desc), 32, 0);
-	ret = -ENOMEM;
 	if (!buffer_pool) {
+		ret = -ENOMEM;
 		goto err;
 	}
 	ctx_pool = dma_pool_create("context", dev,
 			NPE_CTX_LEN, 16, 0);
 	if (!ctx_pool) {
+		ret = -ENOMEM;
 		goto err;
 	}
 	ret = qmgr_request_queue(SEND_QID, NPE_QLEN_TOTAL, 0, 0,
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1271351 — [PATCH v2 3/3] crypto-ixp4xx: Less function calls in init_ixp_crypto() after error detection

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2015-11-17 16:50 +0100
Subject[PATCH v2 3/3] crypto-ixp4xx: Less function calls in init_ixp_crypto() after error detection
Message-ID<qvQG6-6Vs-29@gated-at.bofh.it>
In reply to#1271338
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 17 Nov 2015 16:15:21 +0100

The dma_pool_destroy() function was called in up to two cases by the
init_ixp_crypto() function during error handling even if a call of
the dma_pool_create() function failed.

This implementation detail could be improved by the adjustment
of jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/ixp4xx_crypto.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 79b6958..0a5969c 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -483,23 +483,23 @@ static int init_ixp_crypto(struct device *dev)
 			sizeof(struct buffer_desc), 32, 0);
 	if (!buffer_pool) {
 		ret = -ENOMEM;
-		goto err;
+		goto release_npe;
 	}
 	ctx_pool = dma_pool_create("context", dev,
 			NPE_CTX_LEN, 16, 0);
 	if (!ctx_pool) {
 		ret = -ENOMEM;
-		goto err;
+		goto destroy_buffer_pool;
 	}
 	ret = qmgr_request_queue(SEND_QID, NPE_QLEN_TOTAL, 0, 0,
 				 "ixp_crypto:out", NULL);
 	if (ret)
-		goto err;
+		goto destroy_ctx_pool;
 	ret = qmgr_request_queue(RECV_QID, NPE_QLEN, 0, 0,
 				 "ixp_crypto:in", NULL);
 	if (ret) {
 		qmgr_release_queue(SEND_QID);
-		goto err;
+		goto destroy_ctx_pool;
 	}
 	qmgr_set_irq(RECV_QID, QUEUE_IRQ_SRC_NOT_EMPTY, irqhandler, NULL);
 	tasklet_init(&crypto_done_tasklet, crypto_done_action, 0);
@@ -510,9 +510,11 @@ static int init_ixp_crypto(struct device *dev)
 npe_error:
 	printk(KERN_ERR "%s not responding\n", npe_name(npe_c));
 	ret = -EIO;
-err:
+destroy_ctx_pool:
 	dma_pool_destroy(ctx_pool);
+destroy_buffer_pool:
 	dma_pool_destroy(buffer_pool);
+release_npe:
 	npe_release(npe_c);
 	return ret;
 }
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1271352 — [PATCH v2 1/3] crypto-ixp4xx: Delete unnecessary checks before the function call "dma_pool_destroy"

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2015-11-17 16:50 +0100
Subject[PATCH v2 1/3] crypto-ixp4xx: Delete unnecessary checks before the function call "dma_pool_destroy"
Message-ID<qvQG6-6Vs-35@gated-at.bofh.it>
In reply to#1271338
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 15 Nov 2015 16:51:21 +0100

The dma_pool_destroy() function tests whether its argument is NULL
and then returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/ixp4xx_crypto.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 8f27903..e52496a 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -510,10 +510,8 @@ npe_error:
 	printk(KERN_ERR "%s not responding\n", npe_name(npe_c));
 	ret = -EIO;
 err:
-	if (ctx_pool)
-		dma_pool_destroy(ctx_pool);
-	if (buffer_pool)
-		dma_pool_destroy(buffer_pool);
+	dma_pool_destroy(ctx_pool);
+	dma_pool_destroy(buffer_pool);
 	npe_release(npe_c);
 	return ret;
 }
-- 
2.6.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1271753 — Re: [PATCH v2 0/3] crypto-ixp4xx: Deletion of a few unnecessary checks

FromHerbert Xu <herbert@gondor.apana.org.au>
Date2015-11-18 01:10 +0100
SubjectRe: [PATCH v2 0/3] crypto-ixp4xx: Deletion of a few unnecessary checks
Message-ID<qvYtY-3GN-11@gated-at.bofh.it>
In reply to#1271338
On Tue, Nov 17, 2015 at 04:32:47PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 17 Nov 2015 16:26:01 +0100
> Subject: [PATCH 0/3] crypto-ixp4xx: Deletion of a few unnecessary checks
> 
> Further update suggestions were taken into account after a patch
> was applied from static source code analysis.
> 
> Markus Elfring (3):
>   Delete unnecessary checks before the function call "dma_pool_destroy"
>   Reduce assignment for a variable in init_ixp_crypto()
>   crypto-ixp4xx: Less function calls in init_ixp_crypto() after error detection

You completely ignored my comments.  Nack.
-- 
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1271892 — Re: crypto-ixp4xx: Deletion of a few unnecessary checks

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2015-11-18 08:30 +0100
SubjectRe: crypto-ixp4xx: Deletion of a few unnecessary checks
Message-ID<qw5lL-8cX-7@gated-at.bofh.it>
In reply to#1271753
>>   Delete unnecessary checks before the function call "dma_pool_destroy"

It seems that you accepted this specific update suggestion, didn't you?
https://lkml.org/lkml/2015/11/17/391
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1021951.html


>>   Reduce assignment for a variable in init_ixp_crypto()
>>   crypto-ixp4xx: Less function calls in init_ixp_crypto() after error detection
> 
> You completely ignored my comments.  Nack.

Will it be useful to clarify the proposed changes a bit more?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web