[PATCH net-next v13 08/11] net: mdio: realtek-rtl9300: Check for C45 support during setup

Markus Stockhausen <[email protected]>
Newsgroups org.kernel.vger.linux-devicetree,org.kernel.vger.netdev
Message-ID <[email protected]>
The to-be-merged RTL83xx devices have only 1G ports. Thus the MDIO
bus always runs with C22 mode. For now it makes no sense to add
those devices with C45 helpers that are not used at all. Add a
consistency check in the mapping helper so that it aborts setup
if devicetree defines a C45 PHY for a device that has no such
read/write functions.

Signed-off-by: Markus Stockhausen <[email protected]>
---
 drivers/net/mdio/mdio-realtek-rtl9300.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mdio/mdio-realtek-rtl9300.c b/drivers/net/mdio/mdio-realtek-rtl9300.c
index 88ba73b2ee81..22b1c4e05354 100644
--- a/drivers/net/mdio/mdio-realtek-rtl9300.c
+++ b/drivers/net/mdio/mdio-realtek-rtl9300.c
@@ -782,8 +782,14 @@ static int otto_emdio_map_ports(struct device *dev)
 		 * (i.e. clause 45). Select 10GPHY mode if there is at least one PHY that
 		 * declares compatible = "ethernet-phy-ieee802.3-c45".
 		 */
-		if (of_device_is_compatible(phy_dn, "ethernet-phy-ieee802.3-c45"))
+		if (of_device_is_compatible(phy_dn, "ethernet-phy-ieee802.3-c45")) {
+			if (!priv->info->read_c45 || !priv->info->write_c45) {
+				err = dev_err_probe(dev, -EOPNOTSUPP,
+						    "bus %d does not support C45 access\n", bus);
+				goto put_nodes;
+			}
 			priv->smi_bus_is_c45[bus] = true;
+		}
 
 		__set_bit(pn, priv->valid_ports);
 		priv->smi_bus[pn] = bus;
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.