• Johannes Berg's avatar
    iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id · 971cbe50
    Johannes Berg authored
    Instead of taking the group/command separately, make the function
    take a combined command ID. In many cases, this allows us to pass
    an existing command ID (e.g. cmd.id), or introduce a new variable
    for it, so that we don't use the command ID twice.
    
    This way, we can also use LONG_GROUP implicitly, so we don't need
    to spell that out for many commands.
    
    Apart from mvm.h, fw/img.{c,h} changes and some copyright and
    indentation updates, this was done with spatch:
    
        @@
        identifier cmd;
        expression fw, G, C, def;
        @@
         struct iwl_host_cmd cmd = {
          .id = WIDE_ID(G, C),
        ...
         };
        ...
        -iwl_fw_lookup_cmd_ver(fw, G, C, def)
        +iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
    
        @@
        identifier cmd;
        expression fw, C, def;
        @@
         struct iwl_host_cmd cmd = {
          .id = C,
        ...
         };
        ...
        -iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
        +iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
    
        @@
        identifier func;
        expression fw, G, C, mvm, flags, cmd, size, def;
        type rettype;
        @@
        rettype func(...)
        {
        +u32 cmd_id = WIDE_ID(G, C);
        ...
        -iwl_fw_lookup_cmd_ver(fw, G, C, def)
        +iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
        ...
        -iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
        +iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
        ...
        }
    
        @@
        identifier func;
        expression fw, G, C, mvm, flags, cmd, size, def;
        type rettype;
        @@
        rettype func(...)
        {
        +u32 cmd_id = C;
        ...
        -iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
        +iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
        ...
        -iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
        +iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
        ...
        }
    
        @@
        expression fw, C, def;
        @@
        -iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
        +iwl_fw_lookup_cmd_ver(fw, C, def)
    
        @@
        expression fw, C, G, def;
        @@
        -iwl_fw_lookup_cmd_ver(fw, G, C, def)
        +iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
    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.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeidSigned-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
    971cbe50
tx.c 62.9 KB