All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] sh/intc: Fine-tuning for register_intc_controller()
@ 2017-01-13  9:45 ` SF Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2017-01-13  9:45 UTC (permalink / raw)
  To: linux-sh, Rich Felker, Yoshinori Sato; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Jan 2017 10:42:10 +0100

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

Markus Elfring (3):
  Use kcalloc()
  Combine substrings for a message
  Add a space character for better code readability

 drivers/sh/intc/core.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 0/3] sh/intc: Fine-tuning for register_intc_controller()
@ 2017-01-13  9:45 ` SF Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2017-01-13  9:45 UTC (permalink / raw)
  To: linux-sh, Rich Felker, Yoshinori Sato; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Jan 2017 10:42:10 +0100

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

Markus Elfring (3):
  Use kcalloc()
  Combine substrings for a message
  Add a space character for better code readability

 drivers/sh/intc/core.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] sh/intc: Use kcalloc() in register_intc_controller()
  2017-01-13  9:45 ` SF Markus Elfring
@ 2017-01-13  9:48   ` SF Markus Elfring
  -1 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2017-01-13  9:48 UTC (permalink / raw)
  To: linux-sh, Rich Felker, Yoshinori Sato; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Jan 2017 10:04:38 +0100

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/sh/intc/core.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 8e72bcbd3d6d..27817a8466f1 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -203,7 +203,8 @@ int __init register_intc_controller(struct intc_desc *desc)
 
 	if (desc->num_resources) {
 		d->nr_windows = desc->num_resources;
-		d->window = kzalloc(d->nr_windows * sizeof(*d->window),
+		d->window = kcalloc(d->nr_windows,
+				    sizeof(*d->window),
 				    GFP_NOWAIT);
 		if (!d->window)
 			goto err1;
@@ -229,13 +230,12 @@ int __init register_intc_controller(struct intc_desc *desc)
 	d->nr_reg += hw->sense_regs ? hw->nr_sense_regs : 0;
 	d->nr_reg += hw->ack_regs ? hw->nr_ack_regs : 0;
 	d->nr_reg += hw->subgroups ? hw->nr_subgroups : 0;
-
-	d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT);
+	d->reg = kcalloc(d->nr_reg, sizeof(*d->reg), GFP_NOWAIT);
 	if (!d->reg)
 		goto err2;
 
 #ifdef CONFIG_SMP
-	d->smp = kzalloc(d->nr_reg * sizeof(*d->smp), GFP_NOWAIT);
+	d->smp = kcalloc(d->nr_reg, sizeof(*d->smp), GFP_NOWAIT);
 	if (!d->smp)
 		goto err3;
 #endif
@@ -253,7 +253,8 @@ int __init register_intc_controller(struct intc_desc *desc)
 	}
 
 	if (hw->prio_regs) {
-		d->prio = kzalloc(hw->nr_vectors * sizeof(*d->prio),
+		d->prio = kcalloc(hw->nr_vectors,
+				  sizeof(*d->prio),
 				  GFP_NOWAIT);
 		if (!d->prio)
 			goto err4;
@@ -269,7 +270,8 @@ int __init register_intc_controller(struct intc_desc *desc)
 	}
 
 	if (hw->sense_regs) {
-		d->sense = kzalloc(hw->nr_vectors * sizeof(*d->sense),
+		d->sense = kcalloc(hw->nr_vectors,
+				   sizeof(*d->sense),
 				   GFP_NOWAIT);
 		if (!d->sense)
 			goto err5;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 1/3] sh/intc: Use kcalloc() in register_intc_controller()
@ 2017-01-13  9:48   ` SF Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2017-01-13  9:48 UTC (permalink / raw)
  To: linux-sh, Rich Felker, Yoshinori Sato; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Jan 2017 10:04:38 +0100

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/sh/intc/core.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 8e72bcbd3d6d..27817a8466f1 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -203,7 +203,8 @@ int __init register_intc_controller(struct intc_desc *desc)
 
 	if (desc->num_resources) {
 		d->nr_windows = desc->num_resources;
-		d->window = kzalloc(d->nr_windows * sizeof(*d->window),
+		d->window = kcalloc(d->nr_windows,
+				    sizeof(*d->window),
 				    GFP_NOWAIT);
 		if (!d->window)
 			goto err1;
@@ -229,13 +230,12 @@ int __init register_intc_controller(struct intc_desc *desc)
 	d->nr_reg += hw->sense_regs ? hw->nr_sense_regs : 0;
 	d->nr_reg += hw->ack_regs ? hw->nr_ack_regs : 0;
 	d->nr_reg += hw->subgroups ? hw->nr_subgroups : 0;
-
-	d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT);
+	d->reg = kcalloc(d->nr_reg, sizeof(*d->reg), GFP_NOWAIT);
 	if (!d->reg)
 		goto err2;
 
 #ifdef CONFIG_SMP
-	d->smp = kzalloc(d->nr_reg * sizeof(*d->smp), GFP_NOWAIT);
+	d->smp = kcalloc(d->nr_reg, sizeof(*d->smp), GFP_NOWAIT);
 	if (!d->smp)
 		goto err3;
 #endif
@@ -253,7 +253,8 @@ int __init register_intc_controller(struct intc_desc *desc)
 	}
 
 	if (hw->prio_regs) {
-		d->prio = kzalloc(hw->nr_vectors * sizeof(*d->prio),
+		d->prio = kcalloc(hw->nr_vectors,
+				  sizeof(*d->prio),
 				  GFP_NOWAIT);
 		if (!d->prio)
 			goto err4;
@@ -269,7 +270,8 @@ int __init register_intc_controller(struct intc_desc *desc)
 	}
 
 	if (hw->sense_regs) {
-		d->sense = kzalloc(hw->nr_vectors * sizeof(*d->sense),
+		d->sense = kcalloc(hw->nr_vectors,
+				   sizeof(*d->sense),
 				   GFP_NOWAIT);
 		if (!d->sense)
 			goto err5;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] sh/intc: Combine substrings for a message in register_intc_controller()
  2017-01-13  9:45 ` SF Markus Elfring
@ 2017-01-13  9:49   ` SF Markus Elfring
  -1 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2017-01-13  9:49 UTC (permalink / raw)
  To: linux-sh, Rich Felker, Yoshinori Sato; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Jan 2017 10:16:40 +0100

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

WARNING: quoted string split across lines

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/sh/intc/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 27817a8466f1..95fb29d69ab7 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -353,8 +353,7 @@ int __init register_intc_controller(struct intc_desc *desc)
 					res = irq_domain_associate(d->domain,
 								   irq2, irq2);
 					if (unlikely(res)) {
-						pr_err("domain association "
-						       "failure\n");
+						pr_err("domain association failure\n");
 						continue;
 					}
 				} else {
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] sh/intc: Combine substrings for a message in register_intc_controller()
@ 2017-01-13  9:49   ` SF Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2017-01-13  9:49 UTC (permalink / raw)
  To: linux-sh, Rich Felker, Yoshinori Sato; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Jan 2017 10:16:40 +0100

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

WARNING: quoted string split across lines

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/sh/intc/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 27817a8466f1..95fb29d69ab7 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -353,8 +353,7 @@ int __init register_intc_controller(struct intc_desc *desc)
 					res = irq_domain_associate(d->domain,
 								   irq2, irq2);
 					if (unlikely(res)) {
-						pr_err("domain association "
-						       "failure\n");
+						pr_err("domain association failure\n");
 						continue;
 					}
 				} else {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] sh/intc: Add a space character for better code readability in register_intc_controller()
  2017-01-13  9:45 ` SF Markus Elfring
@ 2017-01-13  9:50   ` SF Markus Elfring
  -1 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2017-01-13  9:50 UTC (permalink / raw)
  To: linux-sh, Rich Felker, Yoshinori Sato; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Jan 2017 10:32:04 +0100

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

ERROR: spaces required around that '+=' (ctx:VxW)

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/sh/intc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 95fb29d69ab7..e7f5aeeb1cee 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -286,7 +286,7 @@ int __init register_intc_controller(struct intc_desc *desc)
 	if (hw->subgroups)
 		for (i = 0; i < hw->nr_subgroups; i++)
 			if (hw->subgroups[i].reg)
-				k+= save_reg(d, k, hw->subgroups[i].reg, 0);
+				k += save_reg(d, k, hw->subgroups[i].reg, 0);
 
 	memcpy(&d->chip, &intc_irq_chip, sizeof(struct irq_chip));
 	d->chip.name = desc->name;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] sh/intc: Add a space character for better code readability in register_intc_controller()
