aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorWey-Yi Guy <wey-yi.w.guy@intel.com>2009-11-20 12:05:00 -0800
committerJohn W. Linville <linville@tuxdriver.com>2009-11-23 17:05:34 -0500
commit2943f136ffe29adb08162197b129bf8106e8191c (patch)
tree9fb6a22a316588f3756b859f299de87e7e454b98 /drivers
parentd23db556819c00d297c0f447bdd75b282d563122 (diff)
iwlwifi: dynamically allocate buffer for sram debugfs file
Dynamically allocate memory for dumping SRAM based on the length of memory to be displayed. Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 4630094b4ca..016ff4014a7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -228,13 +228,21 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
size_t count, loff_t *ppos)
{
u32 val;
- char buf[1024];
+ char *buf;
ssize_t ret;
int i;
int pos = 0;
struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
- const size_t bufsz = sizeof(buf);
+ size_t bufsz;
+ bufsz = 30 + priv->dbgfs->sram_len * sizeof(char) * 12;
+ buf = kmalloc(bufsz, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+ pos += scnprintf(buf + pos, bufsz - pos, "sram_len: %d\n",
+ priv->dbgfs->sram_len);
+ pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: %d\n",
+ priv->dbgfs->sram_offset);
for (i = priv->dbgfs->sram_len; i > 0; i -= 4) {
val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \
priv->dbgfs->sram_len - i);
@@ -251,11 +259,14 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
break;
}
}
+ if (!(i % 16))
+ pos += scnprintf(buf + pos, bufsz - pos, "\n");
pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val);
}
pos += scnprintf(buf + pos, bufsz - pos, "\n");
ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+ kfree(buf);
return ret;
}