Skip to contentSkip to conversation

Ux500 crypto: Adjustments for ux500_cryp_probe()

PATCH In review SF Markus Elfring 2 participants 6 messages Feb 14, 2018 – Feb 22, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Ux500 crypto: Adjustments for ux500_cryp_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 14 Feb 2018 11:12:34 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (4):
Delete an error message for a failed memory allocation Adjust two condition checks
Adjust an error message
Delete two unnecessary variable initialisations

 drivers/crypto/ux500/cryp/cryp_core.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
Signature · 1 line
2.16.1
#1 lore raw

PATCH 1/4 crypto: ux500: Delete an error message for a failed memory allocation in ux500_cryp_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 14 Feb 2018 10:12:38 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/crypto/ux500/cryp/cryp_core.c | 1 -
 1 file changed, 1 deletion(-)
drivers/crypto/ux500/cryp/cryp_core.c +0 -1
index 765f53e548ab..50bfc7b4c641 100644
@@ -1416,7 +1416,6 @@ static int ux500_cryp_probe(struct platform_device *pdev)
 	dev_dbg(dev, "[%s]", __func__);
 	device_data = devm_kzalloc(dev, sizeof(*device_data), GFP_ATOMIC);
 	if (!device_data) {
-		dev_err(dev, "[%s]: kzalloc() failed!", __func__);
 		ret = -ENOMEM;
 		goto out;
 	}
Signature · 1 line
2.16.1
#2 lore raw

PATCH 2/4 crypto: ux500: Adjust two condition checks in ux500_cryp_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 14 Feb 2018 10:38:44 +0100

The local variable "cryp_error" was used only for two condition checks.

* Check the return values from these function calls directly instead.

* Delete this variable which became unnecessary with this refactoring.

---
 drivers/crypto/ux500/cryp/cryp_core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/crypto/ux500/cryp/cryp_core.c +2 -5
index 50bfc7b4c641..07cc92f88933 100644
@@ -1404,7 +1404,6 @@ static void cryp_algs_unregister_all(void)
 static int ux500_cryp_probe(struct platform_device *pdev)
 {
 	int ret;
-	int cryp_error = 0;
 	struct resource *res = NULL;
 	struct resource *res_irq = NULL;
 	struct cryp_device_data *device_data;
@@ -1478,15 +1477,13 @@ static int ux500_cryp_probe(struct platform_device *pdev)
 		goto out_clk_unprepare;
 	}
 
-	cryp_error = cryp_check(device_data);
-	if (cryp_error != 0) {
+	if (cryp_check(device_data)) {
 		dev_err(dev, "[%s]: cryp_init() failed!", __func__);
 		ret = -EINVAL;
 		goto out_power;
 	}
 
-	cryp_error = cryp_configure_protection(device_data, &prot);
-	if (cryp_error != 0) {
+	if (cryp_configure_protection(device_data, &prot)) {
 		dev_err(dev, "[%s]: cryp_configure_protection() failed!",
 			__func__);
 		ret = -EINVAL;
Signature · 1 line
2.16.1
#3 lore raw

PATCH 3/4 crypto: ux500: Adjust an error message in ux500_cryp_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 14 Feb 2018 10:47:31 +0100

Replace the function name in this error message so that the same name is mentioned according to what was called before.

---
 drivers/crypto/ux500/cryp/cryp_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ux500/cryp/cryp_core.c +1 -1
index 07cc92f88933..7c811d7eb274 100644
@@ -1478,7 +1478,7 @@ static int ux500_cryp_probe(struct platform_device *pdev)
 	}
 
 	if (cryp_check(device_data)) {
-		dev_err(dev, "[%s]: cryp_init() failed!", __func__);
+		dev_err(dev, "[%s]: cryp_check() failed!", __func__);
 		ret = -EINVAL;
 		goto out_power;
 	}
Signature · 1 line
2.16.1
#4 lore raw

PATCH 4/4 crypto: ux500: Delete two unnecessary variable initialisations in ux500_cryp_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 14 Feb 2018 10:56:38 +0100

Two local variables will eventually be set to appropriate pointers a bit later. Thus omit their explicit initialisation at the beginning.

---
 drivers/crypto/ux500/cryp/cryp_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/ux500/cryp/cryp_core.c +2 -2
index 7c811d7eb274..cb31b59c9d53 100644
@@ -1404,8 +1404,8 @@ static void cryp_algs_unregister_all(void)
 static int ux500_cryp_probe(struct platform_device *pdev)
 {
 	int ret;
-	struct resource *res = NULL;
-	struct resource *res_irq = NULL;
+	struct resource *res;
+	struct resource *res_irq;
 	struct cryp_device_data *device_data;
 	struct cryp_protection_config prot = {
 		.privilege_access = CRYP_STATE_ENABLE
Signature · 1 line
2.16.1
maintainer
#5 lore raw
In reply to SF Markus Elfring
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 14 Feb 2018 11:12:34 +0100

A few update suggestions were taken into account
from static source code analysis.

Quoted 8 lines

Markus Elfring (4):
Delete an error message for a failed memory allocation Adjust two condition checks
Adjust an error message
Delete two unnecessary variable initialisations

 drivers/crypto/ux500/cryp/cryp_core.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

All applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt