diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2010-06-26 19:16:01 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2010-06-26 19:16:01 +0000 |
commit | 2c3cf2ba39979c9ce1052eccf195007facf0cd3c (patch) | |
tree | 425a359901e464001113fd4da38bbe63eecc4c3b /target/linux/generic-2.6/files/drivers/net/phy/rtl8366s.c | |
parent | f7f98477b9ec4fd954dee695992f9808fb38daa2 (diff) | |
download | upstream-2c3cf2ba39979c9ce1052eccf195007facf0cd3c.tar.gz upstream-2c3cf2ba39979c9ce1052eccf195007facf0cd3c.tar.bz2 upstream-2c3cf2ba39979c9ce1052eccf195007facf0cd3c.zip |
generic: rtl8366: move mii bus handling to the rtl8366_smi code
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@21911 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic-2.6/files/drivers/net/phy/rtl8366s.c')
-rw-r--r-- | target/linux/generic-2.6/files/drivers/net/phy/rtl8366s.c | 64 |
1 files changed, 10 insertions, 54 deletions
diff --git a/target/linux/generic-2.6/files/drivers/net/phy/rtl8366s.c b/target/linux/generic-2.6/files/drivers/net/phy/rtl8366s.c index c09b4b1a2c..9f378657fc 100644 --- a/target/linux/generic-2.6/files/drivers/net/phy/rtl8366s.c +++ b/target/linux/generic-2.6/files/drivers/net/phy/rtl8366s.c @@ -16,7 +16,6 @@ #include <linux/delay.h> #include <linux/skbuff.h> #include <linux/switch.h> -#include <linux/phy.h> #include <linux/rtl8366s.h> #include "rtl8366_smi.h" @@ -149,8 +148,6 @@ struct rtl8366s { struct device *parent; struct rtl8366_smi smi; - struct mii_bus *mii_bus; - int mii_irq[PHY_MAX_ADDR]; struct switch_dev dev; char buf[4096]; #ifdef CONFIG_RTL8366S_PHY_DEBUG_FS @@ -225,6 +222,11 @@ static struct mib_counter rtl8366s_mib_counters[RTL8366S_MIB_COUNT] = { { 70, 2, "IfOutBroadcastPkts " }, }; +static inline struct rtl8366s *smi_to_rtl8366s(struct rtl8366_smi *smi) +{ + return container_of(smi, struct rtl8366s, smi); +} + static inline struct rtl8366s *sw_to_rtl8366s(struct switch_dev *sw) { return container_of(sw, struct rtl8366s, dev); @@ -1469,7 +1471,7 @@ static void rtl8366s_switch_cleanup(struct rtl8366s *rtl) static int rtl8366s_mii_read(struct mii_bus *bus, int addr, int reg) { - struct rtl8366s *rtl = bus->priv; + struct rtl8366s *rtl = smi_to_rtl8366s(bus->priv); u32 val = 0; int err; @@ -1482,7 +1484,7 @@ static int rtl8366s_mii_read(struct mii_bus *bus, int addr, int reg) static int rtl8366s_mii_write(struct mii_bus *bus, int addr, int reg, u16 val) { - struct rtl8366s *rtl = bus->priv; + struct rtl8366s *rtl = smi_to_rtl8366s(bus->priv); u32 t; int err; @@ -1493,47 +1495,6 @@ static int rtl8366s_mii_write(struct mii_bus *bus, int addr, int reg, u16 val) return err; } -static int rtl8366s_mii_init(struct rtl8366s *rtl) -{ - int ret; - int i; - - rtl->mii_bus = mdiobus_alloc(); - if (rtl->mii_bus == NULL) { - ret = -ENOMEM; - goto err; - } - - rtl->mii_bus->priv = (void *) rtl; - rtl->mii_bus->name = "rtl8366-rtl"; - rtl->mii_bus->read = rtl8366s_mii_read; - rtl->mii_bus->write = rtl8366s_mii_write; - snprintf(rtl->mii_bus->id, MII_BUS_ID_SIZE, "%s", - dev_name(rtl->parent)); - rtl->mii_bus->parent = rtl->parent; - rtl->mii_bus->phy_mask = ~(0x1f); - rtl->mii_bus->irq = rtl->mii_irq; - for (i = 0; i < PHY_MAX_ADDR; i++) - rtl->mii_irq[i] = PHY_POLL; - - ret = mdiobus_register(rtl->mii_bus); - if (ret) - goto err_free; - - return 0; - - err_free: - mdiobus_free(rtl->mii_bus); - err: - return ret; -} - -static void rtl8366s_mii_cleanup(struct rtl8366s *rtl) -{ - mdiobus_unregister(rtl->mii_bus); - mdiobus_free(rtl->mii_bus); -} - static int rtl8366s_mii_bus_match(struct mii_bus *bus) { return (bus->read == rtl8366s_mii_read && @@ -1587,6 +1548,8 @@ static int rtl8366s_detect(struct rtl8366_smi *smi) static struct rtl8366_smi_ops rtl8366s_smi_ops = { .detect = rtl8366s_detect, + .mii_read = rtl8366s_mii_read, + .mii_write = rtl8366s_mii_write, }; static int __init rtl8366s_probe(struct platform_device *pdev) @@ -1633,18 +1596,12 @@ static int __init rtl8366s_probe(struct platform_device *pdev) if (err) goto err_clear_drvdata; - err = rtl8366s_mii_init(rtl); - if (err) - goto err_clear_drvdata; - err = rtl8366s_switch_init(rtl); if (err) - goto err_mii_cleanup; + goto err_clear_drvdata; return 0; - err_mii_cleanup: - rtl8366s_mii_cleanup(rtl); err_clear_drvdata: platform_set_drvdata(pdev, NULL); rtl8366_smi_cleanup(smi); @@ -1687,7 +1644,6 @@ static int __devexit rtl8366s_remove(struct platform_device *pdev) if (rtl) { rtl8366s_switch_cleanup(rtl); rtl8366s_debugfs_remove(rtl); - rtl8366s_mii_cleanup(rtl); platform_set_drvdata(pdev, NULL); rtl8366_smi_cleanup(&rtl->smi); kfree(rtl); |