From patchwork Sat Nov 7 03:38:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qing Wang X-Patchwork-Id: 322187 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35EEEC388F7 for ; Sat, 7 Nov 2020 03:39:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E43C020882 for ; Sat, 7 Nov 2020 03:38:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728110AbgKGDi5 (ORCPT ); Fri, 6 Nov 2020 22:38:57 -0500 Received: from m176115.mail.qiye.163.com ([59.111.176.115]:48927 "EHLO m176115.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726880AbgKGDi5 (ORCPT ); Fri, 6 Nov 2020 22:38:57 -0500 Received: from vivo-HP-ProDesk-680-G4-PCI-MT.vivo.xyz (unknown [58.251.74.231]) by m176115.mail.qiye.163.com (Hmail) with ESMTPA id 1750D6665A0; Sat, 7 Nov 2020 11:38:54 +0800 (CST) From: Wang Qing To: "David S. Miller" , Jakub Kicinski , Grygorii Strashko , Kurt Kanzenbach , Samuel Zou , Murali Karicheri , Ivan Khoronzhuk , Wang Qing , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [V2] [PATCH] net/ethernet: update ret when ptp_clock is ERROR Date: Sat, 7 Nov 2020 11:38:38 +0800 Message-Id: <1604720323-3586-1-git-send-email-wangqing@vivo.com> X-Mailer: git-send-email 2.7.4 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZT0keSk0YTBhISkwYVkpNS09MSUtISE9OSEhVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS09ISVVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Kww6Fhw5FT8jDRwyT04*ME0a PAwaFD5VSlVKTUtPTElLSEhPQkhNVTMWGhIXVQwaFRwKEhUcOw0SDRRVGBQWRVlXWRILWUFZTkNV SU5KVUxPVUlISllXWQgBWUFJSEtJNwY+ X-HM-Tid: 0a75a0c916569373kuws1750d6665a0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We always have to update the value of ret, otherwise the error value may be the previous one. And ptp_clock_register() never return NULL when PTP_1588_CLOCK enable, so we use IS_ERR here. Signed-off-by: Wang Qing --- drivers/net/ethernet/ti/am65-cpts.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpts.c b/drivers/net/ethernet/ti/am65-cpts.c index 75056c1..ec8e56d --- a/drivers/net/ethernet/ti/am65-cpts.c +++ b/drivers/net/ethernet/ti/am65-cpts.c @@ -998,11 +998,10 @@ struct am65_cpts *am65_cpts_create(struct device *dev, void __iomem *regs, am65_cpts_settime(cpts, ktime_to_ns(ktime_get_real())); cpts->ptp_clock = ptp_clock_register(&cpts->ptp_info, cpts->dev); - if (IS_ERR_OR_NULL(cpts->ptp_clock)) { + if (IS_ERR(cpts->ptp_clock)) { dev_err(dev, "Failed to register ptp clk %ld\n", PTR_ERR(cpts->ptp_clock)); - if (!cpts->ptp_clock) - ret = -ENODEV; + ret = PTR_ERR(cpts->ptp_clock); goto refclk_disable; } cpts->phc_index = ptp_clock_index(cpts->ptp_clock);