generic: rtl8366: add common rtl8366_sw_get_port_mib function
authorGabor Juhos <juhosg@openwrt.org>
Thu, 15 Jul 2010 13:05:36 +0000 (13:05 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Thu, 15 Jul 2010 13:05:36 +0000 (13:05 +0000)
SVN-Revision: 22200

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 a596c311c1233e1dc2abb37ab99c6c2ea574687a..a45c844cadcf326e5d1514b7f28d1ba869730cce 100644 (file)
@@ -754,6 +754,40 @@ int rtl8366_sw_set_port_pvid(struct switch_dev *dev, int port, int val)
 }
 EXPORT_SYMBOL_GPL(rtl8366_sw_set_port_pvid);
 
+int rtl8366_sw_get_port_mib(struct switch_dev *dev,
+                           const struct switch_attr *attr,
+                           struct switch_val *val)
+{
+       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+       int i, len = 0;
+       unsigned long long counter = 0;
+       char *buf = smi->buf;
+
+       if (val->port_vlan >= smi->num_ports)
+               return -EINVAL;
+
+       len += snprintf(buf + len, sizeof(smi->buf) - len,
+                       "Port %d MIB counters\n",
+                       val->port_vlan);
+
+       for (i = 0; i < smi->num_mib_counters; ++i) {
+               len += snprintf(buf + len, sizeof(smi->buf) - len,
+                               "%-36s: ", smi->mib_counters[i].name);
+               if (!smi->ops->get_mib_counter(smi, i, val->port_vlan,
+                                              &counter))
+                       len += snprintf(buf + len, sizeof(smi->buf) - len,
+                                       "%llu\n", counter);
+               else
+                       len += snprintf(buf + len, sizeof(smi->buf) - len,
+                                       "%s\n", "error");
+       }
+
+       val->value.s = buf;
+       val->len = len;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(rtl8366_sw_get_port_mib);
+
 struct rtl8366_smi *rtl8366_smi_alloc(struct device *parent)
 {
        struct rtl8366_smi *smi;
index d27d94768eb0e9a7d1c1e7d7712aabafae625532..2e8f9298dca9ae998aba44cd83b5f4434ea42501 100644 (file)
@@ -110,5 +110,8 @@ static inline struct rtl8366_smi *sw_to_rtl8366_smi(struct switch_dev *sw)
 
 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,
+                           const struct switch_attr *attr,
+                           struct switch_val *val);
 
 #endif /*  _RTL8366_SMI_H */
index d4fa74a864ef4f75f1083c464d9a38b0cce15892..b6d3f9805f0bf8ff7a87c2b1415f6db31529f057 100644 (file)
@@ -792,39 +792,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_port_mib(struct switch_dev *dev,
-                                   const struct switch_attr *attr,
-                                   struct switch_val *val)
-{
-       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
-       int i, len = 0;
-       unsigned long long counter = 0;
-       char *buf = smi->buf;
-
-       if (val->port_vlan >= smi->num_ports)
-               return -EINVAL;
-
-       len += snprintf(buf + len, sizeof(smi->buf) - len,
-                       "Port %d MIB counters\n",
-                       val->port_vlan);
-
-       for (i = 0; i < smi->num_mib_counters; ++i) {
-               len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "%-36s: ", smi->mib_counters[i].name);
-               if (!smi->ops->get_mib_counter(smi, i, val->port_vlan,
-                                              &counter))
-                       len += snprintf(buf + len, sizeof(smi->buf) - len,
-                                       "%llu\n", counter);
-               else
-                       len += snprintf(buf + len, sizeof(smi->buf) - len,
-                                       "%s\n", "error");
-       }
-
-       val->value.s = buf;
-       val->len = len;
-       return 0;
-}
-
 static int rtl8366rb_sw_get_vlan_ports(struct switch_dev *dev,
                                      struct switch_val *val)
 {
@@ -944,7 +911,7 @@ static struct switch_attr rtl8366rb_port[] = {
                .description = "Get MIB counters for port",
                .max = 33,
                .set = NULL,
-               .get = rtl8366rb_sw_get_port_mib,
+               .get = rtl8366_sw_get_port_mib,
        }, {
                .type = SWITCH_TYPE_INT,
                .name = "led",
index b603c2336041b0cbf5bb6917143c094bbe02eb68..9936b45380b5127dda03ac42db34d6d41f9171d6 100644 (file)
@@ -819,39 +819,6 @@ static int rtl8366s_sw_reset_port_mibs(struct switch_dev *dev,
                                0, (1 << (val->port_vlan + 3)));
 }
 
-static int rtl8366s_sw_get_port_mib(struct switch_dev *dev,
-                                   const struct switch_attr *attr,
-                                   struct switch_val *val)
-{
-       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
-       int i, len = 0;
-       unsigned long long counter = 0;
-       char *buf = smi->buf;
-
-       if (val->port_vlan >= smi->num_ports)
-               return -EINVAL;
-
-       len += snprintf(buf + len, sizeof(smi->buf) - len,
-                       "Port %d MIB counters\n",
-                       val->port_vlan);
-
-       for (i = 0; i < smi->num_mib_counters; ++i) {
-               len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "%-36s: ", smi->mib_counters[i].name);
-               if (!smi->ops->get_mib_counter(smi, i, val->port_vlan,
-                                              &counter))
-                       len += snprintf(buf + len, sizeof(smi->buf) - len,
-                                       "%llu\n", counter);
-               else
-                       len += snprintf(buf + len, sizeof(smi->buf) - len,
-                                       "%s\n", "error");
-       }
-
-       val->value.s = buf;
-       val->len = len;
-       return 0;
-}
-
 static int rtl8366s_sw_get_vlan_ports(struct switch_dev *dev,
                                      struct switch_val *val)
 {
@@ -971,7 +938,7 @@ static struct switch_attr rtl8366s_port[] = {
                .description = "Get MIB counters for port",
                .max = 33,
                .set = NULL,
-               .get = rtl8366s_sw_get_port_mib,
+               .get = rtl8366_sw_get_port_mib,
        }, {
                .type = SWITCH_TYPE_INT,
                .name = "led",