]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iwlwifi: add device name to device_info
authorLuca Coelho <luciano.coelho@intel.com>
Thu, 10 Oct 2019 15:29:26 +0000 (18:29 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Sat, 4 Jan 2020 10:48:41 +0000 (12:48 +0200)
We have a lot of mostly duplicated data structures that are repeated
only because the device name string is different.  To avoid this, move
the string from the cfg to the trans structure and add it
independently from the rest of the configuration to the PCI mapping
tables.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/cfg/9000.c
drivers/net/wireless/intel/iwlwifi/dvm/main.c
drivers/net/wireless/intel/iwlwifi/fw/dbg.c
drivers/net/wireless/intel/iwlwifi/iwl-config.h
drivers/net/wireless/intel/iwlwifi/iwl-trans.h
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
drivers/net/wireless/intel/iwlwifi/mvm/ops.c
drivers/net/wireless/intel/iwlwifi/pcie/drv.c

index e7b95842bb607cabf896d6262263678fddc3e1cc..379ea788e4247c3f2c917508914fbf95bafe6663 100644 (file)
@@ -190,8 +190,10 @@ const struct iwl_cfg iwl9260_2ac_cfg = {
        IWL_DEVICE_9000,
 };
 
+const char iwl9260_160_name[] = "Intel(R) Wireless-AC 9260 160MHz";
+const char iwl9560_160_name[] = "Intel(R) Wireless-AC 9560 160MHz";
+
 const struct iwl_cfg iwl9260_2ac_160_cfg = {
-       .name = "Intel(R) Wireless-AC 9260 160MHz",
        .fw_name_pre = IWL9260_FW_PRE,
        IWL_DEVICE_9000,
 };
index 4f2789bb3b5bf624d6d1972436ce165a564f6486..598ee73155588aeccfd945f5191880e6ec522055 100644 (file)
@@ -1255,7 +1255,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
         ************************/
        hw = iwl_alloc_all();
        if (!hw) {
-               pr_err("%s: Cannot allocate network device\n", cfg->name);
+               pr_err("%s: Cannot allocate network device\n", trans->name);
                goto out;
        }
 
@@ -1390,7 +1390,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
         * 2. Read REV register
         ***********************/
        IWL_INFO(priv, "Detected %s, REV=0x%X\n",
-               priv->cfg->name, priv->trans->hw_rev);
+               priv->trans->name, priv->trans->hw_rev);
 
        if (iwl_trans_start_hw(priv->trans))
                goto out_free_hw;
