Re: [PATCH net-next v3] net: phy: et1011c: don't write an error code to the config register

From: Andrew Lunn

Date: Wed Nov 18 2026 - 10:20:01 EST


> +static int et1011c_probe(struct phy_device *phydev)
> +{
> + phydev->priv = devm_kzalloc_obj(&phydev->mdio.dev, int);
> + return phydev->priv ? 0 : -ENOMEM;

Look at other kernel code. And in look mostly at phy drivers. How
often do you see this sort of return code?

You want your code to look like all the other code.

Also, how often do you see a priv which is not structure?

> static int et1011c_config_aneg(struct phy_device *phydev)
> {
> int ctl = phy_read(phydev, MII_BMCR);
> @@ -60,25 +66,33 @@ static int et1011c_config_aneg(struct phy_device *phydev)
>
> static int et1011c_read_status(struct phy_device *phydev)
> {
> - static int speed;
> + int *configured_speed = phydev->priv;
> + bool was_up = phydev->link;
> + int val;
> int ret;
> - u32 val;
>
> ret = genphy_read_status(phydev);
> + if (ret < 0 || !phydev->link) {
> + *configured_speed = SPEED_UNKNOWN;
> + return ret;
> + }

Look at other users of genphy_read_status(). How many have code like
this? If you are doing something which no other driver does, it is
likely to be wrong.

Andrew

---
pw-bot: cr