aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-03-07 16:32:40 +0000
committerGabor Juhos <juhosg@openwrt.org>2012-03-07 16:32:40 +0000
commit215e07177eb8e710a2e13988c54184406f95d64d (patch)
tree03b2b76ab6f3d829d086a715b48881039f9ee160 /target/linux/generic
parent9e1be3b80964c844201442170e8bb1fbb6c2205b (diff)
downloadupstream-215e07177eb8e710a2e13988c54184406f95d64d.tar.gz
upstream-215e07177eb8e710a2e13988c54184406f95d64d.tar.bz2
upstream-215e07177eb8e710a2e13988c54184406f95d64d.zip
generic: rtl8367: use the generic get_port_link implementation
SVN-Revision: 30844
Diffstat (limited to 'target/linux/generic')
-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 152b06a956..917976e302 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)