[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87pn4qmyl1.fsf@kurt>
Date: Fri, 06 Nov 2020 13:58:18 +0100
From: Kurt Kanzenbach <kurt@...utronix.de>
To: Arnd Bergmann <arnd@...nel.org>,
Grygorii Strashko <grygorii.strashko@...com>
Cc: Wang Qing <wangqing@...o.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Samuel Zou <zou_wei@...wei.com>,
Richard Cochran <richardcochran@...il.com>,
Networking <netdev@...r.kernel.org>,
"linux-kernel\@vger.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] net/ethernet: update ret when ptp_clock is ERROR
On Fri Nov 06 2020, Arnd Bergmann wrote:
> On Fri, Nov 6, 2020 at 12:35 PM Grygorii Strashko
> <grygorii.strashko@...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
Download attachment "signature.asc" of type "application/pgp-signature" (833 bytes)
Powered by blists - more mailing lists