From patchwork Mon Jan 16 12:55:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 44114 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1179865wrn; Mon, 16 Jan 2023 05:04:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXtMveD14OoS2PRPyP1VPxiEWGd2s21riBdcr3adrEeouQr1TACz7zA/Aq/SXkyf9O85URZZ X-Received: by 2002:aa7:d653:0:b0:47e:15ec:155e with SMTP id v19-20020aa7d653000000b0047e15ec155emr75053067edr.26.1673874293899; Mon, 16 Jan 2023 05:04:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673874293; cv=none; d=google.com; s=arc-20160816; b=rQFwe0vz+qV+oco53CThR9ywMAkwDci9QrDdcdwR9n07+DkDf/TonNedbQIUL/IFE5 uv6mWj/1QzNvbV9u2W5FN/CNHACCzpuyeZnzhysaDsi4eMHH13XS4cNu0/59lAaT3XSW lnwqyCvPhA9GgdIKJxQrw86zPGtKquXphQjcEzyqrGqIJtR9T8GA28q1QZ1xEnzjZw5t nYB/BZgopvxRuwE3PlFoQpQbCIWGk5C3eS+rQXeCweuDpeVTAFJ3clpYLgfPQEUyUapN jWZyQ9FrI085IV+Y+Tsezl+/PoQkRSLKaDfLk+ycqIKTImN9H9fi8ypJSfTXqwBxtf1L hfsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ykfQZOm+BASL1GRgngyr2+aX6xmiGeCmWuvPVEfYj38=; b=XHGkiU6RvgN4N4pts/ZvUYoxQFo1lvoFSrlAbeDVX8NXwGGQ8J3YcWLzz8HilqPkHY tmsc3zpA5IcCNBpPLBU1eR0BqYt/OsedQWlG6Rpq2t5B0sAAia1a9mndOqMKaiWFjFGt lNRwEnN6dUDE7L6f7nBij44CjoeCWjBryZyZDGMHNlxfzCmf5NqM2XVNLNjhh8sAf0yU ovHO0ng2vIL9Ha0r9PW404BBay2QSCfV8x4uAurwHA8lm86+Ff9AJ4GNI/IXtst/3EZ4 2+GY1sR1CTiDO3cIU81jdu0dYve5SkQ97fpdRg1h2OZhl2B2nHCK89mpM4Nzw1oHoxtt jDMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=aA2u2Wx7; 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=walle.cc Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i17-20020a0564020f1100b0049defd69a6fsi6851328eda.622.2023.01.16.05.04.30; Mon, 16 Jan 2023 05:04:53 -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=@walle.cc header.s=mail2022082101 header.b=aA2u2Wx7; 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=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231366AbjAPM5d (ORCPT + 99 others); Mon, 16 Jan 2023 07:57:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231326AbjAPM4q (ORCPT ); Mon, 16 Jan 2023 07:56:46 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA8A21F5DE; Mon, 16 Jan 2023 04:55:37 -0800 (PST) Received: from mwalle01.sab.local (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id ACA07166C; Mon, 16 Jan 2023 13:55:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1673873735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ykfQZOm+BASL1GRgngyr2+aX6xmiGeCmWuvPVEfYj38=; b=aA2u2Wx7ZKyQuxkNpuPYxgfMS5B+GnVIDNIN0zt/QCu4YlEArWbIuUj1GPucDXwmCAEf+Y LW64GMhF9PVSps9IXsahMzdwBBcHskaGdAVgCZTKTscquNL2binpZ0yUk4+SLET4biR23t 9b2HL1qR6ZJkbDFjYIBmYsN4XKzBdPpldXAvm7QEE+Dv6Efv50hndXE0bMdf0heUf5AQKn QBqi1c6Lw709w3D78JQrXFIogAKBWkK/z4e+tRzY2OJmbh1VhZFidD3TWO21LWYEpAf9BC VI6DXXHhh1ej+LTrxSCDkupqF3eaOEpaT5m2s8PUTzkOCeD34Acd0db3+oRK9g== From: Michael Walle Date: Mon, 16 Jan 2023 13:55:13 +0100 Subject: [PATCH net-next 1/6] net: mdio: Move mdiobus_scan() within file MIME-Version: 1.0 Message-Id: <20230116-net-next-remove-probe-capabilities-v1-1-5aa29738a023@walle.cc> References: <20230116-net-next-remove-probe-capabilities-v1-0-5aa29738a023@walle.cc> In-Reply-To: <20230116-net-next-remove-probe-capabilities-v1-0-5aa29738a023@walle.cc> To: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , Matthias Brugger , Bryan Whitehead , UNGLinuxDriver@microchip.com, Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Joel Stanley , Andrew Jeffery Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-aspeed@lists.ozlabs.org, Andrew Lunn , Michael Walle X-Mailer: b4 0.11.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,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?1755184411669147207?= X-GMAIL-MSGID: =?utf-8?q?1755184411669147207?= From: Andrew Lunn No functional change, just place it earlier in preparation for some refactoring. While at it, correct the comment format and one typo. Signed-off-by: Andrew Lunn Signed-off-by: Michael Walle Reviewed-by: Jesse Brandeburg --- drivers/net/phy/mdio_bus.c | 101 ++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 902e1c88ef58..61c33c6098a1 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -506,6 +506,56 @@ static int mdiobus_create_device(struct mii_bus *bus, return ret; } +/** + * mdiobus_scan - scan a bus for MDIO devices. + * @bus: mii_bus to scan + * @addr: address on bus to scan + * + * This function scans the MDIO bus, looking for devices which can be + * identified using a vendor/product ID in registers 2 and 3. Not all + * MDIO devices have such registers, but PHY devices typically + * do. Hence this function assumes anything found is a PHY, or can be + * treated as a PHY. Other MDIO devices, such as switches, will + * probably not be found during the scan. + */ +struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr) +{ + struct phy_device *phydev = ERR_PTR(-ENODEV); + int err; + + switch (bus->probe_capabilities) { + case MDIOBUS_NO_CAP: + case MDIOBUS_C22: + phydev = get_phy_device(bus, addr, false); + break; + case MDIOBUS_C45: + phydev = get_phy_device(bus, addr, true); + break; + case MDIOBUS_C22_C45: + phydev = get_phy_device(bus, addr, false); + if (IS_ERR(phydev)) + phydev = get_phy_device(bus, addr, true); + break; + } + + if (IS_ERR(phydev)) + return phydev; + + /* For DT, see if the auto-probed phy has a corresponding child + * in the bus node, and set the of_node pointer in this case. + */ + of_mdiobus_link_mdiodev(bus, &phydev->mdio); + + err = phy_device_register(phydev); + if (err) { + phy_device_free(phydev); + return ERR_PTR(-ENODEV); + } + + return phydev; +} +EXPORT_SYMBOL(mdiobus_scan); + /** * __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus * @bus: target mii_bus @@ -679,57 +729,6 @@ void mdiobus_free(struct mii_bus *bus) } EXPORT_SYMBOL(mdiobus_free); -/** - * mdiobus_scan - scan a bus for MDIO devices. - * @bus: mii_bus to scan - * @addr: address on bus to scan - * - * This function scans the MDIO bus, looking for devices which can be - * identified using a vendor/product ID in registers 2 and 3. Not all - * MDIO devices have such registers, but PHY devices typically - * do. Hence this function assumes anything found is a PHY, or can be - * treated as a PHY. Other MDIO devices, such as switches, will - * probably not be found during the scan. - */ -struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr) -{ - struct phy_device *phydev = ERR_PTR(-ENODEV); - int err; - - switch (bus->probe_capabilities) { - case MDIOBUS_NO_CAP: - case MDIOBUS_C22: - phydev = get_phy_device(bus, addr, false); - break; - case MDIOBUS_C45: - phydev = get_phy_device(bus, addr, true); - break; - case MDIOBUS_C22_C45: - phydev = get_phy_device(bus, addr, false); - if (IS_ERR(phydev)) - phydev = get_phy_device(bus, addr, true); - break; - } - - if (IS_ERR(phydev)) - return phydev; - - /* - * For DT, see if the auto-probed phy has a correspoding child - * in the bus node, and set the of_node pointer in this case. - */ - of_mdiobus_link_mdiodev(bus, &phydev->mdio); - - err = phy_device_register(phydev); - if (err) { - phy_device_free(phydev); - return ERR_PTR(-ENODEV); - } - - return phydev; -} -EXPORT_SYMBOL(mdiobus_scan); - static void mdiobus_stats_acct(struct mdio_bus_stats *stats, bool op, int ret) { preempt_disable();