From patchwork Tue Jan 2 14:03:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 184358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4462074dyb; Tue, 2 Jan 2024 06:04:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzWKNe1TUX/h8MorFqy0nHfBnmNHkx8XZz+ENbjTtlCXMQ3EBItCSi1ofgYiu6kP8UWpN1 X-Received: by 2002:a2e:9995:0:b0:2cc:e48d:d0f7 with SMTP id w21-20020a2e9995000000b002cce48dd0f7mr3146016lji.97.1704204288480; Tue, 02 Jan 2024 06:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704204288; cv=none; d=google.com; s=arc-20160816; b=O5QBSYPzfpZYEtBQFAzggCU9nSM4RU0Ygps9FFXj3kbQ4hYORoWwdzJkYA+USQcaan 2xDJNnlbUh3nALICtQixREiOrkuOFgomrvWMRxJ2Jr9AdTEqUnTE1m1hQ00fnw/d9umC hOrOC7QfQ/j+fyOQ8SyjFHf0t8lZtIwvhJ7zzPWFx6sD4/eQDvpLuXeZW4OIFULq5Iom crUTh4zjddd0x/IGM0IGaegiMqH+Pn/VcYUdlrMDG/jksNu1QMOZX+TNAP+O8DQBaB30 cWbWOt8B6qlUfPWWy7tlFlenxVbYMVNyOPbvhl0uMeO4JEKxzHDmqY7+aCCP782ozfU4 tKIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=8jgtefRyhyrs3KbL6OkxtQpjnArsTGVLXR9LSgz6WQg=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=iyVThpfrFauxeBT91LJSs9llC54Q4ul+6Zu4NWT+Epr7fDjAKcTYRcNTZ5fLgaXRtZ p3aGl9c7XzArkeEZy44iPKkVfg5SOLlvexMTmdSyrPQPuwQfoLn1LnEq1PzaLpYMqeWp mZpSni9NpdtK39p6o/KgE4afJUV1/UKZQdhskDbbpqRb/kPdXtNoR9eUsIwpew46SC2w SrZWevu/yQ8sVLfdBfHnM435+RptsWOwP+VM+qxw9/wYIZ6Zu0XV1cNWbiUldioJHV/w b/o6NuhmpKjaUxISXs+kp/MFypW+G5G3pZLlULI73a57BooX+owHgHsjD5xUSjC33Vwi lVKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ZS7uY0GR; spf=pass (google.com: domain of linux-kernel+bounces-14456-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14456-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i18-20020a50d752000000b00555d5a33cdasi3420821edj.463.2024.01.02.06.04.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 06:04:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14456-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ZS7uY0GR; spf=pass (google.com: domain of linux-kernel+bounces-14456-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14456-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1980F1F22C9E for ; Tue, 2 Jan 2024 14:04:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AD4114F61; Tue, 2 Jan 2024 14:03:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZS7uY0GR" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D643A10961; Tue, 2 Jan 2024 14:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-40d4a7f0c4dso88502835e9.1; Tue, 02 Jan 2024 06:03:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704204217; x=1704809017; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8jgtefRyhyrs3KbL6OkxtQpjnArsTGVLXR9LSgz6WQg=; b=ZS7uY0GRaybditMsCXYaw3+7xG+3LZHBcUnz9PbpOIuGrnPDf+j77TV80JwLyjFh7f rHLzMie/2DSog+CeQydm+USPHRdm3wgFDx7iurlW+BdDnR6xe5JVLgg40YqS+AnttYG/ WAixcMlL/dj5xZnrpZxawq20Ht/vETs2ZrFWO8kug9FJrcsSkGzwqVnWFhd+lVMyGbpC hBp0LZFyR0ieOzKNvR+VxyQEVROmHHkM4RbucVP6GfixuiIIoieqa9JoC1p2WHKPSdZw VJgZ8zWprlkjCRCYO2x71+sthkLROh0CJ/iVbTlJt1NlmT3n99nBCcnABoncUfPE3d29 UFSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704204217; x=1704809017; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8jgtefRyhyrs3KbL6OkxtQpjnArsTGVLXR9LSgz6WQg=; b=Ewb88ueYTMwCzXWjtnmfYpiVlfWVEa/FFkEVCtGz5IJ1dSFXsA0rnxp8NQEy7S1KSS Yvqzg5RdP8estQMNDg1+5OIrFq8U+5vfE/8evvnDHzCvMzPRDMM8e5Hdkp+ZRCoPUf71 MO673r+fDR9F6xOxjp3aA2cZU//Vj42pgpRRe0xwCQjvg11vdJ1ic2FIHR6xPcaElYuy MUB8CFFvY1MzPj8lKzkopML+2MvCXJybRrMUuki5OITlpui8GHgSDGElzUIMAzf1m5Sg wbO6lFpoOhaxMa4Ael2bSzNCx4Rpd/ZtS4zZBF39sgeOgp351/RXKpMUGmryoXDDM/PN xnvg== X-Gm-Message-State: AOJu0Yzf5+hHoT+Peb+u94qZjOIEgRI0KFN+CAjqIMioRi79qpy8Okjf MLyMOd7OIKvBoEHrN/mIYb4= X-Received: by 2002:a05:600c:19cb:b0:40d:8638:bf5 with SMTP id u11-20020a05600c19cb00b0040d86380bf5mr1924814wmq.22.1704204216844; Tue, 02 Jan 2024 06:03:36 -0800 (PST) Received: from localhost.localdomain (host-87-10-250-100.retail.telecomitalia.it. [87.10.250.100]) by smtp.googlemail.com with ESMTPSA id e17-20020a5d5311000000b0033672cfca96sm28427527wrv.89.2024.01.02.06.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 06:03:36 -0800 (PST) From: Christian Marangi To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH v2 1/4] net: phy: at803x: generalize cdt fault length function Date: Tue, 2 Jan 2024 15:03:25 +0100 Message-ID: <20240102140330.7371-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240102140330.7371-1-ansuelsmth@gmail.com> References: <20240102140330.7371-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786987715626137639 X-GMAIL-MSGID: 1786987715626137639 Generalize cable test fault length function since they all base on the same magic values (already reverse engineered to understand the meaning of it) to have consistenct values on every PHY. Signed-off-by: Christian Marangi --- drivers/net/phy/at803x.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 0db653b57494..072bcd670ef0 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -1259,10 +1259,8 @@ static bool at803x_cdt_fault_length_valid(u16 status) return false; } -static int at803x_cdt_fault_length(u16 status) +static int at803x_cdt_fault_length(int dt) { - int dt; - /* According to the datasheet the distance to the fault is * DELTA_TIME * 0.824 meters. * @@ -1278,8 +1276,6 @@ static int at803x_cdt_fault_length(u16 status) * With a VF of 0.69 we get the factor 0.824 mentioned in the * datasheet. */ - dt = FIELD_GET(AT803X_CDT_STATUS_DELTA_TIME_MASK, status); - return (dt * 824) / 10; } @@ -1332,9 +1328,11 @@ static int at803x_cable_test_one_pair(struct phy_device *phydev, int pair) ethnl_cable_test_result(phydev, ethtool_pair[pair], at803x_cable_test_result_trans(val)); - if (at803x_cdt_fault_length_valid(val)) + if (at803x_cdt_fault_length_valid(val)) { + val = FIELD_GET(AT803X_CDT_STATUS_DELTA_TIME_MASK, val); ethnl_cable_test_fault_length(phydev, ethtool_pair[pair], at803x_cdt_fault_length(val)); + } return 1; } @@ -2059,7 +2057,8 @@ static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair) if (val < 0) return val; - return (FIELD_GET(QCA808X_CDT_DIAG_LENGTH, val) * 824) / 10; + val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH, val); + return at803x_cdt_fault_length(val); } static int qca808x_cable_test_start(struct phy_device *phydev)