linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: kvalo@codeaurora.org
Cc: luca@coelho.fi, linux-wireless@vger.kernel.org
Subject: [PATCH 10/11] iwlwifi: pcie: simplify iwl_pci_find_dev_info()
Date: Sun, 24 Oct 2021 16:55:05 +0300	[thread overview]
Message-ID: <iwlwifi.20211024165252.abd85e1391cb.I7681fe90735044cc1c59f120e8591b7ac125535d@changeid> (raw)
In-Reply-To: <20211024135506.285102-1-luca@coelho.fi>

From: Johannes Berg <johannes.berg@intel.com>

We currently match the list of devices from the start to
the end, but then find the *last* match, so we need to
look at each and every entry. We don't want to change the
semantics ("most generic entry must come first"), so just
change the order of matching to be back-to-front, then we
can break out once we find a match.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index 3276f04cfd60..c574f041f096 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -1339,10 +1339,9 @@ iwl_pci_find_dev_info(u16 device, u16 subsystem_device,
 		      u16 mac_type, u8 mac_step,
 		      u16 rf_type, u8 cdb, u8 rf_id, u8 no_160, u8 cores)
 {
-	const struct iwl_dev_info *ret = NULL;
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(iwl_dev_info_table); i++) {
+	for (i = ARRAY_SIZE(iwl_dev_info_table) - 1; i >= 0; i--) {
 		const struct iwl_dev_info *dev_info = &iwl_dev_info_table[i];
 
 		if (dev_info->device != (u16)IWL_CFG_ANY &&
@@ -1381,10 +1380,10 @@ iwl_pci_find_dev_info(u16 device, u16 subsystem_device,
 		    dev_info->cores != cores)
 			continue;
 
-		ret = dev_info;
+		return dev_info;
 	}
 
-	return ret;
+	return NULL;
 }
 
 static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
-- 
2.33.0


  parent reply	other threads:[~2021-10-24 13:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-24 13:54 [PATCH 00/11] iwlwifi: updates intended for v5.16 2021-10-24 Luca Coelho
2021-10-24 13:54 ` [PATCH 01/11] iwlwifi: mvm: fix some kerneldoc issues Luca Coelho
2021-10-24 13:54 ` [PATCH 02/11] iwlwifi: pcie: fix killer name matching for AX200 Luca Coelho
2021-10-24 13:54 ` [PATCH 03/11] iwlwifi: pcie: remove duplicate entry Luca Coelho
2021-10-24 13:54 ` [PATCH 04/11] iwlwifi: pcie: refactor dev_info lookup Luca Coelho
2021-10-24 13:55 ` [PATCH 05/11] iwlwifi: pcie: remove two duplicate PNJ device entries Luca Coelho
2021-10-24 13:55 ` [PATCH 06/11] iwlwifi: mvm: Use all Rx chains for roaming scan Luca Coelho
2021-10-24 13:55 ` [PATCH 07/11] iwlwifi: add new pci SoF with JF Luca Coelho
2021-10-24 13:55 ` [PATCH 08/11] iwlwifi: pcie: update sw error interrupt for BZ family Luca Coelho
2021-10-24 13:55 ` [PATCH 09/11] iwlwifi: ACPI: support revision 3 WGDS tables Luca Coelho
2021-10-24 13:55 ` Luca Coelho [this message]
2021-10-24 13:55 ` [PATCH 11/11] iwlwifi: dump host monitor data when NIC doesn't init Luca Coelho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=iwlwifi.20211024165252.abd85e1391cb.I7681fe90735044cc1c59f120e8591b7ac125535d@changeid \
    --to=luca@coelho.fi \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).