All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] can: flexcan: Fix probing for m68k/coldfire
@ 2026-06-18 14:01 Uwe Kleine-König (The Capable Hub)
  2026-06-18 14:12 ` sashiko-bot
  2026-07-03 16:53 ` Uwe Kleine-König (The Capable Hub)
  0 siblings, 2 replies; 4+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-06-18 14:01 UTC (permalink / raw)
  To: Marc Kleine-Budde, Vincent Mailhol, Rob Herring
  Cc: Jean-Michel Hautbois, linux-can, linux-kernel, stable

When determining the device details was reworked in commit 5e6c3454b405
("net: can: Use device_get_match_data()") there was no replacement for
the previous handling of non-of instantiated devices via the device's
id_entry which then results in a NULL pointer exception. The only
in-tree provider of such a device is arch/m68k/coldfire/device.c.

Given the id_table only contains a single entry just hardcode the result
of `platform_get_device_id(pdev)->driver_data` and drop the unused
assignment to .driver_data from the table.

While touching the id table, drop the unusual comma after the terminator
entry.

Fixes: 5e6c3454b405 ("net: can: Use device_get_match_data()")
Cc: stable@vger.kernel.org
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
Hello,

this is essentially v2 of
https://lore.kernel.org/all/20260528094540.1867783-2-u.kleine-koenig@baylibre.com/,
but that patch was intended to be a cleanup, while the discussion then
revealed that there is a crash to be fixed.

Jean-Michel Hautbois confirmed (off-list) that Marc's and my suspicion
is true and probing the flexcan device provided by
arch/m68k/coldfire/device.c indeed crashes.

Best regards
Uwe

 drivers/net/can/flexcan/flexcan-core.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
index f5d22c61503f..05b8ca72ca2a 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -2077,10 +2077,9 @@ MODULE_DEVICE_TABLE(of, flexcan_of_match);
 static const struct platform_device_id flexcan_id_table[] = {
 	{
 		.name = "flexcan-mcf5441x",
-		.driver_data = (kernel_ulong_t)&fsl_mcf5441x_devtype_data,
 	}, {
 		/* sentinel */
-	},
+	}
 };
 MODULE_DEVICE_TABLE(platform, flexcan_id_table);
 
@@ -2148,6 +2147,15 @@ static int flexcan_probe(struct platform_device *pdev)
 		return PTR_ERR(regs);
 
 	devtype_data = device_get_match_data(&pdev->dev);
+	if (!devtype_data)
+		/*
+		 * If the device was instantiated via the traditional platform
+		 * mechanisms (i.e. not by device tree), device_get_match_data()
+		 * returns NULL. The only remaining such device is mcf_flexcan0
+		 * (defined in arch/m68k/coldfire/device.c). Pick the right
+		 * device type for that.
+		 */
+		devtype_data = &fsl_mcf5441x_devtype_data;
 
 	if ((devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD) &&
 	    !((devtype_data->quirks &

base-commit: e2cae00c05d196491c318196792297f2dfbaa02c
-- 
2.47.3


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

end of thread, other threads:[~2026-07-03 16:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-18 14:01 [PATCH net] can: flexcan: Fix probing for m68k/coldfire Uwe Kleine-König (The Capable Hub)
2026-06-18 14:12 ` sashiko-bot
2026-06-19 17:35   ` Uwe Kleine-König
2026-07-03 16:53 ` Uwe Kleine-König (The Capable Hub)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.