netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next v3] can: raw: fix build without CONFIG_CAN_DEV
@ 2025-11-27 23:08 Oliver Hartkopp
  0 siblings, 0 replies; only message in thread
From: Oliver Hartkopp @ 2025-11-27 23:08 UTC (permalink / raw)
  To: linux-can
  Cc: netdev, davem, kuba, kernel, mkl, Oliver Hartkopp,
	Vincent Mailhol

The feature to instantly reject unsupported CAN frames makes use of CAN
netdevice specific flags which are only accessible when the CAN device
driver infrastructure is built.

Therefore check for CONFIG_CAN_DEV and fall back to MTU testing when the
CAN device driver infrastructure is absent.

Fixes: 1a620a723853 ("can: raw: instantly reject unsupported CAN frames")
Reported-by: Vincent Mailhol <mailhol@kernel.org>
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
---
v2: use #if IS_ENABLED(CONFIG_CAN_DEV) instead of #ifdev CONFIG_CAN_DEV
v3: adopt Marc's suggestion to solve the problem in inclide/linux/can/dev.h
---
 include/linux/can/dev.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 13b25b0dceeb..9f9e54e41702 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -109,11 +109,18 @@ struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max,
 #define alloc_candev_mq(sizeof_priv, echo_skb_max, count) \
 	alloc_candev_mqs(sizeof_priv, echo_skb_max, count, count)
 void free_candev(struct net_device *dev);
 
 /* a candev safe wrapper around netdev_priv */
+#if IS_ENABLED(CONFIG_CAN_DEV)
 struct can_priv *safe_candev_priv(struct net_device *dev);
+#else
+static inline struct can_priv *safe_candev_priv(struct net_device *dev)
+{
+	return NULL;
+}
+#endif
 
 int open_candev(struct net_device *dev);
 void close_candev(struct net_device *dev);
 void can_set_default_mtu(struct net_device *dev);
 int __must_check can_set_static_ctrlmode(struct net_device *dev,
-- 
2.47.3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-11-27 23:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-27 23:08 [net-next v3] can: raw: fix build without CONFIG_CAN_DEV Oliver Hartkopp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).