diff mbox series

[1/5] can: xilinx_can: defer the probe if clock is not found

Message ID 1565594914-18999-2-git-send-email-appana.durga.rao@xilinx.com (mailing list archive)
State Mainlined
Commit 6b0d35891c835319291f2c3b459e666fc809f831
Headers show
Series can: xilinx_can: Bug fixes | expand

Commit Message

Appana Durga Kedareswara rao Aug. 12, 2019, 7:28 a.m. UTC
From: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@xilinx.com>

It's not always the case that clock is already available when can
driver get probed at the first time, e.g. the clock is provided by
clock wizard which may be probed after can driver. So let's defer
the probe when devm_clk_get() call fails and give it chance to
try later.

Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
 drivers/net/can/xilinx_can.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Marc Kleine-Budde Aug. 12, 2019, 9:03 a.m. UTC | #1
On 8/12/19 9:28 AM, Appana Durga Kedareswara rao wrote:
> From: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@xilinx.com>
> 
> It's not always the case that clock is already available when can
> driver get probed at the first time, e.g. the clock is provided by
> clock wizard which may be probed after can driver. So let's defer
> the probe when devm_clk_get() call fails and give it chance to
> try later.

Technically the patch changes the error message to not being printed in
case of EPROBE_DEFER. This patch doesn't change any behaviour apart from
that. Please adjust the patch description accordingly.

Marc

> 
> Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>  drivers/net/can/xilinx_can.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
> index bd95cfa..ac175ab 100644
> --- a/drivers/net/can/xilinx_can.c
> +++ b/drivers/net/can/xilinx_can.c
> @@ -1791,7 +1791,8 @@ static int xcan_probe(struct platform_device *pdev)
>  	/* Getting the CAN can_clk info */
>  	priv->can_clk = devm_clk_get(&pdev->dev, "can_clk");
>  	if (IS_ERR(priv->can_clk)) {
> -		dev_err(&pdev->dev, "Device clock not found.\n");
> +		if (PTR_ERR(priv->can_clk) != -EPROBE_DEFER)
> +			dev_err(&pdev->dev, "Device clock not found.\n");
>  		ret = PTR_ERR(priv->can_clk);
>  		goto err_free;
>  	}
>
Appana Durga Kedareswara Rao Aug. 12, 2019, 9:07 a.m. UTC | #2
Hi Marc,

Thanks for the review...

<Snip> 
> On 8/12/19 9:28 AM, Appana Durga Kedareswara rao wrote:
> > From: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@xilinx.com>
> >
> > It's not always the case that clock is already available when can
> > driver get probed at the first time, e.g. the clock is provided by
> > clock wizard which may be probed after can driver. So let's defer the
> > probe when devm_clk_get() call fails and give it chance to try later.
> 
> Technically the patch changes the error message to not being printed in case
> of EPROBE_DEFER. This patch doesn't change any behaviour apart from that.
> Please adjust the patch description accordingly.

Sure will fix in v2... 

Regards,
Kedar.

> 
> Marc
> 
> >
> > Signed-off-by: Venkatesh Yadav Abbarapu
> > <venkatesh.abbarapu@xilinx.com>
> > Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> > ---
> >  drivers/net/can/xilinx_can.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/can/xilinx_can.c
> > b/drivers/net/can/xilinx_can.c index bd95cfa..ac175ab 100644
> > --- a/drivers/net/can/xilinx_can.c
> > +++ b/drivers/net/can/xilinx_can.c
> > @@ -1791,7 +1791,8 @@ static int xcan_probe(struct platform_device
> *pdev)
> >  	/* Getting the CAN can_clk info */
> >  	priv->can_clk = devm_clk_get(&pdev->dev, "can_clk");
> >  	if (IS_ERR(priv->can_clk)) {
> > -		dev_err(&pdev->dev, "Device clock not found.\n");
> > +		if (PTR_ERR(priv->can_clk) != -EPROBE_DEFER)
> > +			dev_err(&pdev->dev, "Device clock not found.\n");
> >  		ret = PTR_ERR(priv->can_clk);
> >  		goto err_free;
> >  	}
> >
> 
> 
> --
> Pengutronix e.K.                  | Marc Kleine-Budde           |
> Industrial Linux Solutions        | Phone: +49-231-2826-924     |
> Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
> Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
diff mbox series

Patch

diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index bd95cfa..ac175ab 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -1791,7 +1791,8 @@  static int xcan_probe(struct platform_device *pdev)
 	/* Getting the CAN can_clk info */
 	priv->can_clk = devm_clk_get(&pdev->dev, "can_clk");
 	if (IS_ERR(priv->can_clk)) {
-		dev_err(&pdev->dev, "Device clock not found.\n");
+		if (PTR_ERR(priv->can_clk) != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "Device clock not found.\n");
 		ret = PTR_ERR(priv->can_clk);
 		goto err_free;
 	}