diff mbox series

[v5,09/15] clk: at91: clk-master: mask mckr against layout->mask

Message ID 20211011112719.3951784-10-claudiu.beznea@microchip.com (mailing list archive)
State Accepted, archived
Headers show
Series clk: at91: updates for power management and dvfs | expand

Commit Message

Claudiu Beznea Oct. 11, 2021, 11:27 a.m. UTC
Mask values read/written from/to MCKR against layout->mask as this
mask may be different b/w PMC versions.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/clk/at91/clk-master.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Nicolas Ferre Oct. 15, 2021, 7:56 a.m. UTC | #1
On 11/10/2021 at 13:27, Claudiu Beznea wrote:
> Mask values read/written from/to MCKR against layout->mask as this
> mask may be different b/w PMC versions.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

> ---
>   drivers/clk/at91/clk-master.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
> index 2093e13b5068..6da9ae34313a 100644
> --- a/drivers/clk/at91/clk-master.c
> +++ b/drivers/clk/at91/clk-master.c
> @@ -186,8 +186,8 @@ static int clk_master_div_set_rate(struct clk_hw *hw, unsigned long rate,
>   	if (ret)
>   		goto unlock;
>   
> -	tmp = mckr & master->layout->mask;
> -	tmp = (tmp >> MASTER_DIV_SHIFT) & MASTER_DIV_MASK;
> +	mckr &= master->layout->mask;
> +	tmp = (mckr >> MASTER_DIV_SHIFT) & MASTER_DIV_MASK;
>   	if (tmp == div)
>   		goto unlock;
>   
> @@ -384,6 +384,7 @@ static unsigned long clk_master_pres_recalc_rate(struct clk_hw *hw,
>   	regmap_read(master->regmap, master->layout->offset, &val);
>   	spin_unlock_irqrestore(master->lock, flags);
>   
> +	val &= master->layout->mask;
>   	pres = (val >> master->layout->pres_shift) & MASTER_PRES_MASK;
>   	if (pres == 3 && characteristics->have_div3_pres)
>   		pres = 3;
> @@ -403,6 +404,8 @@ static u8 clk_master_pres_get_parent(struct clk_hw *hw)
>   	regmap_read(master->regmap, master->layout->offset, &mckr);
>   	spin_unlock_irqrestore(master->lock, flags);
>   
> +	mckr &= master->layout->mask;
> +
>   	return mckr & AT91_PMC_CSS;
>   }
>   
>
diff mbox series

Patch

diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
index 2093e13b5068..6da9ae34313a 100644
--- a/drivers/clk/at91/clk-master.c
+++ b/drivers/clk/at91/clk-master.c
@@ -186,8 +186,8 @@  static int clk_master_div_set_rate(struct clk_hw *hw, unsigned long rate,
 	if (ret)
 		goto unlock;
 
-	tmp = mckr & master->layout->mask;
-	tmp = (tmp >> MASTER_DIV_SHIFT) & MASTER_DIV_MASK;
+	mckr &= master->layout->mask;
+	tmp = (mckr >> MASTER_DIV_SHIFT) & MASTER_DIV_MASK;
 	if (tmp == div)
 		goto unlock;
 
@@ -384,6 +384,7 @@  static unsigned long clk_master_pres_recalc_rate(struct clk_hw *hw,
 	regmap_read(master->regmap, master->layout->offset, &val);
 	spin_unlock_irqrestore(master->lock, flags);
 
+	val &= master->layout->mask;
 	pres = (val >> master->layout->pres_shift) & MASTER_PRES_MASK;
 	if (pres == 3 && characteristics->have_div3_pres)
 		pres = 3;
@@ -403,6 +404,8 @@  static u8 clk_master_pres_get_parent(struct clk_hw *hw)
 	regmap_read(master->regmap, master->layout->offset, &mckr);
 	spin_unlock_irqrestore(master->lock, flags);
 
+	mckr &= master->layout->mask;
+
 	return mckr & AT91_PMC_CSS;
 }