Re: [PATCH v5 net-next 2/2] net: phy: micrel: Fix warn: passing zero to PTR_ERR

From: Andrew Lunn
Date: Tue Dec 06 2022 - 09:09:28 EST


> > > - if (!IS_ENABLED(CONFIG_PTP_1588_CLOCK) ||
> > > - !IS_ENABLED(CONFIG_NETWORK_PHY_TIMESTAMPING))
> > > - return 0;
> > > -
> >
> > Why are you removing this ?
> >
>
> I got review comment from Richard in v2 as below, making it as consistent by checking ptp_clock. So removed it in next revision.
>
> " > static int lan8814_ptp_probe_once(struct phy_device *phydev)
> > {
> > struct lan8814_shared_priv *shared = phydev->shared->priv;
> >
> > if (!IS_ENABLED(CONFIG_PTP_1588_CLOCK) ||
> > !IS_ENABLED(CONFIG_NETWORK_PHY_TIMESTAMPING))
> > return 0;
>
> It is weird to use macros here, but not before calling ptp_clock_register.
> Make it consistent by checking shared->ptp_clock instead.
> That is also better form."

O.K. If Richard said this fine.

Just out of interest, could you disassemble lan8814_ptp_probe_once()
when CONFIG_PTP_1588_CLOCK is disabled, with and without this check?

My guess is, when PTP is disabled, the mutex still gets initialised,
all the member of shared->ptp_clock_info are set. The optimise cannot
remove it. With the macro check, the function is empty. So you end up
with a slightly bigger text size.

Andrew