From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Chris Packham <chris.packham@alliedtelesis.co.nz>,
andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, sander@svanheule.net,
markus.stockhausen@gmx.de
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v9] net: mdio: Add RTL9300 MDIO driver
Date: Mon, 10 Mar 2025 19:06:13 +0100 [thread overview]
Message-ID: <3514933e-0fdd-4f1e-b1e4-b72a638edfc8@wanadoo.fr> (raw)
In-Reply-To: <20250309232536.19141-1-chris.packham@alliedtelesis.co.nz>
Le 10/03/2025 à 00:25, Chris Packham a écrit :
> Add a driver for the MDIO controller on the RTL9300 family of Ethernet
> switches with integrated SoC. There are 4 physical SMI interfaces on the
> RTL9300 however access is done using the switch ports. The driver takes
> the MDIO bus hierarchy from the DTS and uses this to configure the
> switch ports so they are associated with the correct PHY. This mapping
> is also used when dealing with software requests from phylib.
...
> + fwnode_for_each_child_node(ports, port) {
> + struct device_node *mdio_dn;
> + u32 addr;
> + u32 bus;
> + u32 pn;
> +
> + struct device_node *phy_dn __free(device_node) =
> + of_parse_phandle(to_of_node(port), "phy-handle", 0);
> + /* skip ports without phys */
> + if (!phy_dn)
> + continue;
> +
> + mdio_dn = phy_dn->parent;
> + /* only map ports that are connected to this mdio-controller */
> + if (mdio_dn->parent != dev->of_node)
> + continue;
> +
> + err = fwnode_property_read_u32(port, "reg", &pn);
> + if (err)
> + return err;
> +
> + if (pn >= MAX_PORTS)
> + return dev_err_probe(dev, -EINVAL, "illegal port number %d\n", pn);
While checking for illegal port numbers, does the following make sense:
if (test_bit(pn, priv->valid_ports)
return dev_err_probe(dev, -EINVAL, "duplicated port number %d\n", pn);
> +
> + err = of_property_read_u32(mdio_dn, "reg", &bus);
> + if (err)
> + return err;
> +
> + if (bus >= MAX_SMI_BUSSES)
> + return dev_err_probe(dev, -EINVAL, "illegal smi bus number %d\n", bus);
> +
> + err = of_property_read_u32(phy_dn, "reg", &addr);
> + if (err)
> + return err;
> +
> + bitmap_set(priv->valid_ports, pn, 1);
set_bit(pn, priv->valid_ports) ?
> + priv->smi_bus[pn] = bus;
> + priv->smi_addr[pn] = addr;
> + }
...
CJ
next prev parent reply other threads:[~2025-03-10 18:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-09 23:25 Chris Packham
2025-03-10 1:31 ` Daniel Golle
2025-03-10 2:07 ` Chris Packham
2025-03-10 15:28 ` Daniel Golle
2025-03-13 1:04 ` Chris Packham
2025-03-13 13:05 ` Andrew Lunn
2025-03-10 16:32 ` Andrew Lunn
2025-03-10 16:34 ` Russell King (Oracle)
2025-03-10 16:27 ` Andrew Lunn
2025-03-10 18:06 ` Christophe JAILLET [this message]
2025-03-10 18:15 ` Russell King (Oracle)
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=3514933e-0fdd-4f1e-b1e4-b72a638edfc8@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=andrew@lunn.ch \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=markus.stockhausen@gmx.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sander@svanheule.net \
/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®