linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] clk-mvebu: Fine-tuning for four function implementations
@ 2017-04-19 19:51 SF Markus Elfring
  2017-04-19 19:52 ` [PATCH 1/5] clk: mvebu: Use kcalloc() in of_cpu_clk_setup() SF Markus Elfring
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-04-19 19:51 UTC (permalink / raw)
  To: linux-clk, Michael Turquette, Stephen Boyd; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Apr 2017 21:45:43 +0200

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

Markus Elfring (5):
  Use kcalloc() in of_cpu_clk_setup()
  Adjust two checks for null pointers in of_cpu_clk_setup()
  Use kcalloc() in two functions
  Adjust two checks for null pointers in kirkwood_fix_sscg_deviation()
  Delete an unnecessary variable initialisation in kirkwood_fix_sscg_deviation()

 drivers/clk/mvebu/clk-cpu.c |  8 ++++----
 drivers/clk/mvebu/common.c  | 10 +++++-----
 2 files changed, 9 insertions(+), 9 deletions(-)

-- 
2.12.2

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

* [PATCH 1/5] clk: mvebu: Use kcalloc() in of_cpu_clk_setup()
  2017-04-19 19:51 [PATCH 0/5] clk-mvebu: Fine-tuning for four function implementations SF Markus Elfring
@ 2017-04-19 19:52 ` SF Markus Elfring
  2017-04-22  2:49   ` Stephen Boyd
  2017-04-19 19:54 ` [PATCH 2/5] clk: mvebu: Adjust two checks for null pointers " SF Markus Elfring
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: SF Markus Elfring @ 2017-04-19 19:52 UTC (permalink / raw)
  To: linux-clk, Michael Turquette, Stephen Boyd; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Apr 2017 20:15:21 +0200

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/clk/mvebu/clk-cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/mvebu/clk-cpu.c b/drivers/clk/mvebu/clk-cpu.c
index 044892b6534d..072aa38374ce 100644
--- a/drivers/clk/mvebu/clk-cpu.c
+++ b/drivers/clk/mvebu/clk-cpu.c
@@ -186,11 +186,11 @@ static void __init of_cpu_clk_setup(struct device_node *node)
 	for_each_node_by_type(dn, "cpu")
 		ncpus++;
 
-	cpuclk = kzalloc(ncpus * sizeof(*cpuclk), GFP_KERNEL);
+	cpuclk = kcalloc(ncpus, sizeof(*cpuclk), GFP_KERNEL);
 	if (WARN_ON(!cpuclk))
 		goto cpuclk_out;
 
-	clks = kzalloc(ncpus * sizeof(*clks), GFP_KERNEL);
+	clks = kcalloc(ncpus, sizeof(*clks), GFP_KERNEL);
 	if (WARN_ON(!clks))
 		goto clks_out;
 
-- 
2.12.2

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

* [PATCH 2/5] clk: mvebu: Adjust two checks for null pointers in of_cpu_clk_setup()
  2017-04-19 19:51 [PATCH 0/5] clk-mvebu: Fine-tuning for four function implementations SF Markus Elfring
  2017-04-19 19:52 ` [PATCH 1/5] clk: mvebu: Use kcalloc() in of_cpu_clk_setup() SF Markus Elfring
@ 2017-04-19 19:54 ` SF Markus Elfring
  2017-04-19 19:55 ` [PATCH 3/5] clk: mvebu: Use kcalloc() in two functions SF Markus Elfring
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-04-19 19:54 UTC (permalink / raw)
  To: linux-clk, Michael Turquette, Stephen Boyd; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Apr 2017 20:25:59 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/clk/mvebu/clk-cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/mvebu/clk-cpu.c b/drivers/clk/mvebu/clk-cpu.c
index 072aa38374ce..8162833d2041 100644
--- a/drivers/clk/mvebu/clk-cpu.c
+++ b/drivers/clk/mvebu/clk-cpu.c
@@ -173,13 +173,13 @@ static void __init of_cpu_clk_setup(struct device_node *node)
 	int ncpus = 0;
 	struct device_node *dn;
 
-	if (clock_complex_base == NULL) {
+	if (!clock_complex_base) {
 		pr_err("%s: clock-complex base register not set\n",
 			__func__);
 		return;
 	}
 
-	if (pmu_dfs_base == NULL)
+	if (!pmu_dfs_base)
 		pr_warn("%s: pmu-dfs base register not set, dynamic frequency scaling not available\n",
 			__func__);
 
-- 
2.12.2

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

* [PATCH 3/5] clk: mvebu: Use kcalloc() in two functions
  2017-04-19 19:51 [PATCH 0/5] clk-mvebu: Fine-tuning for four function implementations SF Markus Elfring
  2017-04-19 19:52 ` [PATCH 1/5] clk: mvebu: Use kcalloc() in of_cpu_clk_setup() SF Markus Elfring
  2017-04-19 19:54 ` [PATCH 2/5] clk: mvebu: Adjust two checks for null pointers " SF Markus Elfring
@ 2017-04-19 19:55 ` SF Markus Elfring
  2017-04-22  2:49   ` Stephen Boyd
  2017-04-19 19:56 ` [PATCH 4/5] clk: mvebu: Adjust two checks for null pointers in kirkwood_fix_sscg_deviation() SF Markus Elfring
  2017-04-19 19:57 ` [PATCH 5/5] clk: mvebu: Delete an unnecessary variable initialisation " SF Markus Elfring
  4 siblings, 1 reply; 8+ messages in thread
From: SF Markus Elfring @ 2017-04-19 19:55 UTC (permalink / raw)
  To: linux-clk, Michael Turquette, Stephen Boyd; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Apr 2017 21:08:54 +0200

* 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.

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/clk/mvebu/common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/mvebu/common.c b/drivers/clk/mvebu/common.c
index 66be2e0c82b4..472c88b90256 100644
--- a/drivers/clk/mvebu/common.c
+++ b/drivers/clk/mvebu/common.c
@@ -126,7 +126,7 @@ void __init mvebu_coreclk_setup(struct device_node *np,
 	if (desc->get_refclk_freq)
 		clk_data.clk_num += 1;
 
-	clk_data.clks = kzalloc(clk_data.clk_num * sizeof(struct clk *),
+	clk_data.clks = kcalloc(clk_data.clk_num, sizeof(*clk_data.clks),
 				GFP_KERNEL);
 	if (WARN_ON(!clk_data.clks)) {
 		iounmap(base);
@@ -270,7 +270,7 @@ void __init mvebu_clk_gating_setup(struct device_node *np,
 		n++;
 
 	ctrl->num_gates = n;
-	ctrl->gates = kzalloc(ctrl->num_gates * sizeof(struct clk *),
+	ctrl->gates = kcalloc(ctrl->num_gates, sizeof(*ctrl->gates),
 			      GFP_KERNEL);
 	if (WARN_ON(!ctrl->gates))
 		goto gates_out;
-- 
2.12.2

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

* [PATCH 4/5] clk: mvebu: Adjust two checks for null pointers in kirkwood_fix_sscg_deviation()
  2017-04-19 19:51 [PATCH 0/5] clk-mvebu: Fine-tuning for four function implementations SF Markus Elfring
                   ` (2 preceding siblings ...)
  2017-04-19 19:55 ` [PATCH 3/5] clk: mvebu: Use kcalloc() in two functions SF Markus Elfring
@ 2017-04-19 19:56 ` SF Markus Elfring
  2017-04-19 19:57 ` [PATCH 5/5] clk: mvebu: Delete an unnecessary variable initialisation " SF Markus Elfring
  4 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-04-19 19:56 UTC (permalink / raw)
  To: linux-clk, Michael Turquette, Stephen Boyd; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Apr 2017 21:17:19 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/clk/mvebu/common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/mvebu/common.c b/drivers/clk/mvebu/common.c
index 472c88b90256..659d534a137b 100644
--- a/drivers/clk/mvebu/common.c
+++ b/drivers/clk/mvebu/common.c
@@ -51,13 +51,13 @@ u32 kirkwood_fix_sscg_deviation(u32 system_clk)
 	u64 freq_swing_half;
 
 	sscg_np = of_find_node_by_name(NULL, "sscg");
-	if (sscg_np == NULL) {
+	if (!sscg_np) {
 		pr_err("cannot get SSCG register node\n");
 		return system_clk;
 	}
 
 	sscg_map = of_iomap(sscg_np, 0);
-	if (sscg_map == NULL) {
+	if (!sscg_map) {
 		pr_err("cannot map SSCG register\n");
 		goto out;
 	}
-- 
2.12.2

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

* [PATCH 5/5] clk: mvebu: Delete an unnecessary variable initialisation in kirkwood_fix_sscg_deviation()
  2017-04-19 19:51 [PATCH 0/5] clk-mvebu: Fine-tuning for four function implementations SF Markus Elfring
                   ` (3 preceding siblings ...)
  2017-04-19 19:56 ` [PATCH 4/5] clk: mvebu: Adjust two checks for null pointers in kirkwood_fix_sscg_deviation() SF Markus Elfring
@ 2017-04-19 19:57 ` SF Markus Elfring
  4 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-04-19 19:57 UTC (permalink / raw)
  To: linux-clk, Michael Turquette, Stephen Boyd; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Apr 2017 21:31:43 +0200

