linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: mediatek: get optional clock by devm_clk_get_optional()
@ 2019-03-30 10:00 Chunfeng Yun
  2019-03-31  0:45 ` Honghui Zhang
  2019-03-31 10:10 ` Ryder Lee
  0 siblings, 2 replies; 4+ messages in thread
From: Chunfeng Yun @ 2019-03-30 10:00 UTC (permalink / raw)
  To: Ryder Lee, Honghui Zhang, Lorenzo Pieralisi
  Cc: Bjorn Helgaas, Matthias Brugger, linux-pci, linux-mediatek,
	linux-kernel, linux-arm-kernel, Chunfeng Yun

Use devm_clk_get_optional() to get optional clock

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/pci/controller/pcie-mediatek.c | 46 ++++++--------------------
 1 file changed, 11 insertions(+), 35 deletions(-)

diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
index 0b6c72804e03..9a66a018489b 100644
--- a/drivers/pci/controller/pcie-mediatek.c
+++ b/drivers/pci/controller/pcie-mediatek.c
@@ -915,49 +915,25 @@ static int mtk_pcie_parse_port(struct mtk_pcie *pcie,
 
 	/* sys_ck might be divided into the following parts in some chips */
 	snprintf(name, sizeof(name), "ahb_ck%d", slot);
-	port->ahb_ck = devm_clk_get(dev, name);
-	if (IS_ERR(port->ahb_ck)) {
-		if (PTR_ERR(port->ahb_ck) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
-
-		port->ahb_ck = NULL;
-	}
+	port->ahb_ck = devm_clk_get_optional(dev, name);
+	if (IS_ERR(port->ahb_ck))
+		return PTR_ERR(port->ahb_ck);
 
 	snprintf(name, sizeof(name), "axi_ck%d", slot);
-	port->axi_ck = devm_clk_get(dev, name);
-	if (IS_ERR(port->axi_ck)) {
-		if (PTR_ERR(port->axi_ck) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
-
-		port->axi_ck = NULL;
-	}
+	port->axi_ck = devm_clk_get_optional(dev, name);
+		return PTR_ERR(port->axi_ck);
 
 	snprintf(name, sizeof(name), "aux_ck%d", slot);
-	port->aux_ck = devm_clk_get(dev, name);
-	if (IS_ERR(port->aux_ck)) {
-		if (PTR_ERR(port->aux_ck) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
-
-		port->aux_ck = NULL;
-	}
+	port->aux_ck = devm_clk_get_optional(dev, name);
+		return PTR_ERR(port->aux_ck);
 
 	snprintf(name, sizeof(name), "obff_ck%d", slot);
-	port->obff_ck = devm_clk_get(dev, name);
-	if (IS_ERR(port->obff_ck)) {
-		if (PTR_ERR(port->obff_ck) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
-
-		port->obff_ck = NULL;
-	}
+	port->obff_ck = devm_clk_get_optional(dev, name);
+		return PTR_ERR(port->obff_ck);
 
 	snprintf(name, sizeof(name), "pipe_ck%d", slot);
-	port->pipe_ck = devm_clk_get(dev, name);
-	if (IS_ERR(port->pipe_ck)) {
-		if (PTR_ERR(port->pipe_ck) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
-
-		port->pipe_ck = NULL;
-	}
+	port->pipe_ck = devm_clk_get_optional(dev, name);
+		return PTR_ERR(port->pipe_ck);
 
 	snprintf(name, sizeof(name), "pcie-rst%d", slot);
 	port->reset = devm_reset_control_get_optional_exclusive(dev, name);
-- 
2.20.1


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

* Re: [PATCH] PCI: mediatek: get optional clock by devm_clk_get_optional()
  2019-03-30 10:00 [PATCH] PCI: mediatek: get optional clock by devm_clk_get_optional() Chunfeng Yun
@ 2019-03-31  0:45 ` Honghui Zhang
  2019-03-31 10:10 ` Ryder Lee
  1 sibling, 0 replies; 4+ messages in thread
From: Honghui Zhang @ 2019-03-31  0:45 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Ryder Lee, Lorenzo Pieralisi, Bjorn Helgaas, Matthias Brugger,
	linux-pci, linux-mediatek, linux-kernel, linux-arm-kernel

On Sat, 2019-03-30 at 18:00 +0800, Chunfeng Yun wrote:
> Use devm_clk_get_optional() to get optional clock
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>  drivers/pci/controller/pcie-mediatek.c | 46 ++++++--------------------
>  1 file changed, 11 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
> index 0b6c72804e03..9a66a018489b 100644
> --- a/drivers/pci/controller/pcie-mediatek.c
> +++ b/drivers/pci/controller/pcie-mediatek.c
> @@ -915,49 +915,25 @@ static int mtk_pcie_parse_port(struct mtk_pcie *pcie,
>  
>  	/* sys_ck might be divided into the following parts in some chips */
>  	snprintf(name, sizeof(name), "ahb_ck%d", slot);
> -	port->ahb_ck = devm_clk_get(dev, name);
> -	if (IS_ERR(port->ahb_ck)) {
> -		if (PTR_ERR(port->ahb_ck) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -
> -		port->ahb_ck = NULL;
> -	}
> +	port->ahb_ck = devm_clk_get_optional(dev, name);
> +	if (IS_ERR(port->ahb_ck))
> +		return PTR_ERR(port->ahb_ck);
>  
>  	snprintf(name, sizeof(name), "axi_ck%d", slot);
> -	port->axi_ck = devm_clk_get(dev, name);
> -	if (IS_ERR(port->axi_ck)) {
> -		if (PTR_ERR(port->axi_ck) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -
> -		port->axi_ck = NULL;
> -	}
> +	port->axi_ck = devm_clk_get_optional(dev, name);
> +		return PTR_ERR(port->axi_ck);
>  
>  	snprintf(name, sizeof(name), "aux_ck%d", slot);
> -	port->aux_ck = devm_clk_get(dev, name);
> -	if (IS_ERR(port->aux_ck)) {
> -		if (PTR_ERR(port->aux_ck) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -
> -		port->aux_ck = NULL;
> -	}
> +	port->aux_ck = devm_clk_get_optional(dev, name);
> +		return PTR_ERR(port->aux_ck);
>  
>  	snprintf(name, sizeof(name), "obff_ck%d", slot);
> -	port->obff_ck = devm_clk_get(dev, name);
> -	if (IS_ERR(port->obff_ck)) {
> -		if (PTR_ERR(port->obff_ck) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -
> -		port->obff_ck = NULL;
> -	}
> +	port->obff_ck = devm_clk_get_optional(dev, name);
> +		return PTR_ERR(port->obff_ck);
>  
>  	snprintf(name, sizeof(name), "pipe_ck%d", slot);
> -	port->pipe_ck = devm_clk_get(dev, name);
> -	if (IS_ERR(port->pipe_ck)) {
> -		if (PTR_ERR(port->pipe_ck) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -
> -		port->pipe_ck = NULL;
> -	}
> +	port->pipe_ck = devm_clk_get_optional(dev, name);
> +		return PTR_ERR(port->pipe_ck);
>  

Hi, Chunfeng,

Thanks for this patch, I had not noticed that the devm_clk_get_optional
have been applied, I like this change.

Acked-by: Honghui Zhang <honghui.zhang@mediatek.com>

>  	snprintf(name, sizeof(name), "pcie-rst%d", slot);
>  	port->reset = devm_reset_control_get_optional_exclusive(dev, name);



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

* Re: [PATCH] PCI: mediatek: get optional clock by devm_clk_get_optional()
  2019-03-30 10:00 [PATCH] PCI: mediatek: get optional clock by devm_clk_get_optional() Chunfeng Yun
  2019-03-31  0:45 ` Honghui Zhang
@ 2019-03-31 10:10 ` Ryder Lee
  2019-03-31 12:40   ` Chunfeng Yun
  1 sibling, 1 reply; 4+ messages in thread
From: Ryder Lee @ 2019-03-31 10:10 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Honghui Zhang, Lorenzo Pieralisi, Bjorn Helgaas,
	Matthias Brugger, linux-pci, linux-mediatek, linux-kernel,
	linux-arm-kernel

On Sat, 2019-03-30 at 18:00 +0800, Chunfeng Yun wrote:
> Use devm_clk_get_optional() to get optional clock
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>  drivers/pci/controller/pcie-mediatek.c | 46 ++++++--------------------
>  1 file changed, 11 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
> index 0b6c72804e03..9a66a018489b 100644
> --- a/drivers/pci/controller/pcie-mediatek.c
> +++ b/drivers/pci/controller/pcie-mediatek.c
> @@ -915,49 +915,25 @@ static int mtk_pcie_parse_port(struct mtk_pcie *pcie,
>  
>  	/* sys_ck might be divided into the following parts in some chips */
>  	snprintf(name, sizeof(name), "ahb_ck%d", slot);
> -	port->ahb_ck = devm_clk_get(dev, name);
> -	if (IS_ERR(port->ahb_ck)) {
> -		if (PTR_ERR(port->ahb_ck) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -
> -		port->ahb_ck = NULL;
> -	}
> +	port->ahb_ck = devm_clk_get_optional(dev, name);
> +	if (IS_ERR(port->ahb_ck))
> +		return PTR_ERR(port->ahb_ck);
>  
>  	snprintf(name, sizeof(name), "axi_ck%d", slot);
> -	port->axi_ck = devm_clk_get(dev, name);
> -	if (IS_ERR(port->axi_ck)) {
> -		if (PTR_ERR(port->axi_ck) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -
> -		port->axi_ck = NULL;
> -	}
> +	port->axi_ck = devm_clk_get_optional(dev, name);
> +		return PTR_ERR(port->axi_ck);
>  
>  	snprintf(name, sizeof(name), "aux_ck%d", slot);
> -	port->aux_ck = devm_clk_get(dev, name);
> -	if (IS_ERR(port->aux_ck)) {
> -		if (PTR_ERR(port->aux_ck) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -
> -		port->aux_ck = NULL;
> -	}
> +	port->aux_ck = devm_clk_get_optional(dev, name);
> +		return PTR_ERR(port->aux_ck);
>  
>  	snprintf(name, sizeof(name), "obff_ck%d", slot);
> -	port->obff_ck = devm_clk_get(dev, name);
> -	if (IS_ERR(port->obff_ck)) {
> -		if (PTR_ERR(port->obff_ck) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -
> -		port->obff_ck = NULL;
> -	}
> +	port->obff_ck = devm_clk_get_optional(dev, name);
> +		return PTR_ERR(port->obff_ck);
>  
>  	snprintf(name, sizeof(name), "pipe_ck%d", slot);
> -	port->pipe_ck = devm_clk_get(dev, name);
> -	if (IS_ERR(port->pipe_ck)) {
> -		if (PTR_ERR(port->pipe_ck) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -
> -		port->pipe_ck = NULL;
> -	}
> +	port->pipe_ck = devm_clk_get_optional(dev, name);
> +		return PTR_ERR(port->pipe_ck);
>  
>  	snprintf(name, sizeof(name), "pcie-rst%d", slot);
>  	port->reset = devm_reset_control_get_optional_exclusive(dev, name);

if (IS_ERR(...)) ?


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

* Re: [PATCH] PCI: mediatek: get optional clock by devm_clk_get_optional()
  2019-03-31 10:10 ` Ryder Lee
@ 2019-03-31 12:40   ` Chunfeng Yun
  0 siblings, 0 replies; 4+ messages in thread
From: Chunfeng Yun @ 2019-03-31 12:40 UTC (permalink / raw)
  To: Ryder Lee
  Cc: Honghui Zhang, Lorenzo Pieralisi, Bjorn Helgaas,
	Matthias Brugger, linux-pci, linux-mediatek, linux-kernel,
	linux-arm-kernel

Hi Ryder,

On Sun, 2019-03-31 at 18:10 +0800, Ryder Lee wrote:
> On Sat, 2019-03-30 at 18:00 +0800, Chunfeng Yun wrote:
> > Use devm_clk_get_optional() to get optional clock
> > 
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> >  drivers/pci/controller/pcie-mediatek.c | 46 ++++++--------------------
> >  1 file changed, 11 insertions(+), 35 deletions(-)
> > 
> > diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
> > index 0b6c72804e03..9a66a018489b 100644
> > --- a/drivers/pci/controller/pcie-mediatek.c
> > +++ b/drivers/pci/controller/pcie-mediatek.c
> > @@ -915,49 +915,25 @@ static int mtk_pcie_parse_port(struct mtk_pcie *pcie,
> >  
> >  	/* sys_ck might be divided into the following parts in some chips */
> >  	snprintf(name, sizeof(name), "ahb_ck%d", slot);
> > -	port->ahb_ck = devm_clk_get(dev, name);
> > -	if (IS_ERR(port->ahb_ck)) {
> > -		if (PTR_ERR(port->ahb_ck) == -EPROBE_DEFER)
> > -			return -EPROBE_DEFER;
> > -
> > -		port->ahb_ck = NULL;
> > -	}
> > +	port->ahb_ck = devm_clk_get_optional(dev, name);
> > +	if (IS_ERR(port->ahb_ck))
> > +		return PTR_ERR(port->ahb_ck);
> >  
> >  	snprintf(name, sizeof(name), "axi_ck%d", slot);
> > -	port->axi_ck = devm_clk_get(dev, name);
> > -	if (IS_ERR(port->axi_ck)) {
> > -		if (PTR_ERR(port->axi_ck) == -EPROBE_DEFER)
> > -			return -EPROBE_DEFER;
> > -
> > -		port->axi_ck = NULL;
> > -	}
> > +	port->axi_ck = devm_clk_get_optional(dev, name);
> > +		return PTR_ERR(port->axi_ck);
> >  
> >  	snprintf(name, sizeof(name), "aux_ck%d", slot);
> > -	port->aux_ck = devm_clk_get(dev, name);
> > -	if (IS_ERR(port->aux_ck)) {
> > -		if (PTR_ERR(port->aux_ck) == -EPROBE_DEFER)
> > -			return -EPROBE_DEFER;
> > -
> > -		port->aux_ck = NULL;
> > -	}
> > +	port->aux_ck = devm_clk_get_optional(dev, name);
> > +		return PTR_ERR(port->aux_ck);
> >  
> >  	snprintf(name, sizeof(name), "obff_ck%d", slot);
> > -	port->obff_ck = devm_clk_get(dev, name);
> > -	if (IS_ERR(port->obff_ck)) {
> > -		if (PTR_ERR(port->obff_ck) == -EPROBE_DEFER)
> > -			return -EPROBE_DEFER;
> > -
> > -		port->obff_ck = NULL;
> > -	}
> > +	port->obff_ck = devm_clk_get_optional(dev, name);
> > +		return PTR_ERR(port->obff_ck);
> >  
> >  	snprintf(name, sizeof(name), "pipe_ck%d", slot);
> > -	port->pipe_ck = devm_clk_get(dev, name);
> > -	if (IS_ERR(port->pipe_ck)) {
> > -		if (PTR_ERR(port->pipe_ck) == -EPROBE_DEFER)
> > -			return -EPROBE_DEFER;
> > -
> > -		port->pipe_ck = NULL;
> > -	}
> > +	port->pipe_ck = devm_clk_get_optional(dev, name);
> > +		return PTR_ERR(port->pipe_ck);
> >  
> >  	snprintf(name, sizeof(name), "pcie-rst%d", slot);
> >  	port->reset = devm_reset_control_get_optional_exclusive(dev, name);
> 
> if (IS_ERR(...)) ?
Very sorry for my stupid mistake:(
will send new version

> 



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

end of thread, other threads:[~2019-03-31 12:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-30 10:00 [PATCH] PCI: mediatek: get optional clock by devm_clk_get_optional() Chunfeng Yun
2019-03-31  0:45 ` Honghui Zhang
2019-03-31 10:10 ` Ryder Lee
2019-03-31 12:40   ` Chunfeng Yun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).