diff mbox series

[1/6] dma:at_hdmac:Use devm_clk_get_enabled() helpers

Message ID 20240823101933.9517-2-liaoyuanhong@vivo.com (mailing list archive)
State Changes Requested
Headers show
Series dma:Use devm_clk_get_enabled() helpers | expand

Commit Message

Liao Yuanhong Aug. 23, 2024, 10:19 a.m. UTC
Use devm_clk_get_enabled() instead of clk functions in at_hdmac.

Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
---
 drivers/dma/at_hdmac.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

Comments

Jonathan Cameron Aug. 23, 2024, 11:58 a.m. UTC | #1
On Fri, 23 Aug 2024 18:19:28 +0800
Liao Yuanhong <liaoyuanhong@vivo.com> wrote:

> Use devm_clk_get_enabled() instead of clk functions in at_hdmac.

Doesn't this stop the clock being turned of in suspend?

Or is there some magic handling that which I'm not aware of?


> 
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
> ---
>  drivers/dma/at_hdmac.c | 22 +++++-----------------
>  1 file changed, 5 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
> index 40052d1bd0b5..b1e10541cb12 100644
> --- a/drivers/dma/at_hdmac.c
> +++ b/drivers/dma/at_hdmac.c
> @@ -337,7 +337,6 @@ static inline u8 convert_buswidth(enum dma_slave_buswidth addr_width)
>   * struct at_dma - internal representation of an Atmel HDMA Controller
>   * @dma_device: dmaengine dma_device object members
>   * @regs: memory mapped register base
> - * @clk: dma controller clock
>   * @save_imr: interrupt mask register that is saved on suspend/resume cycle
>   * @all_chan_mask: all channels availlable in a mask
>   * @lli_pool: hw lli table
> @@ -347,7 +346,6 @@ static inline u8 convert_buswidth(enum dma_slave_buswidth addr_width)
>  struct at_dma {
>  	struct dma_device	dma_device;
>  	void __iomem		*regs;
> -	struct clk		*clk;
>  	u32			save_imr;
>  
>  	u8			all_chan_mask;
> @@ -1942,6 +1940,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
>  	int			err;
>  	int			i;
>  	const struct at_dma_platform_data *plat_dat;
> +	struct clk	*clk;
>  
>  	/* setup platform data for each SoC */
>  	dma_cap_set(DMA_MEMCPY, at91sam9rl_config.cap_mask);
> @@ -1975,20 +1974,16 @@ static int __init at_dma_probe(struct platform_device *pdev)
>  	atdma->dma_device.cap_mask = plat_dat->cap_mask;
>  	atdma->all_chan_mask = (1 << plat_dat->nr_channels) - 1;
>  
> -	atdma->clk = devm_clk_get(&pdev->dev, "dma_clk");
> -	if (IS_ERR(atdma->clk))
> -		return PTR_ERR(atdma->clk);
> -
> -	err = clk_prepare_enable(atdma->clk);
> -	if (err)
> -		return err;
> +	clk = devm_clk_get_enabled(&pdev->dev, "dma_clk");
> +	if (IS_ERR(clk))
> +		return PTR_ERR(clk);
>  
>  	/* force dma off, just in case */
>  	at_dma_off(atdma);
>  
>  	err = request_irq(irq, at_dma_interrupt, 0, "at_hdmac", atdma);
>  	if (err)
> -		goto err_irq;
> +		return err;
>  
>  	platform_set_drvdata(pdev, atdma);
>  
> @@ -2105,8 +2100,6 @@ static int __init at_dma_probe(struct platform_device *pdev)
>  	dma_pool_destroy(atdma->lli_pool);
>  err_desc_pool_create:
>  	free_irq(platform_get_irq(pdev, 0), atdma);
> -err_irq:
> -	clk_disable_unprepare(atdma->clk);
>  	return err;
>  }
>  
> @@ -2130,8 +2123,6 @@ static void at_dma_remove(struct platform_device *pdev)
>  		atc_disable_chan_irq(atdma, chan->chan_id);
>  		list_del(&chan->device_node);
>  	}
> -
> -	clk_disable_unprepare(atdma->clk);
>  }
>  
>  static void at_dma_shutdown(struct platform_device *pdev)
> @@ -2139,7 +2130,6 @@ static void at_dma_shutdown(struct platform_device *pdev)
>  	struct at_dma	*atdma = platform_get_drvdata(pdev);
>  
>  	at_dma_off(platform_get_drvdata(pdev));
> -	clk_disable_unprepare(atdma->clk);
>  }
>  
>  static int at_dma_prepare(struct device *dev)
> @@ -2194,7 +2184,6 @@ static int at_dma_suspend_noirq(struct device *dev)
>  
>  	/* disable DMA controller */
>  	at_dma_off(atdma);
> -	clk_disable_unprepare(atdma->clk);
>  	return 0;
>  }
>  
> @@ -2223,7 +2212,6 @@ static int at_dma_resume_noirq(struct device *dev)
>  	struct dma_chan *chan, *_chan;
>  
>  	/* bring back DMA controller */
> -	clk_prepare_enable(atdma->clk);
>  	dma_writel(atdma, EN, AT_DMA_ENABLE);
>  
>  	/* clear any pending interrupt */
Nicolas Ferre Aug. 23, 2024, 12:01 p.m. UTC | #2
On 23/08/2024 at 12:19, Liao Yuanhong wrote:
> Use devm_clk_get_enabled() instead of clk functions in at_hdmac.
> 
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>

