rtl8366_smi: store device pointer instead of plaform_device
[openwrt.git] / target / linux / ar71xx / files / drivers / net / phy / rtl8366_smi.c
index 6b909b5..7e27e42 100644 (file)
 
 
 #define RTL8366S_PORT_VLAN_CTRL_BASE        0x0058
+#define RTL8366S_PORT_VLAN_CTRL_REG(_p)  \
+               (RTL8366S_PORT_VLAN_CTRL_BASE + (_p) / 4)
+#define RTL8366S_PORT_VLAN_CTRL_MASK       0xf
+#define RTL8366S_PORT_VLAN_CTRL_SHIFT(_p)   (4 * ((_p) % 4))
+
+
 #define RTL8366S_VLAN_TABLE_READ_BASE       0x018B
 #define RTL8366S_VLAN_TABLE_WRITE_BASE      0x0185
 
@@ -203,7 +209,7 @@ static const char *MIBCOUNTERS[] = {
 };
 
 struct rtl8366_smi {
-       struct platform_device             *pdev;
+       struct device                      *parent;
        struct rtl8366_smi_platform_data   *pdata;
        spinlock_t                         lock;
        struct mii_bus                     *mii_bus;
@@ -553,13 +559,10 @@ static int rtl8366_get_mib_counter(struct rtl8366_smi *smi, int counter,
        if (port > RTL8366_NUM_PORTS || counter >= RTL8366S_MIB_COUNT)
                return -EINVAL;
 
-       i = 0;
        regoffset = RTL8366S_MIB_COUNTER_PORT_OFFSET * (port);
 
-       while (i < counter) {
+       for (i = 0; i < counter; i++)
                regoffset += mibLength[i];
-               i++;
-       }
 
        addr = RTL8366S_MIB_COUNTER_BASE + regoffset;
 
@@ -758,27 +761,19 @@ static int rtl8366s_set_vlan_member_config(struct rtl8366_smi *smi, u32 index,
 static int rtl8366_get_port_vlan_index(struct rtl8366_smi *smi, int port,
                                       int *val)
 {
-       int err;
-       u32 addr;
        u32 data;
-
-       /* bits mapping to port vlan control register of port n */
-       const u16 bits[RTL8366_NUM_PORTS] = { 0x000F, 0x00F0, 0x0F00,
-                                            0xF000, 0x000F, 0x00F0 };
-       /* bits offset to port vlan control register of port n */
-       const u16 bitoffset[RTL8366_NUM_PORTS] = { 0, 4, 8, 12, 0, 4 };
-       /* address offset to port vlan control register of port n */
-       const u16 addroffset[RTL8366_NUM_PORTS] = { 0, 0, 0, 0, 1, 1 };
+       int err;
 
        if (port >= RTL8366_NUM_PORTS)
                return -EINVAL;
 
-       addr = RTL8366S_PORT_VLAN_CTRL_BASE + addroffset[port];
-       err = rtl8366_smi_read_reg(smi, addr, &data);
+       err = rtl8366_smi_read_reg(smi, RTL8366S_PORT_VLAN_CTRL_REG(port),
+                                  &data);
        if (err)
                return err;
 
-       *val = (data & bits[port]) >> bitoffset[port];
+       *val = (data >> RTL8366S_PORT_VLAN_CTRL_SHIFT(port)) &
+              RTL8366S_PORT_VLAN_CTRL_MASK;
 
        return 0;
 
@@ -806,41 +801,25 @@ static int rtl8366_get_vlan_port_pvid(struct rtl8366_smi *smi, int port,
 static int rtl8366_set_port_vlan_index(struct rtl8366_smi *smi, int port,
                                       int index)
 {
-       int err;
-       u32 addr;
        u32 data;
-       u32 vlan_data;
-       u32 bits;
-
-       /* bits mapping to port vlan control register of port n */
-       const u16 bitmasks[6] = { 0x000F, 0x00F0, 0x0F00,
-                                0xF000, 0x000F, 0x00F0 };
-       /* bits offset to port vlan control register of port n */
-       const u16 bitOff[6] = { 0, 4, 8, 12, 0, 4 };
-       /* address offset to port vlan control register of port n */
-       const u16 addrOff[6] = { 0, 0, 0, 0, 1, 1 };
+       int err;
 
        if (port >= RTL8366_NUM_PORTS || index >= RTL8366_NUM_VLANS)
                return -EINVAL;
 
-       addr = RTL8366S_PORT_VLAN_CTRL_BASE + addrOff[port];
-
-       bits = bitmasks[port];
-
-       data = (index << bitOff[port]) & bits;
-
-       err = rtl8366_smi_read_reg(smi, addr, &vlan_data);
+       err = rtl8366_smi_read_reg(smi, RTL8366S_PORT_VLAN_CTRL_REG(port),
+                                  &data);
        if (err)
                return err;
 
-       vlan_data &= ~(vlan_data & bits);
-       vlan_data |= data;
-
-       err = rtl8366_smi_write_reg(smi, addr, vlan_data);
-       if (err)
-               return err;
+       data &= ~(RTL8366S_PORT_VLAN_CTRL_MASK <<
+                 RTL8366S_PORT_VLAN_CTRL_SHIFT(port));
+       data |= (index & RTL8366S_PORT_VLAN_CTRL_MASK) <<
+                RTL8366S_PORT_VLAN_CTRL_SHIFT(port);
 
-       return 0;
+       err = rtl8366_smi_write_reg(smi, RTL8366S_PORT_VLAN_CTRL_REG(port),
+                                   data);
+       return err;
 }
 
 static int rtl8366_set_vlan_port_pvid(struct rtl8366_smi *smi, int port,
@@ -905,7 +884,7 @@ static int rtl8366_set_vlan_port_pvid(struct rtl8366_smi *smi, int port,
                }
        }
 
-       dev_err(&smi->pdev->dev,
+       dev_err(smi->parent,
                "All 16 vlan member configurations are in use\n");
 
        return -EINVAL;
@@ -918,9 +897,10 @@ static int rtl8366_vlan_set_vlan(struct rtl8366_smi *smi, int enable)
 
        rtl8366_smi_read_reg(smi, RTL8366_CHIP_GLOBAL_CTRL_REG, &data);
 
-       data &= ~(data & RTL8366_CHIP_CTRL_VLAN);
        if (enable)
                data |= RTL8366_CHIP_CTRL_VLAN;
+       else
+               data &= ~RTL8366_CHIP_CTRL_VLAN;
 
        return rtl8366_smi_write_reg(smi, RTL8366_CHIP_GLOBAL_CTRL_REG, data);
 }
@@ -931,9 +911,10 @@ static int rtl8366_vlan_set_4ktable(struct rtl8366_smi *smi, int enable)
 
        rtl8366_smi_read_reg(smi, RTL8366S_VLAN_TB_CTRL_REG, &data);
 
-       data &= ~(data & 1);
        if (enable)
                data |= 1;
+       else
+               data &= ~1;
 
        return rtl8366_smi_write_reg(smi, RTL8366S_VLAN_TB_CTRL_REG, data);
 }
@@ -1107,7 +1088,7 @@ static ssize_t rtl8366_write_debugfs_reg(struct file *file,
 
        len = min(count, sizeof(smi->buf) - 1);
        if (copy_from_user(buf, user_buf, len)) {
-               dev_err(&smi->pdev->dev, "copy from user failed\n");
+               dev_err(smi->parent, "copy from user failed\n");
                return -EFAULT;
        }
 
@@ -1117,11 +1098,11 @@ static ssize_t rtl8366_write_debugfs_reg(struct file *file,
 
 
        if (strict_strtoul(buf, 16, &data)) {
-               dev_err(&smi->pdev->dev, "Invalid reg value %s\n", buf);
+               dev_err(smi->parent, "Invalid reg value %s\n", buf);
        } else {
                err = rtl8366_smi_write_reg(smi, reg, data);
                if (err) {
-                       dev_err(&smi->pdev->dev,
+                       dev_err(smi->parent,
                                "writing reg 0x%04x val 0x%04lx failed\n",
                                reg, data);
                }
@@ -1158,28 +1139,28 @@ static void rtl8366_debugfs_init(struct rtl8366_smi *smi)
                smi->debugfs_root = debugfs_create_dir("rtl8366s", NULL);
 
        if (!smi->debugfs_root) {
-               dev_err(&smi->pdev->dev, "Unable to create debugfs dir\n");
+               dev_err(smi->parent, "Unable to create debugfs dir\n");
                return;
        }
        root = smi->debugfs_root;
 
        node = debugfs_create_x16("reg", S_IRUGO | S_IWUSR, root, &g_dbg_reg);
        if (!node) {
-               dev_err(&smi->pdev->dev, "Creating debugfs file reg failed\n");
+               dev_err(smi->parent, "Creating debugfs file reg failed\n");
                return;
        }
 
        node = debugfs_create_file("val", S_IRUGO | S_IWUSR, root, smi,
                                   &fops_rtl8366_regs);
        if (!node) {
-               dev_err(&smi->pdev->dev, "Creating debugfs file val failed\n");
+               dev_err(smi->parent, "Creating debugfs file val failed\n");
                return;
        }
 
        node = debugfs_create_file("vlan", S_IRUSR, root, smi,
                                   &fops_rtl8366_vlan);
        if (!node) {
-               dev_err(&smi->pdev->dev,
+               dev_err(smi->parent,
                        "Creating debugfs file vlan failed\n");
                return;
        }
@@ -1187,7 +1168,7 @@ static void rtl8366_debugfs_init(struct rtl8366_smi *smi)
        node = debugfs_create_file("mibs", S_IRUSR, root, smi,
                                   &fops_rtl8366_mibs);
        if (!node) {
-               dev_err(&smi->pdev->dev,
+               dev_err(smi->parent,
                        "Creating debugfs file mibs failed\n");
                return;
        }
@@ -1206,9 +1187,9 @@ static inline void rtl8366_debugfs_init(struct rtl8366_smi *smi) {}
 static inline void rtl8366_debugfs_remove(struct rtl8366_smi *smi) {}
 #endif /* CONFIG_RTL8366_SMI_DEBUG_FS */
 
-static int rtl8366_global_reset_mibs(struct switch_dev *dev,
-                                    const struct switch_attr *attr,
-                                    struct switch_val *val)
+static int rtl8366_sw_reset_mibs(struct switch_dev *dev,
+                                const struct switch_attr *attr,
+                                struct switch_val *val)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
        u32 data = 0;
@@ -1222,9 +1203,9 @@ static int rtl8366_global_reset_mibs(struct switch_dev *dev,
        return 0;
 }
 
-static int rtl8366_get_vlan(struct switch_dev *dev,
-                           const struct switch_attr *attr,
-                           struct switch_val *val)
+static int rtl8366_sw_get_vlan_enable(struct switch_dev *dev,
+                                     const struct switch_attr *attr,
+                                     struct switch_val *val)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
        u32 data;
@@ -1248,9 +1229,9 @@ static int rtl8366_get_vlan(struct switch_dev *dev,
        return 0;
 }
 
-static int rtl8366_global_get_blinkrate(struct switch_dev *dev,
-                                       const struct switch_attr *attr,
-                                       struct switch_val *val)
+static int rtl8366_sw_get_blinkrate(struct switch_dev *dev,
+                                   const struct switch_attr *attr,
+                                   struct switch_val *val)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
        u32 data;
@@ -1262,9 +1243,9 @@ static int rtl8366_global_get_blinkrate(struct switch_dev *dev,
        return 0;
 }
 
-static int rtl8366_global_set_blinkrate(struct switch_dev *dev,
-                                       const struct switch_attr *attr,
-                                       struct switch_val *val)
+static int rtl8366_sw_set_blinkrate(struct switch_dev *dev,
+                                   const struct switch_attr *attr,
+                                   struct switch_val *val)
 {
        u32 data;
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
@@ -1274,7 +1255,7 @@ static int rtl8366_global_set_blinkrate(struct switch_dev *dev,
 
        rtl8366_smi_read_reg(smi, RTL8366_LED_BLINKRATE_REG, &data);
 
-       data &= ~(data & RTL8366_LED_BLINKRATE_MASK);
+       data &= ~RTL8366_LED_BLINKRATE_MASK;
        data |= val->value.i;
 
        rtl8366_smi_write_reg(smi, RTL8366_LED_BLINKRATE_REG, data);
@@ -1282,9 +1263,9 @@ static int rtl8366_global_set_blinkrate(struct switch_dev *dev,
        return 0;
 }
 
-static int rtl8366_set_vlan(struct switch_dev *dev,
-                           const struct switch_attr *attr,
-                           struct switch_val *val)
+static int rtl8366_sw_set_vlan_enable(struct switch_dev *dev,
+                                     const struct switch_attr *attr,
+                                     struct switch_val *val)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
 
@@ -1294,79 +1275,60 @@ static int rtl8366_set_vlan(struct switch_dev *dev,
                return rtl8366_vlan_set_4ktable(smi, val->value.i);
 }
 
-static int rtl8366_attr_get_port_link(struct switch_dev *dev,
-                                     const struct switch_attr *attr,
-                                     struct switch_val *val)
+static const char *rtl8366_speed_str(unsigned speed)
+{
+       switch (speed) {
+       case 0:
+               return "10baseT";
+       case 1:
+               return "100baseT";
+       case 2:
+               return "1000baseT";
+       }
+
+       return "unknown";
+}
+
+static int rtl8366_sw_get_port_link(struct switch_dev *dev,
+                                   const struct switch_attr *attr,
+                                   struct switch_val *val)
 {
-       u32 len = 0, data = 0;
-       int speed, duplex, link, txpause, rxpause, nway;
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
-       char *buf = smi->buf;
+       u32 len = 0, data = 0;
 
        if (val->port_vlan >= RTL8366_NUM_PORTS)
                return -EINVAL;
 
-       memset(buf, '\0', sizeof(smi->buf));
+       memset(smi->buf, '\0', sizeof(smi->buf));
        rtl8366_smi_read_reg(smi, RTL8366S_PORT_LINK_STATUS_BASE +
-                            (val->port_vlan >> 1),
-                            &data);
+                            (val->port_vlan / 2), &data);
 
-       if (val->port_vlan & 0x1)
+       if (val->port_vlan % 2)
                data = data >> 8;
 
-       speed = (data & RTL8366S_PORT_STATUS_SPEED_MASK);
-       duplex = (data & RTL8366S_PORT_STATUS_DUPLEX_MASK) >> 2;
-       link = (data & RTL8366S_PORT_STATUS_LINK_MASK) >> 4;
-       txpause = (data & RTL8366S_PORT_STATUS_TXPAUSE_MASK) >> 5;
-       rxpause = (data & RTL8366S_PORT_STATUS_RXPAUSE_MASK) >> 6;
-       nway = (data & RTL8366S_PORT_STATUS_AN_MASK) >> 7;
-
-       len += snprintf(buf + len, sizeof(smi->buf) - len, "Port %d: ",
-                       val->port_vlan);
-
-       if (link)
-               len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "Link UP, Speed: ");
-       else
-               len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "Link DOWN, Speed: ");
-
-       if (speed == 0)
-               len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "10Base-TX ");
-       else if (speed == 1)
-               len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "100Base-TX ");
-       else if (speed == 2)
-               len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "1000Base-TX ");
-
-       if (duplex)
-               len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "Full-Duplex, ");
-       else
-               len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "Half-Duplex, ");
-
-       if (txpause)
-               len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "TX-Pause ");
-       if (rxpause)
-               len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "RX-Pause ");
-       if (nway)
-               len += snprintf(buf + len, sizeof(smi->buf) - len,
-                               "nway ");
-
-       val->value.s = buf;
+       len = snprintf(smi->buf, sizeof(smi->buf),
+                       "port:%d link:%s speed:%s %s-duplex %s%s%s",
+                       val->port_vlan,
+                       (data & RTL8366S_PORT_STATUS_LINK_MASK) ? "up" : "down",
+                       rtl8366_speed_str(data &
+                                         RTL8366S_PORT_STATUS_SPEED_MASK),
+                       (data & RTL8366S_PORT_STATUS_DUPLEX_MASK) ?
+                               "full" : "half",
+                       (data & RTL8366S_PORT_STATUS_TXPAUSE_MASK) ?
+                               "tx-pause ": "",
+                       (data & RTL8366S_PORT_STATUS_RXPAUSE_MASK) ?
+                               "rx-pause " : "",
+                       (data & RTL8366S_PORT_STATUS_AN_MASK) ? "nway ": "");
+
+       val->value.s = smi->buf;
        val->len = len;
 
        return 0;
 }
 
-static int rtl8366_attr_get_vlan_info(struct switch_dev *dev,
-                                     const struct switch_attr *attr,
-                                     struct switch_val *val)
+static int rtl8366_sw_get_vlan_info(struct switch_dev *dev,
+                                   const struct switch_attr *attr,
+                                   struct switch_val *val)
 {
        int i;
        u32 len = 0;
@@ -1413,9 +1375,9 @@ static int rtl8366_attr_get_vlan_info(struct switch_dev *dev,
        return 0;
 }
 
-static int rtl8366_set_port_led(struct switch_dev *dev,
-                               const struct switch_attr *attr,
-                               struct switch_val *val)
+static int rtl8366_sw_set_port_led(struct switch_dev *dev,
+                                  const struct switch_attr *attr,
+                                  struct switch_val *val)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
        u32 data = 0;
@@ -1438,9 +1400,9 @@ static int rtl8366_set_port_led(struct switch_dev *dev,
        return 0;
 }
 
-static int rtl8366_get_port_led(struct switch_dev *dev,
-                               const struct switch_attr *attr,
-                               struct switch_val *val)
+static int rtl8366_sw_get_port_led(struct switch_dev *dev,
+                                  const struct switch_attr *attr,
+                                  struct switch_val *val)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
        u32 data = 0;
@@ -1454,9 +1416,9 @@ static int rtl8366_get_port_led(struct switch_dev *dev,
        return 0;
 }
 
-static int rtl8366_reset_port_mibs(struct switch_dev *dev,
-                                  const struct switch_attr *attr,
-                                  struct switch_val *val)
+static int rtl8366_sw_reset_port_mibs(struct switch_dev *dev,
+                                     const struct switch_attr *attr,
+                                     struct switch_val *val)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
        u32 data = 0;
@@ -1471,9 +1433,9 @@ static int rtl8366_reset_port_mibs(struct switch_dev *dev,
        return 0;
 }
 
-static int rtl8366_get_port_mib(struct switch_dev *dev,
-                               const struct switch_attr *attr,
-                               struct switch_val *val)
+static 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(dev);
        int i, len = 0;
@@ -1503,8 +1465,8 @@ static int rtl8366_get_port_mib(struct switch_dev *dev,
        return 0;
 }
 
-static int rtl8366_get_ports(struct switch_dev *dev,
-                            struct switch_val *val)
+static int rtl8366_sw_get_vlan_ports(struct switch_dev *dev,
+                                    struct switch_val *val)
 {
        struct rtl8366s_vlanconfig vlanmc;
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
@@ -1531,8 +1493,8 @@ static int rtl8366_get_ports(struct switch_dev *dev,
        return 0;
 }
 
-static int rtl8366_set_ports(struct switch_dev *dev,
-                            struct switch_val *val)
+static int rtl8366_sw_set_vlan_ports(struct switch_dev *dev,
+                                    struct switch_val *val)
 {
        struct rtl8366s_vlanconfig vlanmc;
        struct rtl8366s_vlan4kentry vlan4k;
@@ -1565,19 +1527,19 @@ static int rtl8366_set_ports(struct switch_dev *dev,
        return 0;
 }
 
-static int rtl8366_get_port_pvid(struct switch_dev *dev, int port, int *val)
+static int rtl8366_sw_get_port_pvid(struct switch_dev *dev, int port, int *val)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
        return rtl8366_get_vlan_port_pvid(smi, port, val);
 }
 
-static int rtl8366_set_port_pvid(struct switch_dev *dev, int port, int val)
+static int rtl8366_sw_set_port_pvid(struct switch_dev *dev, int port, int val)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
        return rtl8366_set_vlan_port_pvid(smi, port, val);
 }
 
-static int rtl8366_reset_switch(struct switch_dev *dev)
+static int rtl8366_sw_reset_switch(struct switch_dev *dev)
 {
        struct rtl8366_smi *smi = sw_to_rtl8366(dev);
        int timeout = 10;
@@ -1607,23 +1569,23 @@ static struct switch_attr rtl8366_globals[] = {
                .type = SWITCH_TYPE_INT,
                .name = "enable_vlan",
                .description = "Enable VLAN mode",
-               .set = rtl8366_set_vlan,
-               .get = rtl8366_get_vlan,
+               .set = rtl8366_sw_set_vlan_enable,
+               .get = rtl8366_sw_get_vlan_enable,
                .max = 1,
                .ofs = 1
        }, {
                .type = SWITCH_TYPE_INT,
                .name = "enable_vlan4k",
                .description = "Enable VLAN 4K mode",
-               .set = rtl8366_set_vlan,
-               .get = rtl8366_get_vlan,
+               .set = rtl8366_sw_set_vlan_enable,
+               .get = rtl8366_sw_get_vlan_enable,
                .max = 1,
                .ofs = 2
        }, {
                .type = SWITCH_TYPE_INT,
                .name = "reset_mibs",
                .description = "Reset all MIB counters",
-               .set = rtl8366_global_reset_mibs,
+               .set = rtl8366_sw_reset_mibs,
                .get = NULL,
                .max = 1
        }, {
@@ -1631,8 +1593,8 @@ static struct switch_attr rtl8366_globals[] = {
                .name = "blinkrate",
                .description = "Get/Set LED blinking rate (0 = 43ms, 1 = 84ms,"
                " 2 = 120ms, 3 = 170ms, 4 = 340ms, 5 = 670ms)",
-               .set = rtl8366_global_set_blinkrate,
-               .get = rtl8366_global_get_blinkrate,
+               .set = rtl8366_sw_set_blinkrate,
+               .get = rtl8366_sw_get_blinkrate,
                .max = 5
        },
 };
@@ -1644,28 +1606,28 @@ static struct switch_attr rtl8366_port[] = {
                .description = "Get port link information",
                .max = 1,
                .set = NULL,
-               .get = rtl8366_attr_get_port_link
+               .get = rtl8366_sw_get_port_link,
        }, {
                .type = SWITCH_TYPE_INT,
                .name = "reset_mib",
                .description = "Reset single port MIB counters",
                .max = 1,
-               .set = rtl8366_reset_port_mibs,
-               .get = NULL
+               .set = rtl8366_sw_reset_port_mibs,
+               .get = NULL,
        }, {
                .type = SWITCH_TYPE_STRING,
                .name = "mib",
                .description = "Get MIB counters for port",
                .max = 33,
                .set = NULL,
-               .get = rtl8366_get_port_mib
+               .get = rtl8366_sw_get_port_mib,
        }, {
                .type = SWITCH_TYPE_INT,
                .name = "led",
                .description = "Get/Set port group (0 - 3) led mode (0 - 15)",
                .max = 15,
-               .set = rtl8366_set_port_led,
-               .get = rtl8366_get_port_led
+               .set = rtl8366_sw_set_port_led,
+               .get = rtl8366_sw_get_port_led,
        },
 };
 
@@ -1676,7 +1638,7 @@ static struct switch_attr rtl8366_vlan[] = {
                .description = "Get vlan information",
                .max = 1,
                .set = NULL,
-               .get = rtl8366_attr_get_vlan_info
+               .get = rtl8366_sw_get_vlan_info,
        },
 };
 
@@ -1700,11 +1662,11 @@ static struct switch_dev rtldev = {
                .n_attr = ARRAY_SIZE(rtl8366_vlan),
        },
 
-       .get_vlan_ports = rtl8366_get_ports,
-       .set_vlan_ports = rtl8366_set_ports,
-       .get_port_pvid = rtl8366_get_port_pvid,
-       .set_port_pvid = rtl8366_set_port_pvid,
-       .reset_switch = rtl8366_reset_switch,
+       .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 = rtl8366_sw_reset_switch,
 };
 
 static int rtl8366_smi_switch_init(struct rtl8366_smi *smi)
@@ -1714,11 +1676,11 @@ static int rtl8366_smi_switch_init(struct rtl8366_smi *smi)
 
        memcpy(dev, &rtldev, sizeof(struct switch_dev));
        dev->priv = smi;
-       dev->devname = dev_name(&smi->pdev->dev);
+       dev->devname = dev_name(smi->parent);
 
        err = register_switch(dev, NULL);
        if (err)
-               dev_err(&smi->pdev->dev, "switch registration failed\n");
+               dev_err(smi->parent, "switch registration failed\n");
 
        return err;
 }
