linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] MMP clock: Adjustments for seven function implementations
@ 2017-09-27  7:23 SF Markus Elfring
  2017-09-27  7:25 ` [PATCH 1/3] clk/mmp: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-09-27  7:23 UTC (permalink / raw)
  To: linux-clk, Chao Xie, Michael Turquette, Stephen Boyd
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.14.1

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

* [PATCH 1/3] clk/mmp: Delete an error message for a failed memory allocation in three functions
  2017-09-27  7:23 [PATCH 0/3] MMP clock: Adjustments for seven function implementations SF Markus Elfring
@ 2017-09-27  7:25 ` SF Markus Elfring
  2017-11-14  1:59   ` Stephen Boyd
  2017-09-27  7:26 ` [PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix() SF Markus Elfring
  2017-09-27  7:27 ` [PATCH 3/3] clk/mmp: Adjust 12 checks for null pointers SF Markus Elfring
  2 siblings, 1 reply; 8+ messages in thread
From: SF Markus Elfring @ 2017-09-27  7:25 UTC (permalink / raw)
  To: linux-clk, Chao Xie, Michael Turquette, Stephen Boyd
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 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(-)

diff --git a/drivers/clk/mmp/clk-frac.c b/drivers/clk/mmp/clk-frac.c
index 584a9927993b..98dfb9568d4f 100644
--- a/drivers/clk/mmp/clk-frac.c
+++ b/drivers/clk/mmp/clk-frac.c
@@ -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;
diff --git a/drivers/clk/mmp/clk-gate.c b/drivers/clk/mmp/clk-gate.c
index d20cd3431ac2..7355595c42e2 100644
--- a/drivers/clk/mmp/clk-gate.c
+++ b/drivers/clk/mmp/clk-gate.c
@@ -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;
diff --git a/drivers/clk/mmp/clk-mix.c b/drivers/clk/mmp/clk-mix.c
index c554833cffc5..1ae532df20f7 100644
--- a/drivers/clk/mmp/clk-mix.c
+++ b/drivers/clk/mmp/clk-mix.c
@@ -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);
-- 
2.14.1

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

* [PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix()
  2017-09-27  7:23 [PATCH 0/3] MMP clock: Adjustments for seven function implementations SF Markus Elfring
  2017-09-27  7:25 ` [PATCH 1/3] clk/mmp: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
@ 2017-09-27  7:26 ` SF Markus Elfring
  2017-11-14  1:59   ` Stephen Boyd
  2017-09-27  7:27 ` [PATCH 3/3] clk/mmp: Adjust 12 checks for null pointers SF Markus Elfring
  2 siblings, 1 reply; 8+ messages in thread
From: SF Markus Elfring @ 2017-09-27  7:26 UTC (permalink / raw)
  To: linux-clk, Chao Xie, Michael Turquette, Stephen Boyd
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

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

diff --git a/drivers/clk/mmp/clk-mix.c b/drivers/clk/mmp/clk-mix.c
index 1ae532df20f7..b2471fb369f1 100644
--- a/drivers/clk/mmp/clk-mix.c
+++ b/drivers/clk/mmp/clk-mix.c
@@ -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);
 }
-- 
2.14.1

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

* [PATCH 3/3] clk/mmp: Adjust 12 checks for null pointers
  2017-09-27  7:23 [PATCH 0/3] MMP clock: Adjustments for seven function implementations SF Markus Elfring
  2017-09-27  7:25 ` [PATCH 1/3] clk/mmp: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
  2017-09-27  7:26 ` [PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix() SF Markus Elfring
@ 2017-09-27  7:27 ` SF Markus Elfring
  2017-09-27  9:26   ` Sylwester Nawrocki
  2017-11-14  1:59   ` Stephen Boyd
  2 siblings, 2 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-09-27  7:27 UTC (permalink / raw)
  To: linux-clk, Chao Xie, Michael Turquette, Stephen Boyd
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 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(-)

diff --git a/drivers/clk/mmp/clk-mix.c b/drivers/clk/mmp/clk-mix.c
index b2471fb369f1..90814b2613c0 100644
--- a/drivers/clk/mmp/clk-mix.c
+++ b/drivers/clk/mmp/clk-mix.c
@@ -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;
diff --git a/drivers/clk/mmp/clk-mmp2.c b/drivers/clk/mmp/clk-mmp2.c
index 038023483b98..7460031714da 100644
--- a/drivers/clk/mmp/clk-mmp2.c
+++ b/drivers/clk/mmp/clk-mmp2.c
@@ -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;
 	}
