mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Elias Pukari <elias.pukari@gmail.com>
Cc: netdev@vger.kernel.org, Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3] net: phy: et1011c: don't write an error code to the config register
Date: Wed, 18 Nov 2026 16:18:16 +0100	[thread overview]
Message-ID: <1d316b00-bdb1-4e82-aaa4-543990319daa@lunn.ch> (raw)
In-Reply-To: <20261118150718.16924-1-elias.pukari@gmail.com>

> +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

      reply	other threads:[~2026-11-18 15:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 15:07 Elias Pukari
2026-11-18 15:18 ` Andrew Lunn [this message]

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=1d316b00-bdb1-4e82-aaa4-543990319daa@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=elias.pukari@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --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

all inboxes | Powered by JetHome®