A pointer is immediately assigned to the local variable "sscg_np".
Thus omit the explicit initialisation at the beginning.

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

diff --git a/drivers/clk/mvebu/common.c b/drivers/clk/mvebu/common.c
index 659d534a137b..6cfa38566e19 100644
--- a/drivers/clk/mvebu/common.c
+++ b/drivers/clk/mvebu/common.c
@@ -44,7 +44,7 @@ static struct clk_onecell_data clk_data;
  */
 u32 kirkwood_fix_sscg_deviation(u32 system_clk)
 {
-	struct device_node *sscg_np = NULL;
+	struct device_node *sscg_np;
 	void __iomem *sscg_map;
 	u32 sscg_reg;
 	s32 low_bound, high_bound;
-- 
2.12.2

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

* Re: [PATCH 1/5] clk: mvebu: Use kcalloc() in of_cpu_clk_setup()
  2017-04-19 19:52 ` [PATCH 1/5] clk: mvebu: Use kcalloc() in of_cpu_clk_setup() SF Markus Elfring
@ 2017-04-22  2:49   ` Stephen Boyd
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2017-04-22  2:49 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-clk, Michael Turquette, LKML, kernel-janitors

On 04/19, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Apr 2017 20:15:21 +0200
> 
> 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>
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH 3/5] clk: mvebu: Use kcalloc() in two functions
  2017-04-19 19:55 ` [PATCH 3/5] clk: mvebu: Use kcalloc() in two functions SF Markus Elfring
@ 2017-04-22  2:49   ` Stephen Boyd
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2017-04-22  2:49 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-clk, Michael Turquette, LKML, kernel-janitors

On 04/19, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Apr 2017 21:08:54 +0200
> 
> * 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.
> 
> * Replace the specification of data types by pointer dereferences
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

end of thread, other threads:[~2017-04-22  2:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-19 19:51 [PATCH 0/5] clk-mvebu: Fine-tuning for four function implementations SF Markus Elfring
2017-04-19 19:52 ` [PATCH 1/5] clk: mvebu: Use kcalloc() in of_cpu_clk_setup() SF Markus Elfring
2017-04-22  2:49   ` Stephen Boyd
2017-04-19 19:54 ` [PATCH 2/5] clk: mvebu: Adjust two checks for null pointers " SF Markus Elfring
2017-04-19 19:55 ` [PATCH 3/5] clk: mvebu: Use kcalloc() in two functions SF Markus Elfring
2017-04-22  2:49   ` Stephen Boyd
2017-04-19 19:56 ` [PATCH 4/5] clk: mvebu: Adjust two checks for null pointers in kirkwood_fix_sscg_deviation() SF Markus Elfring
2017-04-19 19:57 ` [PATCH 5/5] clk: mvebu: Delete an unnecessary variable initialisation " SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).