n2rng: Fine-tuning for n2rng_probe()
Subsystems (3)
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
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
@@ -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
PATCH 2/2 n2rng: Combine substrings for two messages in n2rng_probe()
In reply to SF Markus ElfringFrom: 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
@@ -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
Re: [PATCH 1/2] n2rng: Use devm_kcalloc() in n2rng_probe()
In reply to SF Markus ElfringQuoted 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.
Signed-off-by Markus Elfring <[email protected]>
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@@ -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)
Re: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:50:04 +0200The script "checkpatch.pl" pointed information out like the following.
WARNING: quoted string split across lines
Thus fix the affected source code places.
Signed-off-by Markus Elfring <[email protected]>
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@@ -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; }
Herbert Xu
maintainerRe: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:50:04 +0200The script "checkpatch.pl" pointed information out like the following.
WARNING: quoted string split across lines
Thus fix the affected source code places.
Signed-off-by Markus Elfring <[email protected]>
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
Herbert Xu
maintainerRe: [PATCH 1/2] n2rng: Use devm_kcalloc() in n2rng_probe()
In reply to SF Markus ElfringQuoted 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.
Signed-off-by Markus Elfring <[email protected]>
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
David Miller
maintainerRe: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()
In reply to Herbert XuFrom: 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 +0200The 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.
Signed-off-by Markus Elfring <[email protected]>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.
Re: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()
In reply to Herbert XuQuoted 6 lines · Herbert Xu
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:50:04 +0200The 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.
Signed-off-by Markus Elfring <[email protected]>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.