@ 2017-01-13  9:50   ` SF Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2017-01-13  9:50 UTC (permalink / raw)
  To: linux-sh, Rich Felker, Yoshinori Sato; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Jan 2017 10:32:04 +0100

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

ERROR: spaces required around that '+=' (ctx:VxW)

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/sh/intc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 95fb29d69ab7..e7f5aeeb1cee 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -286,7 +286,7 @@ int __init register_intc_controller(struct intc_desc *desc)
 	if (hw->subgroups)
 		for (i = 0; i < hw->nr_subgroups; i++)
 			if (hw->subgroups[i].reg)
-				k+= save_reg(d, k, hw->subgroups[i].reg, 0);
+				k += save_reg(d, k, hw->subgroups[i].reg, 0);
 
 	memcpy(&d->chip, &intc_irq_chip, sizeof(struct irq_chip));
 	d->chip.name = desc->name;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] sh/intc: Use kcalloc() in register_intc_controller()
  2017-01-13  9:48   ` SF Markus Elfring
@ 2017-01-13 10:24     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2017-01-13 10:24 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Linux-sh list, Rich Felker, Yoshinori Sato, LKML, kernel-janitors

Hi Markus,

On Fri, Jan 13, 2017 at 10:48 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> --- a/drivers/sh/intc/core.c
> +++ b/drivers/sh/intc/core.c

