From: Markus Elfring <[email protected]>
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
From: Markus Elfring <[email protected]>
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 <[email protected]>
---
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
From: Markus Elfring <[email protected]>
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 <[email protected]>
---
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
From: Markus Elfring <[email protected]>
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 <[email protected]>
---
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
From: Markus Elfring <[email protected]>
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 <[email protected]>
---
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
From: Markus Elfring <[email protected]>
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 <[email protected]>
---
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
On 04/19, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> 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 <[email protected]>
> ---
Applied to clk-next
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
On 04/19, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> 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 <[email protected]>
> ---
Applied to clk-next
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project