diff options
Diffstat (limited to 'drivers/net/dsa/qca')
-rw-r--r-- | drivers/net/dsa/qca/qca8k-8xxx.c | 39 | ||||
-rw-r--r-- | drivers/net/dsa/qca/qca8k-common.c | 2 | ||||
-rw-r--r-- | drivers/net/dsa/qca/qca8k-leds.c | 4 | ||||
-rw-r--r-- | drivers/net/dsa/qca/qca8k.h | 1 |
4 files changed, 24 insertions, 22 deletions
diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c index 6f2a7aee7e..95d78b3181 100644 --- a/drivers/net/dsa/qca/qca8k-8xxx.c +++ b/drivers/net/dsa/qca/qca8k-8xxx.c @@ -947,46 +947,47 @@ static int qca8k_mdio_register(struct qca8k_priv *priv) { struct dsa_switch *ds = priv->ds; + struct device *dev = ds->dev; struct device_node *mdio; struct mii_bus *bus; - int err; + int err = 0; - mdio = of_get_child_by_name(priv->dev->of_node, "mdio"); + mdio = of_get_child_by_name(dev->of_node, "mdio"); + if (mdio && !of_device_is_available(mdio)) + goto out_put_node; - bus = devm_mdiobus_alloc(ds->dev); + bus = devm_mdiobus_alloc(dev); if (!bus) { err = -ENOMEM; goto out_put_node; } + priv->internal_mdio_bus = bus; bus->priv = (void *)priv; snprintf(bus->id, MII_BUS_ID_SIZE, "qca8k-%d.%d", ds->dst->index, ds->index); - bus->parent = ds->dev; - bus->phy_mask = ~ds->phys_mii_mask; - ds->user_mii_bus = bus; + bus->parent = dev; - /* Check if the devicetree declare the port:phy mapping */ - if (of_device_is_available(mdio)) { + if (mdio) { + /* Check if the device tree declares the port:phy mapping */ bus->name = "qca8k user mii"; bus->read = qca8k_internal_mdio_read; bus->write = qca8k_internal_mdio_write; - err = devm_of_mdiobus_register(priv->dev, bus, mdio); - goto out_put_node; + } else { + /* If a mapping can't be found, the legacy mapping is used, + * using qca8k_port_to_phy() + */ + ds->user_mii_bus = bus; + bus->phy_mask = ~ds->phys_mii_mask; + bus->name = "qca8k-legacy user mii"; + bus->read = qca8k_legacy_mdio_read; + bus->write = qca8k_legacy_mdio_write; } - /* If a mapping can't be found the legacy mapping is used, - * using the qca8k_port_to_phy function - */ - bus->name = "qca8k-legacy user mii"; - bus->read = qca8k_legacy_mdio_read; - bus->write = qca8k_legacy_mdio_write; - - err = devm_mdiobus_register(priv->dev, bus); + err = devm_of_mdiobus_register(dev, bus, mdio); out_put_node: of_node_put(mdio); - return err; } diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c index 9243eff891..2358cd399c 100644 --- a/drivers/net/dsa/qca/qca8k-common.c +++ b/drivers/net/dsa/qca/qca8k-common.c @@ -487,7 +487,7 @@ void qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset, return; for (i = 0; i < priv->info->mib_count; i++) - ethtool_sprintf(&data, "%s", ar8327_mib[i].name); + ethtool_puts(&data, ar8327_mib[i].name); } void qca8k_get_ethtool_stats(struct dsa_switch *ds, int port, diff --git a/drivers/net/dsa/qca/qca8k-leds.c b/drivers/net/dsa/qca/qca8k-leds.c index 90e30c2909..811ebeeff4 100644 --- a/drivers/net/dsa/qca/qca8k-leds.c +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -366,7 +366,6 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p { struct fwnode_handle *led = NULL, *leds = NULL; struct led_init_data init_data = { }; - struct dsa_switch *ds = priv->ds; enum led_default_state state; struct qca8k_led *port_led; int led_num, led_index; @@ -429,7 +428,8 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p init_data.default_label = ":port"; init_data.fwnode = led; init_data.devname_mandatory = true; - init_data.devicename = kasprintf(GFP_KERNEL, "%s:0%d", ds->user_mii_bus->id, + init_data.devicename = kasprintf(GFP_KERNEL, "%s:0%d", + priv->internal_mdio_bus->id, port_num); if (!init_data.devicename) return -ENOMEM; diff --git a/drivers/net/dsa/qca/qca8k.h b/drivers/net/dsa/qca/qca8k.h index 2ac7e88f8d..c8785c36c5 100644 --- a/drivers/net/dsa/qca/qca8k.h +++ b/drivers/net/dsa/qca/qca8k.h @@ -454,6 +454,7 @@ struct qca8k_priv { struct qca8k_ports_config ports_config; struct regmap *regmap; struct mii_bus *bus; + struct mii_bus *internal_mdio_bus; struct dsa_switch *ds; struct mutex reg_mutex; struct device *dev; |