From patchwork Sun Oct 24 13:55:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Coelho X-Patchwork-Id: 12580197 X-Patchwork-Delegate: luca@coelho.fi Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97A04C433EF for ; Sun, 24 Oct 2021 13:55:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82E4C60FBF for ; Sun, 24 Oct 2021 13:55:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231724AbhJXN5o (ORCPT ); Sun, 24 Oct 2021 09:57:44 -0400 Received: from paleale.coelho.fi ([176.9.41.70]:58560 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231713AbhJXN5n (ORCPT ); Sun, 24 Oct 2021 09:57:43 -0400 Received: from 91-156-6-193.elisa-laajakaista.fi ([91.156.6.193] helo=kveik.lan) by farmhouse.coelho.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1medy4-000cvJ-W5; Sun, 24 Oct 2021 16:55:21 +0300 From: Luca Coelho To: kvalo@codeaurora.org Cc: luca@coelho.fi, linux-wireless@vger.kernel.org Date: Sun, 24 Oct 2021 16:55:05 +0300 Message-Id: X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211024135506.285102-1-luca@coelho.fi> References: <20211024135506.285102-1-luca@coelho.fi> MIME-Version: 1.0 Subject: [PATCH 10/11] iwlwifi: pcie: simplify iwl_pci_find_dev_info() Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg 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 Signed-off-by: Luca Coelho --- 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)