Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1339902 > unrolled thread

[PATCH 0/9] Change return type of of_clk_get_parent_count() to unsigned

Started byStephen Boyd <sboyd@codeaurora.org>
First post2016-02-22 22:00 +0100
Last post2016-02-22 22:00 +0100
Articles 12 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/9] Change return type of of_clk_get_parent_count() to unsigned Stephen Boyd <sboyd@codeaurora.org> - 2016-02-22 22:00 +0100
    [PATCH 9/9] simplefb: Remove impossible check for of_clk_get_parent_count() < 0 Stephen Boyd <sboyd@codeaurora.org> - 2016-02-22 22:00 +0100
      Re: [PATCH 9/9] simplefb: Remove impossible check for  of_clk_get_parent_count() < 0 Tomi Valkeinen <tomi.valkeinen@ti.com> - 2016-02-26 12:40 +0100
    [PATCH 5/9] clk: st: Remove impossible check for of_clk_get_parent_count() < 0 Stephen Boyd <sboyd@codeaurora.org> - 2016-02-22 22:00 +0100
    [PATCH 8/9] usb: dwc3: Remove impossible check for of_clk_get_parent_count() < 0 Stephen Boyd <sboyd@codeaurora.org> - 2016-02-22 22:00 +0100
      Re: [PATCH 8/9] usb: dwc3: Remove impossible check for of_clk_get_parent_count() < 0 Felipe Balbi <balbi@kernel.org> - 2016-02-23 07:50 +0100
    [PATCH 4/9] clk: h8300: Remove impossible check for of_clk_get_parent_count() Stephen Boyd <sboyd@codeaurora.org> - 2016-02-22 22:00 +0100
    [PATCH 7/9] clk: ti: Update for of_clk_get_parent_count() returning unsigned int Stephen Boyd <sboyd@codeaurora.org> - 2016-02-22 22:00 +0100
    [PATCH 6/9] clk: sunxi: Use proper type for of_clk_get_parent_count() return value Stephen Boyd <sboyd@codeaurora.org> - 2016-02-22 22:00 +0100
    [PATCH 2/9] clk: at91: Remove impossible checks for of_clk_get_parent_count() Stephen Boyd <sboyd@codeaurora.org> - 2016-02-22 22:00 +0100
    [PATCH 1/9] clk: Make of_clk_get_parent_count() return unsigned ints Stephen Boyd <sboyd@codeaurora.org> - 2016-02-22 22:00 +0100
    [PATCH 3/9] clk: gpio: Remove impossible check for of_clk_get_parent_count() < 0 Stephen Boyd <sboyd@codeaurora.org> - 2016-02-22 22:00 +0100

#1339902 — [PATCH 0/9] Change return type of of_clk_get_parent_count() to unsigned

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-02-22 22:00 +0100
Subject[PATCH 0/9] Change return type of of_clk_get_parent_count() to unsigned
Message-ID<r55Ki-2Wr-1@gated-at.bofh.it>
Russell King recently pointed out that of_clk_get_parent_count() can
return a negative number if the "clocks" property isn't present in a
node. Upon investigating all the callers of this API, none of the them
seem to care about that case, and furthermore some callers are assigning
the return value to an unsigned int which could cause very large numbers
of parents to be used.

This series changes the API to return an unsigned int from 0 (no parents)
to N, thereby avoiding any problems with negative return values.

Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: <uclinux-h8-devel@lists.sourceforge.jp>
Cc: Gabriel Fernandez <gabriel.fernandez@st.com>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Chen-Yu Tsai <wens@csie.org> 
Cc: Tero Kristo <t-kristo@ti.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: <linux-usb@vger.kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: <linux-fbdev@vger.kernel.org>