index 09daf0f1f6f877f52e109a997fedf1af334c926c..89d796821023913e063615ed21ce12d1da626a88 100644 (file)
@@ -929,7 +929,7 @@ iwl_fw_error_dump_file(struct iwl_fw_runtime *fwrt,
                        cpu_to_le32(CSR_HW_REV_STEP(fwrt->trans->hw_rev));
                memcpy(dump_info->fw_human_readable, fwrt->fw->human_readable,
                       sizeof(dump_info->fw_human_readable));
-               strncpy(dump_info->dev_human_readable, fwrt->trans->cfg->name,
+               strncpy(dump_info->dev_human_readable, fwrt->trans->name,
                        sizeof(dump_info->dev_human_readable) - 1);
                strncpy(dump_info->bus_human_readable, fwrt->dev->bus->name,
                        sizeof(dump_info->bus_human_readable) - 1);
index 0af1a5184d824a8679aaa644ff809bbb4137abb0..be6a2bf9ce74aa2f1b3b6c5aa203bdbe921110ca 100644 (file)
@@ -458,12 +458,15 @@ struct iwl_dev_info {
        u16 device;
        u16 subdevice;
        const struct iwl_cfg *cfg;
+       const char *name;
 };
 
 /*
  * This list declares the config structures for all devices.
  */
 extern const struct iwl_cfg_trans_params iwl9000_trans_cfg;
+extern const char iwl9260_160_name[];
+extern const char iwl9560_160_name[];
 
 #if IS_ENABLED(CONFIG_IWLDVM)
 extern const struct iwl_cfg iwl5300_agn_cfg;
index 58bee4442e201278a19b272c60f0356e4dcb211e..ab547be4994bcc84daefeb5a9a68f04417fb638d 100644 (file)
@@ -859,6 +859,8 @@ struct iwl_trans {
 
        enum iwl_plat_pm_mode system_pm_mode;
 
+       const char *name;
+
        /* pointer to trans specific struct */
        /*Ensure that this pointer will always be aligned to sizeof pointer */
        char trans_specific[0] __aligned(sizeof(void *));
index aa659162a7c29ce2fa5d40e77c3f73cd569cc507..190cf15b825ce25b22fb7e93a483c822ad05fd78 100644 (file)
@@ -752,7 +752,7 @@ static ssize_t iwl_dbgfs_fw_ver_read(struct file *file, char __user *user_buf,
        pos += scnprintf(pos, endpos - pos, "FW: %s\n",
                         mvm->fwrt.fw->human_readable);
        pos += scnprintf(pos, endpos - pos, "Device: %s\n",
-                        mvm->fwrt.trans->cfg->name);
+                        mvm->fwrt.trans->name);
        pos += scnprintf(pos, endpos - pos, "Bus: %s\n",
                         mvm->fwrt.dev->bus->name);
 
index 945c1ea5cda8642285fec3b95349d0c8cbefc4b2..c46c00706cd5b3cadd027d5d6496b499116fc625 100644 (file)
@@ -178,7 +178,7 @@ static int iwl_nvm_read_chunk(struct iwl_mvm *mvm, u16 section,
                } else {
                        IWL_DEBUG_EEPROM(mvm->trans->dev,
                                         "NVM access command failed with status %d (device: %s)\n",
-                                        ret, mvm->cfg->name);
+                                        ret, mvm->trans->name);
                        ret = -ENODATA;
                }
                goto exit;
index 1b07a8e8f0695598139497e1f26895f0163b98fe..dfe02440d474827e00d052e57be520411a81ce7f 100644 (file)
@@ -830,7 +830,7 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
        }
 
        IWL_INFO(mvm, "Detected %s, REV=0x%X\n",
-                mvm->cfg->name, mvm->trans->hw_rev);
+                mvm->trans->name, mvm->trans->hw_rev);
 
        if (iwlwifi_mod_params.nvm_file)
                mvm->nvm_file_name = iwlwifi_mod_params.nvm_file;
index c2cb6283bc5a53b001ad33d0f3dab025033f4ff3..9d8ffbecf5bed1f84a28eef7e672f073bfd3456a 100644 (file)
@@ -592,20 +592,10 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
        {IWL_PCI_DEVICE(0x2526, 0x1610, iwl9270_2ac_cfg)},
        {IWL_PCI_DEVICE(0x2526, 0x2030, iwl9560_2ac_160_cfg_soc)},
        {IWL_PCI_DEVICE(0x2526, 0x2034, iwl9560_2ac_160_cfg_soc)},
-       {IWL_PCI_DEVICE(0x2526, 0x4010, iwl9260_2ac_160_cfg)},
-       {IWL_PCI_DEVICE(0x2526, 0x4018, iwl9260_2ac_160_cfg)},
-       {IWL_PCI_DEVICE(0x2526, 0x401C, iwl9260_2ac_160_cfg)},
        {IWL_PCI_DEVICE(0x2526, 0x4034, iwl9560_2ac_160_cfg_soc)},
        {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9462_2ac_cfg_soc)},
        {IWL_PCI_DEVICE(0x2526, 0x4234, iwl9560_2ac_cfg_soc)},
        {IWL_PCI_DEVICE(0x2526, 0x42A4, iwl9462_2ac_cfg_soc)},
-       {IWL_PCI_DEVICE(0x2526, 0x6010, iwl9260_2ac_160_cfg)},
-       {IWL_PCI_DEVICE(0x2526, 0x6014, iwl9260_2ac_160_cfg)},
-       {IWL_PCI_DEVICE(0x2526, 0x8014, iwl9260_2ac_160_cfg)},
-       {IWL_PCI_DEVICE(0x2526, 0x8010, iwl9260_2ac_160_cfg)},
-       {IWL_PCI_DEVICE(0x2526, 0xA014, iwl9260_2ac_160_cfg)},
-       {IWL_PCI_DEVICE(0x2526, 0xE010, iwl9260_2ac_160_cfg)},
-       {IWL_PCI_DEVICE(0x2526, 0xE014, iwl9260_2ac_160_cfg)},
        {IWL_PCI_DEVICE(0x2526, PCI_ANY_ID, iwl9000_trans_cfg)},
 
        {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)},
