Subject: Re: [PATCH net-next v6 2/3] net: phy: broadcom: Add PTP support for some Broadcom PHYs.

From: Jakub Kicinski <[email-masked]>
Date: Fri, 10 Jun 2022 18:02:55 -0700

On Wed,  8 Jun 2022 13:44:50 -0700 Jonathan Lemon wrote:
> +config BCM_NET_PHYPTP
> +	tristate "Broadcom PHY PTP support"
> +	depends on NETWORK_PHY_TIMESTAMPING
> +	depends on PHYLIB
> +	depends on PTP_1588_CLOCK
> +	depends on BROADCOM_PHY
> +	depends on NET_PTP_CLASSIFY
> +	help
> +	  Supports PTP timestamping for certain Broadcom PHYs.

This will not prevent:

CONFIG_BCM_NET_PHYLIB=y
CONFIG_BCM_NET_PHYPTP=m

which fails to link:

ld: vmlinux.o: in function `bcm54xx_phy_probe':
broadcom.c:(.text+0x155dd6a): undefined reference to `bcm_ptp_probe'
ld: vmlinux.o: in function `bcm54xx_suspend':
broadcom.c:(.text+0x155e203): undefined reference to `bcm_ptp_stop'
ld: vmlinux.o: in function `bcm54xx_config_init':
broadcom.c:(.text+0x155e8a6): undefined reference to `bcm_ptp_config_init'

Can we always build PTP support in when NETWORK_PHY_TIMESTAMPING is
selected? Without adding an extra Kconfig, do:
 
+ifeq ($(CONFIG_NETWORK_PHY_TIMESTAMPING),)
 obj-$(CONFIG_BCM_NET_PHYLIB)	+= bcm-phy-lib.o
+else
+obj-$(CONFIG_BCM_NET_PHYLIB)	+= bcm-phy-lib.o bcm-phy-ptp.o
+endif

or some form thereof ?