All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <me@felipebalbi.com>
To: Paul Walmsley <paul@pwsan.com>
Cc: Felipe Balbi <me@felipebalbi.com>,
	linux-omap@vger.kernel.org, Felipe Balbi <felipe.balbi@nokia.com>
Subject: Re: [PATCH 1/3] clk: introduce omap_clk_associate
Date: Tue, 14 Oct 2008 20:29:27 +0300	[thread overview]
Message-ID: <20081014172921.GJ20247@frodo> (raw)
In-Reply-To: <alpine.DEB.2.00.0810141039580.15253@utopia.booyaka.com>

On Tue, Oct 14, 2008 at 11:08:48AM -0600, Paul Walmsley wrote:
> Hi Felipe,
> 
> so I'll put most of my comments here.
> 
> On Tue, 7 Oct 2008, Felipe Balbi wrote:
> 
> > Introduce a new mechanism to omap's clk implementation to
> > associate the device with its clock during platform_device
> > registration. Also gives the clock a function name (like
> > mmc_fck, uart_fck, ehci_fck, etc) so drivers won't have to
> > care about clk names any longer.
> 
> Let's make the function names shorter, like "fclk" and "iclk".  That 
> should make them even easier to use in situations where the device name 
> itself changes, e.g., "mmc"/"hsmmc" etc.  Plus the linker will be able to 
> merge many them together into single constant strings.  For a device with 
> multiple fclks like DSS, we can use "tv_fclk" also, etc.

I didn't quite get you here. The idea of mmc_fck is so that

clk_get(dev, "mmc_fck");

works fine and returns the correct clock. If we have several fck and ick
function names, how will we clk_get() the right one ??

> > diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
> > index 7bbfba2..c090f23 100644
> > --- a/arch/arm/plat-omap/clock.c
> > +++ b/arch/arm/plat-omap/clock.c
> > @@ -43,7 +43,7 @@ static struct clk_functions *arch_clock;
> >   */
> >  struct clk * clk_get(struct device *dev, const char *id)
> >  {
> > -	struct clk *p, *clk = ERR_PTR(-ENOENT);
> > +	struct clk *p, *clk;
> >  	int idno;
> >  
> >  	if (dev == NULL || dev->bus != &platform_bus_type)
> > @@ -53,6 +53,15 @@ struct clk * clk_get(struct device *dev, const char *id)
> >  
> >  	mutex_lock(&clocks_mutex);
> >  
> > +	list_for_each_entry(clk, &clocks, node) {
> > +		if (clk->function && (dev == clk->dev) &&
> > +				strcmp(id, clk->function) == 0)
> > +			goto found;
> 
> Please avoid the gotos and use the previously-used form for returning 
> success, e.g., iterate on p; if found, then assign to clk, and break.
> 
> Also, is there some reason why there are two list_for_each_entry() blocks?  
> Those should be merged into one.

Will do.

> 
> > +
> > +		if (strcmp(id, clk->name) == 0)
> > +			goto found;
> 
> Doesn't the following code already handle the above case?

my bad, when merging both list_for_each_entry() this will disappear.

> > +/**
> 
> First, thank you for using kerneldoc.  But ...
> 
> > + * omap_clk_associate - associates a user to a clock so device drivers don't
> > + * have to care about clock names
> 
> ... Documentation/kernel-doc-nano-HOWTO.txt requires the short function 
> description to fit on one line.  If you need more room, please put the 
> larger description after a blank line after the last argument 
> documentation line (e.g., line beginning with '@').

Will fix.

> 
> > + *
> 
> This blank line needs to be removed per kerneldoc - "The @argument 
> descriptions must begin on the very next line ..."
> 
> > + * @id: clock id as defined in arch/arm/mach-omapX/clkxxxx.h
> > + * @dev: device pointer for the clock user
> > + * @f: a function for the clock (uart_[if]ck, musb_ick, ehci_[if]ck, etc)
> > + */
> > +void __init omap_clk_associate(const char *id, struct device *dev, const char *f)
> > +{
> > +	struct clk *clk = clk_get(NULL, id);
> > +
> > +	if (!dev || !clk || !IS_ERR(clk_get(dev, f)))
> > +		return;
> 
> Please break the clk_get() test above out into its own statement, and 
> clk_put() it before returning.

ok.

> There needs to be a test before these lines to ensure that some driver has 
> not already associated a function with this clock, or a device with this 
> clock, and to WARN_ON(1) if it has.

sounds good.

> But there seems to be a deeper problem.  What happens when multiple device 
> drivers want to associate to the same clock?  osc_ck is the pathological 
> case.  Seems like you'll need a different data structure, like a list, to 
> store in the struct clk.

Yeah, have to think about that, but then again, how can several users
concurrently enable and disable the same clock ?

I mean, imagine driver A clk_enable(osc_ck) and while needing that
clock, driver B clk_disable(osc_ck). That would break driver A, right ?

How is omap clk fw handling that case right now ? I'd say we should have
one user per clk and in the case of osc_ck, that would be a clk input
for generating another clk, or something like that, so driver A can
clk_enable(osc_ck_A) and yet driver B could clk_disable(osc_ck_B) and
everything still works.

-- 
balbi

  reply	other threads:[~2008-10-14 17:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-06 22:47 [PATCH 0/3] omap_clk_associate Felipe Balbi
2008-10-06 22:47 ` [PATCH 1/3] clk: introduce omap_clk_associate Felipe Balbi
2008-10-06 22:47   ` [PATCH 2/3] clk: use clk_associate for musb driver Felipe Balbi
2008-10-06 22:47     ` [PATCH 3/3] clk: use clk_associate on watchdog driver Felipe Balbi
2008-10-14 17:08   ` [PATCH 1/3] clk: introduce omap_clk_associate Paul Walmsley
2008-10-14 17:29     ` Felipe Balbi [this message]
2008-10-14 17:47       ` David Brownell
2008-10-14 18:06         ` Felipe Balbi
2008-10-14 20:59           ` Tony Lindgren
2008-10-14 21:09             ` Igor Stoppa
2008-10-14 21:24               ` Tony Lindgren
2008-10-14 21:28                 ` Felipe Balbi
2008-10-15  6:21                 ` Högander Jouni
2008-10-15  7:49                   ` Paul Walmsley
2008-10-15 12:56                     ` Woodruff, Richard
2008-10-15 13:03                     ` Högander Jouni
2008-10-15 13:08                       ` Paul Walmsley
2008-10-15 22:42                       ` Woodruff, Richard
2008-10-15 12:45                   ` Woodruff, Richard
2008-10-16  9:02       ` Paul Walmsley
  -- strict thread matches above, loose matches on Subject: below --
2008-10-25 19:55 Felipe Balbi
2008-10-25 20:03 ` Felipe Balbi
2008-10-28  1:28   ` Felipe Balbi
2008-11-06  0:53   ` Felipe Balbi
2008-10-25 19:58 Felipe Balbi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081014172921.GJ20247@frodo \
    --to=me@felipebalbi.com \
    --cc=felipe.balbi@nokia.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.