* [PATCH 1/4] crypto: ux500: Delete an error message for a failed memory allocation in ux500_cryp_prob
2018-02-14 10:16 [PATCH 0/4] Ux500 crypto: Adjustments for ux500_cryp_probe() SF Markus Elfring
@ 2018-02-14 10:18 ` SF Markus Elfring
2018-02-14 10:19 ` [PATCH 2/4] crypto: ux500: Adjust two condition checks in ux500_cryp_probe() SF Markus Elfring
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2018-02-14 10:18 UTC (permalink / raw)
To: linux-crypto, David S. Miller, Geliang Tang, Herbert Xu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/crypto/ux500/cryp/cryp_core.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c
index 765f53e548ab..50bfc7b4c641 100644
--- a/drivers/crypto/ux500/cryp/cryp_core.c
+++ b/drivers/crypto/ux500/cryp/cryp_core.c
@@ -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;
}
--
2.16.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/4] crypto: ux500: Adjust two condition checks in ux500_cryp_probe()
2018-02-14 10:16 [PATCH 0/4] Ux500 crypto: Adjustments for ux500_cryp_probe() SF Markus Elfring
2018-02-14 10:18 ` [PATCH 1/4] crypto: ux500: Delete an error message for a failed memory allocation in ux500_cryp_prob SF Markus Elfring
@ 2018-02-14 10:19 ` SF Markus Elfring
2018-02-14 10:20 ` [PATCH 3/4] crypto: ux500: Adjust an error message " SF Markus Elfring
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2018-02-14 10:19 UTC (permalink / raw)
To: linux-crypto, David S. Miller, Geliang Tang, Herbert Xu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/crypto/ux500/cryp/cryp_core.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c
index 50bfc7b4c641..07cc92f88933 100644
--- a/drivers/crypto/ux500/cryp/cryp_core.c
+++ b/drivers/crypto/ux500/cryp/cryp_core.c
@@ -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;
--
2.16.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/4] crypto: ux500: Adjust an error message in ux500_cryp_probe()
2018-02-14 10:16 [PATCH 0/4] Ux500 crypto: Adjustments for ux500_cryp_probe() SF Markus Elfring
2018-02-14 10:18 ` [PATCH 1/4] crypto: ux500: Delete an error message for a failed memory allocation in ux500_cryp_prob SF Markus Elfring
2018-02-14 10:19 ` [PATCH 2/4] crypto: ux500: Adjust two condition checks in ux500_cryp_probe() SF Markus Elfring
@ 2018-02-14 10:20 ` SF Markus Elfring
2018-02-14 10:22 ` [PATCH 4/4] crypto: ux500: Delete two unnecessary variable initialisations " SF Markus Elfring
2018-02-22 15:12 ` [PATCH 0/4] Ux500 crypto: Adjustments for ux500_cryp_probe() Herbert Xu
4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2018-02-14 10:20 UTC (permalink / raw)
To: linux-crypto, David S. Miller, Geliang Tang, Herbert Xu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/crypto/ux500/cryp/cryp_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c
index 07cc92f88933..7c811d7eb274 100644
--- a/drivers/crypto/ux500/cryp/cryp_core.c
+++ b/drivers/crypto/ux500/cryp/cryp_core.c
@@ -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;
}
--
2.16.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/4] crypto: ux500: Delete two unnecessary variable initialisations in ux500_cryp_probe()
2018-02-14 10:16 [PATCH 0/4] Ux500 crypto: Adjustments for ux500_cryp_probe() SF Markus Elfring
` (2 preceding siblings ...)
2018-02-14 10:20 ` [PATCH 3/4] crypto: ux500: Adjust an error message " SF Markus Elfring
@ 2018-02-14 10:22 ` SF Markus Elfring
2018-02-22 15:12 ` [PATCH 0/4] Ux500 crypto: Adjustments for ux500_cryp_probe() Herbert Xu
4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2018-02-14 10:22 UTC (permalink / raw)
To: linux-crypto, David S. Miller, Geliang Tang, Herbert Xu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/crypto/ux500/cryp/cryp_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c
index 7c811d7eb274..cb31b59c9d53 100644
--- a/drivers/crypto/ux500/cryp/cryp_core.c
+++ b/drivers/crypto/ux500/cryp/cryp_core.c
@@ -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
--
2.16.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 0/4] Ux500 crypto: Adjustments for ux500_cryp_probe()
2018-02-14 10:16 [PATCH 0/4] Ux500 crypto: Adjustments for ux500_cryp_probe() SF Markus Elfring
` (3 preceding siblings ...)
2018-02-14 10:22 ` [PATCH 4/4] crypto: ux500: Delete two unnecessary variable initialisations " SF Markus Elfring
@ 2018-02-22 15:12 ` Herbert Xu
4 siblings, 0 replies; 6+ messages in thread
From: Herbert Xu @ 2018-02-22 15:12 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-crypto, David S. Miller, Geliang Tang, LKML,
kernel-janitors
On Wed, Feb 14, 2018 at 11:16:39AM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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(-)
All 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] 6+ messages in thread