All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Turquette <mturquette@linaro.org>
To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org
Cc: Kyungmin Park <kyungmin.park@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Tomasz Figa <t.figa@samsung.com>,
	Karol Wrona <k.wrona@samsung.com>
Subject: Re: [PATCH v2] clk: s2mps11: Fix clk_ops
Date: Wed, 02 Jul 2014 10:01:04 -0700	[thread overview]
Message-ID: <20140702170104.7440.66617@quantum> (raw)
In-Reply-To: <1404234839-6005-1-git-send-email-k.wrona@samsung.com>

Quoting Karol Wrona (2014-07-01 10:13:59)
> s2mps11 clocks had registered callbacks for prepare ,unprepare and is_enabled.
> During disabling unused clocks the lack of is_prepared caused that unused
> s2mps11 clocks were not unprepared and stayed active.
> 
> Regmap_read is cached so it can be called in is_prepare callback
> to achieve this information. Enabled field was removed from struct s2mps11_clk.
> 
> Signed-off-by: Karol Wrona <k.wrona@samsung.com>

Applied to clk-next. I didn't take it into clk-fixes since I don't think
the disable_unused bug was introduced any time recently.

Regards,
Mike

> ---
>  drivers/clk/clk-s2mps11.c |   33 +++++++++++----------------------
>  1 file changed, 11 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c
> index b5274a9..5df99a4 100644
> --- a/drivers/clk/clk-s2mps11.c
> +++ b/drivers/clk/clk-s2mps11.c
> @@ -45,7 +45,6 @@ struct s2mps11_clk {
>         struct clk *clk;
>         struct clk_lookup *lookup;
>         u32 mask;
> -       bool enabled;
>         unsigned int reg;
>  };
>  
> @@ -62,8 +61,6 @@ static int s2mps11_clk_prepare(struct clk_hw *hw)
>         ret = regmap_update_bits(s2mps11->iodev->regmap_pmic,
>                                  s2mps11->reg,
>                                  s2mps11->mask, s2mps11->mask);
> -       if (!ret)
> -               s2mps11->enabled = true;
>  
>         return ret;
>  }
> @@ -75,32 +72,32 @@ static void s2mps11_clk_unprepare(struct clk_hw *hw)
>  
>         ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, s2mps11->reg,
>                            s2mps11->mask, ~s2mps11->mask);
> -
> -       if (!ret)
> -               s2mps11->enabled = false;
>  }
>  
> -static int s2mps11_clk_is_enabled(struct clk_hw *hw)
> +static int s2mps11_clk_is_prepared(struct clk_hw *hw)
>  {
> +       int ret;
> +       u32 val;
>         struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw);
>  
> -       return s2mps11->enabled;
> +       ret = regmap_read(s2mps11->iodev->regmap_pmic,
> +                               s2mps11->reg, &val);
> +       if (ret < 0)
> +               return -EINVAL;
> +
> +       return val & s2mps11->mask;
>  }
>  
>  static unsigned long s2mps11_clk_recalc_rate(struct clk_hw *hw,
>                                              unsigned long parent_rate)
>  {
> -       struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw);
> -       if (s2mps11->enabled)
> -               return 32768;
> -       else
> -               return 0;
> +       return 32768;
>  }
>  
>  static struct clk_ops s2mps11_clk_ops = {
>         .prepare        = s2mps11_clk_prepare,
>         .unprepare      = s2mps11_clk_unprepare,
> -       .is_enabled     = s2mps11_clk_is_enabled,
> +       .is_prepared    = s2mps11_clk_is_prepared,
>         .recalc_rate    = s2mps11_clk_recalc_rate,
>  };
>  
> @@ -174,7 +171,6 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
>         unsigned int s2mps11_reg;
>         struct clk_init_data *clks_init;
>         int i, ret = 0;
> -       u32 val;
>  
>         s2mps11_clks = devm_kzalloc(&pdev->dev, sizeof(*s2mps11_clk) *
>                                         S2MPS11_CLKS_NUM, GFP_KERNEL);
> @@ -213,13 +209,6 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
>                 s2mps11_clk->mask = 1 << i;
>                 s2mps11_clk->reg = s2mps11_reg;
>  
> -               ret = regmap_read(s2mps11_clk->iodev->regmap_pmic,
> -                                 s2mps11_clk->reg, &val);
> -               if (ret < 0)
> -                       goto err_reg;
> -
> -               s2mps11_clk->enabled = val & s2mps11_clk->mask;
> -
>                 s2mps11_clk->clk = devm_clk_register(&pdev->dev,
>                                                         &s2mps11_clk->hw);
>                 if (IS_ERR(s2mps11_clk->clk)) {
> -- 
> 1.7.9.5
> 

WARNING: multiple messages have this Message-ID (diff)
From: Mike Turquette <mturquette@linaro.org>
To: Karol Wrona <k.wrona@samsung.com>,
	linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org
Cc: "Kyungmin Park" <kyungmin.park@samsung.com>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	"Bartlomiej Zolnierkiewicz" <b.zolnierkie@samsung.com>,
	"Tomasz Figa" <t.figa@samsung.com>,
	"Karol Wrona" <k.wrona@samsung.com>
Subject: Re: [PATCH v2] clk: s2mps11: Fix clk_ops
Date: Wed, 02 Jul 2014 10:01:04 -0700	[thread overview]
Message-ID: <20140702170104.7440.66617@quantum> (raw)
In-Reply-To: <1404234839-6005-1-git-send-email-k.wrona@samsung.com>

Quoting Karol Wrona (2014-07-01 10:13:59)
> s2mps11 clocks had registered callbacks for prepare ,unprepare and is_enabled.
> During disabling unused clocks the lack of is_prepared caused that unused
> s2mps11 clocks were not unprepared and stayed active.
> 
> Regmap_read is cached so it can be called in is_prepare callback
> to achieve this information. Enabled field was removed from struct s2mps11_clk.
> 
> Signed-off-by: Karol Wrona <k.wrona@samsung.com>

Applied to clk-next. I didn't take it into clk-fixes since I don't think
the disable_unused bug was introduced any time recently.

Regards,
Mike

> ---
>  drivers/clk/clk-s2mps11.c |   33 +++++++++++----------------------
>  1 file changed, 11 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c
> index b5274a9..5df99a4 100644
> --- a/drivers/clk/clk-s2mps11.c
> +++ b/drivers/clk/clk-s2mps11.c
> @@ -45,7 +45,6 @@ struct s2mps11_clk {
>         struct clk *clk;
>         struct clk_lookup *lookup;
>         u32 mask;
> -       bool enabled;
>         unsigned int reg;
>  };
>  
> @@ -62,8 +61,6 @@ static int s2mps11_clk_prepare(struct clk_hw *hw)
>         ret = regmap_update_bits(s2mps11->iodev->regmap_pmic,
>                                  s2mps11->reg,
>                                  s2mps11->mask, s2mps11->mask);
> -       if (!ret)
> -               s2mps11->enabled = true;
>  
>         return ret;
>  }
> @@ -75,32 +72,32 @@ static void s2mps11_clk_unprepare(struct clk_hw *hw)
>  
>         ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, s2mps11->reg,
>                            s2mps11->mask, ~s2mps11->mask);
> -
> -       if (!ret)
> -               s2mps11->enabled = false;
>  }
>  
> -static int s2mps11_clk_is_enabled(struct clk_hw *hw)
> +static int s2mps11_clk_is_prepared(struct clk_hw *hw)
>  {
> +       int ret;
> +       u32 val;
>         struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw);
>  
> -       return s2mps11->enabled;
> +       ret = regmap_read(s2mps11->iodev->regmap_pmic,
> +                               s2mps11->reg, &val);
> +       if (ret < 0)
> +               return -EINVAL;
> +
> +       return val & s2mps11->mask;
>  }
>  
>  static unsigned long s2mps11_clk_recalc_rate(struct clk_hw *hw,
>                                              unsigned long parent_rate)
>  {
> -       struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw);
> -       if (s2mps11->enabled)
> -               return 32768;
> -       else
> -               return 0;
> +       return 32768;
>  }
>  
>  static struct clk_ops s2mps11_clk_ops = {
>         .prepare        = s2mps11_clk_prepare,
>         .unprepare      = s2mps11_clk_unprepare,
> -       .is_enabled     = s2mps11_clk_is_enabled,
> +       .is_prepared    = s2mps11_clk_is_prepared,
>         .recalc_rate    = s2mps11_clk_recalc_rate,
>  };
>  
> @@ -174,7 +171,6 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
>         unsigned int s2mps11_reg;
>         struct clk_init_data *clks_init;
>         int i, ret = 0;
> -       u32 val;
>  
>         s2mps11_clks = devm_kzalloc(&pdev->dev, sizeof(*s2mps11_clk) *
>                                         S2MPS11_CLKS_NUM, GFP_KERNEL);
> @@ -213,13 +209,6 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
>                 s2mps11_clk->mask = 1 << i;
>                 s2mps11_clk->reg = s2mps11_reg;
>  
> -               ret = regmap_read(s2mps11_clk->iodev->regmap_pmic,
> -                                 s2mps11_clk->reg, &val);
> -               if (ret < 0)
> -                       goto err_reg;
> -
> -               s2mps11_clk->enabled = val & s2mps11_clk->mask;
> -
>                 s2mps11_clk->clk = devm_clk_register(&pdev->dev,
>                                                         &s2mps11_clk->hw);
>                 if (IS_ERR(s2mps11_clk->clk)) {
> -- 
> 1.7.9.5
> 

  reply	other threads:[~2014-07-02 17:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-01 17:13 [PATCH v2] clk: s2mps11: Fix clk_ops Karol Wrona
2014-07-02 17:01 ` Mike Turquette [this message]
2014-07-02 17:01   ` Mike Turquette

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=20140702170104.7440.66617@quantum \
    --to=mturquette@linaro.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=k.wrona@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=t.figa@samsung.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.