linux: rtl836x: add a generic reset_switch function
authorGabor Juhos <juhosg@openwrt.org>
Sun, 29 Apr 2012 18:29:31 +0000 (18:29 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sun, 29 Apr 2012 18:29:31 +0000 (18:29 +0000)
SVN-Revision: 31536

target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
target/linux/generic/files/drivers/net/phy/rtl8366rb.c
target/linux/generic/files/drivers/net/phy/rtl8366s.c
target/linux/generic/files/drivers/net/phy/rtl8367.c

index 434cbfbb8511140e2d2cc415bd7304656e9614a6..271e2b513a347b73594e40df46565be3ad9df70d 100644 (file)
@@ -933,6 +933,31 @@ static void rtl8366_smi_mii_cleanup(struct rtl8366_smi *smi)
        mdiobus_free(smi->mii_bus);
 }
 
+int rtl8366_sw_reset_switch(struct switch_dev *dev)
+{
+       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+       int err;
+
+       err = smi->ops->reset_chip(smi);
+       if (err)
+               return err;
+
+       err = smi->ops->setup(smi);
+       if (err)
+               return err;
+
+       err = rtl8366_reset_vlan(smi);
+       if (err)
+               return err;
+
+       err = rtl8366_enable_vlan(smi, 1);
+       if (err)
+               return err;
+
+       return rtl8366_enable_all_ports(smi, 1);
+}
+EXPORT_SYMBOL_GPL(rtl8366_sw_reset_switch);
+
 int rtl8366_sw_get_port_pvid(struct switch_dev *dev, int port, int *val)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
index 1105ce47fcfee6794d26604104797b0d41c29a1a..5c60a3093fcb0439f03e2dd6faf614e0eeba82f8 100644 (file)
@@ -121,6 +121,7 @@ static inline struct rtl8366_smi *sw_to_rtl8366_smi(struct switch_dev *sw)
        return container_of(sw, struct rtl8366_smi, sw_dev);
 }
 
+int rtl8366_sw_reset_switch(struct switch_dev *dev);
 int rtl8366_sw_get_port_pvid(struct switch_dev *dev, int port, int *val);
 int rtl8366_sw_set_port_pvid(struct switch_dev *dev, int port, int val);
 int rtl8366_sw_get_port_mib(struct switch_dev *dev,
index 2323abf3b5c1ba0594e7d7d1f8e44364ab15b56d..3901602f93e684d79a8cb3e25f208382909e3981 100644 (file)
@@ -933,30 +933,6 @@ static int rtl8366rb_sw_reset_port_mibs(struct switch_dev *dev,
                                RTL8366RB_MIB_CTRL_PORT_RESET(val->port_vlan));
 }
 
-static int rtl8366rb_sw_reset_switch(struct switch_dev *dev)
-{
-       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
-       int err;
-
-       err = rtl8366rb_reset_chip(smi);
-       if (err)
-               return err;
-
-       err = rtl8366rb_setup(smi);
-       if (err)
-               return err;
-
-       err = rtl8366_reset_vlan(smi);
-       if (err)
-               return err;
-
-       err = rtl8366_enable_vlan(smi, 1);
-       if (err)
-               return err;
-
-       return rtl8366_enable_all_ports(smi, 1);
-}
-
 static struct switch_attr rtl8366rb_globals[] = {
        {
                .type = SWITCH_TYPE_INT,
@@ -1084,7 +1060,7 @@ static const struct switch_dev_ops rtl8366_ops = {
        .set_vlan_ports = rtl8366_sw_set_vlan_ports,
        .get_port_pvid = rtl8366_sw_get_port_pvid,
        .set_port_pvid = rtl8366_sw_set_port_pvid,
-       .reset_switch = rtl8366rb_sw_reset_switch,
+       .reset_switch = rtl8366_sw_reset_switch,
        .get_port_link = rtl8366rb_sw_get_port_link,
 };
 
index b31d0be2f573c9f00cc35b997dda99e96fcddc21..21f743926ac6e8d3d605bbcc73d3b1a9386ee00b 100644 (file)
@@ -833,30 +833,6 @@ static int rtl8366s_sw_reset_port_mibs(struct switch_dev *dev,
                                0, (1 << (val->port_vlan + 3)));
 }
 
-static int rtl8366s_sw_reset_switch(struct switch_dev *dev)
-{
-       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
-       int err;
-
-       err = rtl8366s_reset_chip(smi);
-       if (err)
-               return err;
-
-       err = rtl8366s_setup(smi);
-       if (err)
-               return err;
-
-       err = rtl8366_reset_vlan(smi);
-       if (err)
-               return err;
-
-       err = rtl8366_enable_vlan(smi, 1);
-       if (err)
-               return err;
-
-       return rtl8366_enable_all_ports(smi, 1);
-}
-
 static struct switch_attr rtl8366s_globals[] = {
        {
                .type = SWITCH_TYPE_INT,
@@ -964,7 +940,7 @@ static const struct switch_dev_ops rtl8366_ops = {
        .set_vlan_ports = rtl8366_sw_set_vlan_ports,
        .get_port_pvid = rtl8366_sw_get_port_pvid,
        .set_port_pvid = rtl8366_sw_set_port_pvid,
-       .reset_switch = rtl8366s_sw_reset_switch,
+       .reset_switch = rtl8366_sw_reset_switch,
        .get_port_link = rtl8366s_sw_get_port_link,
 };
 
index 9959ee3dae84cf363426697f9d9e8fe822e64dfc..d60af022a7226ce7466b1dfcf16f85d989e342fc 100644 (file)
@@ -1475,31 +1475,6 @@ static int rtl8367_sw_reset_port_mibs(struct switch_dev *dev,
                                RTL8367_MIB_CTRL_PORT_RESET_MASK(port % 8));
 }
 
-static int rtl8367_sw_reset_switch(struct switch_dev *dev)
-{
-       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
-       int err;
-
-       err = rtl8367_reset_chip(smi);
-       if (err)
-               return err;
-
-
-       err = rtl8367_setup(smi);
-       if (err)
-               return err;
-
-       err = rtl8366_reset_vlan(smi);
-       if (err)
-               return err;
-
-       err = rtl8366_enable_vlan(smi, 1);
-       if (err)
-               return err;
-
-       return rtl8366_enable_all_ports(smi, 1);
-}
-
 static struct switch_attr rtl8367_globals[] = {
        {
                .type = SWITCH_TYPE_INT,
@@ -1578,7 +1553,7 @@ static const struct switch_dev_ops rtl8366m_ops = {
        .set_vlan_ports = rtl8366_sw_set_vlan_ports,
        .get_port_pvid = rtl8366_sw_get_port_pvid,
        .set_port_pvid = rtl8366_sw_set_port_pvid,
-       .reset_switch = rtl8367_sw_reset_switch,
+       .reset_switch = rtl8366_sw_reset_switch,
        .get_port_link = rtl8367_sw_get_port_link,
 };