summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
diff options
context:
space:
mode:
authorSharon Dvir <sharon.dvir@intel.com>2015-10-15 18:18:09 +0300
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>2015-12-13 08:56:17 +0200
commit39bdb17ebb5bd7a5c8a231d7cac4a4d5ccc58149 (patch)
tree4f7ca523849df1a34bed74e95bf45698eb2175af /drivers/net/wireless/intel/iwlwifi/iwl-trans.c
parent92fe83430b899b786c837e5b716a328220d47ae5 (diff)
iwlwifi: update host command messages to new format
Host commands now have a group id, express this in printed messages. Signed-off-by: Sharon Dvir <sharon.dvir@intel.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Diffstat (limited to 'drivers/net/wireless/intel/iwlwifi/iwl-trans.c')
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-trans.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
index c3fafbc6b654..6069a9ff53fa 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
@@ -61,8 +61,10 @@
*
*****************************************************************************/
#include <linux/kernel.h>
-#include "iwl-drv.h"
+#include <linux/bsearch.h>
+
#include "iwl-trans.h"
+#include "iwl-drv.h"
struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
struct device *dev,
@@ -145,3 +147,59 @@ int iwl_trans_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
return ret;
}
IWL_EXPORT_SYMBOL(iwl_trans_send_cmd);
+
+/* Comparator for struct iwl_hcmd_names.
+ * Used in the binary search over a list of host commands.
+ *
+ * @key: command_id that we're looking for.
+ * @elt: struct iwl_hcmd_names candidate for match.
+ *
+ * @return 0 iff equal.
+ */
+static int iwl_hcmd_names_cmp(const void *key, const void *elt)
+{
+ const struct iwl_hcmd_names *name = elt;
+ u8 cmd1 = *(u8 *)key;
+ u8 cmd2 = name->cmd_id;
+
+ return (cmd1 - cmd2);
+}
+
+const char *iwl_get_cmd_string(struct iwl_trans *trans, u32 id)
+{
+ u8 grp, cmd;
+ struct iwl_hcmd_names *ret;
+ const struct iwl_hcmd_arr *arr;
+ size_t size = sizeof(struct iwl_hcmd_names);
+
+ grp = iwl_cmd_groupid(id);
+ cmd = iwl_cmd_opcode(id);
+
+ if (!trans->command_groups || grp >= trans->command_groups_size ||
+ !trans->command_groups[grp].arr)
+ return "UNKNOWN";
+
+ arr = &trans->command_groups[grp];
+ ret = bsearch(&cmd, arr->arr, arr->size, size, iwl_hcmd_names_cmp);
+ if (!ret)
+ return "UNKNOWN";
+ return ret->cmd_name;
+}
+IWL_EXPORT_SYMBOL(iwl_get_cmd_string);
+
+int iwl_cmd_groups_verify_sorted(const struct iwl_trans_config *trans)
+{
+ int i, j;
+ const struct iwl_hcmd_arr *arr;
+
+ for (i = 0; i < trans->command_groups_size; i++) {
+ arr = &trans->command_groups[i];
+ if (!arr->arr)
+ continue;
+ for (j = 0; j < arr->size - 1; j++)
+ if (arr->arr[j].cmd_id > arr->arr[j + 1].cmd_id)
+ return -1;
+ }
+ return 0;
+}
+IWL_EXPORT_SYMBOL(iwl_cmd_groups_verify_sorted);