When OS reboot, device is still in normal mode. Probing will fail with this error message: refusing to configure device when in normal mode (unnamed net_device) (uninitialized): failed to enable configuration mode Failed registering m_can device -EBUSY The log can be traced, it's from: m_can_dev_setup -> m_can_niso_supported -> m_can_config_enable -> m_can_cccr_update_bits In commit cd5a46ce6fa6 ("can: m_can: don't enable transceiver when probing"), m_can_niso_supported() was reworked to call m_can_config_enable(). However, in m_can_config_enable(), it's noted that CCCR_INIT must be set in order to set CCCR_CCE. The CCCR_INIT bit is set later in m_can_dev_setup(). To fix the problem, move forcing standby mode (set CCCR_INIT) lines before m_can_niso_supported() line in m_can_dev_setup(). Fixes: cd5a46ce6fa6 ("can: m_can: don't enable transceiver when probing") Signed-off-by: Renjaya Raga Zenta <ragazenta@xxxxxxxxx> --- Link: https://lore.kernel.org/linux-can/20241106123700.119074-1-renjaya.zenta@xxxxxxxxxxxxxxx --- drivers/net/can/m_can/m_can.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 533bcb77c9f934e5840b076ded948f8256ad2ad0..9345b181c5e31e1507a4dadc31e5f15545e1dc98 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1685,7 +1685,7 @@ static int m_can_niso_supported(struct m_can_classdev *cdev) static int m_can_dev_setup(struct m_can_classdev *cdev) { struct net_device *dev = cdev->net; - int m_can_version, err, niso; + int m_can_version, err, ret, niso; m_can_version = m_can_check_core_release(cdev); /* return if unsupported version */ @@ -1710,6 +1710,12 @@ static int m_can_dev_setup(struct m_can_classdev *cdev) CAN_CTRLMODE_FD | CAN_CTRLMODE_ONE_SHOT; + /* Forcing standby mode should be redundant, as the chip should be in + * standby after a reset. Write the INIT bit anyways, should the chip + * be configured by previous stage. + */ + ret = m_can_cccr_update_bits(cdev, CCCR_INIT, CCCR_INIT); + /* Set properties depending on M_CAN version */ switch (cdev->version) { case 30: @@ -1746,11 +1752,7 @@ static int m_can_dev_setup(struct m_can_classdev *cdev) return -EINVAL; } - /* Forcing standby mode should be redundant, as the chip should be in - * standby after a reset. Write the INIT bit anyways, should the chip - * be configured by previous stage. - */ - return m_can_cccr_update_bits(cdev, CCCR_INIT, CCCR_INIT); + return ret; } static void m_can_stop(struct net_device *dev) --- base-commit: c7d876495ffad298d7f5fa252000c80fd4fd1b74 change-id: 20241217-m_can_fix-af60055d7c96 Best regards, -- Renjaya Raga Zenta <ragazenta@xxxxxxxxx>