public inbox for linux-can@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] can: m_can: initialize spin lock on device probe
@ 2025-04-24 12:52 Antonios Salios
  2025-04-24 13:11 ` Marc Kleine-Budde
  2025-04-25  8:15 ` Markus Elfring
  0 siblings, 2 replies; 8+ messages in thread
From: Antonios Salios @ 2025-04-24 12:52 UTC (permalink / raw)
  To: rcsekar
  Cc: mkl, mailhol.vincent, linux-can, linux-kernel, lukas, jan,
	Antonios Salios

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.

Signed-off-by: Antonios Salios <antonios@mwa.re>
---
 drivers/net/can/m_can/m_can_pci.c      | 1 +
 drivers/net/can/m_can/m_can_platform.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/net/can/m_can/m_can_pci.c b/drivers/net/can/m_can/m_can_pci.c
index 9ad7419f8..06243cd43 100644
--- a/drivers/net/can/m_can/m_can_pci.c
+++ b/drivers/net/can/m_can/m_can_pci.c
@@ -143,6 +143,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
 	pm_runtime_use_autosuspend(dev);
 	pm_runtime_put_noidle(dev);
 	pm_runtime_allow(dev);
+	spin_lock_init(&mcan_class->tx_handling_spinlock);
 
 	return 0;
 
diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index b832566ef..c09c61d25 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -154,6 +154,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
 	ret = m_can_class_register(mcan_class);
 	if (ret)
 		goto out_runtime_disable;
+	spin_lock_init(&mcan_class->tx_handling_spinlock);
 
 	return ret;
 
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-04-25  9:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-24 12:52 [PATCH] can: m_can: initialize spin lock on device probe Antonios Salios
2025-04-24 13:11 ` Marc Kleine-Budde
2025-04-24 15:23   ` Vincent Mailhol
2025-04-25  6:34     ` Antonios Salios
2025-04-25  7:18       ` Vincent Mailhol
2025-04-25  9:18         ` Antonios Salios
2025-04-25  9:36           ` Vincent Mailhol
2025-04-25  8:15 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox