From: Michael Walle <michael@walle.cc>
To: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Xu Liang <lxu@maxlinear.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Florian Fainelli <f.fainelli@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Michael Walle <michael@walle.cc>
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 [thread overview]
Message-ID: <20220325213518.2668832-5-michael@walle.cc> (raw)
In-Reply-To: <20220325213518.2668832-1-michael@walle.cc>
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 <michael@walle.cc>
---
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
next prev parent reply other threads:[~2022-03-25 21:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-25 21:35 [PATCH RFC net-next v2 0/8] net: phy: C45-over-C22 access Michael Walle
2022-03-25 21:35 ` [PATCH RFC net-next v2 1/8] net: phy: mscc-miim: reject clause 45 register accesses Michael Walle
2022-03-25 21:35 ` [PATCH RFC net-next v2 2/8] net: phy: mscc-miim: add probe_capabilities Michael Walle
2022-03-25 21:35 ` [PATCH RFC net-next v2 3/8] net: phy: add error checks in __phy_mmd_indirect() and export it Michael Walle
2022-03-25 21:35 ` Michael Walle [this message]
2022-03-25 21:35 ` [PATCH RFC net-next v2 5/8] net: phy: support indirect c45 access in get_phy_c45_ids() Michael Walle
2022-03-25 21:35 ` [PATCH RFC net-next v2 6/8] net: phy: add support for C45-over-C22 transfers Michael Walle
2022-03-25 21:35 ` [PATCH RFC net-next v2 7/8] phy: net: introduce phy_promote_to_c45() Michael Walle
2022-03-25 21:35 ` [PATCH RFC net-next v2 8/8] net: phy: mxl-gpy: remove unneeded ops Michael Walle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220325213518.2668832-5-michael@walle.cc \
--to=michael@walle.cc \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lxu@maxlinear.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).