Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3218786pxb; Tue, 20 Apr 2021 03:24:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwrA6b+vReDBr1od4pjA7NqNGZX2zTY9a0XhgUgZnfy1fJyEgAZ4DVIuGRJsCAE7Rz55ai X-Received: by 2002:aa7:88c5:0:b029:24e:8807:e4f1 with SMTP id k5-20020aa788c50000b029024e8807e4f1mr23832504pff.9.1618914266200; Tue, 20 Apr 2021 03:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618914266; cv=none; d=google.com; s=arc-20160816; b=BEJ5jXj1R1wea3314Rwa74R2KCNsiUMdk9UYeLPcza5Z6JOs78OmZXni9apaY8s1L5 uPBQNF7lowoFaTR3VEZZ2tXxEMZ+OFdro1TLsFUEZupEt9qxBlCTTUtBDdo5fSdAQYCj oXOIb0VHcvSEeISchTWUr/u+SUG3ck8cODYs0rNZfNwh85cnODDdUcPZPGTFoGQshECG jFgD0rQbS5kw2ytADwaOrz8SqDflroa/8zd6GdBiHumlvYDFb9Wd1jejOl/HYhdL3+LM lfHrCwfCRxQgJOmvJdKn0zoekoYzjFm3AHtlzd5R0uKa2silO8jvssWMaqBGqyskEQyP S/4w== 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=VXJRy9VzNsHT9ZmGp3xAw1tC+n20lg5dvIivLVfnwRY=; b=ySy/3G2s5VA0aV89grzvtE2msdSBFfid621wt2M/m4u6SjYMg0B8SdNgifu1OsqIE4 Wt8XbTlj9wOtohe3HYdiWdimLVy5YAUMwGwaeToQhVFWYdhqXBREinkgjGPODkrRSjHD 5qsPqNVIhuB0uxXWyX4KHsTqnnDW4YtKw7wdAvBhlmjTuXaaSUVQ0+ZgAp72IZ10ul1v U6IdQh9I479wJHHZJTPb61QeVQ5SoJl8LEIe4mtmXiXwIhrkX5tCvHPRySbjV+5ypgV7 g+809JUjdGznNK1fE22Rx+R9bC0djoolJJaSH+cvZPAJ20wFQgbjZNFzx0kE5XEvv2FP gylQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=q7NG8HRI; 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 g36si19348102pgb.208.2021.04.20.03.24.13; Tue, 20 Apr 2021 03:24:26 -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=q7NG8HRI; 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 S231520AbhDTKW5 (ORCPT + 99 others); Tue, 20 Apr 2021 06:22:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbhDTKW4 (ORCPT ); Tue, 20 Apr 2021 06:22:56 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91F12C06174A; Tue, 20 Apr 2021 03:22:25 -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 A1E2E22249; Tue, 20 Apr 2021 12:22:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1618914141; 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=VXJRy9VzNsHT9ZmGp3xAw1tC+n20lg5dvIivLVfnwRY=; b=q7NG8HRIdNbiyrn/dEJEJDRSw2slKBPuzfLRMs3ewyHrVaVx3hEuxsKClDw/j4cLJKZAbl 4eKkQ0bCAtKxxkYUFJs+4VSSmCwd7BcM0zQ38ivwJulzKyQZNBDH7cOQqosdItwImbMbpL K45Mg4G0cYXO0rCgpqDG0EUvGVCE6dY= 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] net: phy: at803x: fix probe error if copper page is selected Date: Tue, 20 Apr 2021 12:22:08 +0200 Message-Id: <20210420102208.5834-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 --- drivers/net/phy/at803x.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index e0f56850edc5..5bec200f2132 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,28 @@ 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); + ret = at803x_write_page(phydev, AT803X_PAGE_COPPER); + if (ret) + goto err; } + return 0; + +err: + if (priv->vddio) + regulator_disable(priv->vddio); + return ret; } -- 2.20.1