summaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-03-07 16:32:40 +0000
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-03-07 16:32:40 +0000
commitb1fa0c1a379d37f78be2318a2f5def3603c32f55 (patch)
tree5d38e1d491b1dab2123cd4013b45dc7a40f12d45 /target/linux
parent1f9f2939368da9e3536de7ba2af5cb1a491fcaf2 (diff)
generic: rtl8367: use the generic get_port_link implementation
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@30844 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8367.c75
1 files changed, 28 insertions, 47 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367.c b/target/linux/generic/files/drivers/net/phy/rtl8367.c
index 152b06a95..917976e30 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8367.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8367.c
@@ -1376,56 +1376,43 @@ static int rtl8367_sw_reset_mibs(struct switch_dev *dev,
RTL8367_MIB_CTRL_GLOBAL_RESET_MASK);
}
-static const char *rtl8367_speed_str(unsigned speed)
-{
- switch (speed) {
- case RTL8367_PORT_STATUS_SPEED_10:
- return "10baseT";
- case RTL8367_PORT_STATUS_SPEED_100:
- return "100baseT";
- case RTL8367_PORT_STATUS_SPEED_1000:
- return "1000baseT";
- }
-
- return "unknown";
-}
-
static int rtl8367_sw_get_port_link(struct switch_dev *dev,
- const struct switch_attr *attr,
- struct switch_val *val)
+ int port,
+ struct switch_port_link *link)
{
struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
- u32 len = 0, data = 0;
- int port;
+ u32 data = 0;
+ u32 speed;
- port = val->port_vlan;
if (port >= RTL8367_NUM_PORTS)
return -EINVAL;
- memset(smi->buf, '\0', sizeof(smi->buf));
rtl8366_smi_read_reg(smi, RTL8367_PORT_STATUS_REG(port), &data);
- if (data & RTL8367_PORT_STATUS_LINK) {
- len = snprintf(smi->buf, sizeof(smi->buf),
- "port:%d link:up speed:%s %s-duplex %s%s%s",
- port,
- rtl8367_speed_str(data &
- RTL8367_PORT_STATUS_SPEED_MASK),
- (data & RTL8367_PORT_STATUS_DUPLEX) ?
- "full" : "half",
- (data & RTL8367_PORT_STATUS_TXPAUSE) ?
- "tx-pause ": "",
- (data & RTL8367_PORT_STATUS_RXPAUSE) ?
- "rx-pause " : "",
- (data & RTL8367_PORT_STATUS_NWAY) ?
- "nway ": "");
- } else {
- len = snprintf(smi->buf, sizeof(smi->buf), "port:%d link:down",
- port);
- }
+ link->link = !!(data & RTL8367_PORT_STATUS_LINK);
+ if (!link->link)
+ return 0;
- val->value.s = smi->buf;
- val->len = len;
+ link->duplex = !!(data & RTL8367_PORT_STATUS_DUPLEX);
+ link->rx_flow = !!(data & RTL8367_PORT_STATUS_RXPAUSE);
+ link->tx_flow = !!(data & RTL8367_PORT_STATUS_TXPAUSE);
+ link->aneg = !!(data & RTL8367_PORT_STATUS_NWAY);
+
+ speed = (data & RTL8367_PORT_STATUS_SPEED_MASK);
+ switch (speed) {
+ case 0:
+ link->speed = SWITCH_PORT_SPEED_10;
+ break;
+ case 1:
+ link->speed = SWITCH_PORT_SPEED_100;
+ break;
+ case 2:
+ link->speed = SWITCH_PORT_SPEED_1000;
+ break;
+ default:
+ link->speed = SWITCH_PORT_SPEED_UNKNOWN;
+ break;
+ }
return 0;
}
@@ -1548,13 +1535,6 @@ static struct switch_attr rtl8367_globals[] = {
static struct switch_attr rtl8367_port[] = {
{
- .type = SWITCH_TYPE_STRING,
- .name = "link",
- .description = "Get port link information",
- .max = 1,
- .set = NULL,
- .get = rtl8367_sw_get_port_link,
- }, {
.type = SWITCH_TYPE_NOVAL,
.name = "reset_mib",
.description = "Reset single port MIB counters",
@@ -1599,6 +1579,7 @@ static const struct switch_dev_ops rtl8366m_ops = {
.get_port_pvid = rtl8366_sw_get_port_pvid,
.set_port_pvid = rtl8366_sw_set_port_pvid,
.reset_switch = rtl8367_sw_reset_switch,
+ .get_port_link = rtl8367_sw_get_port_link,
};
static int rtl8367_switch_init(struct rtl8366_smi *smi)