Skip to contentSkip to conversation

can: raw: fix build without CONFIG_CAN_DEV

PATCH New Oliver Hartkopp 1 participant 1 message Nov 27, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 can: raw: fix build without CONFIG_CAN_DEV

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")

---
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(+)
include/linux/can/dev.h +7 -0
index 13b25b0dceeb..9f9e54e41702 100644
@@ -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,
Signature · 1 line
2.47.3