]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: mdio: rename iterator to "addr"
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Mon, 12 Jan 2026 16:33:19 +0000 (17:33 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Wed, 21 Jan 2026 22:32:54 +0000 (23:32 +0100)
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@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21438
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c

index 83fcb935a407460979895da843ce32aa98052440..b87497fe6a43e863fd4ae6e928ded4d8f0a18ccd 100644 (file)
@@ -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");