Subject: AW: [PATCH net-next 6/8] net: mdio: realtek-rtl9300: relocate topology setup

From: "Markus Stockhausen" <[email-masked]>
Date: Tue, 2 Jun 2026 12:50:31 +0200

> Von: Jagielski, Jedrzej <[email-masked]> 
> Gesendet: Dienstag, 2. Juni 2026 11:51
> Betreff: RE: [PATCH net-next 6/8] net: mdio: realtek-rtl9300: relocate
topology setup
> ... 
> >-static int otto_emdio_9300_mdiobus_init(struct otto_emdio_priv *priv)
> >+static int otto_emdio_write_mapping(struct otto_emdio_priv *priv, u32
base, u32 port,
> >+				    u32 ports_per_reg, u32 bits_per_val, u32
value)
> > {
> >-	u32 glb_ctrl_mask = 0, glb_ctrl_val = 0;
> >-	struct regmap *regmap = priv->regmap;
> >-	u32 port_addr[5] = { 0 };
> >-	u32 poll_sel[2] = { 0 };
> >-	int i, err;
> >+	u32 shift = (port % ports_per_reg) * bits_per_val;
>
> are we sure @ports_per_reg cannot be equal to 0 in any scenario?

This helper is only implemented to make the topology 
setup code easier to read. So this is never gets a zero input. 
I can rename the function to clearer indicate the tight coupling.

> ... 
> >-		pos = (i % 16) * 2;
> >-		poll_sel[i / 16] |= (priv->smi_bus[i] & 0x3) << pos;
> >+	for_each_set_bit(port, priv->valid_ports, info->num_ports) {
> >+		if (info->bus_map_base) {
> >+			/* 16 ports per register, 2 bits per port (bus index
0-3) */
> >+			ret = otto_emdio_write_mapping(priv,
info->bus_map_base, port,
> >+						       16, 2,
priv->smi_bus[port]);
> >+			if (ret)
> >+				return ret;
> >+		}
> >+		if (info->addr_map_base) {
> >+			/* 6 ports per register, 5 bits per port (PHY
address 0-31) */
> >+			ret = otto_emdio_write_mapping(priv,
info->addr_map_base, port,
> >+						       6, 5,
priv->smi_addr[port]);
> >+			if (ret)
> >+				return ret;
> >+		}
> > 	}
> >+	return 0;
>
> Magic numbers appearing here and there, what is discouraged in netdev i
believe
> Any chance to replace them with corresponding defines?

No problem, will ad that to v2.

Markus