]> git.itanic.dy.fi Git - linux-stable/commit
net: dsa: qca8k: assign ds->user_mii_bus only for the non-OF case
authorVladimir Oltean <vladimir.oltean@nxp.com>
Thu, 4 Jan 2024 14:00:33 +0000 (16:00 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 5 Jan 2024 11:56:35 +0000 (11:56 +0000)
commit525366b81f3382ad1c76ba5e47b71e8b7925c85e
tree97dd9939bd75b7d4fa888ecf30fc93db1d201734
parente66bf63a7f670a600338faf889bed71f90c183bf
net: dsa: qca8k: assign ds->user_mii_bus only for the non-OF case

To simplify reasoning about why the DSA framework provides the
ds->user_mii_bus functionality, drivers should only use it if they
need to. The qca8k driver appears to also use it simply as storage
for a pointer, which is not a good enough reason to make the core
much more difficult to follow.

ds->user_mii_bus is useful for only 2 cases:

1. The driver probes on platform_data (no OF)
2. The driver probes on OF, but there is no OF node for the MDIO bus.

It is unclear if case (1) is supported with qca8k. It might not be:
the driver might crash when of_device_get_match_data() returns NULL
and then it dereferences priv->info without NULL checking.

Anyway, let us limit the ds->user_mii_bus usage only to the above cases,
and not assign it when an OF node is present.

The bus->phy_mask assignment follows along with the movement, because
__of_mdiobus_register() overwrites this bus field anyway. The value set
by the driver only matters for the non-OF code path.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/qca/qca8k-8xxx.c
drivers/net/dsa/qca/qca8k-leds.c
drivers/net/dsa/qca/qca8k.h