Re: [PATCH] net/ethernet: update ret when ptp_clock is ERROR

From: Arnd Bergmann
Date: Fri Nov 06 2020 - 07:11:35 EST


On Fri, Nov 6, 2020 at 12:35 PM Grygorii Strashko
<grygorii.strashko@xxxxxx> 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.

Arnd