Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2301721pxb; Fri, 25 Mar 2022 15:01:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLG0Lu98o8MbFvn3nAsRlAvu2bRAUr24i9/RxbHllrXPXKQl4o04QjbmyNZvdCIpRLj+S7 X-Received: by 2002:a17:902:d48d:b0:153:a517:6ff2 with SMTP id c13-20020a170902d48d00b00153a5176ff2mr13970804plg.141.1648245701957; Fri, 25 Mar 2022 15:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648245701; cv=none; d=google.com; s=arc-20160816; b=Q1xaOZSiGS1gagjPEXijJ9ZPJGk4uYiReQC5PzbWDuEmOQTnUjSHx/gdTGrmRhW+cP m65zO/HQTp90gRAET/o/IGh0ex34OYN5M3jNRYKi6iqrq5OVWLyl2wVJ0DE+iYHtmRc/ gqdbhsx3ncebBNSFmlQhNjDH0hkNLd+ZeMl21uGONm6p6IfmSaVN4z9dPRZm7gMTGyIX YV0z/K+9Krvmg8uTiLdpcDnIyT6VIU6U64H0QNqQPgQYGjXhbDnyaJ4g4AM4yiwTdDaa qtoxH4uL4PLHlojfhBA5Jf+DMV8Ew2i5l9OcfzHdCjL+1y9j5w7pTKa1vjZnyOYS4H2a ahCA== 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=c+IHVZ2wDiBsBATZdF0ZEbYHHJLaJMi9OlfJjiVvU+c=; b=SCWvyuT/GIpQ3ISGk269xFDSYpLGfu787mUXUqiSjXFm2ckaF3dx/rUmZBE7UYgzK3 jeyisw4mH6u4McTNvC4WiQMKCQGU3/ceRPXi+k8Q9XecAGHuqP94RapDkE5UKRLmrQps iOuYGNy2jJwwWu7HT3iiqcwepx3ABdDoXqH3mszQH8eUP2v/tSwszlZ2iblvJGTnCMVr +552pthDTHsV4WsYccKU5h4ZGIUxYRWVfNGm36UGouDPnpb3egOIAN4mDR0KkBoOxAaN Enl+IepboJXxEdHGQ/3Bc6OHSy0kUs1BNgct5LOYGuYwGu2mBW5iOddIEneMYK5pFqe2 tZBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=UWUS3cDh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bm17-20020a656e91000000b003816043f155si3414029pgb.842.2022.03.25.15.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 15:01:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=UWUS3cDh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 7A70653E2F; Fri, 25 Mar 2022 14:35:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233473AbiCYVh0 (ORCPT + 99 others); Fri, 25 Mar 2022 17:37:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233444AbiCYVhF (ORCPT ); Fri, 25 Mar 2022 17:37:05 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF7024D240; Fri, 25 Mar 2022 14:35:28 -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 E4167223F6; Fri, 25 Mar 2022 22:35:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1648244127; 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=c+IHVZ2wDiBsBATZdF0ZEbYHHJLaJMi9OlfJjiVvU+c=; b=UWUS3cDhZ5byMLen9kWjBe53/FNH0m9x+5iM8NOIo3CEG1Us5KSxUgHChlsdgTxTBqKBX+ V5n7iprNTPUTHJtLQOJ8Sq8Oo39cfQ1ZYAr/vCeJdWo/3rxNw2kYDDE/WjXx6Bu8vM2GbQ DDYWOp5a3VGj8LjwZf6YtbJrWFn1fMQ= 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 4/8] net: phy: add error handling for __phy_{read,write}_mmd Date: Fri, 25 Mar 2022 22:35:14 +0100 Message-Id: <20220325213518.2668832-5-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 Now that __phy_mmd_indirect() returns an error code, check it and additionally check the error code of the last read or write access. Signed-off-by: Michael Walle --- drivers/net/phy/phy-core.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c index dd9b6b64757d..2a300c58d1e5 100644 --- a/drivers/net/phy/phy-core.c +++ b/drivers/net/phy/phy-core.c @@ -493,8 +493,11 @@ int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum) } else { struct mii_bus *bus = phydev->mdio.bus; int phy_addr = phydev->mdio.addr; + int ret; - __phy_mmd_indirect(bus, phy_addr, devad, regnum); + ret = __phy_mmd_indirect(bus, phy_addr, devad, regnum); + if (ret) + return ret; /* Read the content of the MMD's selected register */ val = __mdiobus_read(bus, phy_addr, MII_MMD_DATA); @@ -550,12 +553,12 @@ int __phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val) struct mii_bus *bus = phydev->mdio.bus; int phy_addr = phydev->mdio.addr; - __phy_mmd_indirect(bus, phy_addr, devad, regnum); + ret = __phy_mmd_indirect(bus, phy_addr, devad, regnum); + if (ret) + return ret; /* Write the data into MMD's selected register */ - __mdiobus_write(bus, phy_addr, MII_MMD_DATA, val); - - ret = 0; + ret = __mdiobus_write(bus, phy_addr, MII_MMD_DATA, val); } return ret; } -- 2.30.2