Commit c76c8309 authored by Johannes Berg's avatar Johannes Berg Committed by Luca Coelho

iwlwifi: dbg-tlv: clean up iwl_dbg_tlv_update_drams()

This function puts a fairly large structure unnecessarily
on the stack, and also has a few other very strange things,
clean it up a bit.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220130115024.9f2c282a3104.If6b868c96c0d089579ca72fd270387de81359d5b@changeidSigned-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
parent 872f6bb0
...@@ -769,33 +769,40 @@ static int iwl_dbg_tlv_update_dram(struct iwl_fw_runtime *fwrt, ...@@ -769,33 +769,40 @@ static int iwl_dbg_tlv_update_dram(struct iwl_fw_runtime *fwrt,
static void iwl_dbg_tlv_update_drams(struct iwl_fw_runtime *fwrt) static void iwl_dbg_tlv_update_drams(struct iwl_fw_runtime *fwrt)
{ {
int ret, i, dram_alloc = 0; int ret, i;
struct iwl_dram_info dram_info; bool dram_alloc = false;
struct iwl_dram_data *frags = struct iwl_dram_data *frags =
&fwrt->trans->dbg.fw_mon_ini[IWL_FW_INI_ALLOCATION_ID_DBGC1].frags[0]; &fwrt->trans->dbg.fw_mon_ini[IWL_FW_INI_ALLOCATION_ID_DBGC1].frags[0];
struct iwl_dram_info *dram_info;
if (!frags || !frags->block)
return;
dram_info = frags->block;
if (!fw_has_capa(&fwrt->fw->ucode_capa, if (!fw_has_capa(&fwrt->fw->ucode_capa,
IWL_UCODE_TLV_CAPA_DRAM_FRAG_SUPPORT)) IWL_UCODE_TLV_CAPA_DRAM_FRAG_SUPPORT))
return; return;
dram_info.first_word = cpu_to_le32(DRAM_INFO_FIRST_MAGIC_WORD); dram_info->first_word = cpu_to_le32(DRAM_INFO_FIRST_MAGIC_WORD);
dram_info.second_word = cpu_to_le32(DRAM_INFO_SECOND_MAGIC_WORD); dram_info->second_word = cpu_to_le32(DRAM_INFO_SECOND_MAGIC_WORD);
for (i = IWL_FW_INI_ALLOCATION_ID_DBGC1; for (i = IWL_FW_INI_ALLOCATION_ID_DBGC1;
i <= IWL_FW_INI_ALLOCATION_ID_DBGC3; i++) { i <= IWL_FW_INI_ALLOCATION_ID_DBGC3; i++) {
ret = iwl_dbg_tlv_update_dram(fwrt, i, &dram_info); ret = iwl_dbg_tlv_update_dram(fwrt, i, dram_info);
if (!ret) if (!ret)
dram_alloc++; dram_alloc = true;
else else
IWL_WARN(fwrt, IWL_WARN(fwrt,
"WRT: Failed to set DRAM buffer for alloc id %d, ret=%d\n", "WRT: Failed to set DRAM buffer for alloc id %d, ret=%d\n",
i, ret); i, ret);
} }
if (dram_alloc) {
memcpy(frags->block, &dram_info, sizeof(dram_info)); if (dram_alloc)
IWL_DEBUG_FW(fwrt, "block data after %016x\n", IWL_DEBUG_FW(fwrt, "block data after %08x\n",
*((int *)fwrt->trans->dbg.fw_mon_ini[1].frags[0].block)); dram_info->first_word);
} else
memset(frags->block, 0, sizeof(*dram_info));
} }
static void iwl_dbg_tlv_send_hcmds(struct iwl_fw_runtime *fwrt, static void iwl_dbg_tlv_send_hcmds(struct iwl_fw_runtime *fwrt,
......
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