Re: [PATCH net-next] net: enetc: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()

From: Vladimir Oltean
Date: Fri May 09 2025 - 06:24:29 EST


On Fri, May 09, 2025 at 06:15:40AM +0300, Wei Fang wrote:
> > -static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)
> > +int enetc_hwtstamp_set(struct net_device *ndev,
> > + struct kernel_hwtstamp_config *config,
> > + struct netlink_ext_ack *extack)
> > +EXPORT_SYMBOL_GPL(enetc_hwtstamp_set);
> >
> > -static int enetc_hwtstamp_get(struct net_device *ndev, struct ifreq *ifr)
> > +int enetc_hwtstamp_get(struct net_device *ndev,
> > + struct kernel_hwtstamp_config *config)
> > +EXPORT_SYMBOL_GPL(enetc_hwtstamp_get);
>
> The definitions of enetc_hwtstamp_set() and enetc_hwtstamp_set()
> should also be wrapped with:
> #if IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
> #endif
>
> Otherwise, there will be some compilation errors when
> CONFIG_FSL_ENETC_PTP_CLOCK is not enabled.
>
> > +#if IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
> > +
> > +int enetc_hwtstamp_get(struct net_device *ndev,
> > + struct kernel_hwtstamp_config *config);
> > +int enetc_hwtstamp_set(struct net_device *ndev,
> > + struct kernel_hwtstamp_config *config,
> > + struct netlink_ext_ack *extack);
> > +
> > +#else
> > +
> > +#define enetc_hwtstamp_get(ndev, config) NULL
> > +#define enetc_hwtstamp_set(ndev, config, extack) NULL
>
> checkpatch.pl reports some warnings, for example:
> WARNING: Argument 'ndev' is not used in function-like macro
> #140: FILE: drivers/net/ethernet/freescale/enetc/enetc.h:531:
> +#define enetc_hwtstamp_get(ndev, config) NULL
>
> And there are also compilation errors when
> CONFIG_FSL_ENETC_PTP_CLOCK is not enabled. It should be
> modified as follows.
>
> #define enetc_hwtstamp_get NULL
> #define enetc_hwtstamp_set NULL
>

Ah, you're right... for some reason I forgot to test with
CONFIG_FSL_ENETC_PTP_CLOCK=n :-/

I'll send v2 as follows instead:

int enetc_hwtstamp_get(struct net_device *ndev,
struct kernel_hwtstamp_config *config)
{
struct enetc_ndev_priv *priv = netdev_priv(ndev);

if (!IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK))
return -EOPNOTSUPP;

...
}

Much simpler to handle.

I thought that enetc_hwtstamp_get() is in a translation module that only
gets built when CONFIG_FSL_ENETC_PTP_CLOCK is enabled, but obviously
that's not true.