net: can: fix build dependency
Subsystems (2)
PATCH 1/1 net: can: fix build dependency
From: Arnd Bergmann <[email protected]>
A recent bugfix introduced a new problem with Kconfig dependencies:
WARNING: unmet direct dependencies detected for CAN_DEV
Depends on [n]: NETDEVICES [=n] && CAN [=m] Selected by [m]:
- CAN [=m] && NET [=y]
Since the CAN core code now links into the CAN device code, that particular function needs to be available, though the rest of it does not.
Revert the incomplete fix and instead use Makefile logic to avoid the link failure.
--- drivers/net/can/Kconfig | 4 ++-- drivers/net/can/Makefile | 2 +- drivers/net/can/dev/Makefile | 5 ++--- net/can/Kconfig | 1 - 4 files changed, 5 insertions(+), 7 deletions(-)
drivers/net/can/Kconfig +2 -2
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only menuconfig CAN_DEV - tristate "CAN Device Drivers" + bool "CAN Device Drivers" default y depends on CAN help
@@ -20,7 +20,7 @@ menuconfig CAN_DEV To compile as a module, choose M here: the module will be called can-dev. -if CAN_DEV +if CAN_DEV && CAN config CAN_VCAN tristate "Virtual Local CAN Interface (vcan)"
drivers/net/can/Makefile +1 -1
@@ -7,7 +7,7 @@ obj-$(CONFIG_CAN_VCAN) += vcan.o obj-$(CONFIG_CAN_VXCAN) += vxcan.o obj-$(CONFIG_CAN_SLCAN) += slcan/ -obj-y += dev/ +obj-$(CONFIG_CAN_DEV) += dev/ obj-y += esd/ obj-y += rcar/ obj-y += rockchip/
drivers/net/can/dev/Makefile +2 -3
@@ -1,9 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_CAN_DEV) += can-dev.o - -can-dev-y += skb.o +obj-$(CONFIG_CAN) += can-dev.o +can-dev-$(CONFIG_CAN_DEV) += skb.o can-dev-$(CONFIG_CAN_CALC_BITTIMING) += calc_bittiming.o can-dev-$(CONFIG_CAN_NETLINK) += bittiming.o can-dev-$(CONFIG_CAN_NETLINK) += dev.o
net/can/Kconfig +0 -1
@@ -5,7 +5,6 @@ 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
Signature · 1 line
2.39.5
Hello Arnd,
Quoted 13 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
A recent bugfix introduced a new problem with
Kconfigdependencies:WARNING: unmet direct dependencies detected for
CAN_DEV
Depends on [n]: NETDEVICES [=n] && CAN [=m] Selected by [m]:
- CAN [=m] && NET [=y]Since the CAN core code now links into the CAN device code, that particular function needs to be available, though the rest of it does not.
Quoted 5 lines
Revert the incomplete fix and instead use
Makefilelogic to avoid the link failure.Fixes cb2dc6d2869a ("can: Kconfig: select CAN driver infrastructure by default")Signed-off-by Arnd Bergmann <[email protected]>
I'm still not sure what this patch really does but it works excellent and fits exactly what is intended! ;-)
Many thanks,
Oliver
Quoted 70 lines
--- drivers/net/can/Kconfig | 4 ++-- drivers/net/can/Makefile | 2 +- drivers/net/can/dev/Makefile | 5 ++--- net/can/Kconfig | 1 - 4 files changed, 5 insertions(+), 7 deletions(-)drivers/net/can/Kconfig +2
-2@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only menuconfig CAN_DEV - tristate "CAN Device Drivers" + bool "CAN Device Drivers" default y depends on CAN help@@ -20,7 +20,7 @@ menuconfig CAN_DEV To compile as a module, choose M here: the module will be called can-dev. -if CAN_DEV +if CAN_DEV && CAN config CAN_VCAN tristate "Virtual Local CAN Interface (vcan)"drivers/net/can/Makefile +1
-1@@ -7,7 +7,7 @@ obj-$(CONFIG_CAN_VCAN) += vcan.o obj-$(CONFIG_CAN_VXCAN) += vxcan.o obj-$(CONFIG_CAN_SLCAN) += slcan/ -obj-y += dev/ +obj-$(CONFIG_CAN_DEV) += dev/ obj-y += esd/ obj-y += rcar/ obj-y += rockchip/drivers/net/can/dev/Makefile +2
-3@@ -1,9 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_CAN_DEV) += can-dev.o - -can-dev-y += skb.o +obj-$(CONFIG_CAN) += can-dev.o +can-dev-$(CONFIG_CAN_DEV) += skb.o can-dev-$(CONFIG_CAN_CALC_BITTIMING) += calc_bittiming.o can-dev-$(CONFIG_CAN_NETLINK) += bittiming.o can-dev-$(CONFIG_CAN_NETLINK) += dev.onet/can/Kconfig +0
-1@@ -5,7 +5,6 @@ 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
Vincent Mailhol
maintainerHi Arnd,
Thanks for the fix!
Quoted 39 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
A recent bugfix introduced a new problem with
Kconfigdependencies:WARNING: unmet direct dependencies detected for
CAN_DEV
Depends on [n]: NETDEVICES [=n] && CAN [=m] Selected by [m]:
- CAN [=m] && NET [=y]Since the CAN core code now links into the CAN device code, that particular function needs to be available, though the rest of it does not.
Revert the incomplete fix and instead use
Makefilelogic to avoid the link failure.Fixes cb2dc6d2869a ("can: Kconfig: select CAN driver infrastructure by default")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/can/Kconfig | 4 ++-- drivers/net/can/Makefile | 2 +- drivers/net/can/dev/Makefile | 5 ++--- net/can/Kconfig | 1 - 4 files changed, 5 insertions(+), 7 deletions(-)drivers/net/can/Kconfig +1
-1@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only menuconfig CAN_DEV - tristate "CAN Device Drivers" + bool "CAN Device Drivers" default y depends on CAN help
drivers/net/can/Kconfig menuconfig CAN_DEV · line 20
Quoted 1 line
drivers/net/can/Kconfig +0
-0@@ -20,7 +20,7 @@ menuconfig CAN_DEV To compile as a module, choose M here: the module will be called
^^^^^^^^
After this change, it is not possible to "choose M" for CAN_DEV anymore. I would suggest to modify (or remove) the above sentence.
drivers/net/can/Kconfig menuconfig CAN_DEV · line 22
Quoted 2 lines
drivers/net/can/Kconfig +1
-0can-dev.> -if CAN_DEV +if CAN_DEV && CAN
^^^^^^
Is this needed? CAN_DEV depends on CAN, so the condition
CAN_DEV && !CAN
should not be reachable.
Quoted 36 lines
drivers/net/can/Kconfig +0
-0config CAN_VCAN tristate "Virtual Local CAN Interface (vcan)"drivers/net/can/Makefile +1
-1@@ -7,7 +7,7 @@ obj-$(CONFIG_CAN_VCAN) += vcan.o obj-$(CONFIG_CAN_VXCAN) += vxcan.o obj-$(CONFIG_CAN_SLCAN) += slcan/ -obj-y += dev/ +obj-$(CONFIG_CAN_DEV) += dev/ obj-y += esd/ obj-y += rcar/ obj-y += rockchip/drivers/net/can/dev/Makefile +2
-3@@ -1,9 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_CAN_DEV) += can-dev.o - -can-dev-y += skb.o +obj-$(CONFIG_CAN) += can-dev.o +can-dev-$(CONFIG_CAN_DEV) += skb.o can-dev-$(CONFIG_CAN_CALC_BITTIMING) += calc_bittiming.o can-dev-$(CONFIG_CAN_NETLINK) += bittiming.o can-dev-$(CONFIG_CAN_NETLINK) += dev.onet/can/Kconfig +0
-0
net/can/Kconfig line 10
Quoted 7 lines
net/can/Kconfig +0
-1@@ -5,7 +5,6 @@ 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
Yours sincerely,
Vincent Mailhol
Marc Kleine-Budde
maintainerQuoted 16 lines · Vincent Mailhol
Quoted 14 lines
drivers/net/can/Kconfig +1
-1@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only menuconfig CAN_DEV - tristate "CAN Device Drivers" + bool "CAN Device Drivers" default y depends on CAN helpdrivers/net/can/Kconfig menuconfig CAN_DEV · line 20
Quoted 1 line
drivers/net/can/Kconfig +0
-0@@ -20,7 +20,7 @@ menuconfig CAN_DEV To compile as a module, choose M here: the module will be called^^^^^^^^
Quoted 2 lines
After this change, it is not possible to "choose M" for
CAN_DEVanymore. I would suggest to modify (or remove) the above sentence.
Removed the sentence why applying the patch.
Quoted 9 lines
drivers/net/can/Kconfig menuconfig CAN_DEV · line 22
Quoted 3 lines
drivers/net/can/Kconfig +1
-0can-dev.> -if CAN_DEV +if CAN_DEV && CAN^^^^^^Is this needed?
CAN_DEVdepends on CAN, so the conditionCAN_DEV && !CANshould not be reachable.
Removed the '&& CAN' while applying the patch.
Thanks,
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 |
Quoted 4 lines · Marc Kleine-Budde
Quoted 2 lines · Vincent Mailhol
Quoted 2 lines
(quoted diff) +1
-0can-dev.> -if CAN_DEV +if CAN_DEV && CAN
Quoted 8 lines
Quoted 6 lines
^^^^^^Is this needed?
CAN_DEVdepends on CAN, so the conditionCAN_DEV && !CANshould not be reachable.
Removed the '&& CAN' while applying the patch.
Sorry I forgot to reply here: the '&& CAN' is absolutely required here, otherwise you can configure CAN device drivers as built-in with CAN_DEV=y CAN=m, and that results in a link failure.
Arnd
Marc Kleine-Budde
maintainerQuoted 10 lines · Arnd Bergmann
Quoted 9 lines · Marc Kleine-Budde
Quoted 7 lines · Vincent Mailhol
Review
Quoted 2 lines
(quoted diff) +1
-0can-dev.> -if CAN_DEV +if CAN_DEV && CAN^^^^^^Is this needed?
CAN_DEVdepends on CAN, so the conditionCAN_DEV && !CAN
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
should not be reachable.
Removed the '&& CAN' while applying the patch.
Sorry I forgot to reply here: the '&& CAN' is absolutely required here, otherwise you can configure CAN device drivers as built-in with CAN_DEV=y CAN=m, and that results in a link failure.
You mean:
| $ grep ^CONFIG_CAN .config | CONFIG_CAN=m | CONFIG_CAN_RAW=m | CONFIG_CAN_BCM=m | CONFIG_CAN_GW=m | CONFIG_CAN_DEV=y | CONFIG_CAN_VXCAN=y | CONFIG_CAN_NETLINK=y | CONFIG_CAN_CALC_BITTIMING=y | CONFIG_CAN_RX_OFFLOAD=y | CONFIG_CAN_DUMMY=y | CONFIG_CAN_GS_USB=y
...which works for me.
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 |
Quoted 10 lines · Marc Kleine-Budde
Quoted 6 lines · Arnd Bergmann
On Wed, Dec 10, 2025, at 09:16, Marc Kleine-Budde wrote:
Sorry I forgot to reply here: the '&& CAN' is absolutely required here, otherwise you can configure CAN device drivers as built-in with CAN_DEV=y CAN=m, and that results in a link failure.
You mean:
Quoted 12 lines
| $ grep ^CONFIG_CAN .config | CONFIG_CAN=m | CONFIG_CAN_RAW=m | CONFIG_CAN_BCM=m | CONFIG_CAN_GW=m | CONFIG_CAN_DEV=y | CONFIG_CAN_VXCAN=y | CONFIG_CAN_NETLINK=y | CONFIG_CAN_CALC_BITTIMING=y | CONFIG_CAN_RX_OFFLOAD=y | CONFIG_CAN_DUMMY=y | CONFIG_CAN_GS_USB=y
Yes, I'm pretty sure I saw link failures with configurations like this one.
Quoted 1 line
...which works for me.
Looking at a random exported symbol from can_dev.ko, I see
obj-$(CONFIG_CAN) += can-dev.o drivers/net/can/dev/dev.c:EXPORT_SYMBOL(can_hwtstamp_get);drivers/net/can/usb/gs_usb.c: return can_hwtstamp_get(netdev, cfg);
so in the configuration you list above, can-dev.ko is a loadable module that exports can_hwtstamp_get, while gs_usb.o is built-in and unable to link to that symbol.
Arnd