Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: realtek: remove direct calls to realtek-smi

Remove the only two direct calls from subdrivers to realtek-smi.
Now they are called from realtek_priv. Subdrivers can now be
linked independently from realtek-smi.

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Luiz Angelo Daros de Luca and committed by
David S. Miller
cd645dc5 f5f11907

+27 -25
+9 -7
drivers/net/dsa/realtek/realtek-smi-core.c
··· 292 292 * is when issueing soft reset. Since the device reset as soon as we write 293 293 * that bit, no ACK will come back for natural reasons. 294 294 */ 295 - int realtek_smi_write_reg_noack(struct realtek_priv *priv, u32 addr, 296 - u32 data) 295 + static int realtek_smi_write_reg_noack(void *ctx, u32 reg, u32 val) 297 296 { 298 - return realtek_smi_write_reg(priv, addr, data, false); 297 + return realtek_smi_write_reg(ctx, reg, val, false); 299 298 } 300 - EXPORT_SYMBOL_GPL(realtek_smi_write_reg_noack); 301 299 302 300 /* Regmap accessors */ 303 301 ··· 340 342 return priv->ops->phy_write(priv, addr, regnum, val); 341 343 } 342 344 343 - int realtek_smi_setup_mdio(struct realtek_priv *priv) 345 + static int realtek_smi_setup_mdio(struct dsa_switch *ds) 344 346 { 347 + struct realtek_priv *priv = ds->priv; 345 348 struct device_node *mdio_np; 346 349 int ret; 347 350 ··· 362 363 priv->slave_mii_bus->read = realtek_smi_mdio_read; 363 364 priv->slave_mii_bus->write = realtek_smi_mdio_write; 364 365 snprintf(priv->slave_mii_bus->id, MII_BUS_ID_SIZE, "SMI-%d", 365 - priv->ds->index); 366 + ds->index); 366 367 priv->slave_mii_bus->dev.of_node = mdio_np; 367 368 priv->slave_mii_bus->parent = priv->dev; 368 - priv->ds->slave_mii_bus = priv->slave_mii_bus; 369 + ds->slave_mii_bus = priv->slave_mii_bus; 369 370 370 371 ret = devm_of_mdiobus_register(priv->dev, priv->slave_mii_bus, mdio_np); 371 372 if (ret) { ··· 411 412 priv->cmd_read = var->cmd_read; 412 413 priv->cmd_write = var->cmd_write; 413 414 priv->ops = var->ops; 415 + 416 + priv->setup_interface = realtek_smi_setup_mdio; 417 + priv->write_reg_noack = realtek_smi_write_reg_noack; 414 418 415 419 dev_set_drvdata(dev, priv); 416 420 spin_lock_init(&priv->lock);
+2 -5
drivers/net/dsa/realtek/realtek.h
··· 66 66 struct rtl8366_mib_counter *mib_counters; 67 67 68 68 const struct realtek_ops *ops; 69 + int (*setup_interface)(struct dsa_switch *ds); 70 + int (*write_reg_noack)(void *ctx, u32 addr, u32 data); 69 71 70 72 int vlan_enabled; 71 73 int vlan4k_enabled; ··· 116 114 u8 cmd_write; 117 115 size_t chip_data_sz; 118 116 }; 119 - 120 - /* SMI core calls */ 121 - int realtek_smi_write_reg_noack(struct realtek_priv *priv, u32 addr, 122 - u32 data); 123 - int realtek_smi_setup_mdio(struct realtek_priv *priv); 124 117 125 118 /* RTL8366 library helpers */ 126 119 int rtl8366_mc_is_used(struct realtek_priv *priv, int mc_index, int *used);
+8 -7
drivers/net/dsa/realtek/rtl8365mb.c
··· 1767 1767 { 1768 1768 u32 val; 1769 1769 1770 - realtek_smi_write_reg_noack(priv, RTL8365MB_CHIP_RESET_REG, 1771 - FIELD_PREP(RTL8365MB_CHIP_RESET_HW_MASK, 1772 - 1)); 1770 + priv->write_reg_noack(priv, RTL8365MB_CHIP_RESET_REG, 1771 + FIELD_PREP(RTL8365MB_CHIP_RESET_HW_MASK, 1)); 1773 1772 1774 1773 /* Realtek documentation says the chip needs 1 second to reset. Sleep 1775 1774 * for 100 ms before accessing any registers to prevent ACK timeouts. ··· 1848 1849 if (ret) 1849 1850 goto out_teardown_irq; 1850 1851 1851 - ret = realtek_smi_setup_mdio(priv); 1852 - if (ret) { 1853 - dev_err(priv->dev, "could not set up MDIO bus\n"); 1854 - goto out_teardown_irq; 1852 + if (priv->setup_interface) { 1853 + ret = priv->setup_interface(ds); 1854 + if (ret) { 1855 + dev_err(priv->dev, "could not set up MDIO bus\n"); 1856 + goto out_teardown_irq; 1857 + } 1855 1858 } 1856 1859 1857 1860 /* Start statistics counter polling */
+8 -6
drivers/net/dsa/realtek/rtl8366rb.c
··· 1030 1030 if (ret) 1031 1031 dev_info(priv->dev, "no interrupt support\n"); 1032 1032 1033 - ret = realtek_smi_setup_mdio(priv); 1034 - if (ret) { 1035 - dev_info(priv->dev, "could not set up MDIO bus\n"); 1036 - return -ENODEV; 1033 + if (priv->setup_interface) { 1034 + ret = priv->setup_interface(ds); 1035 + if (ret) { 1036 + dev_err(priv->dev, "could not set up MDIO bus\n"); 1037 + return -ENODEV; 1038 + } 1037 1039 } 1038 1040 1039 1041 return 0; ··· 1709 1707 u32 val; 1710 1708 int ret; 1711 1709 1712 - realtek_smi_write_reg_noack(priv, RTL8366RB_RESET_CTRL_REG, 1713 - RTL8366RB_CHIP_CTRL_RESET_HW); 1710 + priv->write_reg_noack(priv, RTL8366RB_RESET_CTRL_REG, 1711 + RTL8366RB_CHIP_CTRL_RESET_HW); 1714 1712 do { 1715 1713 usleep_range(20000, 25000); 1716 1714 ret = regmap_read(priv->map, RTL8366RB_RESET_CTRL_REG, &val);