All of lore.kernel.org
 help / color / mirror / Atom feed
From: mturquette@linaro.org (Mike Turquette)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] clk: composite: allow fixed rates & fixed dividers
Date: Thu, 11 Apr 2013 10:56:13 -0700	[thread overview]
Message-ID: <20130411175613.7915.25443@quantum> (raw)
In-Reply-To: <5166A2E6.70907@nvidia.com>

Quoting Prashant Gaikwad (2013-04-11 04:47:50)
> On Thursday 11 April 2013 03:32 AM, Mike Turquette wrote:
> > The composite clock assumes that any clock implementing the .recalc_rate
> > callback will also implement .round_rate and .set_rate.  This is not
> > always true; the basic fixed-rate clock will only implement .recalc_rate
> > and a fixed-divider clock may choose to implement .recalc_rate and
> > .round_rate but not .set_rate.
> >
> > Fix this by conditionally registering .round_rate and .set_rate
> > callbacks based on the rate_ops passed in to clk_composite_register.
> >
> > Signed-off-by: Mike Turquette <mturquette@linaro.org>
> > Cc: Prashant Gaikwad <pgaikwad@nvidia.com>
> > Cc: Emilio L?pez <emilio@elopez.com.ar>
> > Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
> > ---
> >   drivers/clk/clk-composite.c |   13 +++++++++----
> >   1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
> > index 6f4728c..2779fb3 100644
> > --- a/drivers/clk/clk-composite.c
> > +++ b/drivers/clk/clk-composite.c
> > @@ -150,17 +150,22 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
> >       }
> >   
> >       if (rate_hw && rate_ops) {
> > -             if (!rate_ops->recalc_rate || !rate_ops->round_rate ||
> > -                 !rate_ops->set_rate) {
> > +             if (!rate_ops->recalc_rate) {
> >                       clk = ERR_PTR(-EINVAL);
> >                       goto err;
> >               }
> >   
> > +             /* .round_rate is a prerequisite for .set_rate */
> > +             if (rate_ops->round_rate) {
> > +                     clk_composite_ops->round_rate = clk_composite_round_rate;
> > +                     if (rate_ops->set_rate) {
> > +                             clk_composite_ops->set_rate = clk_composite_set_rate;
> > +                     }
> > +             }
> > +
> 
> What if rate_ops has only recalc_rate and set_rate? clk_composite_ops 
> will have only recalc_rate and it will pass the sanity check in clk_init 
> and caller of clk_register_composite will expect set_rate to work.
> We should check here if rate_ops has set_rate but not round_rate then 
> return error.
> 

I think I will instead put a WARN here instead of completely bailing out
of the clock registration.

Thanks,
Mike

> >               composite->rate_hw = rate_hw;
> >               composite->rate_ops = rate_ops;
> >               clk_composite_ops->recalc_rate = clk_composite_recalc_rate;
> > -             clk_composite_ops->round_rate = clk_composite_round_rate;
> > -             clk_composite_ops->set_rate = clk_composite_set_rate;
> >       }
> >   
> >       if (gate_hw && gate_ops) {

  reply	other threads:[~2013-04-11 17:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-09 13:48 [PATCH 0/3] sunxi: unify main oscillator and its gate Emilio López
2013-04-09 13:48 ` [PATCH 1/3] clk: composite: Add fixed-rate support Emilio López
2013-04-09 15:41   ` Gregory CLEMENT
2013-04-09 16:04     ` Emilio López
2013-04-10 22:02   ` [PATCH 0/3] fixed-rate and fixed-factor clocks in composite clock Mike Turquette
2013-04-10 22:02     ` [PATCH 1/3] clk: composite: rename 'div' references to 'rate' Mike Turquette
2013-04-11 11:40       ` Prashant Gaikwad
2013-04-11 17:56         ` Mike Turquette
2013-04-10 22:02     ` [PATCH 2/3] clk: composite: allow fixed rates & fixed dividers Mike Turquette
2013-04-11 11:47       ` Prashant Gaikwad
2013-04-11 17:56         ` Mike Turquette [this message]
2013-04-10 22:02     ` [PATCH v2 3/3] clk: sunxi: Unify oscillator clock Mike Turquette
2013-04-11  0:07       ` Emilio López
2013-04-12 18:40         ` Mike Turquette
2013-04-11 18:31     ` [PATCH v2 1/2] clk: composite: rename 'div' references to 'rate' Mike Turquette
2013-04-11 18:31       ` [PATCH v2 2/2] clk: composite: allow fixed rates & fixed dividers Mike Turquette
2013-04-09 13:48 ` [PATCH 2/3] clk: sunxi: Unify oscillator clock Emilio López
2013-04-09 13:48 ` [PATCH 3/3] ARM: sunxi: unify osc24M_fixed and osc24M Emilio López
2013-04-15  8:45   ` Maxime Ripard
2013-04-09 14:56 ` [PATCH 0/3] sunxi: unify main oscillator and its gate Gregory CLEMENT
2013-04-09 15:04   ` Emilio López

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=20130411175613.7915.25443@quantum \
    --to=mturquette@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.