aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2011-05-07 12:40:26 +0000
committerGabor Juhos <juhosg@openwrt.org>2011-05-07 12:40:26 +0000
commit3c6c9f58665024f7a3fcca1db765e9d490fe49ef (patch)
treeae63667c05e7f5d3913b7b3623ffc0f0c2681a24
parent24b135c75c639335b9616ae961dac09fd54df374 (diff)
downloadupstream-3c6c9f58665024f7a3fcca1db765e9d490fe49ef.tar.gz
upstream-3c6c9f58665024f7a3fcca1db765e9d490fe49ef.tar.bz2
upstream-3c6c9f58665024f7a3fcca1db765e9d490fe49ef.zip
ar71xx: ag71xx: use dynamically allocated buffer for napi_stats
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@26843 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_debugfs.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_debugfs.c b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_debugfs.c
index eca0905218..47b7cbd84f 100644
--- a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_debugfs.c
+++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_debugfs.c
@@ -99,38 +99,48 @@ static ssize_t read_file_napi_stats(struct file *file, char __user *user_buf,
{
struct ag71xx *ag = file->private_data;
struct ag71xx_napi_stats *stats = &ag->debug.napi_stats;
- char buf[2048];
+ char *buf;
+ unsigned int buflen;
unsigned int len = 0;
unsigned long rx_avg = 0;
unsigned long tx_avg = 0;
+ int ret;
int i;
+ buflen = 2048;
+ buf = kmalloc(buflen, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
if (stats->rx_count)
rx_avg = stats->rx_packets / stats->rx_count;
if (stats->tx_count)
tx_avg = stats->tx_packets / stats->tx_count;
- len += snprintf(buf + len, sizeof(buf) - len, "%3s %10s %10s\n",
+ len += snprintf(buf + len, buflen - len, "%3s %10s %10s\n",
"len", "rx", "tx");
for (i = 1; i <= AG71XX_NAPI_WEIGHT; i++)
- len += snprintf(buf + len, sizeof(buf) - len,
+ len += snprintf(buf + len, buflen - len,
"%3d: %10lu %10lu\n",
i, stats->rx[i], stats->tx[i]);
- len += snprintf(buf + len, sizeof(buf) - len, "\n");
+ len += snprintf(buf + len, buflen - len, "\n");
- len += snprintf(buf + len, sizeof(buf) - len, "%3s: %10lu %10lu\n",
+ len += snprintf(buf + len, buflen - len, "%3s: %10lu %10lu\n",
"sum", stats->rx_count, stats->tx_count);
- len += snprintf(buf + len, sizeof(buf) - len, "%3s: %10lu %10lu\n",
+ len += snprintf(buf + len, buflen - len, "%3s: %10lu %10lu\n",
"avg", rx_avg, tx_avg);
- len += snprintf(buf + len, sizeof(buf) - len, "%3s: %10lu %10lu\n",
+ len += snprintf(buf + len, buflen - len, "%3s: %10lu %10lu\n",
"max", stats->rx_packets_max, stats->tx_packets_max);
- len += snprintf(buf + len, sizeof(buf) - len, "%3s: %10lu %10lu\n",
+ len += snprintf(buf + len, buflen - len, "%3s: %10lu %10lu\n",
"pkt", stats->rx_packets, stats->tx_packets);
- return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+ ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+ kfree(buf);
+
+ return ret;
}
static const struct file_operations ag71xx_fops_napi_stats = {