[openwrt/openwrt] realtek: mdio: rename iterator to "addr"

LEDE Commits lede-commits at lists.infradead.org
Wed Jan 21 14:36:19 PST 2026


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/3722b006a69cfa9545844739258f67e92fd4d823

commit 3722b006a69cfa9545844739258f67e92fd4d823
Author: Markus Stockhausen <markus.stockhausen at gmx.de>
AuthorDate: Mon Jan 12 17:33:19 2026 +0100

    realtek: mdio: rename iterator to "addr"
    
    During initialization the mdio driver registers phys with the
    iterator "pn". To make clear that it is a phy address rename it
    to "addr".
    
    While we are here improve the upper bound check of the maximum
    possible address. This is the family specific cpu port and not
    the generic upper bound constant for all devices.
    
    Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
    Link: https://github.com/openwrt/openwrt/pull/21438
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 .../drivers/net/mdio/mdio-realtek-otto.c           | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c
index 83fcb935a4..b87497fe6a 100644
--- a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c
+++ b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c
@@ -1016,14 +1016,14 @@ static int rtmdio_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct rtmdio_bus_priv *priv;
 	struct mii_bus *bus;
-	u32 pn;
+	int addr;
 
 	bus = devm_mdiobus_alloc_size(dev, sizeof(*priv));
 	if (!bus)
 		return -ENOMEM;
 
 	priv = bus->priv;
-	for (int addr = 0; addr < RTMDIO_MAX_PORT; addr++)
+	for (addr = 0; addr < RTMDIO_MAX_PORT; addr++)
 		priv->smi_bus[addr] = -1;
 
 	priv->cfg = (const struct rtmdio_config *)device_get_match_data(dev);
@@ -1040,29 +1040,29 @@ static int rtmdio_probe(struct platform_device *pdev)
 	for_each_node_by_name(dn, "ethernet-phy") {
 		u32 smi_addr[2];
 
-		if (of_property_read_u32(dn, "reg", &pn))
+		if (of_property_read_u32(dn, "reg", &addr))
 			continue;
 
-		if (pn >= RTMDIO_MAX_PORT) {
-			pr_err("%s: illegal port number %d\n", __func__, pn);
+		if (addr >= priv->cfg->cpu_port) {
+			pr_err("%s: illegal port number %d\n", __func__, addr);
 			return -ENODEV;
 		}
 
 		if (of_property_read_u32_array(dn, "realtek,smi-address", &smi_addr[0], 2)) {
-			priv->smi_bus[pn] = 0;
-			priv->smi_addr[pn] = pn;
+			priv->smi_bus[addr] = 0;
+			priv->smi_addr[addr] = addr;
 		} else {
-			priv->smi_bus[pn] = smi_addr[0];
-			priv->smi_addr[pn] = smi_addr[1];
+			priv->smi_bus[addr] = smi_addr[0];
+			priv->smi_addr[addr] = smi_addr[1];
 		}
 
-		if (priv->smi_bus[pn] >= RTMDIO_MAX_SMI_BUS) {
-			pr_err("%s: illegal SMI bus number %d\n", __func__, priv->smi_bus[pn]);
+		if (priv->smi_bus[addr] >= RTMDIO_MAX_SMI_BUS) {
+			pr_err("%s: illegal SMI bus number %d\n", __func__, priv->smi_bus[addr]);
 			return -ENODEV;
 		}
 
 		if (of_device_is_compatible(dn, "ethernet-phy-ieee802.3-c45"))
-			priv->smi_bus_isc45[priv->smi_bus[pn]] = true;
+			priv->smi_bus_isc45[priv->smi_bus[addr]] = true;
 	}
 
 	dn = of_find_compatible_node(NULL, NULL, "realtek,rtl83xx-switch");




More information about the lede-commits mailing list