generic: rtl8366: generealize rtl8366{s,rb}_sw_get_port_mib functions
[openwrt.git] / target / linux / generic / files / drivers / net / phy / rtl8366s.c
index 6f3fdd5..b603c23 100644 (file)
@@ -828,17 +828,18 @@ static int rtl8366s_sw_get_port_mib(struct switch_dev *dev,
        unsigned long long counter = 0;
        char *buf = smi->buf;
 
-       if (val->port_vlan >= RTL8366S_NUM_PORTS)
+       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 < ARRAY_SIZE(rtl8366s_mib_counters); ++i) {
+       for (i = 0; i < smi->num_mib_counters; ++i) {
                len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "%-36s: ", rtl8366s_mib_counters[i].name);
-               if (!rtl8366_get_mib_counter(smi, i, val->port_vlan, &counter))
+                               "%-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
@@ -902,18 +903,6 @@ static int rtl8366s_sw_set_vlan_ports(struct switch_dev *dev,
        return rtl8366_set_vlan(smi, val->port_vlan, member, untag, 0);
 }
 
-static int rtl8366s_sw_get_port_pvid(struct switch_dev *dev, int port, int *val)
-{
-       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
-       return rtl8366_get_pvid(smi, port, val);
-}
-
-static int rtl8366s_sw_set_port_pvid(struct switch_dev *dev, int port, int val)
-{
-       struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
-       return rtl8366_set_pvid(smi, port, val);
-}
-
 static int rtl8366s_sw_reset_switch(struct switch_dev *dev)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
@@ -1025,8 +1014,8 @@ static struct switch_dev rtl8366_switch_dev = {
 
        .get_vlan_ports = rtl8366s_sw_get_vlan_ports,
        .set_vlan_ports = rtl8366s_sw_set_vlan_ports,
-       .get_port_pvid = rtl8366s_sw_get_port_pvid,
-       .set_port_pvid = rtl8366s_sw_set_port_pvid,
+       .get_port_pvid = rtl8366_sw_get_port_pvid,
+       .set_port_pvid = rtl8366_sw_set_port_pvid,
        .reset_switch = rtl8366s_sw_reset_switch,
 };
 
@@ -1130,6 +1119,8 @@ static int rtl8366s_detect(struct rtl8366_smi *smi)
 
 static struct rtl8366_smi_ops rtl8366s_smi_ops = {
        .detect         = rtl8366s_detect,
+       .setup          = rtl8366s_setup,
+
        .mii_read       = rtl8366s_mii_read,
        .mii_write      = rtl8366s_mii_write,
 
@@ -1181,10 +1172,6 @@ static int __init rtl8366s_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, smi);
 
-       err = rtl8366s_setup(smi);
-       if (err)
-               goto err_clear_drvdata;
-
        err = rtl8366s_switch_init(smi);
        if (err)
                goto err_clear_drvdata;
This page took 0.032231 seconds and 4 git commands to generate.