@@ -981,19 +971,28 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
 };
 MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
 
-#define IWL_DEV_INFO(_device, _subdevice, _cfg) \
-       {.device = (_device), .subdevice = (_subdevice), .cfg = &(_cfg)}
+#define IWL_DEV_INFO(_device, _subdevice, _cfg, _name)                  \
+       { .device = (_device), .subdevice = (_subdevice), .cfg = &(_cfg), \
+         .name = _name }
 
 static const struct iwl_dev_info iwl_dev_info_table[] = {
 #if IS_ENABLED(CONFIG_IWLMVM)
-       IWL_DEV_INFO(0x2526, 0x0010, iwl9260_2ac_160_cfg),
-       IWL_DEV_INFO(0x2526, 0x0014, iwl9260_2ac_160_cfg),
-       IWL_DEV_INFO(0x2526, 0x0018, iwl9260_2ac_160_cfg),
-       IWL_DEV_INFO(0x2526, 0x001C, iwl9260_2ac_160_cfg),
-       IWL_DEV_INFO(0x2526, 0x0030, iwl9560_2ac_160_cfg),
-       IWL_DEV_INFO(0x2526, 0x0038, iwl9560_2ac_160_cfg),
-       IWL_DEV_INFO(0x2526, 0x003C, iwl9560_2ac_160_cfg),
-       IWL_DEV_INFO(0x2526, 0x4030, iwl9560_2ac_160_cfg),
+       IWL_DEV_INFO(0x2526, 0x0010, iwl9260_2ac_160_cfg, iwl9260_160_name),
+       IWL_DEV_INFO(0x2526, 0x0014, iwl9260_2ac_160_cfg, iwl9260_160_name),
+       IWL_DEV_INFO(0x2526, 0x0018, iwl9260_2ac_160_cfg, iwl9260_160_name),
+       IWL_DEV_INFO(0x2526, 0x001C, iwl9260_2ac_160_cfg, iwl9260_160_name),
+       IWL_DEV_INFO(0x2526, 0x6010, iwl9260_2ac_160_cfg, iwl9260_160_name),
+       IWL_DEV_INFO(0x2526, 0x6014, iwl9260_2ac_160_cfg, iwl9260_160_name),
+       IWL_DEV_INFO(0x2526, 0x8014, iwl9260_2ac_160_cfg, iwl9260_160_name),
+       IWL_DEV_INFO(0x2526, 0x8010, iwl9260_2ac_160_cfg, iwl9260_160_name),
+       IWL_DEV_INFO(0x2526, 0xA014, iwl9260_2ac_160_cfg, iwl9260_160_name),
+       IWL_DEV_INFO(0x2526, 0xE010, iwl9260_2ac_160_cfg, iwl9260_160_name),
+       IWL_DEV_INFO(0x2526, 0xE014, iwl9260_2ac_160_cfg, iwl9260_160_name),
+
+       IWL_DEV_INFO(0x2526, 0x0030, iwl9560_2ac_160_cfg, iwl9560_160_name),
+       IWL_DEV_INFO(0x2526, 0x0038, iwl9560_2ac_160_cfg, iwl9560_160_name),
+       IWL_DEV_INFO(0x2526, 0x003C, iwl9560_2ac_160_cfg, iwl9560_160_name),
+       IWL_DEV_INFO(0x2526, 0x4030, iwl9560_2ac_160_cfg, iwl9560_160_name),
 #endif /* CONFIG_IWLMVM */
 };
 
@@ -1037,6 +1036,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                    (dev_info->subdevice == IWL_CFG_ANY ||
                     dev_info->subdevice == pdev->subsystem_device)) {
                        iwl_trans->cfg = dev_info->cfg;
+                       iwl_trans->name = dev_info->name;
                        goto found;
                }
        }
@@ -1164,6 +1164,10 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                iwl_trans->cfg = cfg;
 
 found:
+       /* if we don't have a name yet, copy name from the old cfg */
+       if (!iwl_trans->name)
+               iwl_trans->name = iwl_trans->cfg->name;
+
        if (iwl_trans->trans_cfg->mq_rx_supported) {
                if (WARN_ON(!iwl_trans->cfg->num_rbds)) {
                        ret = -EINVAL;