Re: [PATCH] can: mcp251x: add error handling for power enable in open and resume

Markus Elfring <[email protected]>
Newsgroups org.kernel.vger.kernel-janitors,org.kernel.vger.linux-can,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
> Add missing error handling for mcp251x_power_enable() calls in both
> mcp251x_open() and mcp251x_can_resume() functions.
…
> In mcp251x_can_resume(), if power enable fails during system resume,
> propagate the error to PM framework and log the error with dev_err()
> for debugging.
…

How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?


…
> @@ -1516,11 +1521,23 @@ static int __maybe_unused mcp251x_can_resume(struct device *dev)
>  {
>  	struct spi_device *spi = to_spi_device(dev);
>  	struct mcp251x_priv *priv = spi_get_drvdata(spi);
> +	int ret = 0;

How do you think about to use the return value at an other place
(at the end)?


>  
> -	if (priv->after_suspend & AFTER_SUSPEND_POWER)
> -		mcp251x_power_enable(priv->power, 1);
> -	if (priv->after_suspend & AFTER_SUSPEND_UP)
> -		mcp251x_power_enable(priv->transceiver, 1);
…
> +	if (priv->after_suspend & AFTER_SUSPEND_UP) {
> +		ret = mcp251x_power_enable(priv->power, 1);
> +		if (ret) {
> +			dev_err(dev, "Failed to restore power: %d\n", ret);
> +			goto out;
> +		}
> +	}
>  
>  	if (priv->after_suspend & (AFTER_SUSPEND_POWER | AFTER_SUSPEND_UP))
>  		queue_work(priv->wq, &priv->restart_work);
> @@ -1529,6 +1546,7 @@ static int __maybe_unused mcp251x_can_resume(struct device *dev)
>  
>  	priv->force_quit = 0;
>  	enable_irq(spi->irq);
> +out:
>  	return 0;
> }

Would you like to avoid duplicate source code here?

Regards,
Markus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.