All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: tegra: Implement locking for super clock
@ 2013-02-07 16:24 Peter De Schrijver
  2013-02-07 18:57 ` Mike Turquette
  2013-02-08  5:21 ` Prashant Gaikwad
  0 siblings, 2 replies; 5+ messages in thread
From: Peter De Schrijver @ 2013-02-07 16:24 UTC (permalink / raw)
  To: pdeschrijver
  Cc: Stephen Warren, Mike Turquette, Prashant Gaikwad, linux-kernel

Although tegra_clk_register_super_mux() has a lock parameter, the lock is not
actually used by the code. Fixed with this patch.

Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
---
 drivers/clk/tegra/clk-super.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/tegra/clk-super.c b/drivers/clk/tegra/clk-super.c
index 7ad48a8..2fd924d 100644
--- a/drivers/clk/tegra/clk-super.c
+++ b/drivers/clk/tegra/clk-super.c
@@ -73,7 +73,12 @@ static int clk_super_set_parent(struct clk_hw *hw, u8 index)
 {
 	struct tegra_clk_super_mux *mux = to_clk_super_mux(hw);
 	u32 val, state;
+	int err = 0;
 	u8 parent_index, shift;
+	unsigned long flags = 0;
+
+	if (mux->lock)
+		spin_lock_irqsave(mux->lock, flags);
 
 	val = readl_relaxed(mux->reg);
 	state = val & SUPER_STATE_MASK;
@@ -92,8 +97,10 @@ static int clk_super_set_parent(struct clk_hw *hw, u8 index)
 					       (index == mux->pllx_index))) {
 		parent_index = clk_super_get_parent(hw);
 		if ((parent_index == mux->div2_index) ||
-		    (parent_index == mux->pllx_index))
-			return -EINVAL;
+		    (parent_index == mux->pllx_index)) {
+			err = -EINVAL;
+			goto out;
+		}
 
 		val ^= SUPER_LP_DIV2_BYPASS;
 		writel_relaxed(val, mux->reg);
@@ -107,7 +114,12 @@ static int clk_super_set_parent(struct clk_hw *hw, u8 index)
 
 	writel_relaxed(val, mux->reg);
 	udelay(2);
-	return 0;
+
+out:
+	if (mux->lock)
+		spin_unlock_irqrestore(mux->lock, flags);
+
+	return err;
 }
 
 const struct clk_ops tegra_clk_super_ops = {
-- 
1.7.7.rc0.72.g4b5ea.dirty


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: tegra: Implement locking for super clock
  2013-02-07 16:24 [PATCH] clk: tegra: Implement locking for super clock Peter De Schrijver
@ 2013-02-07 18:57 ` Mike Turquette
  2013-02-07 19:13   ` Stephen Warren
  2013-02-08 10:16   ` Peter De Schrijver
  2013-02-08  5:21 ` Prashant Gaikwad
  1 sibling, 2 replies; 5+ messages in thread
From: Mike Turquette @ 2013-02-07 18:57 UTC (permalink / raw)
  To: Peter De Schrijver, pdeschrijver
  Cc: Stephen Warren, Prashant Gaikwad, linux-kernel

Quoting Peter De Schrijver (2013-02-07 08:24:14)
> Although tegra_clk_register_super_mux() has a lock parameter, the lock is not
> actually used by the code. Fixed with this patch.
> 
> Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
> ---
>  drivers/clk/tegra/clk-super.c |   18 +++++++++++++++---
>  1 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/clk/tegra/clk-super.c b/drivers/clk/tegra/clk-super.c
> index 7ad48a8..2fd924d 100644
> --- a/drivers/clk/tegra/clk-super.c
> +++ b/drivers/clk/tegra/clk-super.c
> @@ -73,7 +73,12 @@ static int clk_super_set_parent(struct clk_hw *hw, u8 index)
>  {
>         struct tegra_clk_super_mux *mux = to_clk_super_mux(hw);
>         u32 val, state;
> +       int err = 0;
>         u8 parent_index, shift;
> +       unsigned long flags = 0;

I don't think initializing flags to zero is necessary but it is not a
big deal.  Is gcc throwing a warning?  Otherwise:

Acked-by: Mike Turquette <mturquette@linaro.org>

Regards,
Mike

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: tegra: Implement locking for super clock
  2013-02-07 18:57 ` Mike Turquette
@ 2013-02-07 19:13   ` Stephen Warren
  2013-02-08 10:16   ` Peter De Schrijver
  1 sibling, 0 replies; 5+ messages in thread
From: Stephen Warren @ 2013-02-07 19:13 UTC (permalink / raw)
  To: Mike Turquette
  Cc: Peter De Schrijver, Stephen Warren, Prashant Gaikwad, linux-kernel

On 02/07/2013 11:57 AM, Mike Turquette wrote:
> Quoting Peter De Schrijver (2013-02-07 08:24:14)
>> Although tegra_clk_register_super_mux() has a lock parameter, the lock is not
>> actually used by the code. Fixed with this patch.
>>
>> Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
>> ---
>>  drivers/clk/tegra/clk-super.c |   18 +++++++++++++++---
>>  1 files changed, 15 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/clk/tegra/clk-super.c b/drivers/clk/tegra/clk-super.c
>> index 7ad48a8..2fd924d 100644
>> --- a/drivers/clk/tegra/clk-super.c
>> +++ b/drivers/clk/tegra/clk-super.c
>> @@ -73,7 +73,12 @@ static int clk_super_set_parent(struct clk_hw *hw, u8 index)
>>  {
>>         struct tegra_clk_super_mux *mux = to_clk_super_mux(hw);
>>         u32 val, state;
>> +       int err = 0;
>>         u8 parent_index, shift;
>> +       unsigned long flags = 0;
> 
> I don't think initializing flags to zero is necessary but it is not a
> big deal.  Is gcc throwing a warning?  Otherwise:
> 
> Acked-by: Mike Turquette <mturquette@linaro.org>

I've applied this to Tegra's for-3.9/soc-ccf-fixes branch. If you want
to repost given Mike's comments, I can take an updated version.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: tegra: Implement locking for super clock
  2013-02-07 16:24 [PATCH] clk: tegra: Implement locking for super clock Peter De Schrijver
  2013-02-07 18:57 ` Mike Turquette
@ 2013-02-08  5:21 ` Prashant Gaikwad
  1 sibling, 0 replies; 5+ messages in thread
From: Prashant Gaikwad @ 2013-02-08  5:21 UTC (permalink / raw)
  To: Peter De Schrijver; +Cc: Stephen Warren, Mike Turquette, linux-kernel

On Thursday 07 February 2013 09:54 PM, Peter De Schrijver wrote:
> Although tegra_clk_register_super_mux() has a lock parameter, the lock is not
> actually used by the code. Fixed with this patch.
>
> Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>

Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>

> ---
>   drivers/clk/tegra/clk-super.c |   18 +++++++++++++++---
>   1 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/tegra/clk-super.c b/drivers/clk/tegra/clk-super.c
> index 7ad48a8..2fd924d 100644
> --- a/drivers/clk/tegra/clk-super.c
> +++ b/drivers/clk/tegra/clk-super.c
> @@ -73,7 +73,12 @@ static int clk_super_set_parent(struct clk_hw *hw, u8 index)
>   {
>   	struct tegra_clk_super_mux *mux = to_clk_super_mux(hw);
>   	u32 val, state;
> +	int err = 0;
>   	u8 parent_index, shift;
> +	unsigned long flags = 0;
> +
> +	if (mux->lock)
> +		spin_lock_irqsave(mux->lock, flags);
>   
>   	val = readl_relaxed(mux->reg);
>   	state = val & SUPER_STATE_MASK;
> @@ -92,8 +97,10 @@ static int clk_super_set_parent(struct clk_hw *hw, u8 index)
>   					       (index == mux->pllx_index))) {
>   		parent_index = clk_super_get_parent(hw);
>   		if ((parent_index == mux->div2_index) ||
> -		    (parent_index == mux->pllx_index))
> -			return -EINVAL;
> +		    (parent_index == mux->pllx_index)) {
> +			err = -EINVAL;
> +			goto out;
> +		}
>   
>   		val ^= SUPER_LP_DIV2_BYPASS;
>   		writel_relaxed(val, mux->reg);
> @@ -107,7 +114,12 @@ static int clk_super_set_parent(struct clk_hw *hw, u8 index)
>   
>   	writel_relaxed(val, mux->reg);
>   	udelay(2);
> -	return 0;
> +
> +out:
> +	if (mux->lock)
> +		spin_unlock_irqrestore(mux->lock, flags);
> +
> +	return err;
>   }
>   
>   const struct clk_ops tegra_clk_super_ops = {


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: tegra: Implement locking for super clock
  2013-02-07 18:57 ` Mike Turquette
  2013-02-07 19:13   ` Stephen Warren
@ 2013-02-08 10:16   ` Peter De Schrijver
  1 sibling, 0 replies; 5+ messages in thread
From: Peter De Schrijver @ 2013-02-08 10:16 UTC (permalink / raw)
  To: Mike Turquette; +Cc: Stephen Warren, Prashant Gaikwad, linux-kernel

On Thu, Feb 07, 2013 at 07:57:42PM +0100, Mike Turquette wrote:
> Quoting Peter De Schrijver (2013-02-07 08:24:14)
> > Although tegra_clk_register_super_mux() has a lock parameter, the lock is not
> > actually used by the code. Fixed with this patch.
> > 
> > Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
> > ---
> >  drivers/clk/tegra/clk-super.c |   18 +++++++++++++++---
> >  1 files changed, 15 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/clk/tegra/clk-super.c b/drivers/clk/tegra/clk-super.c
> > index 7ad48a8..2fd924d 100644
> > --- a/drivers/clk/tegra/clk-super.c
> > +++ b/drivers/clk/tegra/clk-super.c
> > @@ -73,7 +73,12 @@ static int clk_super_set_parent(struct clk_hw *hw, u8 index)
> >  {
> >         struct tegra_clk_super_mux *mux = to_clk_super_mux(hw);
> >         u32 val, state;
> > +       int err = 0;
> >         u8 parent_index, shift;
> > +       unsigned long flags = 0;
> 
> I don't think initializing flags to zero is necessary but it is not a
> big deal.  Is gcc throwing a warning?  Otherwise:
> 

Yes. gcc throws a warning if it's not initialized.

Cheers,

Peter.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-02-08 10:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-07 16:24 [PATCH] clk: tegra: Implement locking for super clock Peter De Schrijver
2013-02-07 18:57 ` Mike Turquette
2013-02-07 19:13   ` Stephen Warren
2013-02-08 10:16   ` Peter De Schrijver
2013-02-08  5:21 ` Prashant Gaikwad

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.