[PATCH] can: rcar_canfd: Register the CAN device when fully ready

Lad Prabhakar posted 1 patch 4 years, 4 months ago
drivers/net/can/rcar/rcar_canfd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] can: rcar_canfd: Register the CAN device when fully ready
Posted by Lad Prabhakar 4 years, 4 months ago
Register the CAN device only when all the necessary initialization
is completed. This patch makes sure all the data structures and locks are
initialized before registering the CAN device.

Reported-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/net/can/rcar/rcar_canfd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index 3ad3a6f6a1dd..8c378b20b2aa 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1783,15 +1783,15 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
 
 	netif_napi_add(ndev, &priv->napi, rcar_canfd_rx_poll,
 		       RCANFD_NAPI_WEIGHT);
+	spin_lock_init(&priv->tx_lock);
+	devm_can_led_init(ndev);
+	gpriv->ch[priv->channel] = priv;
 	err = register_candev(ndev);
 	if (err) {
 		dev_err(&pdev->dev,
 			"register_candev() failed, error %d\n", err);
 		goto fail_candev;
 	}
-	spin_lock_init(&priv->tx_lock);
-	devm_can_led_init(ndev);
-	gpriv->ch[priv->channel] = priv;
 	dev_info(&pdev->dev, "device registered (channel %u)\n", priv->channel);
 	return 0;
 
-- 
2.17.1

Re: [PATCH] can: rcar_canfd: Register the CAN device when fully ready
Posted by Ulrich Hecht 4 years, 4 months ago
> On 02/21/2022 11:59 PM Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:
> 
>  
> Register the CAN device only when all the necessary initialization
> is completed. This patch makes sure all the data structures and locks are
> initialized before registering the CAN device.
> 
> Reported-by: Pavel Machek <pavel@denx.de>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>  drivers/net/can/rcar/rcar_canfd.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
> index 3ad3a6f6a1dd..8c378b20b2aa 100644
> --- a/drivers/net/can/rcar/rcar_canfd.c
> +++ b/drivers/net/can/rcar/rcar_canfd.c
> @@ -1783,15 +1783,15 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
>  
>  	netif_napi_add(ndev, &priv->napi, rcar_canfd_rx_poll,
>  		       RCANFD_NAPI_WEIGHT);
> +	spin_lock_init(&priv->tx_lock);
> +	devm_can_led_init(ndev);
> +	gpriv->ch[priv->channel] = priv;
>  	err = register_candev(ndev);
>  	if (err) {
>  		dev_err(&pdev->dev,
>  			"register_candev() failed, error %d\n", err);
>  		goto fail_candev;
>  	}
> -	spin_lock_init(&priv->tx_lock);
> -	devm_can_led_init(ndev);
> -	gpriv->ch[priv->channel] = priv;
>  	dev_info(&pdev->dev, "device registered (channel %u)\n", priv->channel);
>  	return 0;
>  
> -- 
> 2.17.1

Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>

CU
Uli
Re: [PATCH] can: rcar_canfd: Register the CAN device when fully ready
Posted by Marc Kleine-Budde 4 years, 3 months ago
On 21.02.2022 22:59:35, Lad Prabhakar wrote:
> Register the CAN device only when all the necessary initialization
> is completed. This patch makes sure all the data structures and locks are
> initialized before registering the CAN device.

Applied to can/testing.

Thanks,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
Re: [PATCH] can: rcar_canfd: Register the CAN device when fully ready
Posted by Pavel Machek 4 years, 4 months ago
On Mon 2022-02-21 22:59:35, Lad Prabhakar wrote:
> Register the CAN device only when all the necessary initialization
> is completed. This patch makes sure all the data structures and locks are
> initialized before registering the CAN device.

Reviewed-by: Pavel Machek <pavel@denx.de>

I guess it will go to mainline and then -stable so that we don't have
to do anything special?

Best regards,

								Pavel
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Re: [PATCH] can: rcar_canfd: Register the CAN device when fully ready
Posted by Marc Kleine-Budde 4 years, 4 months ago
On 22.02.2022 14:43:58, Pavel Machek wrote:
> On Mon 2022-02-21 22:59:35, Lad Prabhakar wrote:
> > Register the CAN device only when all the necessary initialization
> > is completed. This patch makes sure all the data structures and locks are
> > initialized before registering the CAN device.
> 
> Reviewed-by: Pavel Machek <pavel@denx.de>
> 
> I guess it will go to mainline and then -stable so that we don't have
> to do anything special?

ACK

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |