diff options
author | Johannes Berg <johannes.berg@intel.com> | 2015-09-22 12:24:31 +0200 |
---|---|---|
committer | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2015-11-26 16:38:50 +0200 |
commit | 4707fde5cdefc73c408915af2579c4acaf49ade4 (patch) | |
tree | a240ace8b7b9b0078a9d8fbefde87ff8d9c69e28 /drivers/net/wireless/intel/iwlwifi | |
parent | 59fd4bf64591fbd02c6115d9282e2e7cffefa6e1 (diff) |
iwlwifi: mvm: use build-time assertion for fw trigger ID
The firmware debug trigger ID is always a compile-time constant,
so we can use a build-time assertion to validate that it is in
fact a valid constant.
To make that really guaranteed to work, convert this and the
inline function iwl_fw_dbg_trigger_simple_stop() to macros.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Diffstat (limited to 'drivers/net/wireless/intel/iwlwifi')
-rw-r--r-- | drivers/net/wireless/intel/iwlwifi/iwl-fw.h | 11 | ||||
-rw-r--r-- | drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 15 |
2 files changed, 15 insertions, 11 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-fw.h b/drivers/net/wireless/intel/iwlwifi/iwl-fw.h index 84ec0cefb62a..c6946f1644fc 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-fw.h +++ b/drivers/net/wireless/intel/iwlwifi/iwl-fw.h @@ -311,12 +311,15 @@ iwl_fw_dbg_conf_usniffer(const struct iwl_fw *fw, u8 id) }) static inline struct iwl_fw_dbg_trigger_tlv* -iwl_fw_dbg_get_trigger(const struct iwl_fw *fw, u8 id) +_iwl_fw_dbg_get_trigger(const struct iwl_fw *fw, enum iwl_fw_dbg_trigger id) { - if (WARN_ON(id >= ARRAY_SIZE(fw->dbg_trigger_tlv))) - return NULL; - return fw->dbg_trigger_tlv[id]; } +#define iwl_fw_dbg_get_trigger(fw, id) ({ \ + BUILD_BUG_ON(!__builtin_constant_p(id)); \ + BUILD_BUG_ON((id) >= FW_DBG_TRIGGER_MAX); \ + _iwl_fw_dbg_get_trigger((fw), (id)); \ +}) + #endif /* __iwl_fw_h__ */ diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h index aff71d300592..347d953f5604 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h @@ -1524,20 +1524,21 @@ iwl_fw_dbg_trigger_check_stop(struct iwl_mvm *mvm, } static inline void -iwl_fw_dbg_trigger_simple_stop(struct iwl_mvm *mvm, - struct ieee80211_vif *vif, - enum iwl_fw_dbg_trigger trig) +_iwl_fw_dbg_trigger_simple_stop(struct iwl_mvm *mvm, + struct ieee80211_vif *vif, + struct iwl_fw_dbg_trigger_tlv *trigger) { - struct iwl_fw_dbg_trigger_tlv *trigger; - - if (!iwl_fw_dbg_trigger_enabled(mvm->fw, trig)) + if (!trigger) return; - trigger = iwl_fw_dbg_get_trigger(mvm->fw, trig); if (!iwl_fw_dbg_trigger_check_stop(mvm, vif, trigger)) return; iwl_mvm_fw_dbg_collect_trig(mvm, trigger, NULL); } +#define iwl_fw_dbg_trigger_simple_stop(mvm, vif, trig) \ + _iwl_fw_dbg_trigger_simple_stop((mvm), (vif), \ + iwl_fw_dbg_get_trigger((mvm)->fw,\ + (trig))) #endif /* __IWL_MVM_H__ */ |