[PATCH v2] can: m_can: initialize spin lock on device probe

From: Antonios Salios
Date: Thu Apr 24 2025 - 10:32:30 EST


The spin lock tx_handling_spinlock in struct m_can_classdev is not being
initialized. This leads to bug complaints from the kernel, eg. when
trying to send CAN frames with cansend from can-utils.

This patch fixes that by initializing the spin lock in the corresponding
device probe functions.

Fixes: 1fa80e23c150 ("can: m_can: Introduce a tx_fifo_in_flight counter")

Signed-off-by: Antonios Salios <antonios@xxxxxx>
---

Changes since v1:
* Move spin_lock_init from device probe functions to classdev alloc function
* Add a fixes tag
---
drivers/net/can/m_can/m_can.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 884a6352c..12e313998 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -2379,6 +2379,8 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev,
SET_NETDEV_DEV(net_dev, dev);

m_can_of_parse_mram(class_dev, mram_config_vals);
+
+ spin_lock_init(&class_dev->tx_handling_spinlock);
out:
return class_dev;
}
--
2.49.0