MMP clock: Adjustments for seven function implementations
Subsystems (2)
cover MMP clock: Adjustments for seven function implementations
From: Markus Elfring <[email protected]>
Date: Wed, 27 Sep 2017 09:21:23 +0200
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in three functions Use common error handling code in mmp_clk_register_mix() Adjust 12 checks for null pointers
drivers/clk/mmp/clk-frac.c | 4 +--- drivers/clk/mmp/clk-gate.c | 4 +--- drivers/clk/mmp/clk-mix.c | 27 +++++++++++---------------- drivers/clk/mmp/clk-mmp2.c | 6 +++--- drivers/clk/mmp/clk-pxa168.c | 6 +++--- drivers/clk/mmp/clk-pxa910.c | 8 ++++---- 6 files changed, 23 insertions(+), 32 deletions(-)
Signature · 1 line
2.14.1
PATCH 1/3 clk/mmp: Delete an error message for a failed memory allocation in three functions
From: Markus Elfring <[email protected]>
Date: Tue, 26 Sep 2017 22:25:38 +0200
Omit extra messages for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
--- drivers/clk/mmp/clk-frac.c | 4 +--- drivers/clk/mmp/clk-gate.c | 4 +--- drivers/clk/mmp/clk-mix.c | 9 +-------- 3 files changed, 3 insertions(+), 14 deletions(-)
drivers/clk/mmp/clk-frac.c +1 -3
@@ -172,10 +172,8 @@ struct clk *mmp_clk_register_factor(const char *name, const char *parent_name, } factor =kzalloc (sizeof (*factor),GFP_KERNEL ); -if (!factor) { -pr_err ("%s: could not allocate factor clk\n" , __func__); +if (!factor)return ERR_PTR (-ENOMEM ); - }/* struct clk_aux assignments */ factor->base = base;
drivers/clk/mmp/clk-gate.c +1 -3
@@ -103,10 +103,8 @@ struct clk *mmp_clk_register_gate(struct device *dev, const char *name,/* allocate the gate */ gate =kzalloc (sizeof (*gate),GFP_KERNEL ); -if (!gate) { -pr_err ("%s:%s could not allocate gate clk\n" , __func__, name); +if (!gate)return ERR_PTR (-ENOMEM ); - } init.name = name; init.ops = &mmp_clk_gate_ops;
drivers/clk/mmp/clk-mix.c +1 -8
@@ -451,11 +451,8 @@ struct clk *mmp_clk_register_mix(struct device *dev,size_t table_bytes; mix =kzalloc (sizeof (*mix),GFP_KERNEL ); -if (!mix) { -pr_err ("%s:%s: could not allocate mmp mix clk\n" , - __func__, name); +if (!mix)return ERR_PTR (-ENOMEM ); - } init.name = name; init.flags = flags |CLK_GET_RATE_NOCACHE ;
@@ -468,8 +465,6 @@ struct clk *mmp_clk_register_mix(struct device *dev, table_bytes =sizeof (*config->table) * config->table_size; mix->table =kmemdup (config->table, table_bytes,GFP_KERNEL );if (!mix->table) { -pr_err ("%s:%s: could not allocate mmp mix table\n" , - __func__, name);kfree (mix);return ERR_PTR (-ENOMEM ); }
@@ -481,8 +476,6 @@ struct clk *mmp_clk_register_mix(struct device *dev, mix->mux_table =kmemdup (config->mux_table, table_bytes,GFP_KERNEL );if (!mix->mux_table) { -pr_err ("%s:%s: could not allocate mmp mix mux-table\n" , - __func__, name);kfree (mix->table);kfree (mix);return ERR_PTR (-ENOMEM );
Signature · 1 line
2.14.1
Stephen Boyd
AppliedRe: [PATCH 1/3] clk/mmp: Delete an error message for a failed memory allocation in three functions
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 26 Sep 2017 22:25:38 +0200Omit extra messages for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>---
Applied to clk-next
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 2/3 clk/mmp: Use common error handling code in mmp_clk_register_mix()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 26 Sep 2017 22:33:18 +0200
Add a jump target so that a bit of exception handling can be better reused at the end of this function.
--- drivers/clk/mmp/clk-mix.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/clk/mmp/clk-mix.c +8 -6
@@ -464,10 +464,9 @@ struct clk *mmp_clk_register_mix(struct device *dev,if (config->table) { table_bytes =sizeof (*config->table) * config->table_size; mix->table =kmemdup (config->table, table_bytes,GFP_KERNEL ); -if (!mix->table) { -kfree (mix); -return ERR_PTR (-ENOMEM ); - } +if (!mix->table) + goto free_mix; + mix->table_size = config->table_size; }
@@ -477,8 +476,7 @@ struct clk *mmp_clk_register_mix(struct device *dev, GFP_KERNEL);if (!mix->mux_table) {kfree (mix->table); -kfree (mix); -return ERR_PTR (-ENOMEM ); + goto free_mix; } }
@@ -502,4 +500,8 @@ struct clk *mmp_clk_register_mix(struct device *dev, }return clk; + +free_mix: +kfree (mix); +return ERR_PTR (-ENOMEM ); }
Signature · 1 line
2.14.1
Stephen Boyd
AppliedRe: [PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix()
Quoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 26 Sep 2017 22:33:18 +0200Add a jump target so that a bit of exception handling can be better reused at the end of this function.
Signed-off-by Markus Elfring <[email protected]>---
Applied to clk-next
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 3/3 clk/mmp: Adjust 12 checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 27 Sep 2017 09:00:21 +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.
--- drivers/clk/mmp/clk-mix.c | 4 ++-- drivers/clk/mmp/clk-mmp2.c | 6 +++--- drivers/clk/mmp/clk-pxa168.c | 6 +++--- drivers/clk/mmp/clk-pxa910.c | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-)
drivers/clk/mmp/clk-mix.c +2 -2
@@ -229,7 +229,7 @@ static int mmp_clk_mix_determine_rate(struct clk_hw *hw, parent_rate =clk_hw_get_rate (parent); mix_rate = parent_rate / item->divisor; gap =abs (mix_rate - req->rate); -if (parent_best =NULL || gap < gap_best) { +if (!parent_best || gap < gap_best) { parent_best = parent; parent_rate_best = parent_rate; mix_rate_best = mix_rate;
@@ -247,7 +247,7 @@ static int mmp_clk_mix_determine_rate(struct clk_hw *hw, div =_get_div (mix, j); mix_rate = parent_rate / div; gap =abs (mix_rate - req->rate); -if (parent_best =NULL || gap < gap_best) { +if (!parent_best || gap < gap_best) { parent_best = parent; parent_rate_best = parent_rate; mix_rate_best = mix_rate;
drivers/clk/mmp/clk-mmp2.c +3 -3
@@ -83,19 +83,19 @@ void __init mmp2_clk_init(phys_addr_t mpmu_phys, phys_addr_t apmu_phys,void __iomem *apbc_base; mpmu_base =ioremap (mpmu_phys,SZ_4K ); -if (mpmu_base =NULL ) { +if (!mpmu_base) {pr_err ("error to ioremap MPMU base\n" );return ; } apmu_base =ioremap (apmu_phys,SZ_4K ); -if (apmu_base =NULL ) { +if (!apmu_base) {pr_err ("error to ioremap APMU base\n" );return ; } apbc_base =ioremap (apbc_phys,SZ_4K ); -if (apbc_base =NULL ) { +if (!apbc_base) {pr_err ("error to ioremap APBC base\n" );return ; }
drivers/clk/mmp/clk-pxa168.c +3 -3
@@ -75,19 +75,19 @@ void __init pxa168_clk_init(phys_addr_t mpmu_phys, phys_addr_t apmu_phys,void __iomem *apbc_base; mpmu_base =ioremap (mpmu_phys,SZ_4K ); -if (mpmu_base =NULL ) { +if (!mpmu_base) {pr_err ("error to ioremap MPMU base\n" );return ; } apmu_base =ioremap (apmu_phys,SZ_4K ); -if (apmu_base =NULL ) { +if (!apmu_base) {pr_err ("error to ioremap APMU base\n" );return ; } apbc_base =ioremap (apbc_phys,SZ_4K ); -if (apbc_base =NULL ) { +if (!apbc_base) {pr_err ("error to ioremap APBC base\n" );return ; }
drivers/clk/mmp/clk-pxa910.c +4 -4
@@ -74,25 +74,25 @@ void __init pxa910_clk_init(phys_addr_t mpmu_phys, phys_addr_t apmu_phys,void __iomem *apbc_base; mpmu_base =ioremap (mpmu_phys,SZ_4K ); -if (mpmu_base =NULL ) { +if (!mpmu_base) {pr_err ("error to ioremap MPMU base\n" );return ; } apmu_base =ioremap (apmu_phys,SZ_4K ); -if (apmu_base =NULL ) { +if (!apmu_base) {pr_err ("error to ioremap APMU base\n" );return ; } apbcp_base =ioremap (apbcp_phys,SZ_4K ); -if (apbcp_base =NULL ) { +if (!apbcp_base) {pr_err ("error to ioremap APBC extension base\n" );return ; } apbc_base =ioremap (apbc_phys,SZ_4K ); -if (apbc_base =NULL ) { +if (!apbc_base) {pr_err ("error to ioremap APBC base\n" );return ; }
Signature · 1 line
2.14.1
Re: [PATCH 3/3] clk/mmp: Adjust 12 checks for null pointers
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 27 Sep 2017 09:00:21 +0200MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Can you please fix your process and stop posting with above tags in the commit message? These 3 tags are already in the header of message you are sending. After your patches get applied we end up with a mess in commit messages as below.
------------------------------8<------------------------------- commit 0b08273c8ab7e688832120c4817b1adfdc56e231
Author: Markus Elfring <[email protected]> Date: Thu Aug 17 21:35:16 2017 +0200
orangefs: Adjust three checks for null pointers
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 affected source code places.
------------------------------8<-------------------------------
Please see "DISCUSSION" paragraph of [1] for an explanation of what should be put in the message body.
[1] https://git-scm.com/docs/git-format-patch
--
Thanks,
Sylwester
Quoted 7 lines
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]>
Stephen Boyd
AppliedRe: [PATCH 3/3] clk/mmp: Adjust 12 checks for null pointers
In reply to SF Markus ElfringQuoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 27 Sep 2017 09:00:21 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Quoted 8 lines
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]>---
Applied to clk-next
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project