@@ -1772,8 +1734,8 @@ static int rtl8366_smi_mii_init(struct rtl8366_smi *smi)
        smi->mii_bus->read = rtl8366_smi_mii_read;
        smi->mii_bus->write = rtl8366_smi_mii_write;
        snprintf(smi->mii_bus->id, MII_BUS_ID_SIZE, "%s",
-                       dev_name(&smi->pdev->dev));
-       smi->mii_bus->parent = &smi->pdev->dev;
+                       dev_name(smi->parent));
+       smi->mii_bus->parent = smi->parent;
        smi->mii_bus->phy_mask = ~(0x1f);
        smi->mii_bus->irq = smi->mii_irq;
        for (i = 0; i < PHY_MAX_ADDR; i++)
@@ -1811,7 +1773,7 @@ static int rtl8366_smi_setup(struct rtl8366_smi *smi)
 
        ret = rtl8366_smi_read_reg(smi, RTL8366S_CHIP_ID_REG, &chip_id);
        if (ret) {
-               dev_err(&smi->pdev->dev, "unable to read chip id\n");
+               dev_err(smi->parent, "unable to read chip id\n");
                return ret;
        }
 
@@ -1819,18 +1781,18 @@ static int rtl8366_smi_setup(struct rtl8366_smi *smi)
        case RTL8366S_CHIP_ID_8366:
                break;
        default:
-               dev_err(&smi->pdev->dev, "unknown chip id (%04x)\n", chip_id);
+               dev_err(smi->parent, "unknown chip id (%04x)\n", chip_id);
                return -ENODEV;
        }
 
        ret = rtl8366_smi_read_reg(smi, RTL8366S_CHIP_VERSION_CTRL_REG,
                                   &chip_ver);
        if (ret) {
-               dev_err(&smi->pdev->dev, "unable to read chip version\n");
+               dev_err(smi->parent, "unable to read chip version\n");
                return ret;
        }
 
-       dev_info(&smi->pdev->dev, "RTL%04x ver. %u chip found\n",
+       dev_info(smi->parent, "RTL%04x ver. %u chip found\n",
                 chip_id, chip_ver & RTL8366S_CHIP_VERSION_MASK);
 
        rtl8366_debugfs_init(smi);
@@ -1877,7 +1839,7 @@ static int __init rtl8366_smi_probe(struct platform_device *pdev)
                goto err_free_sda;
        }
 
-       smi->pdev = pdev;
+       smi->parent = &pdev->dev;
        smi->pdata = pdata;
        spin_lock_init(&smi->lock);
 
@@ -1913,7 +1875,7 @@ static int __init rtl8366_smi_probe(struct platform_device *pdev)
        return err;
 }
 
-int rtl8366_phy_config_init(struct phy_device *phydev)
+static int rtl8366_phy_config_init(struct phy_device *phydev)
 {
        if (!rtl8366_smi_mii_bus_match(phydev->bus))
                return -EINVAL;
@@ -1921,7 +1883,7 @@ int rtl8366_phy_config_init(struct phy_device *phydev)
        return 0;
 }
 
-int rtl8366_phy_config_aneg(struct phy_device *phydev)
+static int rtl8366_phy_config_aneg(struct phy_device *phydev)
 {
        return 0;
 }
This page took 0.057796 seconds and 4 git commands to generate.