Skip to contentSkip to conversation

n2rng: Fine-tuning for n2rng_probe()

PATCH In review SF Markus Elfring 5 participants 9 messages Apr 19, 2017 – Apr 21, 2017

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

cover n2rng: Fine-tuning for n2rng_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 11:00:11 +0200

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

Markus Elfring (2):
Use devm_kcalloc()
Combine substrings for two messages

 drivers/char/hw_random/n2-drv.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
Signature · 1 line
2.12.2
#1 lore raw

PATCH 1/2 n2rng: Use devm_kcalloc() in n2rng_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:30:47 +0200

* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "devm_kcalloc".

* Replace the specification of a data structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.

---
 drivers/char/hw_random/n2-drv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/char/hw_random/n2-drv.c +1 -3
index 31cbdbbaebfc..92dd4e925315 100644
@@ -748,9 +748,7 @@ static int n2rng_probe(struct platform_device *op)
 
 	dev_info(&op->dev, "Registered RNG HVAPI major %lu minor %lu\n",
 		 np->hvapi_major, np->hvapi_minor);
-
-	np->units = devm_kzalloc(&op->dev,
-				 sizeof(struct n2rng_unit) * np->num_units,
+	np->units = devm_kcalloc(&op->dev, np->num_units, sizeof(*np->units),
 				 GFP_KERNEL);
 	err = -ENOMEM;
 	if (!np->units)
Signature · 1 line
2.12.2
#4 lore raw

PATCH 2/2 n2rng: Combine substrings for two messages in n2rng_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:50:04 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code places.

---
 drivers/char/hw_random/n2-drv.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/char/hw_random/n2-drv.c +4 -4
index 92dd4e925315..f3e67c768101 100644
@@ -723,16 +723,16 @@ static int n2rng_probe(struct platform_device *op)
 		if (sun4v_hvapi_register(HV_GRP_RNG,
 					 np->hvapi_major,
 					 &np->hvapi_minor)) {
-			dev_err(&op->dev, "Cannot register suitable "
-				"HVAPI version.\n");
+			dev_err(&op->dev,
+				"Cannot register suitable HVAPI version.\n");
 			goto out;
 		}
 	}
 
 	if (np->flags & N2RNG_FLAG_MULTI) {
 		if (np->hvapi_major < 2) {
-			dev_err(&op->dev, "multi-unit-capable RNG requires "
-				"HVAPI major version 2 or later, got %lu\n",
+			dev_err(&op->dev,
+				"multi-unit-capable RNG requires HVAPI major version 2 or later, got %lu\n",
 				np->hvapi_major);
 			goto out_hvapi_unregister;
 		}
Signature · 1 line
2.12.2
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] n2rng: Use devm_kcalloc() in n2rng_probe()

In reply to SF Markus Elfring
Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:30:47 +0200

* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "devm_kcalloc".

Quoted 5 lines

* Replace the specification of a data structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.

Thanks Markus.

Quoted 20 lines
---
 drivers/char/hw_random/n2-drv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/char/hw_random/n2-drv.c +1 -3
index 31cbdbbaebfc..92dd4e925315 100644
@@ -748,9 +748,7 @@ static int n2rng_probe(struct platform_device *op)
 
 	dev_info(&op->dev, "Registered RNG HVAPI major %lu minor %lu\n",
 		 np->hvapi_major, np->hvapi_minor);
-
-	np->units = devm_kzalloc(&op->dev,
-				 sizeof(struct n2rng_unit) * np->num_units,
+	np->units = devm_kcalloc(&op->dev, np->num_units, sizeof(*np->units),
 				 GFP_KERNEL);
 	err = -ENOMEM;
 	if (!np->units)
Acked-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:50:04 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code places.

Thanks Markus.

Quoted 30 lines
---
 drivers/char/hw_random/n2-drv.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/char/hw_random/n2-drv.c +4 -4
index 92dd4e925315..f3e67c768101 100644
@@ -723,16 +723,16 @@ static int n2rng_probe(struct platform_device *op)
 		if (sun4v_hvapi_register(HV_GRP_RNG,
 					 np->hvapi_major,
 					 &np->hvapi_minor)) {
-			dev_err(&op->dev, "Cannot register suitable "
-				"HVAPI version.\n");
+			dev_err(&op->dev,
+				"Cannot register suitable HVAPI version.\n");
 			goto out;
 		}
 	}
 
 	if (np->flags & N2RNG_FLAG_MULTI) {
 		if (np->hvapi_major < 2) {
-			dev_err(&op->dev, "multi-unit-capable RNG requires "
-				"HVAPI major version 2 or later, got %lu\n",
+			dev_err(&op->dev,
+				"multi-unit-capable RNG requires HVAPI major version 2 or later, got %lu\n",
 				np->hvapi_major);
 			goto out_hvapi_unregister;
 		}
maintainer
#6 lore raw

Re: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:50:04 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code places.

This patch doesn't seem to add any value so I'm not taking it.

Please don't send patches based purely on a checkpatch complaint.

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
maintainer
#3 lore raw

Re: [PATCH 1/2] n2rng: Use devm_kcalloc() in n2rng_probe()

In reply to SF Markus Elfring
Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:30:47 +0200

* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "devm_kcalloc".

Quoted 5 lines

* Replace the specification of a data structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.

Patch 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
maintainer
#7 lore raw

Re: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()

In reply to Herbert Xu

From: Herbert Xu <[email protected]>
Date: Fri, 21 Apr 2017 19:36:41 +0800

Quoted 8 lines · SF Markus Elfring
Quoted 7 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:50:04 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Quoted 7 lines
Quoted 3 lines

Thus fix the affected source code places.

This patch doesn't seem to add any value so I'm not taking it.

Please don't send patches based purely on a checkpatch complaint.

Thank you Herbert.

#8 lore raw

Re: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()

In reply to Herbert Xu
Quoted 6 lines · Herbert Xu
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:50:04 +0200

The script "checkpatch.pl" pointed information out like the following.

Quoted 7 lines
Quoted 5 lines

WARNING: quoted string split across lines

Thus fix the affected source code places.

This patch doesn't seem to add any value so I'm not taking it.

Your choice.

The general reason to merge strings is in CodingStyle

2) Breaking long lines and strings
[]
never break user-visible strings such as
printk messages, because that breaks the ability to grep for them.