diff mbox series

[2/5] dmaengine: axi-dmac: move clock enable earlier

Message ID 20200819071633.76494-2-alexandru.ardelean@analog.com (mailing list archive)
State Changes Requested
Headers show
Series [1/5] dmaengine: axi-dmac: move version read in probe | expand

Commit Message

Alexandru Ardelean Aug. 19, 2020, 7:16 a.m. UTC
The clock may also be required to read registers from the IP core (if it is
provided and the driver needs to control it).
So, move it earlier in the probe.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/dma/dma-axi-dmac.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Vinod Koul Aug. 25, 2020, 11:24 a.m. UTC | #1
On 19-08-20, 10:16, Alexandru Ardelean wrote:
> The clock may also be required to read registers from the IP core (if it is
> provided and the driver needs to control it).
> So, move it earlier in the probe.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> ---
>  drivers/dma/dma-axi-dmac.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
> index 088c79137398..07665c60c21b 100644
> --- a/drivers/dma/dma-axi-dmac.c
> +++ b/drivers/dma/dma-axi-dmac.c
> @@ -850,6 +850,10 @@ static int axi_dmac_probe(struct platform_device *pdev)
>  	if (IS_ERR(dmac->clk))
>  		return PTR_ERR(dmac->clk);
>  
> +	ret = clk_prepare_enable(dmac->clk);
> +	if (ret < 0)
> +		return ret;
> +
>  	INIT_LIST_HEAD(&dmac->chan.active_descs);

Change is fine, but then you need to jump to err_clk_disable in few
place below this and not return error

>  
>  	of_channels = of_get_child_by_name(pdev->dev.of_node, "adi,channels");
> @@ -892,10 +896,6 @@ static int axi_dmac_probe(struct platform_device *pdev)
>  	dmac->chan.vchan.desc_free = axi_dmac_desc_free;
>  	vchan_init(&dmac->chan.vchan, dma_dev);
>  
> -	ret = clk_prepare_enable(dmac->clk);
> -	if (ret < 0)
> -		return ret;
> -
>  	version = axi_dmac_read(dmac, ADI_AXI_REG_VERSION);
>  
>  	ret = axi_dmac_detect_caps(dmac, version);
> -- 
> 2.17.1
Alexandru Ardelean Aug. 25, 2020, 12:34 p.m. UTC | #2
On Tue, Aug 25, 2020 at 2:24 PM Vinod Koul <vkoul@kernel.org> wrote:
>
> On 19-08-20, 10:16, Alexandru Ardelean wrote:
> > The clock may also be required to read registers from the IP core (if it is
> > provided and the driver needs to control it).
> > So, move it earlier in the probe.
> >
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> > ---
> >  drivers/dma/dma-axi-dmac.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
> > index 088c79137398..07665c60c21b 100644
> > --- a/drivers/dma/dma-axi-dmac.c
> > +++ b/drivers/dma/dma-axi-dmac.c
> > @@ -850,6 +850,10 @@ static int axi_dmac_probe(struct platform_device *pdev)
> >       if (IS_ERR(dmac->clk))
> >               return PTR_ERR(dmac->clk);
> >
> > +     ret = clk_prepare_enable(dmac->clk);
> > +     if (ret < 0)
> > +             return ret;
> > +
> >       INIT_LIST_HEAD(&dmac->chan.active_descs);
>
> Change is fine, but then you need to jump to err_clk_disable in few
> place below this and not return error

oops;
thanks for catching this;
will send a v2

>
> >
> >       of_channels = of_get_child_by_name(pdev->dev.of_node, "adi,channels");
> > @@ -892,10 +896,6 @@ static int axi_dmac_probe(struct platform_device *pdev)
> >       dmac->chan.vchan.desc_free = axi_dmac_desc_free;
> >       vchan_init(&dmac->chan.vchan, dma_dev);
> >
> > -     ret = clk_prepare_enable(dmac->clk);
> > -     if (ret < 0)
> > -             return ret;
> > -
> >       version = axi_dmac_read(dmac, ADI_AXI_REG_VERSION);
> >
> >       ret = axi_dmac_detect_caps(dmac, version);
> > --
> > 2.17.1
>
> --
> ~Vinod
diff mbox series

Patch

diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
index 088c79137398..07665c60c21b 100644
--- a/drivers/dma/dma-axi-dmac.c
+++ b/drivers/dma/dma-axi-dmac.c
@@ -850,6 +850,10 @@  static int axi_dmac_probe(struct platform_device *pdev)
 	if (IS_ERR(dmac->clk))
 		return PTR_ERR(dmac->clk);
 
+	ret = clk_prepare_enable(dmac->clk);
+	if (ret < 0)
+		return ret;
+
 	INIT_LIST_HEAD(&dmac->chan.active_descs);
 
 	of_channels = of_get_child_by_name(pdev->dev.of_node, "adi,channels");
@@ -892,10 +896,6 @@  static int axi_dmac_probe(struct platform_device *pdev)
 	dmac->chan.vchan.desc_free = axi_dmac_desc_free;
 	vchan_init(&dmac->chan.vchan, dma_dev);
 
-	ret = clk_prepare_enable(dmac->clk);
-	if (ret < 0)
-		return ret;
-
 	version = axi_dmac_read(dmac, ADI_AXI_REG_VERSION);
 
 	ret = axi_dmac_detect_caps(dmac, version);