diff --git a/drivers/clk/mmp/clk-pxa168.c b/drivers/clk/mmp/clk-pxa168.c
index a9ef9209532a..8e2551ab8462 100644
--- a/drivers/clk/mmp/clk-pxa168.c
+++ b/drivers/clk/mmp/clk-pxa168.c
@@ -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;
 	}
diff --git a/drivers/clk/mmp/clk-pxa910.c b/drivers/clk/mmp/clk-pxa910.c
index a520cf7702a1..7a7965141918 100644
--- a/drivers/clk/mmp/clk-pxa910.c
+++ b/drivers/clk/mmp/clk-pxa910.c
@@ -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;
 	}
-- 
2.14.1

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

* Re: [PATCH 3/3] clk/mmp: Adjust 12 checks for null pointers
  2017-09-27  7:27 ` [PATCH 3/3] clk/mmp: Adjust 12 checks for null pointers SF Markus Elfring
@ 2017-09-27  9:26   ` Sylwester Nawrocki
  2017-11-14  1:59   ` Stephen Boyd
  1 sibling, 0 replies; 8+ messages in thread
From: Sylwester Nawrocki @ 2017-09-27  9:26 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-clk, Chao Xie, Michael Turquette, Stephen Boyd, LKML,
	kernel-janitors

On 09/27/2017 09:27 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 27 Sep 2017 09:00:21 +0200

> MIME-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 <elfring@users.sourceforge.net>
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.
    
    Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
    Signed-off-by: Mike Marshall <hubcap@omnibond.com>
------------------------------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

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

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

* Re: [PATCH 3/3] clk/mmp: Adjust 12 checks for null pointers
  2017-09-27  7:27 ` [PATCH 3/3] clk/mmp: Adjust 12 checks for null pointers SF Markus Elfring
  2017-09-27  9:26   ` Sylwester Nawrocki
@ 2017-11-14  1:59   ` Stephen Boyd
  1 sibling, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2017-11-14  1:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-clk, Chao Xie, Michael Turquette, LKML, kernel-janitors

On 09/27, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> 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 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix()
  2017-09-27  7:26 ` [PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix() SF Markus Elfring
@ 2017-11-14  1:59   ` Stephen Boyd
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2017-11-14  1:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-clk, Chao Xie, Michael Turquette, LKML, kernel-janitors

On 09/27, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> 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 1/3] clk/mmp: Delete an error message for a failed memory allocation in three functions
  2017-09-27  7:25 ` [PATCH 1/3] clk/mmp: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
@ 2017-11-14  1:59   ` Stephen Boyd
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2017-11-14  1:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-clk, Chao Xie, Michael Turquette, LKML, kernel-janitors

On 09/27, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> 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-11-14  1:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-27  7:23 [PATCH 0/3] MMP clock: Adjustments for seven function implementations SF Markus Elfring
2017-09-27  7:25 ` [PATCH 1/3] clk/mmp: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
2017-11-14  1:59   ` Stephen Boyd
2017-09-27  7:26 ` [PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix() SF Markus Elfring
2017-11-14  1:59   ` Stephen Boyd
2017-09-27  7:27 ` [PATCH 3/3] clk/mmp: Adjust 12 checks for null pointers SF Markus Elfring
2017-09-27  9:26   ` Sylwester Nawrocki
2017-11-14  1:59   ` Stephen Boyd

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