On Fri Nov 06 2020, Arnd Bergmann wrote: > On Fri, Nov 6, 2020 at 12:35 PM Grygorii Strashko > <grygorii.stras...@ti.com> wrote: >> On 06/11/2020 09:56, Wang Qing wrote: > >> > +++ b/drivers/net/ethernet/ti/am65-cpts.c >> > @@ -1001,8 +1001,7 @@ struct am65_cpts *am65_cpts_create(struct device >> > *dev, void __iomem *regs, >> >> there is >> cpts->ptp_clock = ptp_clock_register(&cpts->ptp_info, cpts->dev); >> >> >> > if (IS_ERR_OR_NULL(cpts->ptp_clock)) { >> >> And ptp_clock_register() can return NULL only if PTP support is disabled. >> In which case, we should not even get here. >> >> So, I'd propose to s/IS_ERR_OR_NULL/IS_ERR above, >> and just assign ret = PTR_ERR(cpts->ptp_clock) here. > > Right, using IS_ERR_OR_NULL() is almost ever a mistake, either > from misunderstanding the interface, or from a badly designed > interface that needs to be changed.
The NULL case should be handled differently and it is documented: /** * ptp_clock_register() - register a PTP hardware clock driver [...] * Returns a valid pointer on success or PTR_ERR on failure. If PHC * support is missing at the configuration level, this function * returns NULL, and drivers are expected to gracefully handle that * case separately. */ Thanks, Kurt
signature.asc
Description: PGP signature