Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1242895pxb; Fri, 6 Nov 2020 05:00:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8ejr+08ESK154x0S243fwOIfE5QKh0pB7xvUg95ZoMD9tIozfLGm/vU2yl7pCetD3vCKg X-Received: by 2002:a05:6402:a57:: with SMTP id bt23mr1812252edb.62.1604667619363; Fri, 06 Nov 2020 05:00:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604667619; cv=none; d=google.com; s=arc-20160816; b=q3XopvDmrYIzCgAmR9dHD38VTgap6mkFNgyitlzf9FjaulG42dJWfu0LkWbCV5w8Lh 0+XUy0PfjVvDeXHOQcQCn1x1SIjqs+LFVbHs/PSoC5ykUMdcIUjVkgS7n5MPRvvZBk7f EJX4BYiq/yjGUizVa3dNyS0Qkq3Az2zJzZMKLtjqXjb2J3aEpW/uNDPsJ+bAGYQWqiUH qI+tvP6LIFE5se9Ftxi2sSgbmzsnxegXdNZBO4rAUJgJNQGS+3GrJ+pmBjxcF4bUIGQr ToUmFlK0WBqn5mAYN3XciZlO9u2xeJpoq/9Kmqp/HDGnCSYK8/XoJQPCE4b4HP8f0Ysk CjnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=shG7AJpj82cx0oUcROwbU9VWQmTdciDrS6ngB9yxIsI=; b=hihB3A+Bw3qdg2wg8lNo+V+5BWu1p5b7/rErsKHheW7D6pZtdPdFLBWC6dkYiFaCRj frFRt4AfWtDlj512jqaGGIkI2ZrT+mrLCvMCf2SvB9irwbn5TImLoKE7UDaGP5eWGc7q r1lOZ6CaBY++egUiDft8e8u65AFUl190ZeTpgVx31FvytfXXtbVg0YeWTa1CtPo/iVPx OzPE60YBCNtE4rOWeJwIR19eXX0AoIHzTz2KcVkniG7O7X1ItDKHbF++QFKdlZBpANJK UL+w8p9UAs1UTVX52ZXEwDVAIwlM1xjj/KHO4EGGCOwLYHGOhXllFTmL4qJr2TZlkE3n znxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XT8ck3td; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si851968ejb.290.2020.11.06.04.59.55; Fri, 06 Nov 2020 05:00:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XT8ck3td; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727362AbgKFM6c (ORCPT + 99 others); Fri, 6 Nov 2020 07:58:32 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:35266 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbgKFM6b (ORCPT ); Fri, 6 Nov 2020 07:58:31 -0500 From: Kurt Kanzenbach DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1604667508; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=shG7AJpj82cx0oUcROwbU9VWQmTdciDrS6ngB9yxIsI=; b=XT8ck3tdgI8gpazP3uo9gZ3YlqtdHmdo+MHdiKukS1mBakVCU1hSQkmwy7SWadArJSVIPI +IsVliIg1BTkXIUCBY6fsctAv2AHc91I+tScG0CwKi12MxqQmKxkrIYk+3iQPZPYZPtIQq NzKnQ/lHnW5iMU0qwC83y1qRwkoPz+0KxeTMKoA7CsiypTkueTL1YD16tkRYfrsdVrF1oR EGO520h3I1JW5GhC/A9Yw4Osig43uVqrpaX105PlgOPKHVciocqHxDV4ZZ40eZU5Oa0kLP hqy8BN6a41+/ApkdXLes2EXIwFXZGbZHEiZ/nd77wqskP6D2JhFfgQdFVeX/+A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1604667508; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=shG7AJpj82cx0oUcROwbU9VWQmTdciDrS6ngB9yxIsI=; b=l1jx89VfA8343zcD85kbWd3IMbrAPDVCx+SenZX7zqcDAWEdOEYgfwru8Pl46clgdLkGfE kIJK+0WdY0yfNRAQ== To: Arnd Bergmann , Grygorii Strashko Cc: Wang Qing , "David S. Miller" , Jakub Kicinski , Samuel Zou , Richard Cochran , Networking , "linux-kernel\@vger.kernel.org" Subject: Re: [PATCH] net/ethernet: update ret when ptp_clock is ERROR In-Reply-To: References: <1604649411-24886-1-git-send-email-wangqing@vivo.com> Date: Fri, 06 Nov 2020 13:58:18 +0100 Message-ID: <87pn4qmyl1.fsf@kurt> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain On Fri Nov 06 2020, Arnd Bergmann wrote: > On Fri, Nov 6, 2020 at 12:35 PM Grygorii Strashko > 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 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEooWgvezyxHPhdEojeSpbgcuY8KYFAl+lSGoACgkQeSpbgcuY 8KZp9BAAqQMVJ3ieO7c2694yqOwaG7+VL38Jv7x6L1Tjr1AFq1pnroPnS1oP+EPj ESSOG5Zrdtya/+E3k8a+hbHpbrljlvkLlCv6SSZwRQuxSzuoeY+EDtqCTnYLXJqT XtVwWWHRNWvFQivXSfbvfFAcP+TsL/1EMgehZgAcRD8LnmyCJgXeSaUY/NkHTIer kIu0KPsfkFYFsTWdHcgzGh1n7PRZx9SLZTetJH4xqUd2YDE7WzFcrvBVrYutCGg/ Bu+aLOodUK1z0JJTIzAIl/Ug9O//10d1uiVdLF209wgUuDcIzN3HT6LNzZNfcPCE IobDVvg09w+MayGx2wg1FROhsGLLmjbCtGc+wf+MySeTCXOlACvfVSsw7ULoKgCh bE0CnOTg+5c0iYYMtavM6PwabO3XJTUTFfxYTtJpQ9GNDipjJZMqxfqXCUO4HuNQ 33fSBfmI54VWRb88ATVAYyLzosJzpNgYR5lbiw8A/zbBtynHQoCh9jpQXink78Y/ 3xLxtDvWQQuSmRnPLrbcPc+T2Er3RVKNd9ZxeNGZbgu8OQmm75Zk01PNRL18tKwn KO3EtDSyHFVJEmIa338qY+6x4GTuCa0L152og7kX4u8gECbK1WBOTS0pPeDbRcrq cAVAy2/xPt5aG2/ygJpfHdNvMP740uix9g4lDxMNBpCNsEy/yr8= =Dvwr -----END PGP SIGNATURE----- --=-=-=--