diff options
author | Wey-Yi Guy <wey-yi.w.guy@intel.com> | 2009-11-20 15:05:00 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-11-23 17:05:34 -0500 |
commit | 2943f136ffe29adb08162197b129bf8106e8191c (patch) | |
tree | 9fb6a22a316588f3756b859f299de87e7e454b98 | |
parent | d23db556819c00d297c0f447bdd75b282d563122 (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>
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-debugfs.c | 15 |
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 4630094b4ca1..016ff4014a7b 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, | |||
228 | size_t count, loff_t *ppos) | 228 | size_t count, loff_t *ppos) |
229 | { | 229 | { |
230 | u32 val; | 230 | u32 val; |
231 | char buf[1024]; | 231 | char *buf; |
232 | ssize_t ret; | 232 | ssize_t ret; |
233 | int i; | 233 | int i; |
234 | int pos = 0; | 234 | int pos = 0; |
235 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; | 235 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
236 | const size_t bufsz = sizeof(buf); | 236 | size_t bufsz; |
237 | 237 | ||
238 | bufsz = 30 + priv->dbgfs->sram_len * sizeof(char) * 12; | ||
239 | buf = kmalloc(bufsz, GFP_KERNEL); | ||
240 | if (!buf) | ||
241 | return -ENOMEM; | ||
242 | pos += scnprintf(buf + pos, bufsz - pos, "sram_len: %d\n", | ||
243 | priv->dbgfs->sram_len); | ||
244 | pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: %d\n", | ||
245 | priv->dbgfs->sram_offset); | ||
238 | for (i = priv->dbgfs->sram_len; i > 0; i -= 4) { | 246 | for (i = priv->dbgfs->sram_len; i > 0; i -= 4) { |
239 | val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \ | 247 | val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \ |
240 | priv->dbgfs->sram_len - i); | 248 | priv->dbgfs->sram_len - i); |
@@ -251,11 +259,14 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, | |||
251 | break; | 259 | break; |
252 | } | 260 | } |
253 | } | 261 | } |
262 | if (!(i % 16)) | ||
263 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); | ||
254 | pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); | 264 | pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); |
255 | } | 265 | } |
256 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); | 266 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
257 | 267 | ||
258 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | 268 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
269 | kfree(buf); | ||
259 | return ret; | 270 | return ret; |
260 | } | 271 | } |
261 | 272 | ||