Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: microchip: ptp: fix up PTP dependency

When NET_DSA_MICROCHIP_KSZ_COMMON is built-in but PTP is a loadable
module, the ksz_ptp support still causes a link failure:

ld.lld-16: error: undefined symbol: ptp_clock_index
>>> referenced by ksz_ptp.c
>>> drivers/net/dsa/microchip/ksz_ptp.o:(ksz_get_ts_info) in archive vmlinux.a

This can happen if NET_DSA_MICROCHIP_KSZ8863_SMI is enabled, or
even if none of the KSZ9477_I2C/KSZ_SPI/KSZ8863_SMI ones are active
but only the common module is.

The most straightforward way to address this is to move the
dependency to NET_DSA_MICROCHIP_KSZ_PTP itself, which can now
only be enabled if both PTP_1588_CLOCK support is reachable
from NET_DSA_MICROCHIP_KSZ_COMMON. Alternatively, one could make
NET_DSA_MICROCHIP_KSZ_COMMON a hidden Kconfig symbol and extend the
PTP_1588_CLOCK_OPTIONAL dependency to NET_DSA_MICROCHIP_KSZ8863_SMI as
well, but that is a little more fragile.

Fixes: eac1ea20261e ("net: dsa: microchip: ptp: add the posix clock support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20230130131808.1084796-1-arnd@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Arnd Bergmann and committed by
Paolo Abeni
562c6548 a266ef69

+1 -2
+1 -2
drivers/net/dsa/microchip/Kconfig
··· 11 11 config NET_DSA_MICROCHIP_KSZ9477_I2C 12 12 tristate "KSZ series I2C connected switch driver" 13 13 depends on NET_DSA_MICROCHIP_KSZ_COMMON && I2C 14 - depends on PTP_1588_CLOCK_OPTIONAL 15 14 select REGMAP_I2C 16 15 help 17 16 Select to enable support for registering switches configured through I2C. ··· 18 19 config NET_DSA_MICROCHIP_KSZ_SPI 19 20 tristate "KSZ series SPI connected switch driver" 20 21 depends on NET_DSA_MICROCHIP_KSZ_COMMON && SPI 21 - depends on PTP_1588_CLOCK_OPTIONAL 22 22 select REGMAP_SPI 23 23 help 24 24 Select to enable support for registering switches configured through SPI. ··· 25 27 config NET_DSA_MICROCHIP_KSZ_PTP 26 28 bool "Support for the PTP clock on the KSZ9563/LAN937x Ethernet Switch" 27 29 depends on NET_DSA_MICROCHIP_KSZ_COMMON && PTP_1588_CLOCK 30 + depends on NET_DSA_MICROCHIP_KSZ_COMMON=m || PTP_1588_CLOCK=y 28 31 help 29 32 Select to enable support for timestamping & PTP clock manipulation in 30 33 KSZ8563/KSZ9563/LAN937x series of switches. KSZ9563/KSZ8563 supports