Devicetree
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Maxime Chevallier <maxime.chevallier@bootlin.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Andrew Lunn <andrew@lunn.ch>, Eric Dumazet <edumazet@google.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Vladimir Oltean <olteanv@gmail.com>,
	Woojung Huh <woojung.huh@microchip.com>,
	Arun Ramadoss <arun.ramadoss@microchip.com>,
	Conor Dooley <conor+dt@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, UNGLinuxDriver@microchip.com,
	"Russell King (Oracle)" <linux@armlinux.org.uk>,
	devicetree@vger.kernel.org, Marek Vasut <marex@denx.de>
Subject: Re: [PATCH net-next v3 6/6] net: dsa: microchip: parse PHY config from device tree
Date: Tue, 5 Nov 2024 15:32:09 +0100	[thread overview]
Message-ID: <ZyosafnNkdqt4JMb@pengutronix.de> (raw)
In-Reply-To: <20241105152805.25f8b065@fedora.home>

Hi Maxime,

On Tue, Nov 05, 2024 at 03:28:05PM +0100, Maxime Chevallier wrote:
> > +	dsa_switch_for_each_user_port(dp, dev->ds) {
> > +		if (!dev->info->internal_phy[dp->index])
> > +			continue;
> > +
> > +		phy_node = of_parse_phandle(dp->dn, "phy-handle", 0);
> > +		if (!phy_node) {
> > +			dev_err(dev->dev, "failed to parse phy-handle for port %d.\n",
> > +				dp->index);
> > +			phys_are_valid = false;
> > +			continue;
> > +		}
> > +
> > +		phy_parent_node = of_get_parent(phy_node);
> > +		if (!phy_parent_node) {
> > +			dev_err(dev->dev, "failed to get PHY-parent node for port %d\n",
> > +				dp->index);
> > +			phys_are_valid = false;
> > +		} else if (dev->info->internal_phy[dp->index] &&
> > +			   phy_parent_node != mdio_np) {
> 
> There's a check a few lines above that guarantees that at this point
> dev->info->internal_phy[dp->index] will always evaluate as true,
> so you could simplify that condition a bit :)

good point :)

> > +			dev_err(dev->dev, "PHY-parent node mismatch for port %d, expected %pOF, got %pOF\n",
> > +				dp->index, mdio_np, phy_parent_node);
> > +			phys_are_valid = false;
> > +		} else {
> > +			ret = of_property_read_u32(phy_node, "reg", &phy_id);
> > +			if (ret < 0) {
> > +				dev_err(dev->dev, "failed to read PHY ID for port %d. Error %d\n",
> > +					dp->index, ret);
> > +				phys_are_valid = false;
> > +			} else if (phy_id != dev->phy_addr_map[dp->index]) {
> > +				dev_err(dev->dev, "PHY ID mismatch for port %d, expected 0x%x, got 0x%x\n",
> > +					dp->index, dev->phy_addr_map[dp->index],
> > +					phy_id);
> 
> In this context, PHY ID might be a bit misleading, as PHY ID usually
> refers to the identifier (OUI + model id used at probe to select the
> driver). May I suggest phy_addr instead ?

ack, will rework it.

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

      reply	other threads:[~2024-11-05 14:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-05  9:09 [PATCH net-next v3 0/6] Side MDIO Support for LAN937x Switches Oleksij Rempel
2024-11-05  9:09 ` [PATCH net-next v3 1/6] dt-bindings: net: dsa: ksz: add internal MDIO bus description Oleksij Rempel
2024-11-05  9:09 ` [PATCH net-next v3 2/6] dt-bindings: net: dsa: ksz: add mdio-parent-bus property for internal MDIO Oleksij Rempel
2024-11-05  9:09 ` [PATCH net-next v3 3/6] net: dsa: microchip: Refactor MDIO handling for side MDIO access Oleksij Rempel
2024-11-05 18:15   ` Andrew Lunn
2024-11-05  9:09 ` [PATCH net-next v3 4/6] net: dsa: microchip: cleanup error handling in ksz_mdio_register Oleksij Rempel
2024-11-05  9:09 ` [PATCH net-next v3 5/6] net: dsa: microchip: add support for side MDIO interface in LAN937x Oleksij Rempel
2024-11-05 18:21   ` Andrew Lunn
2024-11-05  9:09 ` [PATCH net-next v3 6/6] net: dsa: microchip: parse PHY config from device tree Oleksij Rempel
2024-11-05 14:28   ` Maxime Chevallier
2024-11-05 14:32     ` Oleksij Rempel [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=ZyosafnNkdqt4JMb@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=arun.ramadoss@microchip.com \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=marex@denx.de \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=robh+dt@kernel.org \
    --cc=woojung.huh@microchip.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