Commit 60191d99 authored by Johannes Berg's avatar Johannes Berg

iwlwifi: mvm: don't store section offset/length in debugfs

When different images can (soon) be accessed through this
file, storing the section offset/length on first access to
the file breaks (or needs manual reset). Avoid this by not
storing the offset/length values but using them locally in
the function only. That way, the correct values are always
used.

While at it, correct the check that firmware is loaded.
Reviewed-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 4f59334b
...@@ -145,16 +145,18 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf, ...@@ -145,16 +145,18 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
char *buf; char *buf;
u8 *ptr; u8 *ptr;
if (!mvm->ucode_loaded)
return -EINVAL;
/* default is to dump the entire data segment */ /* default is to dump the entire data segment */
if (!mvm->dbgfs_sram_offset && !mvm->dbgfs_sram_len) { if (!mvm->dbgfs_sram_offset && !mvm->dbgfs_sram_len) {
if (!mvm->ucode_loaded)
return -EINVAL;
img = &mvm->fw->img[mvm->cur_ucode]; img = &mvm->fw->img[mvm->cur_ucode];
mvm->dbgfs_sram_offset = ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
img->sec[IWL_UCODE_SECTION_DATA].offset; len = img->sec[IWL_UCODE_SECTION_DATA].len;
mvm->dbgfs_sram_len = img->sec[IWL_UCODE_SECTION_DATA].len; } else {
ofs = mvm->dbgfs_sram_offset;
len = mvm->dbgfs_sram_len;
} }
len = mvm->dbgfs_sram_len;
bufsz = len * 4 + 256; bufsz = len * 4 + 256;
buf = kzalloc(bufsz, GFP_KERNEL); buf = kzalloc(bufsz, GFP_KERNEL);
...@@ -168,12 +170,9 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf, ...@@ -168,12 +170,9 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
} }
pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", len); pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", len);
pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", ofs);
mvm->dbgfs_sram_offset);
iwl_trans_read_mem_bytes(mvm->trans, iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len);
mvm->dbgfs_sram_offset,
ptr, len);
for (ofs = 0; ofs < len; ofs += 16) { for (ofs = 0; ofs < len; ofs += 16) {
pos += scnprintf(buf + pos, bufsz - pos, "0x%.4x ", ofs); pos += scnprintf(buf + pos, bufsz - pos, "0x%.4x ", ofs);
hex_dump_to_buffer(ptr + ofs, 16, 16, 1, buf + pos, hex_dump_to_buffer(ptr + ofs, 16, 16, 1, buf + pos,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment