generic: rtl8366: add common rtl8366_sw_{get,set}_vlan_ports functions
authorGabor Juhos <juhosg@openwrt.org>
Thu, 15 Jul 2010 13:05:50 +0000 (13:05 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Thu, 15 Jul 2010 13:05:50 +0000 (13:05 +0000)
SVN-Revision: 22204

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

index e46768f8277c488a5718939ec7570847ea5ed949..341f2e99ab1dbb8287b4363f17077689680f9574 100644 (file)
@@ -830,6 +830,57 @@ int rtl8366_sw_get_vlan_info(struct switch_dev *dev,
 }
 EXPORT_SYMBOL_GPL(rtl8366_sw_get_vlan_info);
 
+int rtl8366_sw_get_vlan_ports(struct switch_dev *dev, struct switch_val *val)
+{
+       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+       struct switch_port *port;
+       struct rtl8366_vlan_4k vlan4k;
+       int i;
+
+       if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
+               return -EINVAL;
+
+       smi->ops->get_vlan_4k(smi, val->port_vlan, &vlan4k);
+
+       port = &val->value.ports[0];
+       val->len = 0;
+       for (i = 0; i < smi->num_ports; i++) {
+               if (!(vlan4k.member & BIT(i)))
+                       continue;
+
+               port->id = i;
+               port->flags = (vlan4k.untag & BIT(i)) ?
+                                       0 : BIT(SWITCH_PORT_FLAG_TAGGED);
+               val->len++;
+               port++;
+       }
+       return 0;
+}
+EXPORT_SYMBOL_GPL(rtl8366_sw_get_vlan_ports);
+
+int rtl8366_sw_set_vlan_ports(struct switch_dev *dev, struct switch_val *val)
+{
+       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+       struct switch_port *port;
+       u32 member = 0;
+       u32 untag = 0;
+       int i;
+
+       if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
+               return -EINVAL;
+
+       port = &val->value.ports[0];
+       for (i = 0; i < val->len; i++, port++) {
+               member |= BIT(port->id);
+
+               if (!(port->flags & BIT(SWITCH_PORT_FLAG_TAGGED)))
+                       untag |= BIT(port->id);
+       }
+
+       return rtl8366_set_vlan(smi, val->port_vlan, member, untag, 0);
+}
+EXPORT_SYMBOL_GPL(rtl8366_sw_set_vlan_ports);
+
 struct rtl8366_smi *rtl8366_smi_alloc(struct device *parent)
 {
        struct rtl8366_smi *smi;
index ae3b7db6f2b62edd06820ca1c7ebbc564dd3e20a..66448e6092ec82b6c302541684e0908614e15e82 100644 (file)
@@ -117,5 +117,7 @@ int rtl8366_sw_get_port_mib(struct switch_dev *dev,
 int rtl8366_sw_get_vlan_info(struct switch_dev *dev,
                             const struct switch_attr *attr,
                             struct switch_val *val);
+int rtl8366_sw_get_vlan_ports(struct switch_dev *dev, struct switch_val *val);
+int rtl8366_sw_set_vlan_ports(struct switch_dev *dev, struct switch_val *val);
 
 #endif /*  _RTL8366_SMI_H */
index 231e482912cf30a3a09682b8eeb44335521804af..79533263bba2ea6f9066a604691b15c4b2bbe1b0 100644 (file)
@@ -759,57 +759,6 @@ static int rtl8366rb_sw_reset_port_mibs(struct switch_dev *dev,
                                RTL8366RB_MIB_CTRL_PORT_RESET(val->port_vlan));
 }
 
-static int rtl8366rb_sw_get_vlan_ports(struct switch_dev *dev,
-                                     struct switch_val *val)
-{
-       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
-       struct switch_port *port;
-       struct rtl8366_vlan_4k vlan4k;
-       int i;
-
-       if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
-               return -EINVAL;
-
-       smi->ops->get_vlan_4k(smi, val->port_vlan, &vlan4k);
-
-       port = &val->value.ports[0];
-       val->len = 0;
-       for (i = 0; i < smi->num_ports; i++) {
-               if (!(vlan4k.member & BIT(i)))
-                       continue;
-
-               port->id = i;
-               port->flags = (vlan4k.untag & BIT(i)) ?
-                                       0 : BIT(SWITCH_PORT_FLAG_TAGGED);
-               val->len++;
-               port++;
-       }
-       return 0;
-}
-
-static int rtl8366rb_sw_set_vlan_ports(struct switch_dev *dev,
-                                     struct switch_val *val)
-{
-       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
-       struct switch_port *port;
-       u32 member = 0;
-       u32 untag = 0;
-       int i;
-
-       if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
-               return -EINVAL;
-
-       port = &val->value.ports[0];
-       for (i = 0; i < val->len; i++, port++) {
-               member |= BIT(port->id);
-
-               if (!(port->flags & BIT(SWITCH_PORT_FLAG_TAGGED)))
-                       untag |= BIT(port->id);
-       }
-
-       return rtl8366_set_vlan(smi, val->port_vlan, member, untag, 0);
-}
-
 static int rtl8366rb_sw_reset_switch(struct switch_dev *dev)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
@@ -919,8 +868,8 @@ static struct switch_dev rtl8366_switch_dev = {
                .n_attr = ARRAY_SIZE(rtl8366rb_vlan),
        },
 
-       .get_vlan_ports = rtl8366rb_sw_get_vlan_ports,
-       .set_vlan_ports = rtl8366rb_sw_set_vlan_ports,
+       .get_vlan_ports = rtl8366_sw_get_vlan_ports,
+       .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,
index 167f34f8c33e9ab9a189c6c2d8e4360255702141..17050451fc90f6afaf2fb726997199dc12766edc 100644 (file)
@@ -786,57 +786,6 @@ static int rtl8366s_sw_reset_port_mibs(struct switch_dev *dev,
                                0, (1 << (val->port_vlan + 3)));
 }
 
-static int rtl8366s_sw_get_vlan_ports(struct switch_dev *dev,
-                                     struct switch_val *val)
-{
-       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
-       struct switch_port *port;
-       struct rtl8366_vlan_4k vlan4k;
-       int i;
-
-       if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
-               return -EINVAL;
-
-       smi->ops->get_vlan_4k(smi, val->port_vlan, &vlan4k);
-
-       port = &val->value.ports[0];
-       val->len = 0;
-       for (i = 0; i < smi->num_ports; i++) {
-               if (!(vlan4k.member & BIT(i)))
-                       continue;
-
-               port->id = i;
-               port->flags = (vlan4k.untag & BIT(i)) ?
-                                       0 : BIT(SWITCH_PORT_FLAG_TAGGED);
-               val->len++;
-               port++;
-       }
-       return 0;
-}
-
-static int rtl8366s_sw_set_vlan_ports(struct switch_dev *dev,
-                                     struct switch_val *val)
-{
-       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
-       struct switch_port *port;
-       u32 member = 0;
-       u32 untag = 0;
-       int i;
-
-       if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
-               return -EINVAL;
-
-       port = &val->value.ports[0];
-       for (i = 0; i < val->len; i++, port++) {
-               member |= BIT(port->id);
-
-               if (!(port->flags & BIT(SWITCH_PORT_FLAG_TAGGED)))
-                       untag |= BIT(port->id);
-       }
-
-       return rtl8366_set_vlan(smi, val->port_vlan, member, untag, 0);
-}
-
 static int rtl8366s_sw_reset_switch(struct switch_dev *dev)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
@@ -946,8 +895,8 @@ static struct switch_dev rtl8366_switch_dev = {
                .n_attr = ARRAY_SIZE(rtl8366s_vlan),
        },
 
-       .get_vlan_ports = rtl8366s_sw_get_vlan_ports,
-       .set_vlan_ports = rtl8366s_sw_set_vlan_ports,
+       .get_vlan_ports = rtl8366_sw_get_vlan_ports,
+       .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,