Stephen Boyd (9):
  clk: Make of_clk_get_parent_count() return unsigned ints
  clk: at91: Remove impossible checks for of_clk_get_parent_count()
  clk: gpio: Remove impossible check for of_clk_get_parent_count() < 0
  clk: h8300: Remove impossible check for of_clk_get_parent_count()
  clk: st: Remove impossible check for of_clk_get_parent_count() < 0
  clk: sunxi: Use proper type for of_clk_get_parent_count() return value
  clk: ti: Update for of_clk_get_parent_count() returning unsigned int
  usb: dwc3: Remove impossible check for of_clk_get_parent_count() < 0
  simplefb: Remove impossible check for of_clk_get_parent_count() < 0

 drivers/clk/at91/clk-generated.c    |  4 ++--
 drivers/clk/at91/clk-main.c         |  4 ++--
 drivers/clk/at91/clk-master.c       |  4 ++--
 drivers/clk/at91/clk-programmable.c |  4 ++--
 drivers/clk/at91/clk-slow.c         |  6 +++---
 drivers/clk/at91/clk-smd.c          |  4 ++--
 drivers/clk/at91/clk-usb.c          |  4 ++--
 drivers/clk/clk-gpio.c              |  6 ++----
 drivers/clk/clk.c                   | 16 ++++++++++++++--
 drivers/clk/h8300/clk-div.c         |  4 ++--
 drivers/clk/h8300/clk-h8s2678.c     |  4 ++--
 drivers/clk/st/clk-flexgen.c        |  4 ++--
 drivers/clk/st/clkgen-mux.c         |  4 ++--
 drivers/clk/sunxi/clk-sun6i-ar100.c |  2 +-
 drivers/clk/ti/clockdomain.c        |  2 +-
 drivers/clk/ti/composite.c          |  8 ++++----
 drivers/clk/ti/dpll.c               |  2 +-
 drivers/clk/ti/mux.c                |  4 ++--
 drivers/usb/dwc3/dwc3-of-simple.c   |  9 +++++----
 drivers/video/fbdev/simplefb.c      |  4 ++--
 include/linux/clk-provider.h        |  2 +-
 21 files changed, 56 insertions(+), 45 deletions(-)

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

[toc] | [next] | [standalone]


#1339903 — [PATCH 9/9] simplefb: Remove impossible check for of_clk_get_parent_count() < 0

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-02-22 22:00 +0100
Subject[PATCH 9/9] simplefb: Remove impossible check for of_clk_get_parent_count() < 0
Message-ID<r55Ki-2Wr-3@gated-at.bofh.it>
In reply to#1339902
The check for < 0 is impossible now that
of_clk_get_parent_count() returns an unsigned int. Simplify the
code and update the types.

Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: <linux-fbdev@vger.kernel.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---

Please ack so this can go through clk tree along with patch 1.

 drivers/video/fbdev/simplefb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c
