Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3224188pxb; Tue, 20 Apr 2021 03:33:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaxekO14shGd/s2OMO3rFs2kYTjXrtfbB+LPOCKfKeCfl1Y4XUukrko5UVQ//Oia+3jir2 X-Received: by 2002:a17:906:2818:: with SMTP id r24mr26728788ejc.502.1618914810895; Tue, 20 Apr 2021 03:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618914810; cv=none; d=google.com; s=arc-20160816; b=il8lmB5TxW9fhFoMi69s/gtyVHSGUi5m7YkKzPLoN94UvWn20XNwh1DqKpLZdT4czg heQnpfsQYLeApajGujTt/6HdvbUB9meOBgRa0TOQroPUExBFj3Z8FBl1HSO/biqMfK6k ikDsOS9tfIShUKLNuVgj7a5/HUSgvEH52IWj4xStyjcVnn1r+T4HY+39yrPMViQfL+1W Qg4vRz1UVLdBL6pG8phZYxAwnDXnXYgFwdzvO7Lb/NgBhv14Ytq80XRdJ2Pl5LJ2gwW7 nyacClAzbJ3WoNQjTT26ka5s5ZRKKINwt6af/zl9cfokhdZ2h6Xz8iFZZjwMSVI/3wRB dI/A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ZQIa58xXT6JLjPg9IEQx79FJQAMp7Fys04CwVO2aGt0=; b=IdTUNXPY1O+uz4p5SVJ43Ocm/0I5HDHZ4EPwn18mO53/Asw8UXEZaudDQtWP8KAK9f ha24XNRrpnVGPVeVPO5GItdMdDYOyRT0c0IZTcfNzqGlbhRHPulddbf1qE1g3ugkMcKQ p+YGIeijmsJQ/JnBZG62UaMl2h2r+vh8epfWrBWm/k+h6PgFp59y7TJjYrh77fy+5tQt urvFWzIp4Yr0mFeGim9VjOBdyvEI3vYEFFSghVOhJ02qml5wymbwZ5BIllQwtz06sJJS 20M0BfBlz6ojXXQeyQSPgZPjbQROynYZW8A8uvCOzaMspdjpfuURhFcEhD1m7kGbSxt4 bsHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=rTxzOt58; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si3706274eji.715.2021.04.20.03.33.07; Tue, 20 Apr 2021 03:33:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=rTxzOt58; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231574AbhDTKaJ (ORCPT + 99 others); Tue, 20 Apr 2021 06:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231509AbhDTKaI (ORCPT ); Tue, 20 Apr 2021 06:30:08 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD260C06174A; Tue, 20 Apr 2021 03:29:37 -0700 (PDT) Received: from mwalle01.fritz.box (unknown [IPv6:2a02:810c:c200:2e91:fa59:71ff:fe9b:b851]) (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 DA9BB22249; Tue, 20 Apr 2021 12:29:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1618914576; 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; bh=ZQIa58xXT6JLjPg9IEQx79FJQAMp7Fys04CwVO2aGt0=; b=rTxzOt58YroOOb03KtF37s3iua2hAzUchFZll0+u38DHN3rnjol/VwIDSMWuSXcezAEyRg tLXfA0DN0e0sKav1Rb+fHM6czJ5bvGNF/sU0ogusTFMG2+3Gi6y8f0wyEa8kriu1WnDsA7 6i4zh96cFcnocZxm+QUbd47oSsF+7jI= From: Michael Walle To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , David Bauer , Michael Walle Subject: [PATCH net-next v2] net: phy: at803x: fix probe error if copper page is selected Date: Tue, 20 Apr 2021 12:29:29 +0200 Message-Id: <20210420102929.13505-1-michael@walle.cc> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The commit c329e5afb42f ("net: phy: at803x: select correct page on config init") selects the copper page during probe. This fails if the copper page was already selected. In this case, the value of the copper page (which is 1) is propagated through phy_restore_page() and is finally returned for at803x_probe(). Fix it, by just using the at803x_page_write() directly. Also in case of an error, the regulator is not disabled and leads to a WARN_ON() when the probe fails. This couldn't happen before, because at803x_parse_dt() was the last call in at803x_probe(). It is hard to see, that the parse_dt() actually enables the regulator. Thus move the regulator_enable() to the probe function and undo it in case of an error. Fixes: c329e5afb42f ("net: phy: at803x: select correct page on config init") Signed-off-by: Michael Walle --- Changes since v1: - take the bus lock drivers/net/phy/at803x.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index e0f56850edc5..32af52dd5aed 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -554,10 +554,6 @@ static int at803x_parse_dt(struct phy_device *phydev) phydev_err(phydev, "failed to get VDDIO regulator\n"); return PTR_ERR(priv->vddio); } - - ret = regulator_enable(priv->vddio); - if (ret < 0) - return ret; } return 0; @@ -579,15 +575,30 @@ static int at803x_probe(struct phy_device *phydev) if (ret) return ret; + if (priv->vddio) { + ret = regulator_enable(priv->vddio); + if (ret < 0) + return ret; + } + /* Some bootloaders leave the fiber page selected. * Switch to the copper page, as otherwise we read * the PHY capabilities from the fiber side. */ if (at803x_match_phy_id(phydev, ATH8031_PHY_ID)) { - ret = phy_select_page(phydev, AT803X_PAGE_COPPER); - ret = phy_restore_page(phydev, AT803X_PAGE_COPPER, ret); + phy_lock_mdio_bus(phydev); + ret = at803x_write_page(phydev, AT803X_PAGE_COPPER); + phy_unlock_mdio_bus(phydev); + if (ret) + goto err; } + return 0; + +err: + if (priv->vddio) + regulator_disable(priv->vddio); + return ret; } -- 2.20.1