mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v3 1/1] serial: ns16550: move iomem/ioport init after clock init
@ 2023-02-17 14:20 Maxim Kochetkov
  2023-02-17 14:23 ` Ahmad Fatoum
  2023-02-21 10:28 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Maxim Kochetkov @ 2023-02-17 14:20 UTC (permalink / raw)
  To: barebox; +Cc: pmamonov, a.kuyan, p.mamonov, Maxim Kochetkov, Maxim Kochetkov

While probing ns16550 clock provider may be unavailable and
clk_get() returns -EPROBE_DEFER. Next ns16550_probe() attempts
will be failed too because of dev_request_mem_resource() has already
acquired this resource for the device and returns -EBUSY.
So move resource allocation just after clock init. It will let proper
probe for defered clocks on boards with deep probe disabled.

Signed-off-by: Maxim Kochetkov <m.kochetkov@yadro.com>
Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
---
 drivers/serial/serial_ns16550.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 16f3576645..9ce4feed43 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -479,13 +479,6 @@ static int ns16550_probe(struct device *dev)
 
 	priv = xzalloc(sizeof(*priv));
 
-	ret = ns16550_init_iomem(dev, priv);
-	if (ret)
-		ret = ns16550_init_ioport(dev, priv);
-
-	if (ret)
-		return ret;
-
 	if (plat)
 		priv->plat = *plat;
 	else
@@ -511,6 +504,13 @@ static int ns16550_probe(struct device *dev)
 		goto err;
 	}
 
+	ret = ns16550_init_iomem(dev, priv);
+	if (ret)
+		ret = ns16550_init_ioport(dev, priv);
+
+	if (ret)
+		goto err;
+
 	cdev = &priv->cdev;
 	cdev->dev = dev;
 	cdev->tstc = ns16550_tstc;
-- 
2.38.1




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

* Re: [PATCH v3 1/1] serial: ns16550: move iomem/ioport init after clock init
  2023-02-17 14:20 [PATCH v3 1/1] serial: ns16550: move iomem/ioport init after clock init Maxim Kochetkov
@ 2023-02-17 14:23 ` Ahmad Fatoum
  2023-02-21 10:28 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-02-17 14:23 UTC (permalink / raw)
  To: Maxim Kochetkov, barebox; +Cc: pmamonov, a.kuyan, p.mamonov, Maxim Kochetkov

On 17.02.23 15:20, Maxim Kochetkov wrote:
> While probing ns16550 clock provider may be unavailable and
> clk_get() returns -EPROBE_DEFER. Next ns16550_probe() attempts
> will be failed too because of dev_request_mem_resource() has already
> acquired this resource for the device and returns -EBUSY.
> So move resource allocation just after clock init. It will let proper
> probe for defered clocks on boards with deep probe disabled.
> 
> Signed-off-by: Maxim Kochetkov <m.kochetkov@yadro.com>
> Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Thanks!
Ahmad

> ---
>  drivers/serial/serial_ns16550.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
> index 16f3576645..9ce4feed43 100644
> --- a/drivers/serial/serial_ns16550.c
> +++ b/drivers/serial/serial_ns16550.c
> @@ -479,13 +479,6 @@ static int ns16550_probe(struct device *dev)
>  
>  	priv = xzalloc(sizeof(*priv));
>  
> -	ret = ns16550_init_iomem(dev, priv);
> -	if (ret)
> -		ret = ns16550_init_ioport(dev, priv);
> -
> -	if (ret)
> -		return ret;
> -
>  	if (plat)
>  		priv->plat = *plat;
>  	else
> @@ -511,6 +504,13 @@ static int ns16550_probe(struct device *dev)
>  		goto err;
>  	}
>  
> +	ret = ns16550_init_iomem(dev, priv);
> +	if (ret)
> +		ret = ns16550_init_ioport(dev, priv);
> +
> +	if (ret)
> +		goto err;
> +
>  	cdev = &priv->cdev;
>  	cdev->dev = dev;
>  	cdev->tstc = ns16550_tstc;

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

* Re: [PATCH v3 1/1] serial: ns16550: move iomem/ioport init after clock init
  2023-02-17 14:20 [PATCH v3 1/1] serial: ns16550: move iomem/ioport init after clock init Maxim Kochetkov
  2023-02-17 14:23 ` Ahmad Fatoum
@ 2023-02-21 10:28 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2023-02-21 10:28 UTC (permalink / raw)
  To: Maxim Kochetkov; +Cc: barebox, pmamonov, a.kuyan, p.mamonov, Maxim Kochetkov

On Fri, Feb 17, 2023 at 05:20:06PM +0300, Maxim Kochetkov wrote:
> While probing ns16550 clock provider may be unavailable and
> clk_get() returns -EPROBE_DEFER. Next ns16550_probe() attempts
> will be failed too because of dev_request_mem_resource() has already
> acquired this resource for the device and returns -EBUSY.
> So move resource allocation just after clock init. It will let proper
> probe for defered clocks on boards with deep probe disabled.
> 
> Signed-off-by: Maxim Kochetkov <m.kochetkov@yadro.com>
> Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
> ---
>  drivers/serial/serial_ns16550.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
> index 16f3576645..9ce4feed43 100644
> --- a/drivers/serial/serial_ns16550.c
> +++ b/drivers/serial/serial_ns16550.c
> @@ -479,13 +479,6 @@ static int ns16550_probe(struct device *dev)
>  
>  	priv = xzalloc(sizeof(*priv));
>  
> -	ret = ns16550_init_iomem(dev, priv);
> -	if (ret)
> -		ret = ns16550_init_ioport(dev, priv);
> -
> -	if (ret)
> -		return ret;
> -
>  	if (plat)
>  		priv->plat = *plat;
>  	else
> @@ -511,6 +504,13 @@ static int ns16550_probe(struct device *dev)
>  		goto err;
>  	}
>  
> +	ret = ns16550_init_iomem(dev, priv);
> +	if (ret)
> +		ret = ns16550_init_ioport(dev, priv);
> +
> +	if (ret)
> +		goto err;
> +
>  	cdev = &priv->cdev;
>  	cdev->dev = dev;
>  	cdev->tstc = ns16550_tstc;
> -- 
> 2.38.1
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2023-02-21 10:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-17 14:20 [PATCH v3 1/1] serial: ns16550: move iomem/ioport init after clock init Maxim Kochetkov
2023-02-17 14:23 ` Ahmad Fatoum
2023-02-21 10:28 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox