Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2302197pxb; Fri, 25 Mar 2022 15:02:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynt+fG5L5oqF6TFQ4kyXaivyplBH+1ZgozO045H4s0isYYbhTtUPoHVdJu4FuTguHKkESq X-Received: by 2002:a17:90a:628b:b0:1c6:a410:d73f with SMTP id d11-20020a17090a628b00b001c6a410d73fmr27659187pjj.96.1648245728304; Fri, 25 Mar 2022 15:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648245728; cv=none; d=google.com; s=arc-20160816; b=FcSz3kiiFQPCxbz2+oZz9cModhdNv3rSLMK+mP41c4sEL/qVMS54vS8WMFwLgFHA0t 0Yn1znIwUcYWDmNi3cirlYMrke+EDwHZkoWhFMqX9RHeomVFj15yZMCh7HStnl6d44AG 5MU0GZYr64Lv3jQvw4N4kr5OwP2Sxvi5P/K0Bhj/cVapnRuEESudgsUn1bM9Hcwv2fjc +uTDgeXeyGYsFTmODa0UozImVtz5qZQMf8uRSoHN3d4FyEIuo+j4P0RDjLpm0dSFb4mv bO49bH9wENUuKZk43YHiJ64UigCXNPfEsEImvI5KblifDoKnxBNSUrSPtGA4/jeYFYXj mblg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=H8VkAdaZqV/fF69kPMLAXYZCpovyMDnXX53kDMmonNE=; b=lRGwn27wBd4d9TtWzE7ZlcLWlEtv9Y0lXtXUItUjAdT6mU3BMI4awIUlAYuuICtp6Z JpG/9tdnKWI3IFhSI042XfDB+PCVo78gVQJMebgFlaoEI9iX73hZmeVYGaNcm8dNR5rc Km2OoOLkbbzQfHAUeU40BwiXyC+GmfgRq/Gsm2s/Xm9yY6TpTbLhPBJFs7yILFq2dru5 EO3AoIbtAKPioMk44s33l/B3Qd71j21aesOKQMDWsrHoY5pd2Xq/7Jvol4E0QNbMN4B/ r2E1LoatOoEMK2GEZ1Bd13FcGJ4nRyniuD4p8lZ7jyrXscn2OxHF9FRqhrIBj7MS4ZuE Vvkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=Q3jRUy9z; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e18-20020a635452000000b003816043ef8bsi3394193pgm.384.2022.03.25.15.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 15:02:08 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=Q3jRUy9z; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C0922583AD; Fri, 25 Mar 2022 14:36:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233464AbiCYVhe (ORCPT + 99 others); Fri, 25 Mar 2022 17:37:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233465AbiCYVhG (ORCPT ); Fri, 25 Mar 2022 17:37:06 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D29424C7A0; Fri, 25 Mar 2022 14:35:31 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 18A4922438; Fri, 25 Mar 2022 22:35:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1648244128; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H8VkAdaZqV/fF69kPMLAXYZCpovyMDnXX53kDMmonNE=; b=Q3jRUy9zCYFTg6krSaXovRlK0b9oAqpD2mttDgPc/ppJVURS65urJxLnYrw/PcGrrcCl+4 WCeKmQ3KUgeyfSUsJZZtLlg7ZEbRThU3IWp4AIOwkynzNH2zf6Byg7pI6TUhLP4UfELdyh 9A0dyeYp/Ylvvw57Yz9d1gVw9gfD5k8= From: Michael Walle To: Andrew Lunn , Heiner Kallweit , Russell King , Jakub Kicinski , Paolo Abeni Cc: "David S . Miller" , Xu Liang , Alexandre Belloni , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH RFC net-next v2 7/8] phy: net: introduce phy_promote_to_c45() Date: Fri, 25 Mar 2022 22:35:17 +0100 Message-Id: <20220325213518.2668832-8-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220325213518.2668832-1-michael@walle.cc> References: <20220325213518.2668832-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 If not explitly asked to be probed as a C45 PHY, on a bus which is capable of doing both C22 and C45 transfers, C45 PHYs are first tried to be probed as C22 PHYs. To be able to promote the PHY to be a C45 one, the driver can call phy_promote_to_c45() in its probe function. This was already done in the mxl-gpy driver by the following snippet: if (!phydev->has_c45) { phydev->has_c45 = true; ret = phy_get_c45_ids(phydev); if (ret < 0) return ret; } Move that code into the core by creating a new function phy_promote_to_c45(). Signed-off-by: Michael Walle --- drivers/net/phy/mxl-gpy.c | 8 ++------ drivers/net/phy/phy_device.c | 19 +++++++++++++++---- include/linux/phy.h | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c index 2a19905984fc..fe9417528444 100644 --- a/drivers/net/phy/mxl-gpy.c +++ b/drivers/net/phy/mxl-gpy.c @@ -98,12 +98,8 @@ static int gpy_probe(struct phy_device *phydev) { int ret; - if (!phydev->has_c45) { - phydev->has_c45 = true; - ret = phy_get_c45_ids(phydev); - if (ret < 0) - return ret; - } + /* This might have been probed as a C22 PHY, but this is a C45 PHY */ + phy_promote_to_c45(phydev); /* Show GPY PHY FW version in dmesg */ ret = phy_read(phydev, PHY_FWV); diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 920bc8859069..3dc7d012051d 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1007,18 +1007,29 @@ void phy_device_remove(struct phy_device *phydev) EXPORT_SYMBOL(phy_device_remove); /** - * phy_get_c45_ids - Read 802.3-c45 IDs for phy device. - * @phydev: phy_device structure to read 802.3-c45 IDs + * phy_promote_to_c45 - Promote to a C45 PHY + * @phydev: phy_device structure + * + * If a PHY supports both C22 and C45 and it isn't specifically asked to probe + * as a C45 PHY it might be probed as a C22 PHY. The driver can call this + * function to promote a PHY from C22 to C45. + * + * Can also be called if a PHY is already a C45 one. In this case this does + * nothing. * * Returns zero on success, %-EIO on bus access error, or %-ENODEV if * the "devices in package" is invalid. */ -int phy_get_c45_ids(struct phy_device *phydev) +int phy_promote_to_c45(struct phy_device *phydev) { + if (phydev->has_c45) + return 0; + + phydev->has_c45 = true; return get_phy_c45_ids(phydev->mdio.bus, phydev->mdio.addr, &phydev->c45_ids); } -EXPORT_SYMBOL(phy_get_c45_ids); +EXPORT_SYMBOL(phy_promote_to_c45); /** * phy_find_first - finds the first PHY device on the bus diff --git a/include/linux/phy.h b/include/linux/phy.h index 64f2dff2f125..4473e760264a 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1470,7 +1470,7 @@ static inline int phy_device_register(struct phy_device *phy) static inline void phy_device_free(struct phy_device *phydev) { } #endif /* CONFIG_PHYLIB */ void phy_device_remove(struct phy_device *phydev); -int phy_get_c45_ids(struct phy_device *phydev); +int phy_promote_to_c45(struct phy_device *phydev); int phy_init_hw(struct phy_device *phydev); int phy_suspend(struct phy_device *phydev); int phy_resume(struct phy_device *phydev); -- 2.30.2