From patchwork Mon Apr 19 13:01:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 12211811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B74D5C433ED for ; Mon, 19 Apr 2021 13:03:31 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 634906113C for ; Mon, 19 Apr 2021 13:03:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 634906113C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YTXi7OcYL6xFNUi30x/nSOYgMfzBYiUfozl4iIsvwmQ=; b=pF8Uep4X8mwO0FSpXOklBGdxA BN3ynvxZmHC1Gy+Mnd6txSiAzTHDdA7WCXgwC0tIv1OvfA7FhiPNKNEe4qmyTlQCkW0XhWkTTY8Vm UOGAz2ZR+NePT6hiJXy8ReY83Bsze7p1ODYYe7YpaHrAn759Z9glFmG+RHiM2BbCAvo56AxQpz+TJ IiFttpM187fSfIkcJGH7OUhSA6AF9xCBiiTb5ksKGgg44vyRq55w3cmMEw5QDixX2VJb3LmZroQED n3Mwln+GtJk77TWuM2LUxKRIn0Z3YWgpYuslZyz9nVI7/PvJHTmAtmnE9TEV+Xid3dyCT1a42Jy/3 rh159yVwg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYTWn-009taI-2h; Mon, 19 Apr 2021 13:01:25 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYTWh-009ta8-Uy for linux-arm-kernel@desiato.infradead.org; Mon, 19 Apr 2021 13:01:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=tEfJV6Wcvt7TYwmSECvcOcAoyw3ikh+5khI/HsQ/yeI=; b=oIwnt+ck+g9/3vH61IMthE8KvK Iu23PUflR6x81dRM6Z8C5HGweXTLzHDKQG8h9v0LXH8jLipFmgUSMV9h+sKECc+IIekBOXcyHGtDg SpEuYwr4Kvvge07GqjlAz6hJJA18XuLvv24Ie42qgHHhgW690dqpmivhTl3/u/mvErW17sYktUWw0 t6KYI2+qNBpUA7eRx/Gb86KnmVLbWRGYv+Lnu8CUzj4MX+5y9TnVXkAPjadXJnwuA479mzRY0gWm7 CLovwnT1Fo3hOsU7WJwqw3GpNzVzyivTEEfDH/T2PZ0ztNX6qJ/RHeqtIOijSSVZcPSvn9H2dKd9e x3l4BfpQ==; Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYTWf-00BMwN-CJ for linux-arm-kernel@lists.infradead.org; Mon, 19 Apr 2021 13:01:18 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lYTWa-0003te-VR; Mon, 19 Apr 2021 15:01:12 +0200 Received: from ore by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lYTWW-0001lm-Vb; Mon, 19 Apr 2021 15:01:08 +0200 From: Oleksij Rempel To: Shawn Guo , Sascha Hauer , Andrew Lunn , Florian Fainelli , Heiner Kallweit , Fugang Duan Cc: Oleksij Rempel , kernel@pengutronix.de, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, Fabio Estevam , David Jander , Russell King , Philippe Schenker Subject: [PATCH net-next v3 1/6] net: phy: execute genphy_loopback() per default on all PHYs Date: Mon, 19 Apr 2021 15:01:01 +0200 Message-Id: <20210419130106.6707-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210419130106.6707-1-o.rempel@pengutronix.de> References: <20210419130106.6707-1-o.rempel@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210419_060117_435054_B433591C X-CRM114-Status: GOOD ( 13.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The generic loopback is really generic and is defined by the 802.3 standard, we should just mandate that drivers implement a custom loopback if the generic one cannot work. Suggested-by: Florian Fainelli Signed-off-by: Oleksij Rempel --- drivers/net/phy/phy_device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 73d29fd5e03d..320a3e5cd10a 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1777,6 +1777,9 @@ int phy_loopback(struct phy_device *phydev, bool enable) struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver); int ret = 0; + if (!phydrv) + return -ENODEV; + mutex_lock(&phydev->lock); if (enable && phydev->loopback_enabled) { @@ -1789,10 +1792,10 @@ int phy_loopback(struct phy_device *phydev, bool enable) goto out; } - if (phydev->drv && phydrv->set_loopback) + if (phydrv->set_loopback) ret = phydrv->set_loopback(phydev, enable); else - ret = -EOPNOTSUPP; + ret = genphy_loopback(phydev, enable); if (ret) goto out;