Re: [PATCH v2] can: tcan4x5x: put tcan into sleep when removing driver

From: Marc Kleine-Budde

Date: Mon Aug 03 2026 - 07:36:26 EST


On 03.08.2026 12:19:26, Sean Nyekjaer wrote:
> Put the tcan4x5x transceiver into sleep mode when the driver is
> removed, instead of leaving it in its current operating mode.
> This reduces power consumption(3mA@12V) once the driver is
> no longer bound to the device.
>
> Signed-off-by: Sean Nyekjaer <sean@xxxxxxxxxx>

Seems you patch is not complete:

| drivers/net/can/m_can/tcan4x5x-core.c: In function ‘tcan4x5x_can_remove’:
| drivers/net/can/m_can/tcan4x5x-core.c:552:35: error: passing argument 1 of ‘tcan4x5x_power_enable’ from incompatible pointer type [-Wincompatible-pointer-types]
| 552 | tcan4x5x_power_enable(priv->power, 0);
| | ~~~~^~~~~~~
| | |
| | struct regulator *
| drivers/net/can/m_can/tcan4x5x-core.c:214:56: note: expected ‘struct tcan4x5x_priv *’ but argument is of type ‘struct regulator *’
| 214 | static int tcan4x5x_power_enable(struct tcan4x5x_priv *priv, int enable)
| | ~~~~~~~~~~~~~~~~~~~~~~^~~~

> ---
> Changes since v1:
> - Moved enter sleep mode into tcan4x5x_power_enable()
>
> drivers/net/can/m_can/tcan4x5x-core.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c
> index 31cc9d0abd45..67902b8b0fab 100644
> --- a/drivers/net/can/m_can/tcan4x5x-core.c
> +++ b/drivers/net/can/m_can/tcan4x5x-core.c
> @@ -211,15 +211,21 @@ static int tcan4x5x_write_fifo(struct m_can_classdev *cdev,
> return regmap_bulk_write(priv->regmap, TCAN4X5X_MRAM_START + addr_offset, val, val_count);
> }
>
> -static int tcan4x5x_power_enable(struct regulator *reg, int enable)
> +static int tcan4x5x_power_enable(struct tcan4x5x_priv *priv, int enable)
> {

If you add:

struct regulator *reg = priv->power;

the diff should be smaller.

> - if (IS_ERR_OR_NULL(reg))
> + if (IS_ERR_OR_NULL(priv->power)) {

Can you please add a comment that the reset GPIO is needed to get the
device out of sleep mode.

regards,
Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |

Attachment: signature.asc
Description: PGP signature