With this patch, you remove the possibility to stop the clock during a 
suspend/resume cycle: why avoid to gain power during... low power phases?

NACK.

Regards,
   Nicolas

> ---
>   drivers/dma/at_hdmac.c | 22 +++++-----------------
>   1 file changed, 5 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
> index 40052d1bd0b5..b1e10541cb12 100644
> --- a/drivers/dma/at_hdmac.c
> +++ b/drivers/dma/at_hdmac.c
> @@ -337,7 +337,6 @@ static inline u8 convert_buswidth(enum dma_slave_buswidth addr_width)
>    * struct at_dma - internal representation of an Atmel HDMA Controller
>    * @dma_device: dmaengine dma_device object members
>    * @regs: memory mapped register base
> - * @clk: dma controller clock
>    * @save_imr: interrupt mask register that is saved on suspend/resume cycle
>    * @all_chan_mask: all channels availlable in a mask
>    * @lli_pool: hw lli table
> @@ -347,7 +346,6 @@ static inline u8 convert_buswidth(enum dma_slave_buswidth addr_width)
>   struct at_dma {
>          struct dma_device       dma_device;
>          void __iomem            *regs;
> -       struct clk              *clk;
>          u32                     save_imr;
> 
>          u8                      all_chan_mask;
> @@ -1942,6 +1940,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
>          int                     err;
>          int                     i;
>          const struct at_dma_platform_data *plat_dat;
> +       struct clk      *clk;
> 
>          /* setup platform data for each SoC */
>          dma_cap_set(DMA_MEMCPY, at91sam9rl_config.cap_mask);
> @@ -1975,20 +1974,16 @@ static int __init at_dma_probe(struct platform_device *pdev)
>          atdma->dma_device.cap_mask = plat_dat->cap_mask;
>          atdma->all_chan_mask = (1 << plat_dat->nr_channels) - 1;
> 
> -       atdma->clk = devm_clk_get(&pdev->dev, "dma_clk");
> -       if (IS_ERR(atdma->clk))
> -               return PTR_ERR(atdma->clk);
> -
> -       err = clk_prepare_enable(atdma->clk);
> -       if (err)
> -               return err;
> +       clk = devm_clk_get_enabled(&pdev->dev, "dma_clk");
> +       if (IS_ERR(clk))
> +               return PTR_ERR(clk);
> 
>          /* force dma off, just in case */
>          at_dma_off(atdma);
> 
>          err = request_irq(irq, at_dma_interrupt, 0, "at_hdmac", atdma);
>          if (err)
> -               goto err_irq;
> +               return err;
> 
>          platform_set_drvdata(pdev, atdma);
> 
> @@ -2105,8 +2100,6 @@ static int __init at_dma_probe(struct platform_device *pdev)
>          dma_pool_destroy(atdma->lli_pool);
>   err_desc_pool_create:
>          free_irq(platform_get_irq(pdev, 0), atdma);
> -err_irq:
> -       clk_disable_unprepare(atdma->clk);
>          return err;
>   }
> 
> @@ -2130,8 +2123,6 @@ static void at_dma_remove(struct platform_device *pdev)
>                  atc_disable_chan_irq(atdma, chan->chan_id);
>                  list_del(&chan->device_node);
>          }
> -
> -       clk_disable_unprepare(atdma->clk);
>   }
> 
>   static void at_dma_shutdown(struct platform_device *pdev)
> @@ -2139,7 +2130,6 @@ static void at_dma_shutdown(struct platform_device *pdev)
>          struct at_dma   *atdma = platform_get_drvdata(pdev);
> 
>          at_dma_off(platform_get_drvdata(pdev));
> -       clk_disable_unprepare(atdma->clk);
>   }
> 
>   static int at_dma_prepare(struct device *dev)
> @@ -2194,7 +2184,6 @@ static int at_dma_suspend_noirq(struct device *dev)
> 
>          /* disable DMA controller */
>          at_dma_off(atdma);
> -       clk_disable_unprepare(atdma->clk);
>          return 0;
>   }
> 
> @@ -2223,7 +2212,6 @@ static int at_dma_resume_noirq(struct device *dev)
>          struct dma_chan *chan, *_chan;
> 
>          /* bring back DMA controller */
> -       clk_prepare_enable(atdma->clk);
>          dma_writel(atdma, EN, AT_DMA_ENABLE);
> 
>          /* clear any pending interrupt */
> --
> 2.25.1
> 
>
diff mbox series