> @@ -253,7 +253,8 @@ int __init register_intc_controller(struct intc_desc *desc)
>         }
>
>         if (hw->prio_regs) {
> -               d->prio = kzalloc(hw->nr_vectors * sizeof(*d->prio),
> +               d->prio = kcalloc(hw->nr_vectors,
> +                                 sizeof(*d->prio),

Please don't split lines without a good reason.

>                                   GFP_NOWAIT);

In this particular case, I'd even use the opportunity to merge the above line
with the previous one instead, now it fits in 80 characters ;-)

>                 if (!d->prio)
>                         goto err4;
> @@ -269,7 +270,8 @@ int __init register_intc_controller(struct intc_desc *desc)
>         }
>
>         if (hw->sense_regs) {
> -               d->sense = kzalloc(hw->nr_vectors * sizeof(*d->sense),
> +               d->sense = kcalloc(hw->nr_vectors,
> +                                  sizeof(*d->sense),

Likewise

>                                    GFP_NOWAIT);
>                 if (!d->sense)

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] sh/intc: Use kcalloc() in register_intc_controller()
@ 2017-01-13 10:24     ` Geert Uytterhoeven
  0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2017-01-13 10:24 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Linux-sh list, Rich Felker, Yoshinori Sato, LKML, kernel-janitors

Hi Markus,

On Fri, Jan 13, 2017 at 10:48 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> --- a/drivers/sh/intc/core.c
> +++ b/drivers/sh/intc/core.c

> @@ -253,7 +253,8 @@ int __init register_intc_controller(struct intc_desc *desc)
>         }
>
>         if (hw->prio_regs) {
> -               d->prio = kzalloc(hw->nr_vectors * sizeof(*d->prio),
> +               d->prio = kcalloc(hw->nr_vectors,
> +                                 sizeof(*d->prio),

Please don't split lines without a good reason.

>                                   GFP_NOWAIT);

In this particular case, I'd even use the opportunity to merge the above line
with the previous one instead, now it fits in 80 characters ;-)

>                 if (!d->prio)
>                         goto err4;
> @@ -269,7 +270,8 @@ int __init register_intc_controller(struct intc_desc *desc)
>         }
>
>         if (hw->sense_regs) {
> -               d->sense = kzalloc(hw->nr_vectors * sizeof(*d->sense),
> +               d->sense = kcalloc(hw->nr_vectors,
> +                                  sizeof(*d->sense),

Likewise

>                                    GFP_NOWAIT);
>                 if (!d->sense)

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-01-13 10:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-13  9:45 [PATCH 0/3] sh/intc: Fine-tuning for register_intc_controller() SF Markus Elfring
2017-01-13  9:45 ` SF Markus Elfring
2017-01-13  9:48 ` [PATCH 1/3] sh/intc: Use kcalloc() in register_intc_controller() SF Markus Elfring
2017-01-13  9:48   ` SF Markus Elfring
2017-01-13 10:24   ` Geert Uytterhoeven
2017-01-13 10:24     ` Geert Uytterhoeven
2017-01-13  9:49 ` [PATCH 2/3] sh/intc: Combine substrings for a message " SF Markus Elfring
2017-01-13  9:49   ` SF Markus Elfring
2017-01-13  9:50 ` [PATCH 3/3] sh/intc: Add a space character for better code readability " SF Markus Elfring
2017-01-13  9:50   ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.