From patchwork Wed Jul 3 13:28:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 13722230 X-Patchwork-Delegate: kuba@kernel.org Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F52F17BB10 for ; Wed, 3 Jul 2024 13:28:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720013304; cv=none; b=NRnwJ0nnVsq3GlWsYiTr6b0HLOJl2tykAFa0NfKax8nXmgymRPeCnZKv+BsZ1UPZmiNaJFeOG6C740otRs+C7sLvSymsBo8Qytx4D1jcYKNWVM+G6AbqVMHh9gAaNMsQIhsXE4uUkWcP8sC06I2D+XZRjR2rdkfoG7aHYTkxyPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720013304; c=relaxed/simple; bh=xl9E7mdmU2QSEhuoiWZFWr/Cz68F3jKLgGkRANW/65g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FDHaoZEhgc/bUxZmeKkiV/KsZkZ74Zq0TIiH0iXBdUf3dBXeVVnrGETkgWhv/oIygJ4+ip3QhVq3tnQqm1NfcgYCihJVpWMiN8YMsx7AB8BnZ38VPYkWrkrRQZ081z8sB76QgpajLuvvo2tlQeIWRU9iY05pkfRxslooIZEmXMs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sP01k-0005Vy-HF; Wed, 03 Jul 2024 15:28:04 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sP01i-006rQg-Sc; Wed, 03 Jul 2024 15:28:02 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1sP01i-002c8U-2d; Wed, 03 Jul 2024 15:28:02 +0200 From: Oleksij Rempel To: "David S. Miller" , Andrew Lunn , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Paolo Abeni , Woojung Huh , Arun Ramadoss , Heiner Kallweit , Russell King , Yuiko Oshino Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com Subject: [PATCH net v1 2/2] net: phy: microchip: lan87xx: do not report SQI if no link Date: Wed, 3 Jul 2024 15:28:01 +0200 Message-Id: <20240703132801.623218-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240703132801.623218-1-o.rempel@pengutronix.de> References: <20240703132801.623218-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Do not report SQI if no link is detected. Otherwise ethtool will show non zero value even if no cable is attached. Fixes: b649695248b15 ("net: phy: LAN87xx: add ethtool SQI support") Signed-off-by: Oleksij Rempel Reviewed-by: Michal Kubiak --- drivers/net/phy/microchip_t1.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/phy/microchip_t1.c b/drivers/net/phy/microchip_t1.c index a35528497a576..22530a5b76365 100644 --- a/drivers/net/phy/microchip_t1.c +++ b/drivers/net/phy/microchip_t1.c @@ -840,6 +840,9 @@ static int lan87xx_get_sqi(struct phy_device *phydev) u8 sqi_value = 0; int rc; + if (!phydev->link) + return 0; + rc = access_ereg(phydev, PHYACC_ATTR_MODE_WRITE, PHYACC_ATTR_BANK_DSP, T1_COEF_RW_CTL_CFG, 0x0301); if (rc < 0)