index 48ccf6db62a2..e9cf19977285 100644
--- a/drivers/video/fbdev/simplefb.c
+++ b/drivers/video/fbdev/simplefb.c
@@ -174,7 +174,7 @@ static int simplefb_parse_pd(struct platform_device *pdev,
 struct simplefb_par {
 	u32 palette[PSEUDO_PALETTE_SIZE];
 #if defined CONFIG_OF && defined CONFIG_COMMON_CLK
-	int clk_count;
+	unsigned int clk_count;
 	struct clk **clks;
 #endif
 #if defined CONFIG_OF && defined CONFIG_REGULATOR
@@ -213,7 +213,7 @@ static int simplefb_clocks_init(struct simplefb_par *par,
 		return 0;
 
 	par->clk_count = of_clk_get_parent_count(np);
-	if (par->clk_count <= 0)
+	if (!par->clk_count)
 		return 0;
 
 	par->clks = kcalloc(par->clk_count, sizeof(struct clk *), GFP_KERNEL);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1344185 — Re: [PATCH 9/9] simplefb: Remove impossible check for of_clk_get_parent_count() < 0

FromTomi Valkeinen <tomi.valkeinen@ti.com>
Date2016-02-26 12:40 +0100
SubjectRe: [PATCH 9/9] simplefb: Remove impossible check for of_clk_get_parent_count() < 0
Message-ID<r6oUx-2x3-5@gated-at.bofh.it>
In reply to#1339903

[Multipart message — attachments visible in raw view] — view raw

On 22/02/16 22:54, Stephen Boyd wrote:
> The check for < 0 is impossible now that
> of_clk_get_parent_count() returns an unsigned int. Simplify the
> code and update the types.
> 
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: <linux-fbdev@vger.kernel.org>
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> ---
> 
> Please ack so this can go through clk tree along with patch 1.
> 
>  drivers/video/fbdev/simplefb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

 Tomi

[toc] | [prev] | [next] | [standalone]


#1339905 — [PATCH 5/9] clk: st: Remove impossible check for of_clk_get_parent_count() < 0

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-02-22 22:00 +0100
Subject[PATCH 5/9] clk: st: Remove impossible check for of_clk_get_parent_count() < 0
Message-ID<r55Ki-2Wr-9@gated-at.bofh.it>
In reply to#1339902
The checks for < 0 are impossible now that
of_clk_get_parent_count() returns an unsigned int. Simplify the
code and update the types.

Cc: Gabriel Fernandez <gabriel.fernandez@st.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/clk/st/clk-flexgen.c | 4 ++--
 drivers/clk/st/clkgen-mux.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/st/clk-flexgen.c b/drivers/clk/st/clk-flexgen.c
index 24d99594c0b3..627267c7ec5c 100644
--- a/drivers/clk/st/clk-flexgen.c
+++ b/drivers/clk/st/clk-flexgen.c
@@ -244,10 +244,10 @@ static const char ** __init flexgen_get_parents(struct device_node *np,
 						       int *num_parents)
 {
 	const char **parents;
-	int nparents;
+	unsigned int nparents;
 
 	nparents = of_clk_get_parent_count(np);
-	if (WARN_ON(nparents <= 0))
+	if (WARN_ON(!nparents))
 		return NULL;
 
 	parents = kcalloc(nparents, sizeof(const char *), GFP_KERNEL);
diff --git a/drivers/clk/st/clkgen-mux.c b/drivers/clk/st/clkgen-mux.c
index 0d9a74b66ea3..b1e10ffe7a44 100644
--- a/drivers/clk/st/clkgen-mux.c
+++ b/drivers/clk/st/clkgen-mux.c
@@ -26,10 +26,10 @@ static const char ** __init clkgen_mux_get_parents(struct device_node *np,
 						       int *num_parents)
 {
 	const char **parents;
-	int nparents;
+	unsigned int nparents;
 
 	nparents = of_clk_get_parent_count(np);
-	if (WARN_ON(nparents <= 0))
+	if (WARN_ON(!nparents))
 		return ERR_PTR(-EINVAL);
 
 	parents = kcalloc(nparents, sizeof(const char *), GFP_KERNEL);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1339906 — [PATCH 8/9] usb: dwc3: Remove impossible check for of_clk_get_parent_count() < 0

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-02-22 22:00 +0100
Subject[PATCH 8/9] usb: dwc3: Remove impossible check for of_clk_get_parent_count() < 0
Message-ID<r55Ki-2Wr-13@gated-at.bofh.it>
In reply to#1339902
The check for < 0 is impossible now that
of_clk_get_parent_count() returns an unsigned int. Simplify the
code and update the types.

Cc: Felipe Balbi <balbi@ti.com>
Cc: <linux-usb@vger.kernel.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---

Please ack so this can go through clk tree along with patch 1.

 drivers/usb/dwc3/dwc3-of-simple.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
index 9c9f74155066..974335377d9f 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -42,6 +42,7 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
 	struct device		*dev = &pdev->dev;
 	struct device_node	*np = dev->of_node;
 
+	unsigned int		count;
 	int			ret;
 	int			i;
 
@@ -49,11 +50,11 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
 	if (!simple)
 		return -ENOMEM;
 
-	ret = of_clk_get_parent_count(np);
-	if (ret < 0)
-		return ret;
+	count = of_clk_get_parent_count(np);
+	if (!count)
+		return -ENOENT;
 
-	simple->num_clocks = ret;
+	simple->num_clocks = count;
 
 	simple->clks = devm_kcalloc(dev, simple->num_clocks,
 			sizeof(struct clk *), GFP_KERNEL);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1340338 — Re: [PATCH 8/9] usb: dwc3: Remove impossible check for of_clk_get_parent_count() < 0

FromFelipe Balbi <balbi@kernel.org>
Date2016-02-23 07:50 +0100
SubjectRe: [PATCH 8/9] usb: dwc3: Remove impossible check for of_clk_get_parent_count() < 0
Message-ID<r5eXg-1sV-5@gated-at.bofh.it>
In reply to#1339906

[Multipart message — attachments visible in raw view] — view raw

Hi,

Stephen Boyd <sboyd@codeaurora.org> writes:
> The check for < 0 is impossible now that
> of_clk_get_parent_count() returns an unsigned int. Simplify the
> code and update the types.
>
> Cc: Felipe Balbi <balbi@ti.com>
> Cc: <linux-usb@vger.kernel.org>
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> ---
>
> Please ack so this can go through clk tree along with patch 1.

sure, no problem ;-) patch looks okay

Acked-by: Felipe Balbi <balbi@kernel.org>

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1339908 — [PATCH 4/9] clk: h8300: Remove impossible check for of_clk_get_parent_count()

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-02-22 22:00 +0100
Subject[PATCH 4/9] clk: h8300: Remove impossible check for of_clk_get_parent_count()
Message-ID<r55Ki-2Wr-15@gated-at.bofh.it>
In reply to#1339902
The checks for < 1 can be simplified now that
of_clk_get_parent_count() returns an unsigned int. Update the
code to reflect the int to unsigned int change.

Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: <uclinux-h8-devel@lists.sourceforge.jp>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/clk/h8300/clk-div.c     | 4 ++--
 drivers/clk/h8300/clk-h8s2678.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/h8300/clk-div.c b/drivers/clk/h8300/clk-div.c
index d71d01157dbb..5ecc0664e33c 100644
--- a/drivers/clk/h8300/clk-div.c
+++ b/drivers/clk/h8300/clk-div.c
@@ -13,7 +13,7 @@ static DEFINE_SPINLOCK(clklock);
 
 static void __init h8300_div_clk_setup(struct device_node *node)
 {
-	int num_parents;
+	unsigned int num_parents;
 	struct clk *clk;
 	const char *clk_name = node->name;
 	const char *parent_name;
@@ -22,7 +22,7 @@ static void __init h8300_div_clk_setup(struct device_node *node)
 	int offset;
 
 	num_parents = of_clk_get_parent_count(node);
-	if (num_parents < 1) {
+	if (!num_parents) {
 		pr_err("%s: no parent found", clk_name);
 		return;
 	}
diff --git a/drivers/clk/h8300/clk-h8s2678.c b/drivers/clk/h8300/clk-h8s2678.c
index 6cf38dc1c929..c9c2fd575ef7 100644
--- a/drivers/clk/h8300/clk-h8s2678.c
+++ b/drivers/clk/h8300/clk-h8s2678.c
@@ -83,7 +83,7 @@ static const struct clk_ops pll_ops = {
 
 static void __init h8s2678_pll_clk_setup(struct device_node *node)
 {
-	int num_parents;
+	unsigned int num_parents;
 	struct clk *clk;
 	const char *clk_name = node->name;
 	const char *parent_name;
@@ -91,7 +91,7 @@ static void __init h8s2678_pll_clk_setup(struct device_node *node)
 	struct clk_init_data init;
 
 	num_parents = of_clk_get_parent_count(node);
-	if (num_parents < 1) {
+	if (!num_parents) {
 		pr_err("%s: no parent found", clk_name);
 		return;
 	}
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1339909 — [PATCH 7/9] clk: ti: Update for of_clk_get_parent_count() returning unsigned int

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-02-22 22:00 +0100
Subject[PATCH 7/9] clk: ti: Update for of_clk_get_parent_count() returning unsigned int
Message-ID<r55Ki-2Wr-19@gated-at.bofh.it>
In reply to#1339902
Change the types here to unsigned int instead of int and update
the checks for == 0 instead < 1 to be more explicit about what's
going on now that of_clk_get_parent_count() has changed return
types.

Cc: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/clk/ti/clockdomain.c | 2 +-
 drivers/clk/ti/composite.c   | 8 ++++----
 drivers/clk/ti/dpll.c        | 2 +-
 drivers/clk/ti/mux.c         | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/ti/clockdomain.c b/drivers/clk/ti/clockdomain.c
index b9bc3b8df659..6cf9dd189a92 100644
--- a/drivers/clk/ti/clockdomain.c
+++ b/drivers/clk/ti/clockdomain.c
@@ -109,7 +109,7 @@ static void __init of_ti_clockdomain_setup(struct device_node *node)
 	struct clk_hw *clk_hw;
 	const char *clkdm_name = node->name;
 	int i;
-	int num_clks;
+	unsigned int num_clks;
 
 	num_clks = of_clk_get_parent_count(node);
 
diff --git a/drivers/clk/ti/composite.c b/drivers/clk/ti/composite.c
index 43345c417815..1cf70f452e1e 100644
--- a/drivers/clk/ti/composite.c
+++ b/drivers/clk/ti/composite.c
@@ -234,14 +234,14 @@ cleanup:
 
 static void __init of_ti_composite_clk_setup(struct device_node *node)
 {
-	int num_clks;
+	unsigned int num_clks;
 	int i;
 	struct clk_hw_omap_comp *cclk;
 
 	/* Number of component clocks to be put inside this clock */
 	num_clks = of_clk_get_parent_count(node);
 
-	if (num_clks < 1) {
+	if (!num_clks) {
 		pr_err("composite clk %s must have component(s)\n", node->name);
 		return;
 	}
@@ -271,13 +271,13 @@ CLK_OF_DECLARE(ti_composite_clock, "ti,composite-clock",
 int __init ti_clk_add_component(struct device_node *node, struct clk_hw *hw,
 				int type)
 {
-	int num_parents;
+	unsigned int num_parents;
 	const char **parent_names;
 	struct component_clk *clk;
 
 	num_parents = of_clk_get_parent_count(node);
 
-	if (num_parents < 1) {
+	if (!num_parents) {
 		pr_err("component-clock %s must have parent(s)\n", node->name);
 		return -EINVAL;
 	}
diff --git a/drivers/clk/ti/dpll.c b/drivers/clk/ti/dpll.c
index 5519b386edc0..4e54d25b2c6a 100644
--- a/drivers/clk/ti/dpll.c
+++ b/drivers/clk/ti/dpll.c
@@ -361,7 +361,7 @@ static void __init of_ti_dpll_setup(struct device_node *node,
 	init->ops = ops;
 
 	init->num_parents = of_clk_get_parent_count(node);
-	if (init->num_parents < 1) {
+	if (!init->num_parents) {
 		pr_err("%s must have parent(s)\n", node->name);
 		goto cleanup;
 	}
diff --git a/drivers/clk/ti/mux.c b/drivers/clk/ti/mux.c
index 618ded96ace3..44777ab6fdeb 100644
--- a/drivers/clk/ti/mux.c
+++ b/drivers/clk/ti/mux.c
@@ -178,7 +178,7 @@ static void of_mux_clk_setup(struct device_node *node)
 {
 	struct clk *clk;
 	void __iomem *reg;
-	int num_parents;
+	unsigned int num_parents;
 	const char **parent_names;
 	u8 clk_mux_flags = 0;
 	u32 mask = 0;
@@ -261,7 +261,7 @@ struct clk_hw *ti_clk_build_component_mux(struct ti_clk_mux *setup)
 static void __init of_ti_composite_mux_clk_setup(struct device_node *node)
 {
 	struct clk_mux *mux;
-	int num_parents;
+	unsigned int num_parents;
 	u32 val;
 
 	mux = kzalloc(sizeof(*mux), GFP_KERNEL);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1339912 — [PATCH 6/9] clk: sunxi: Use proper type for of_clk_get_parent_count() return value

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-02-22 22:00 +0100
Subject[PATCH 6/9] clk: sunxi: Use proper type for of_clk_get_parent_count() return value
Message-ID<r55Kj-2Wr-27@gated-at.bofh.it>
In reply to#1339902
The return type of of_clk_get_parent_count() is an unsigned int
now, so let's update the code here to be more explicit about the
range of values we can test for.

Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Chen-Yu Tsai <wens@csie.org> 
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/clk/sunxi/clk-sun6i-ar100.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/sunxi/clk-sun6i-ar100.c b/drivers/clk/sunxi/clk-sun6i-ar100.c
index 20887686bdbe..c90370572a16 100644
--- a/drivers/clk/sunxi/clk-sun6i-ar100.c
+++ b/drivers/clk/sunxi/clk-sun6i-ar100.c
@@ -181,7 +181,7 @@ static int sun6i_a31_ar100_clk_probe(struct platform_device *pdev)
 	struct ar100_clk *ar100;
 	struct resource *r;
 	struct clk *clk;
-	int nparents;
+	unsigned int nparents;
 
 	ar100 = devm_kzalloc(&pdev->dev, sizeof(*ar100), GFP_KERNEL);
 	if (!ar100)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1339913 — [PATCH 2/9] clk: at91: Remove impossible checks for of_clk_get_parent_count()

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-02-22 22:00 +0100
Subject[PATCH 2/9] clk: at91: Remove impossible checks for of_clk_get_parent_count()
Message-ID<r55Kj-2Wr-29@gated-at.bofh.it>
In reply to#1339902
These checks for < 0 are impossible now that
of_clk_get_parent_count() returns an unsigned int. Change the
checks for == 0 and update the type.

Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/clk/at91/clk-generated.c    | 4 ++--
 drivers/clk/at91/clk-main.c         | 4 ++--
 drivers/clk/at91/clk-master.c       | 4 ++--
 drivers/clk/at91/clk-programmable.c | 4 ++--
 drivers/clk/at91/clk-slow.c         | 6 +++---
 drivers/clk/at91/clk-smd.c          | 4 ++--
 drivers/clk/at91/clk-usb.c          | 4 ++--
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c
index abc80949e1dd..f82b16a65dee 100644
--- a/drivers/clk/at91/clk-generated.c
+++ b/drivers/clk/at91/clk-generated.c
@@ -268,13 +268,13 @@ void __init of_sama5d2_clk_generated_setup(struct device_node *np,
 	u32 id;
 	const char *name;
 	struct clk *clk;
-	int num_parents;
+	unsigned int num_parents;
 	const char *parent_names[GENERATED_SOURCE_MAX];
 	struct device_node *gcknp;
 	struct clk_range range = CLK_RANGE(0, 0);
 
 	num_parents = of_clk_get_parent_count(np);
-	if (num_parents <= 0 || num_parents > GENERATED_SOURCE_MAX)
+	if (num_parents == 0 || num_parents > GENERATED_SOURCE_MAX)
 		return;
 
 	of_clk_parent_fill(np, parent_names, num_parents);
diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
index fd7247deabdc..b85f43529396 100644
--- a/drivers/clk/at91/clk-main.c
+++ b/drivers/clk/at91/clk-main.c
@@ -611,12 +611,12 @@ void __init of_at91sam9x5_clk_main_setup(struct device_node *np,
 {
 	struct clk *clk;
 	const char *parent_names[2];
-	int num_parents;
+	unsigned int num_parents;
 	unsigned int irq;
 	const char *name = np->name;
 
 	num_parents = of_clk_get_parent_count(np);
-	if (num_parents <= 0 || num_parents > 2)
+	if (num_parents == 0 || num_parents > 2)
 		return;
 
 	of_clk_parent_fill(np, parent_names, num_parents);
diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
index 620ea323356b..016fe110b5ba 100644
--- a/drivers/clk/at91/clk-master.c
+++ b/drivers/clk/at91/clk-master.c
@@ -221,14 +221,14 @@ of_at91_clk_master_setup(struct device_node *np, struct at91_pmc *pmc,
 			 const struct clk_master_layout *layout)
 {
 	struct clk *clk;
-	int num_parents;
+	unsigned int num_parents;
 	unsigned int irq;
 	const char *parent_names[MASTER_SOURCE_MAX];
 	const char *name = np->name;
 	struct clk_master_characteristics *characteristics;
 
 	num_parents = of_clk_get_parent_count(np);
-	if (num_parents <= 0 || num_parents > MASTER_SOURCE_MAX)
+	if (num_parents == 0 || num_parents > MASTER_SOURCE_MAX)
 		return;
 
 	of_clk_parent_fill(np, parent_names, num_parents);
diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c
index 14b270b85fec..b955fb81876f 100644
--- a/drivers/clk/at91/clk-programmable.c
+++ b/drivers/clk/at91/clk-programmable.c
@@ -232,13 +232,13 @@ of_at91_clk_prog_setup(struct device_node *np, struct at91_pmc *pmc,
 	int num;
 	u32 id;
 	struct clk *clk;
-	int num_parents;
+	unsigned int num_parents;
 	const char *parent_names[PROG_SOURCE_MAX];
 	const char *name;
 	struct device_node *progclknp;
 
 	num_parents = of_clk_get_parent_count(np);
-	if (num_parents <= 0 || num_parents > PROG_SOURCE_MAX)
+	if (num_parents == 0 || num_parents > PROG_SOURCE_MAX)
 		return;
 
 	of_clk_parent_fill(np, parent_names, num_parents);
diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c
index 6f99a530ead6..67b304726d06 100644
--- a/drivers/clk/at91/clk-slow.c
+++ b/drivers/clk/at91/clk-slow.c
@@ -366,11 +366,11 @@ void __init of_at91sam9x5_clk_slow_setup(struct device_node *np,
 {
 	struct clk *clk;
 	const char *parent_names[2];
-	int num_parents;
+	unsigned int num_parents;
 	const char *name = np->name;
 
 	num_parents = of_clk_get_parent_count(np);
-	if (num_parents <= 0 || num_parents > 2)
+	if (num_parents == 0 || num_parents > 2)
 		return;
 
 	of_clk_parent_fill(np, parent_names, num_parents);
@@ -437,7 +437,7 @@ void __init of_at91sam9260_clk_slow_setup(struct device_node *np,
 {
 	struct clk *clk;
 	const char *parent_names[2];
-	int num_parents;
+	unsigned int num_parents;
 	const char *name = np->name;
 
 	num_parents = of_clk_get_parent_count(np);
diff --git a/drivers/clk/at91/clk-smd.c b/drivers/clk/at91/clk-smd.c
index a7f8501cfa05..f525830ed5a1 100644
--- a/drivers/clk/at91/clk-smd.c
+++ b/drivers/clk/at91/clk-smd.c
@@ -145,12 +145,12 @@ void __init of_at91sam9x5_clk_smd_setup(struct device_node *np,
 					struct at91_pmc *pmc)
 {
 	struct clk *clk;
-	int num_parents;
+	unsigned int num_parents;
 	const char *parent_names[SMD_SOURCE_MAX];
 	const char *name = np->name;
 
 	num_parents = of_clk_get_parent_count(np);
-	if (num_parents <= 0 || num_parents > SMD_SOURCE_MAX)
+	if (num_parents == 0 || num_parents > SMD_SOURCE_MAX)
 		return;
 
 	of_clk_parent_fill(np, parent_names, num_parents);
diff --git a/drivers/clk/at91/clk-usb.c b/drivers/clk/at91/clk-usb.c
index 8ab8502778a2..be1c7f531837 100644
--- a/drivers/clk/at91/clk-usb.c
+++ b/drivers/clk/at91/clk-usb.c
@@ -373,12 +373,12 @@ void __init of_at91sam9x5_clk_usb_setup(struct device_node *np,
 					struct at91_pmc *pmc)
 {
 	struct clk *clk;
-	int num_parents;
+	unsigned int num_parents;
 	const char *parent_names[USB_SOURCE_MAX];
 	const char *name = np->name;
 
 	num_parents = of_clk_get_parent_count(np);
-	if (num_parents <= 0 || num_parents > USB_SOURCE_MAX)
+	if (num_parents == 0 || num_parents > USB_SOURCE_MAX)
 		return;
 
 	of_clk_parent_fill(np, parent_names, num_parents);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1339914 — [PATCH 1/9] clk: Make of_clk_get_parent_count() return unsigned ints

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-02-22 22:00 +0100
Subject[PATCH 1/9] clk: Make of_clk_get_parent_count() return unsigned ints
Message-ID<r55Kj-2Wr-31@gated-at.bofh.it>
In reply to#1339902
Russell King recently pointed out a bug in the clk-gpio code
where it fails to register the clk if of_clk_get_parent_count()
returns an error because the "clocks" property isn't present in
the DT node. If we're trying to count parents from DT we'd like
to know the count, not if there is a "clocks" property or not.
Furthermore, some drivers are assigning the return value to their
clk_init_data::num_parents member which is unsigned, leading to
potentially large numbers of parents when the property isn't
present.

Let's change the API to return an unsigned int instead of an int.
All the callers just want to know the count anyway, and this
avoids the bug that was in the clk-gpio driver.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/clk/clk.c            | 16 ++++++++++++++--
 include/linux/clk-provider.h |  2 +-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 58ef3dab894a..0e7206761d27 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3021,9 +3021,21 @@ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec)
 }
 EXPORT_SYMBOL_GPL(of_clk_get_from_provider);
 
-int of_clk_get_parent_count(struct device_node *np)
+/**
+ * of_clk_get_parent_count() - Count the number of clocks a device node has
+ * @np: device node to count
+ *
+ * Returns: The number of clocks that are possible parents of this node
+ */
+unsigned int of_clk_get_parent_count(struct device_node *np)
 {
-	return of_count_phandle_with_args(np, "clocks", "#clock-cells");
+	int count;
+
+	count = of_count_phandle_with_args(np, "clocks", "#clock-cells");
+	if (count < 0)
+		return 0;
+
+	return count;
 }
 EXPORT_SYMBOL_GPL(of_clk_get_parent_count);
 
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index fce7f027f8a7..da95258127aa 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -716,7 +716,7 @@ void of_clk_del_provider(struct device_node *np);
 struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec,
 				  void *data);
 struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data);
-int of_clk_get_parent_count(struct device_node *np);
+unsigned int of_clk_get_parent_count(struct device_node *np);
 int of_clk_parent_fill(struct device_node *np, const char **parents,
 		       unsigned int size);
 const char *of_clk_get_parent_name(struct device_node *np, int index);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1339916 — [PATCH 3/9] clk: gpio: Remove impossible check for of_clk_get_parent_count() < 0

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-02-22 22:00 +0100
Subject[PATCH 3/9] clk: gpio: Remove impossible check for of_clk_get_parent_count() < 0
Message-ID<r55Kj-2Wr-39@gated-at.bofh.it>
In reply to#1339902
The check for < 0 is impossible now that
of_clk_get_parent_count() returns an unsigned int. Simplify the
code and update the type here.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/clk/clk-gpio.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
index 522bffdbacc5..08f65acc5d57 100644
--- a/drivers/clk/clk-gpio.c
+++ b/drivers/clk/clk-gpio.c
@@ -205,15 +205,13 @@ static int gpio_clk_driver_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	const char **parent_names, *gpio_name;
-	int num_parents, gpio;
+	unsigned int num_parents;
+	int gpio;
 	enum of_gpio_flags of_flags;
 	struct clk *clk;
 	bool active_low, is_mux;
 
 	num_parents = of_clk_get_parent_count(node);
-	if (num_parents < 0)
-		num_parents = 0;
-
 	if (num_parents) {
 		parent_names = devm_kcalloc(&pdev->dev, num_parents,
 					    sizeof(char *), GFP_KERNEL);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web