summaryrefslogtreecommitdiff
path: root/target/linux/generic
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2010-06-28 17:23:48 +0000
committerGabor Juhos <juhosg@openwrt.org>2010-06-28 17:23:48 +0000
commit19ed040c625eecf4442e36d6cff07f86e04f8f01 (patch)
tree3fd578e43a5e03ba3489a1fbdc04a730b827fdb2 /target/linux/generic
parent830b04bd726d2ed9a555b751347191056d3231a3 (diff)
downloadmtk-20170518-19ed040c625eecf4442e36d6cff07f86e04f8f01.zip
mtk-20170518-19ed040c625eecf4442e36d6cff07f86e04f8f01.tar.gz
mtk-20170518-19ed040c625eecf4442e36d6cff07f86e04f8f01.tar.bz2
generic: rtl8366: move buf to struct rtl8366_smi
SVN-Revision: 21980
Diffstat (limited to 'target/linux/generic')
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366_smi.h2
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366rb.c68
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366s.c68
3 files changed, 66 insertions, 72 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
index f111f2b..8639553 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
@@ -30,6 +30,8 @@ struct rtl8366_smi {
unsigned int num_vlan_mc;
struct rtl8366_smi_ops *ops;
+
+ char buf[4096];
};
struct rtl8366_vlan_mc {
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
index 02de055..0bab80a 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
@@ -164,7 +164,6 @@ struct rtl8366rb {
struct device *parent;
struct rtl8366_smi smi;
struct switch_dev dev;
- char buf[4096];
#ifdef CONFIG_RTL8366S_PHY_DEBUG_FS
struct dentry *debugfs_root;
#endif
@@ -699,30 +698,30 @@ static ssize_t rtl8366rb_read_debugfs_mibs(struct file *file,
struct rtl8366rb *rtl = (struct rtl8366rb *)file->private_data;
struct rtl8366_smi *smi = &rtl->smi;
int i, j, len = 0;
- char *buf = rtl->buf;
+ char *buf = smi->buf;
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"%-36s %12s %12s %12s %12s %12s %12s\n",
"Counter",
"Port 0", "Port 1", "Port 2",
"Port 3", "Port 4", "Port 5");
for (i = 0; i < ARRAY_SIZE(rtl8366rb_mib_counters); ++i) {
- len += snprintf(buf + len, sizeof(rtl->buf) - len, "%-36s ",
+ len += snprintf(buf + len, sizeof(smi->buf) - len, "%-36s ",
rtl8366rb_mib_counters[i].name);
for (j = 0; j < RTL8366RB_NUM_PORTS; ++j) {
unsigned long long counter = 0;
if (!rtl8366_get_mib_counter(smi, i, j, &counter))
len += snprintf(buf + len,
- sizeof(rtl->buf) - len,
+ sizeof(smi->buf) - len,
"%12llu ", counter);
else
len += snprintf(buf + len,
- sizeof(rtl->buf) - len,
+ sizeof(smi->buf) - len,
"%12s ", "error");
}
- len += snprintf(buf + len, sizeof(rtl->buf) - len, "\n");
+ len += snprintf(buf + len, sizeof(smi->buf) - len, "\n");
}
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
@@ -735,9 +734,9 @@ static ssize_t rtl8366rb_read_debugfs_vlan_mc(struct file *file,
struct rtl8366rb *rtl = (struct rtl8366rb *)file->private_data;
struct rtl8366_smi *smi = &rtl->smi;
int i, len = 0;
- char *buf = rtl->buf;
+ char *buf = smi->buf;
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"%2s %6s %4s %6s %6s %3s\n",
"id", "vid","prio", "member", "untag", "fid");
@@ -746,7 +745,7 @@ static ssize_t rtl8366rb_read_debugfs_vlan_mc(struct file *file,
rtl8366rb_get_vlan_mc(smi, i, &vlanmc);
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"%2d %6d %4d 0x%04x 0x%04x %3d\n",
i, vlanmc.vid, vlanmc.priority,
vlanmc.member, vlanmc.untag, vlanmc.fid);
@@ -763,18 +762,18 @@ static ssize_t rtl8366rb_read_debugfs_reg(struct file *file,
struct rtl8366_smi *smi = &rtl->smi;
u32 t, reg = gl_dbg_reg;
int err, len = 0;
- char *buf = rtl->buf;
+ char *buf = smi->buf;
- memset(buf, '\0', sizeof(rtl->buf));
+ memset(buf, '\0', sizeof(smi->buf));
err = rtl8366_smi_read_reg(smi, reg, &t);
if (err) {
- len += snprintf(buf, sizeof(rtl->buf),
+ len += snprintf(buf, sizeof(smi->buf),
"Read failed (reg: 0x%04x)\n", reg);
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}
- len += snprintf(buf, sizeof(rtl->buf), "reg = 0x%04x, val = 0x%04x\n",
+ len += snprintf(buf, sizeof(smi->buf), "reg = 0x%04x, val = 0x%04x\n",
reg, t);
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
@@ -790,9 +789,9 @@ static ssize_t rtl8366rb_write_debugfs_reg(struct file *file,
u32 reg = gl_dbg_reg;
int err;
size_t len;
- char *buf = rtl->buf;
+ char *buf = smi->buf;
- len = min(count, sizeof(rtl->buf) - 1);
+ len = min(count, sizeof(smi->buf) - 1);
if (copy_from_user(buf, user_buf, len)) {
dev_err(rtl->parent, "copy from user failed\n");
return -EFAULT;
@@ -993,14 +992,13 @@ static int rtl8366rb_sw_get_port_link(struct switch_dev *dev,
const struct switch_attr *attr,
struct switch_val *val)
{
- struct rtl8366rb *rtl = sw_to_rtl8366rb(dev);
- struct rtl8366_smi *smi = &rtl->smi;
+ struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
u32 len = 0, data = 0;
if (val->port_vlan >= RTL8366RB_NUM_PORTS)
return -EINVAL;
- memset(rtl->buf, '\0', sizeof(rtl->buf));
+ memset(smi->buf, '\0', sizeof(smi->buf));
rtl8366_smi_read_reg(smi, RTL8366RB_PORT_LINK_STATUS_BASE +
(val->port_vlan / 2), &data);
@@ -1008,7 +1006,7 @@ static int rtl8366rb_sw_get_port_link(struct switch_dev *dev,
data = data >> 8;
if (data & RTL8366RB_PORT_STATUS_LINK_MASK) {
- len = snprintf(rtl->buf, sizeof(rtl->buf),
+ len = snprintf(smi->buf, sizeof(smi->buf),
"port:%d link:up speed:%s %s-duplex %s%s%s",
val->port_vlan,
rtl8366rb_speed_str(data &
@@ -1022,11 +1020,11 @@ static int rtl8366rb_sw_get_port_link(struct switch_dev *dev,
(data & RTL8366RB_PORT_STATUS_AN_MASK) ?
"nway ": "");
} else {
- len = snprintf(rtl->buf, sizeof(rtl->buf), "port:%d link: down",
+ len = snprintf(smi->buf, sizeof(smi->buf), "port:%d link: down",
val->port_vlan);
}
- val->value.s = rtl->buf;
+ val->value.s = smi->buf;
val->len = len;
return 0;
@@ -1039,32 +1037,31 @@ static int rtl8366rb_sw_get_vlan_info(struct switch_dev *dev,
int i;
u32 len = 0;
struct rtl8366_vlan_4k vlan4k;
- struct rtl8366rb *rtl = sw_to_rtl8366rb(dev);
- struct rtl8366_smi *smi = &rtl->smi;
- char *buf = rtl->buf;
+ struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+ char *buf = smi->buf;
int err;
if (val->port_vlan == 0 || val->port_vlan >= RTL8366RB_NUM_VLANS)
return -EINVAL;
- memset(buf, '\0', sizeof(rtl->buf));
+ memset(buf, '\0', sizeof(smi->buf));
err = rtl8366rb_get_vlan_4k(smi, val->port_vlan, &vlan4k);
if (err)
return err;
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"VLAN %d: Ports: '", vlan4k.vid);
for (i = 0; i < RTL8366RB_NUM_PORTS; i++) {
if (!(vlan4k.member & (1 << i)))
continue;
- len += snprintf(buf + len, sizeof(rtl->buf) - len, "%d%s", i,
+ len += snprintf(buf + len, sizeof(smi->buf) - len, "%d%s", i,
(vlan4k.untag & (1 << i)) ? "" : "t");
}
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"', members=%04x, untag=%04x, fid=%u",
vlan4k.member, vlan4k.untag, vlan4k.fid);
@@ -1132,27 +1129,26 @@ static int rtl8366rb_sw_get_port_mib(struct switch_dev *dev,
const struct switch_attr *attr,
struct switch_val *val)
{
- struct rtl8366rb *rtl = sw_to_rtl8366rb(dev);
- struct rtl8366_smi *smi = &rtl->smi;
+ struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
int i, len = 0;
unsigned long long counter = 0;
- char *buf = rtl->buf;
+ char *buf = smi->buf;
if (val->port_vlan >= RTL8366RB_NUM_PORTS)
return -EINVAL;
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"Port %d MIB counters\n",
val->port_vlan);
for (i = 0; i < ARRAY_SIZE(rtl8366rb_mib_counters); ++i) {
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"%-36s: ", rtl8366rb_mib_counters[i].name);
if (!rtl8366_get_mib_counter(smi, i, val->port_vlan, &counter))
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"%llu\n", counter);
else
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"%s\n", "error");
}
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366s.c b/target/linux/generic/files/drivers/net/phy/rtl8366s.c
index 40c9c01..6e55ccd 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366s.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366s.c
@@ -170,7 +170,6 @@ struct rtl8366s {
struct device *parent;
struct rtl8366_smi smi;
struct switch_dev dev;
- char buf[4096];
#ifdef CONFIG_RTL8366S_PHY_DEBUG_FS
struct dentry *debugfs_root;
#endif
@@ -688,30 +687,30 @@ static ssize_t rtl8366s_read_debugfs_mibs(struct file *file,
struct rtl8366s *rtl = (struct rtl8366s *)file->private_data;
struct rtl8366_smi *smi = &rtl->smi;
int i, j, len = 0;
- char *buf = rtl->buf;
+ char *buf = smi->buf;
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"%-36s %12s %12s %12s %12s %12s %12s\n",
"Counter",
"Port 0", "Port 1", "Port 2",
"Port 3", "Port 4", "Port 5");
for (i = 0; i < ARRAY_SIZE(rtl8366s_mib_counters); ++i) {
- len += snprintf(buf + len, sizeof(rtl->buf) - len, "%-36s ",
+ len += snprintf(buf + len, sizeof(smi->buf) - len, "%-36s ",
rtl8366s_mib_counters[i].name);
for (j = 0; j < RTL8366S_NUM_PORTS; ++j) {
unsigned long long counter = 0;
if (!rtl8366_get_mib_counter(smi, i, j, &counter))
len += snprintf(buf + len,
- sizeof(rtl->buf) - len,
+ sizeof(smi->buf) - len,
"%12llu ", counter);
else
len += snprintf(buf + len,
- sizeof(rtl->buf) - len,
+ sizeof(smi->buf) - len,
"%12s ", "error");
}
- len += snprintf(buf + len, sizeof(rtl->buf) - len, "\n");
+ len += snprintf(buf + len, sizeof(smi->buf) - len, "\n");
}
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
@@ -724,9 +723,9 @@ static ssize_t rtl8366s_read_debugfs_vlan_mc(struct file *file,
struct rtl8366s *rtl = (struct rtl8366s *)file->private_data;
struct rtl8366_smi *smi = &rtl->smi;
int i, len = 0;
- char *buf = rtl->buf;
+ char *buf = smi->buf;
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"%2s %6s %4s %6s %6s %3s\n",
"id", "vid","prio", "member", "untag", "fid");
@@ -735,7 +734,7 @@ static ssize_t rtl8366s_read_debugfs_vlan_mc(struct file *file,
rtl8366s_get_vlan_mc(smi, i, &vlanmc);
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"%2d %6d %4d 0x%04x 0x%04x %3d\n",
i, vlanmc.vid, vlanmc.priority,
vlanmc.member, vlanmc.untag, vlanmc.fid);
@@ -752,18 +751,18 @@ static ssize_t rtl8366s_read_debugfs_reg(struct file *file,
struct rtl8366_smi *smi = &rtl->smi;
u32 t, reg = g_dbg_reg;
int err, len = 0;
- char *buf = rtl->buf;
+ char *buf = smi->buf;
- memset(buf, '\0', sizeof(rtl->buf));
+ memset(buf, '\0', sizeof(smi->buf));
err = rtl8366_smi_read_reg(smi, reg, &t);
if (err) {
- len += snprintf(buf, sizeof(rtl->buf),
+ len += snprintf(buf, sizeof(smi->buf),
"Read failed (reg: 0x%04x)\n", reg);
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}
- len += snprintf(buf, sizeof(rtl->buf), "reg = 0x%04x, val = 0x%04x\n",
+ len += snprintf(buf, sizeof(smi->buf), "reg = 0x%04x, val = 0x%04x\n",
reg, t);
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
@@ -779,9 +778,9 @@ static ssize_t rtl8366s_write_debugfs_reg(struct file *file,
u32 reg = g_dbg_reg;
int err;
size_t len;
- char *buf = rtl->buf;
+ char *buf = smi->buf;
- len = min(count, sizeof(rtl->buf) - 1);
+ len = min(count, sizeof(smi->buf) - 1);
if (copy_from_user(buf, user_buf, len)) {
dev_err(rtl->parent, "copy from user failed\n");
return -EFAULT;
@@ -981,14 +980,13 @@ static int rtl8366s_sw_get_port_link(struct switch_dev *dev,
const struct switch_attr *attr,
struct switch_val *val)
{
- struct rtl8366s *rtl = sw_to_rtl8366s(dev);
- struct rtl8366_smi *smi = &rtl->smi;
+ struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
u32 len = 0, data = 0;
if (val->port_vlan >= RTL8366S_NUM_PORTS)
return -EINVAL;
- memset(rtl->buf, '\0', sizeof(rtl->buf));
+ memset(smi->buf, '\0', sizeof(smi->buf));
rtl8366_smi_read_reg(smi, RTL8366S_PORT_LINK_STATUS_BASE +
(val->port_vlan / 2), &data);
@@ -996,7 +994,7 @@ static int rtl8366s_sw_get_port_link(struct switch_dev *dev,
data = data >> 8;
if (data & RTL8366S_PORT_STATUS_LINK_MASK) {
- len = snprintf(rtl->buf, sizeof(rtl->buf),
+ len = snprintf(smi->buf, sizeof(smi->buf),
"port:%d link:up speed:%s %s-duplex %s%s%s",
val->port_vlan,
rtl8366s_speed_str(data &
@@ -1010,11 +1008,11 @@ static int rtl8366s_sw_get_port_link(struct switch_dev *dev,
(data & RTL8366S_PORT_STATUS_AN_MASK) ?
"nway ": "");
} else {
- len = snprintf(rtl->buf, sizeof(rtl->buf), "port:%d link: down",
+ len = snprintf(smi->buf, sizeof(smi->buf), "port:%d link: down",
val->port_vlan);
}
- val->value.s = rtl->buf;
+ val->value.s = smi->buf;
val->len = len;
return 0;
@@ -1027,32 +1025,31 @@ static int rtl8366s_sw_get_vlan_info(struct switch_dev *dev,
int i;
u32 len = 0;
struct rtl8366_vlan_4k vlan4k;
- struct rtl8366s *rtl = sw_to_rtl8366s(dev);
- struct rtl8366_smi *smi = &rtl->smi;
- char *buf = rtl->buf;
+ struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+ char *buf = smi->buf;
int err;
if (val->port_vlan == 0 || val->port_vlan >= RTL8366S_NUM_VLANS)
return -EINVAL;
- memset(buf, '\0', sizeof(rtl->buf));
+ memset(buf, '\0', sizeof(smi->buf));
err = rtl8366s_get_vlan_4k(smi, val->port_vlan, &vlan4k);
if (err)
return err;
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"VLAN %d: Ports: '", vlan4k.vid);
for (i = 0; i < RTL8366S_NUM_PORTS; i++) {
if (!(vlan4k.member & (1 << i)))
continue;
- len += snprintf(buf + len, sizeof(rtl->buf) - len, "%d%s", i,
+ len += snprintf(buf + len, sizeof(smi->buf) - len, "%d%s", i,
(vlan4k.untag & (1 << i)) ? "" : "t");
}
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"', members=%04x, untag=%04x, fid=%u",
vlan4k.member, vlan4k.untag, vlan4k.fid);
@@ -1122,27 +1119,26 @@ static int rtl8366s_sw_get_port_mib(struct switch_dev *dev,
const struct switch_attr *attr,
struct switch_val *val)
{
- struct rtl8366s *rtl = sw_to_rtl8366s(dev);
- struct rtl8366_smi *smi = &rtl->smi;
+ struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
int i, len = 0;
unsigned long long counter = 0;
- char *buf = rtl->buf;
+ char *buf = smi->buf;
if (val->port_vlan >= RTL8366S_NUM_PORTS)
return -EINVAL;
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ 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) {
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ 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))
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"%llu\n", counter);
else
- len += snprintf(buf + len, sizeof(rtl->buf) - len,
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
"%s\n", "error");
}