From patchwork Thu Dec 8 19:30:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Ray X-Patchwork-Id: 31474 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp384083wrr; Thu, 8 Dec 2022 11:34:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf5a/o9sTp3c6UMu9r76xDZyYLrgFp5f4POvFAjv/7l4Kre7ncUqQWgelvV3pK4QASTCU7QB X-Received: by 2002:a17:902:7c82:b0:189:760d:c5f2 with SMTP id y2-20020a1709027c8200b00189760dc5f2mr59484053pll.90.1670528084843; Thu, 08 Dec 2022 11:34:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670528084; cv=none; d=google.com; s=arc-20160816; b=rD50rkRtjibeB3bRf7XbggLuc+dYF30W84R8OLvzcuJ2wn3him5PePxrnqg8JCXvK8 A+m4YcIeJS8uizFDt/gUBpdJ1bHuqt/KKb93cDnBihQppG5fanJ4YDJelB/lmwTqWWUF 8uEdpc6y0108OZI5sccLcWXyG2YMt4RTTQCdLnJdI3anMiW0sfpRQhii+mpko1YsW57D nULbyvsqmPUk8bs/eWlkYUbpst+y91E5FexMfACOok+AGZcqfRMjR/z6Kf4ZH3pmZJ4w GEjZoXstBH2z04XflR2nwSCE8GB9FkCbJkUpknxxIZwDv4MxfDBvHZwhh4hpFl41yc5f 59FQ== 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:subject:to:from :dkim-signature; bh=hBZl1oyBLyyGwL0yFw9sOV7YwcyScHIEG5iLXju9HJI=; b=eu4ekuquO3qCVi8cs1PFDxaibZZwyqhP6Ge0Iuk2/AgcCb5geHL0e99q8CF9XRWjl5 sIsDQUQAgybw0iwIet9TuwddsuXU/Abqbjlc0cWHn/q8lg2Rbm1UCSWmvomj5Jcmbp1S 3XvY35sVV+uvxuZmLcKC6jSujEVHN62ThctM8YlyHSt62BN1TJ6DFity49pNFm7VX35W PBKwD1NJLb2FwOPSucVC/5wUQVvHY916185NS51WfdIPCDk3WE/hN0VaqoD5pWeGSeyU UDmEqux0knezWrJFkNH4IqzDqaDPQW6DpIZma4082LdJ+CjBECI1nJo7wP3t77nC5in5 TjfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=yV9W5ZFI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 185-20020a6304c2000000b00478c151f29esi12187056pge.664.2022.12.08.11.34.31; Thu, 08 Dec 2022 11:34:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=yV9W5ZFI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbiLHTaO (ORCPT + 99 others); Thu, 8 Dec 2022 14:30:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbiLHTaM (ORCPT ); Thu, 8 Dec 2022 14:30:12 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC5519B2A3; Thu, 8 Dec 2022 11:30:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670527811; x=1702063811; h=from:to:subject:date:message-id:mime-version; bh=NOuLtBAEfPRVp4erYU2PYxtgRLXk4Rc5kofNmn0gXUs=; b=yV9W5ZFIUQ/95TJFWgg2RuzSDIOgV/OJgp6KDp64mjmzrriIk8cyi5CS Qht1XRqHEOD3HQlO29Tz52ShzVRU9+CzJa8Kfz9PyqyGiXwK17sv5UxTC Lt1lC/vcLWudeMrO7OMxNlB2XTeLQarVEwoJ6cxmy9oXuKD+EUG3knIYC SHaVxpz0nLDh3pv9opYjEdNmwK+4QJBY+wKrFaEl2wmuWhKjpecaj6ImX Hc5rKOWZJrKfOdur1KryRBe5X2n/m9sNgkdHrLGtZGEoXNIFh9P2+EplR awMOH9GXVfhpbcn7+f7R1dsyWLZSP+rUrO6jnM6GYJvS2vzsxOizaRmvp A==; X-IronPort-AV: E=Sophos;i="5.96,227,1665471600"; d="scan'208";a="187244671" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 08 Dec 2022 12:30:10 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Thu, 8 Dec 2022 12:30:08 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Thu, 8 Dec 2022 12:30:06 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , , , , Jerry Ray Subject: [PATCH net-next] lan9303: Fix read error execution path Date: Thu, 8 Dec 2022 13:30:05 -0600 Message-ID: <20221208193005.12434-1-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751675657233297916?= X-GMAIL-MSGID: =?utf-8?q?1751675657233297916?= This patch fixes an issue where a read failure of a port statistic counter will return unknown results. While it is highly unlikely the read will ever fail, it is much cleaner to return a zero for the stat count. Fixes: a1292595e006 ("net: dsa: add new DSA switch driver for the SMSC-LAN9303") Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 80f07bd20593..2e270b479143 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1005,9 +1005,11 @@ static void lan9303_get_ethtool_stats(struct dsa_switch *ds, int port, ret = lan9303_read_switch_port( chip, port, lan9303_mib[u].offset, ®); - if (ret) + if (ret) { dev_warn(chip->dev, "Reading status port %d reg %u failed\n", port, lan9303_mib[u].offset); + reg = 0; + } data[u] = reg; } }