Message ID | 1519856861-31384-2-git-send-email-jollys@xilinx.com (mailing list archive) |
---|---|
State | Rejected, archived |
Headers | show |
Quoting Jolly Shah (2018-02-28 14:27:39) > From: Jolly Shah <jolly.shah@xilinx.com> > > This API helps to determine the users for any clock. Ok, but why do you need it? > > Signed-off-by: Jolly Shah <jollys@xilinx.com> > Signed-off-by: Tejas Patel <tejasp@xilinx.com> > Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> > --- > drivers/clk/clk.c | 28 ++++++++++++++++++++++++++++ > include/linux/clk-provider.h | 1 + > 2 files changed, 29 insertions(+) > > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > index 0f686a9..947a18b 100644 > --- a/drivers/clk/clk.c > +++ b/drivers/clk/clk.c > @@ -274,6 +274,34 @@ struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw) > } > EXPORT_SYMBOL_GPL(clk_hw_get_parent); > > +static unsigned int sibling; Looks very thread unsafe! > + > +static void clk_show_subtree(struct clk_core *c, > + int level) > +{ > + struct clk_core *child; > + > + if (!c) > + return; > + > + if (level == 1) > + sibling++; > + > + hlist_for_each_entry(child, &c->children, child_node) > + clk_show_subtree(child, level + 1); > +} > + > +unsigned int clk_get_children(char *name) > +{ > + struct clk_core *core; > + struct clk *pclk = __clk_lookup(name); > + > + sibling = 0; > + core = pclk->core; > + clk_show_subtree(core, 0); > + return sibling; > +} > + > static struct clk_core *__clk_lookup_subtree(const char *name, > struct clk_core *core) > { > diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h > index f711be6..e94dfb2 100644 > --- a/include/linux/clk-provider.h > +++ b/include/linux/clk-provider.h > @@ -745,6 +745,7 @@ unsigned int __clk_get_enable_count(struct clk *clk); > unsigned long clk_hw_get_rate(const struct clk_hw *hw); > unsigned long __clk_get_flags(struct clk *clk); > unsigned long clk_hw_get_flags(const struct clk_hw *hw); > +unsigned int clk_get_children(char *name); And uses a string lookup instead of having the clk_hw pointer in hand. No thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-clk" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Stephan, > -----Original Message----- > From: Stephen Boyd [mailto:sboyd@kernel.org] > Sent: Monday, March 19, 2018 11:22 AM > To: Jolly Shah <JOLLYS@xilinx.com>; linux-clk@vger.kernel.org; > mark.rutland@arm.com; michal.simek@xilinx.com; mturquette@baylibre.com; > robh+dt@kernel.org; sboyd@codeaurora.org > Cc: Rajan Vaja <RAJANV@xilinx.com>; devicetree@vger.kernel.org; linux-arm- > kernel@lists.infradead.org; linux-kernel@vger.kernel.org; Jolly Shah > <JOLLYS@xilinx.com>; Jolly Shah <JOLLYS@xilinx.com>; Tejas Patel > <TEJASP@xilinx.com>; Shubhrajyoti Datta <shubhraj@xilinx.com> > Subject: Re: [PATCH 1/3] drivers: clk: Add clk_get_children support > > Quoting Jolly Shah (2018-02-28 14:27:39) > > From: Jolly Shah <jolly.shah@xilinx.com> > > > > This API helps to determine the users for any clock. > > Ok, but why do you need it? As you suggested in other patch, we will move children validation in FW. > > > > > Signed-off-by: Jolly Shah <jollys@xilinx.com> > > Signed-off-by: Tejas Patel <tejasp@xilinx.com> > > Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> > > --- > > drivers/clk/clk.c | 28 ++++++++++++++++++++++++++++ > > include/linux/clk-provider.h | 1 + > > 2 files changed, 29 insertions(+) > > > > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index > > 0f686a9..947a18b 100644 > > --- a/drivers/clk/clk.c > > +++ b/drivers/clk/clk.c > > @@ -274,6 +274,34 @@ struct clk_hw *clk_hw_get_parent(const struct > > clk_hw *hw) } EXPORT_SYMBOL_GPL(clk_hw_get_parent); > > > > +static unsigned int sibling; > > Looks very thread unsafe! > > > + > > +static void clk_show_subtree(struct clk_core *c, > > + int level) { > > + struct clk_core *child; > > + > > + if (!c) > > + return; > > + > > + if (level == 1) > > + sibling++; > > + > > + hlist_for_each_entry(child, &c->children, child_node) > > + clk_show_subtree(child, level + 1); } > > + > > +unsigned int clk_get_children(char *name) { > > + struct clk_core *core; > > + struct clk *pclk = __clk_lookup(name); > > + > > + sibling = 0; > > + core = pclk->core; > > + clk_show_subtree(core, 0); > > + return sibling; > > +} > > + > > static struct clk_core *__clk_lookup_subtree(const char *name, > > struct clk_core *core) { > > diff --git a/include/linux/clk-provider.h > > b/include/linux/clk-provider.h index f711be6..e94dfb2 100644 > > --- a/include/linux/clk-provider.h > > +++ b/include/linux/clk-provider.h > > @@ -745,6 +745,7 @@ unsigned int __clk_get_enable_count(struct clk > > *clk); unsigned long clk_hw_get_rate(const struct clk_hw *hw); > > unsigned long __clk_get_flags(struct clk *clk); unsigned long > > clk_hw_get_flags(const struct clk_hw *hw); > > +unsigned int clk_get_children(char *name); > > And uses a string lookup instead of having the clk_hw pointer in hand. > No thanks.
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0f686a9..947a18b 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -274,6 +274,34 @@ struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw) } EXPORT_SYMBOL_GPL(clk_hw_get_parent); +static unsigned int sibling; + +static void clk_show_subtree(struct clk_core *c, + int level) +{ + struct clk_core *child; + + if (!c) + return; + + if (level == 1) + sibling++; + + hlist_for_each_entry(child, &c->children, child_node) + clk_show_subtree(child, level + 1); +} + +unsigned int clk_get_children(char *name) +{ + struct clk_core *core; + struct clk *pclk = __clk_lookup(name); + + sibling = 0; + core = pclk->core; + clk_show_subtree(core, 0); + return sibling; +} + static struct clk_core *__clk_lookup_subtree(const char *name, struct clk_core *core) { diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index f711be6..e94dfb2 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -745,6 +745,7 @@ unsigned int __clk_get_enable_count(struct clk *clk); unsigned long clk_hw_get_rate(const struct clk_hw *hw); unsigned long __clk_get_flags(struct clk *clk); unsigned long clk_hw_get_flags(const struct clk_hw *hw); +unsigned int clk_get_children(char *name); bool clk_hw_is_prepared(const struct clk_hw *hw); bool clk_hw_rate_is_protected(const struct clk_hw *hw); bool clk_hw_is_enabled(const struct clk_hw *hw);