Patch

diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 40052d1bd0b5..b1e10541cb12 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -337,7 +337,6 @@  static inline u8 convert_buswidth(enum dma_slave_buswidth addr_width)
  * struct at_dma - internal representation of an Atmel HDMA Controller
  * @dma_device: dmaengine dma_device object members
  * @regs: memory mapped register base
- * @clk: dma controller clock
  * @save_imr: interrupt mask register that is saved on suspend/resume cycle
  * @all_chan_mask: all channels availlable in a mask
  * @lli_pool: hw lli table
@@ -347,7 +346,6 @@  static inline u8 convert_buswidth(enum dma_slave_buswidth addr_width)
 struct at_dma {
 	struct dma_device	dma_device;
 	void __iomem		*regs;
-	struct clk		*clk;
 	u32			save_imr;
 
 	u8			all_chan_mask;
@@ -1942,6 +1940,7 @@  static int __init at_dma_probe(struct platform_device *pdev)
 	int			err;
 	int			i;
 	const struct at_dma_platform_data *plat_dat;
+	struct clk	*clk;
 
 	/* setup platform data for each SoC */
 	dma_cap_set(DMA_MEMCPY, at91sam9rl_config.cap_mask);
@@ -1975,20 +1974,16 @@  static int __init at_dma_probe(struct platform_device *pdev)
 	atdma->dma_device.cap_mask = plat_dat->cap_mask;
 	atdma->all_chan_mask = (1 << plat_dat->nr_channels) - 1;
 
-	atdma->clk = devm_clk_get(&pdev->dev, "dma_clk");
-	if (IS_ERR(atdma->clk))
-		return PTR_ERR(atdma->clk);
-
-	err = clk_prepare_enable(atdma->clk);
-	if (err)
-		return err;
+	clk = devm_clk_get_enabled(&pdev->dev, "dma_clk");
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
 
 	/* force dma off, just in case */
 	at_dma_off(atdma);
 
 	err = request_irq(irq, at_dma_interrupt, 0, "at_hdmac", atdma);
 	if (err)
-		goto err_irq;
+		return err;
 
 	platform_set_drvdata(pdev, atdma);
 
@@ -2105,8 +2100,6 @@  static int __init at_dma_probe(struct platform_device *pdev)
 	dma_pool_destroy(atdma->lli_pool);
 err_desc_pool_create:
 	free_irq(platform_get_irq(pdev, 0), atdma);
-err_irq:
-	clk_disable_unprepare(atdma->clk);
 	return err;
 }
 
@@ -2130,8 +2123,6 @@  static void at_dma_remove(struct platform_device *pdev)
 		atc_disable_chan_irq(atdma, chan->chan_id);
 		list_del(&chan->device_node);
 	}
-
-	clk_disable_unprepare(atdma->clk);
 }
 
 static void at_dma_shutdown(struct platform_device *pdev)
@@ -2139,7 +2130,6 @@  static void at_dma_shutdown(struct platform_device *pdev)
 	struct at_dma	*atdma = platform_get_drvdata(pdev);
 
 	at_dma_off(platform_get_drvdata(pdev));
-	clk_disable_unprepare(atdma->clk);
 }
 
 static int at_dma_prepare(struct device *dev)
@@ -2194,7 +2184,6 @@  static int at_dma_suspend_noirq(struct device *dev)
 
 	/* disable DMA controller */
 	at_dma_off(atdma);
-	clk_disable_unprepare(atdma->clk);
 	return 0;
 }
 
@@ -2223,7 +2212,6 @@  static int at_dma_resume_noirq(struct device *dev)
 	struct dma_chan *chan, *_chan;
 
 	/* bring back DMA controller */
-	clk_prepare_enable(atdma->clk);
 	dma_writel(atdma, EN, AT_DMA_ENABLE);
 
 	/* clear any pending interrupt */