can: Kconfig: select CAN driver infrastructure by default
Subsystems (4)
Oliver Hartkopp
maintainerPATCH v3 1/1 can: Kconfig: select CAN driver infrastructure by default
The CAN bus support enabled with CONFIG_CAN provides a socket-based access to CAN interfaces. With the introduction of the latest CAN protocol CAN XL additional configuration status information needs to be exposed to the network layer than formerly provided by standard Linux network drivers.
This requires the CAN driver infrastructure to be selected by default. As the CAN network layer can only operate on CAN interfaces anyway all distributions and common default configs enable at least one CAN driver.
So selecting CONFIG_CAN_DEV when CONFIG_CAN is selected by the user has no effect on established configurations but solves potential build issues when CONFIG_CAN[_XXX]=y is set together with CANFIG_CAN_DEV=m
---
v2: In fact CONFIG_CAN_NETLINK was missing too. Reported by kernel test robot.
v3: With the change in dev.h the compilation of the of the netlink code can be
avoided when only virtual CAN interfaces (vcan, vxcan) are required.
---
include/linux/can/dev.h | 7 +++++++ net/can/Kconfig | 1 + 2 files changed, 8 insertions(+)
include/linux/can/dev.h +7 -0
@@ -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_NETLINK )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,
net/can/Kconfig +1 -0
@@ -3,10 +3,11 @@ # Controller Area Network (CAN) network layer core configuration # menuconfig CAN tristate "CAN bus subsystem support" + select CAN_DEV help Controller Area Network (CAN) is a slow (up to 1Mbit/s) serial communications protocol. Development of the CAN bus started in 1983 at Robert Bosch GmbH, and the protocol was officially released in 1986. The CAN bus was originally mainly for automotive,
Signature · 1 line
2.47.3
Vincent Mailhol
maintainerHi Oliver,
Quoted 39 lines · Oliver Hartkopp
The CAN bus support enabled with
CONFIG_CANprovides a socket-based access to CAN interfaces. With the introduction of the latest CAN protocol CAN XL additional configuration status information needs to be exposed to the network layer than formerly provided by standard Linux network drivers.This requires the CAN driver infrastructure to be selected by default. As the CAN network layer can only operate on CAN interfaces anyway all distributions and common default configs enable at least one CAN driver.
So selecting
CONFIG_CAN_DEVwhenCONFIG_CANis selected by the user has no effect on established configurations but solves potential build issues when CONFIG_CAN[_XXX]=y is set together with CANFIG_CAN_DEV=mFixes 1a620a723853 ("can: raw: instantly reject unsupported CAN frames")Reported-by Vincent Mailhol <[email protected]>Reported-by kernel test robot <[email protected]>Suggested-by Marc Kleine-Budde <[email protected]>Signed-off-by Oliver Hartkopp <[email protected]>---
v2: In fact
CONFIG_CAN_NETLINKwas missing too. Reported by kernel test robot.
v3: With the change indev.hthe compilation of the of the netlink code can be
avoided when only virtual CAN interfaces (vcan, vxcan) are required.---
include/linux/can/dev.h | 7 +++++++ net/can/Kconfig | 1 + 2 files changed, 8 insertions(+)include/linux/can/dev.h +0
-0@@ -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);
include/linux/can/dev.h struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max, · line 121
Quoted 10 lines
include/linux/can/dev.h +7
-0/* a candev safe wrapper around netdev_priv */ +#if IS_ENABLED (CONFIG_CAN_NETLINK )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
As far as I can see, safe_candev_priv() is only used in raw.c. I think it would be cleaner to just move it there and turn it into a static function.
Quoted 10 lines
include/linux/can/dev.h +0
-0int 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,net/can/Kconfig +0
-0@@ -3,10 +3,11 @@ # Controller Area Network (CAN) network layer core configuration
net/can/Kconfig line 13
Quoted 10 lines
net/can/Kconfig +1
-0# menuconfig CAN tristate "CAN bus subsystem support" + select CAN_DEV help Controller Area Network (CAN) is a slow (up to 1Mbit/s) serial communications protocol. Development of the CAN bus started in 1983 at Robert Bosch GmbH, and the protocol was officially released in 1986. The CAN bus was originally mainly for automotive,
Yours sincerely,
Vincent Mailhol
Oliver Hartkopp
maintainerHi Vincent,
Quoted 9 lines · Vincent Mailhol
Quoted 9 lines
include/linux/can/dev.h +0
-0@@ -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);
Quoted 13 lines
include/linux/can/dev.h struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max, · line 121
Quoted 9 lines
include/linux/can/dev.h +7
-0/* a candev safe wrapper around netdev_priv */ +#if IS_ENABLED (CONFIG_CAN_NETLINK )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 As far as I can see,
safe_candev_priv()is only used inraw.c. I think it would be cleaner to just move it there and turn it into a static function.
safe_candev_priv() has been introduced 13 years ago:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bf03a5379cd3492fbeca4
And obviously the user (inside some notifier code) has been vanished due to some code updates.
In the end there's a new user now. IMO the location in dev.h is pretty good as it belongs to CAN devices and netlink. And maybe some new user will show up in the future.
Best regards,
Oliver
Marc Kleine-Budde
maintainerQuoted 13 lines · Oliver Hartkopp
The CAN bus support enabled with
CONFIG_CANprovides a socket-based access to CAN interfaces. With the introduction of the latest CAN protocol CAN XL additional configuration status information needs to be exposed to the network layer than formerly provided by standard Linux network drivers.This requires the CAN driver infrastructure to be selected by default. As the CAN network layer can only operate on CAN interfaces anyway all distributions and common default configs enable at least one CAN driver.
So selecting
CONFIG_CAN_DEVwhenCONFIG_CANis selected by the user has no effect on established configurations but solves potential build issues when CONFIG_CAN[_XXX]=y is set together with CANFIG_CAN_DEV=m
Quoted 6 lines
Fixes 1a620a723853 ("can: raw: instantly reject unsupported CAN frames")Reported-by Vincent Mailhol <[email protected]>Reported-by kernel test robot <[email protected]>Suggested-by Marc Kleine-Budde <[email protected]>Signed-off-by Oliver Hartkopp <[email protected]>
Added to linux-can-next and included in my latest PR.
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Oliver Hartkopp
maintainerQuoted 10 lines · Marc Kleine-Budde
Quoted 6 lines · Oliver Hartkopp
Fixes 1a620a723853 ("can: raw: instantly reject unsupported CAN frames")Reported-by Vincent Mailhol <[email protected]>Reported-by kernel test robot <[email protected]>Suggested-by Marc Kleine-Budde <[email protected]>Signed-off-by Oliver Hartkopp <[email protected]>Added to linux-can-next and included in my latest PR.
Thanks Marc!
BR Oliver