From patchwork Thu Jan 4 21:30:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 185150 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5881380dyb; Thu, 4 Jan 2024 13:31:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEu82MH5TZ+bimbsVKaxLlYtw6F57ZBSbDUBVBm2tzyE7L5Uhl65st0qrHtrVFx/DXzDXKK X-Received: by 2002:a05:6214:23c5:b0:67f:940a:ed1c with SMTP id hr5-20020a05621423c500b0067f940aed1cmr1253278qvb.66.1704403917768; Thu, 04 Jan 2024 13:31:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704403917; cv=none; d=google.com; s=arc-20160816; b=jtkeJR+d1bjuOTFswgj9QW7En5nzj0V9YAHMId5KQg3132YFyA7m6i9bqJvjoY3CXC hdGs2Pnuy8Fx0J7vBLhbJkOEs3GtadF9cjAnR1+ZCccH0hZcxKaII9SI7XXj6tbOdhqX 5peJcXQbFYVZ4Youj9fbqqb+U64IpgtZEv6onYh7Kbdr2MKg9KI9zBEINrrnsdvwdr6V WEajwEMGn9ERhwcuyHRmZbfSRGCTsDxeHcK/JGGxcTf62rFncIwqIBKkkta/gan7WNgN 5quV5FlrVZayovDnwI3gQwaWaRtYWCE9RTp0okpCSE9Bhdxe4fLF+dORqf7XiSDpkAUj ElaA== 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=5FUG0RjbzXaQnEDKhMBI3aguQZ4xhkiJthc0BKthtiw=; fh=MvcO/qbov/Jg3JUMnEaLiYmZQOpKUGfoaGgrkqZQNf0=; b=eQKK3lAcHeleB8Yvsrp9cesnzsHvQGZLI09oZKeUtLkXOqaw4qY2AWhKdOcbPa0BFk MVbPoqvqISaWUP97ECxeaPIrNlKH0xjyblCbyM0T6GPRnkZ9dhx/tFv+cE17ypmaDcjt 6nkSxf/NyqRPlBITAzZ4kPePX3mK9ZCezy3d9VhVCS4RGZIPp7NjxOFpTrjVIwXutEhz yYJr9speBTcntrXTcW4NYUAknSXmIddwbvvCTwaVNt3nD96Z6qNxibeP6/IuIAWQm600 VrZdUmKjzkAKc0ERzDcRMc5TvWXEYSCSCxHkFPj+qOoPu+l/0wGC1V/tQAWBNMATa1mJ wWtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lU48WKG9; spf=pass (google.com: domain of linux-kernel+bounces-17243-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17243-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bp43-20020a05620a45ab00b0077f46d21e3csi343975qkb.338.2024.01.04.13.31.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 13:31:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17243-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lU48WKG9; spf=pass (google.com: domain of linux-kernel+bounces-17243-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17243-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8D8441C21012 for ; Thu, 4 Jan 2024 21:31:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C7D12C6B7; Thu, 4 Jan 2024 21:31:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lU48WKG9" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 455772C69C; Thu, 4 Jan 2024 21:31:08 +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-f45.google.com with SMTP id 5b1f17b1804b1-40d60ad5f0bso10522015e9.0; Thu, 04 Jan 2024 13:31:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704403866; x=1705008666; 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=5FUG0RjbzXaQnEDKhMBI3aguQZ4xhkiJthc0BKthtiw=; b=lU48WKG9tmhG8ib74GNaWRRkUIrcaXLKfKy8E3qLtBF3nEpmVROt7gbjG/nggozL5n KQo6utlgo+56UxjD7j6taYbKxdZZuOZ4CS+oqS6Zsiup5VhuluFdDOTAQBJjyY8CIKAC F/PC9s4B/HeI78geA/v4gfrg33X8EUX/LApRplMFF8cPx9AfqRYz7OYB2oyov2GlbGwD Wy1ynu1F3aqcYWcBhg6KH+u0Sz+8yAq7f9NEjG9iD8KlOsRhaCo7/KFmIlcXFubFQhqf L/0t4JE71HtPf5bXMPpxQRe7/Gn9Ws8AX+2Qbm6GTij6LbT4AY+rlJ+NbjmV4Tf4YKYE L+tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704403866; x=1705008666; 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=5FUG0RjbzXaQnEDKhMBI3aguQZ4xhkiJthc0BKthtiw=; b=dU21GsIgGeolJeu+8EZ3w7+aYtauHQnteIpSPMZMQsIJp9KfonRXUDab4lMcVJLqnM 0KCQaUX7SqME1t0uNODXqXIIxjHmkh4+k9E2yvS8gXk7ARe53fztKIiXHMO0JVbb8OqK JhJya8vmmNP+It4rYEg2dyCGBC1r6fkIl4RXtP9qnsII1uCcYfhE1zQlK/4PG6bcBJ8X uniAxrpz61yNVEpzlGLb6SUUtRmHEwkd9qsVpGeQ+kryub9WG1H1rDjLQ2mqzJAlToRj IEurBD/+HgPz/4TRIjcN1wbib4eiEy23QVtAvmAdXb/dp7TvZd/keTqwJCNM7LA/2/XK aZgg== X-Gm-Message-State: AOJu0Yz5r/4grmjsCH8n33+oJF3SXEMg2pgRduu0kLUoJIB1A6bdfdm0 nPr24AEX4yZHaAGW4g3JiPo= X-Received: by 2002:a05:600c:1c09:b0:40e:353c:8a1b with SMTP id j9-20020a05600c1c0900b0040e353c8a1bmr596255wms.91.1704403866102; Thu, 04 Jan 2024 13:31:06 -0800 (PST) Received: from localhost.localdomain (host-80-116-159-187.pool80116.interbusiness.it. [80.116.159.187]) by smtp.googlemail.com with ESMTPSA id f14-20020a05600c4e8e00b0040d3dc78003sm407291wmq.17.2024.01.04.13.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 13:31:05 -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 , Simon Horman Subject: [net-next PATCH v4 1/4] net: phy: at803x: generalize cdt fault length function Date: Thu, 4 Jan 2024 22:30:38 +0100 Message-ID: <20240104213044.4653-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240104213044.4653-1-ansuelsmth@gmail.com> References: <20240104213044.4653-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: 1787197042053333808 X-GMAIL-MSGID: 1787197042053333808 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 Reviewed-by: Simon Horman --- 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 aaf6c654aaed..acf483fa0887 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -1192,10 +1192,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. * @@ -1211,8 +1209,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; } @@ -1265,9 +1261,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; } @@ -1994,7 +1992,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)