Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7564222rwd; Tue, 20 Jun 2023 03:07:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5j4XpoeruB01H+kpT6FamKY82Qr4aiu0vesPEWQQfhvYt47XjICGGduG466pUnXbgSEMCV X-Received: by 2002:a05:6359:c06:b0:130:ebdd:cfdb with SMTP id gn6-20020a0563590c0600b00130ebddcfdbmr3907743rwb.8.1687255645499; Tue, 20 Jun 2023 03:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687255645; cv=none; d=google.com; s=arc-20160816; b=qqiZwGrgoaBYQc+LxcpgH7M3VZ6nKtn3yw0sNjU2S8/KjCgKIRSvRlOwWFK+0lOUjB dD3UZKLxgGWPZIjpThHw+kQYEkAW/Pyh13Vi25yYIPhuPuHaDXI4R1GdCplKfHSQdV0S TVd88YA09z5amBPkQmRLYRqYAjPT3QwgUCVD7fu2oKf4TQubFBQJBWP6O7QUUF/IfazQ VlXV5uUlq0sGmB0Tbd0K0oePx03Sl0a1pK/nJjPFWh1fE2/h3jx1cmypgJR64mQeqvFz krSlq2fDQVOwWmMU2bTMwczSdNzUhGhi6s7nAruIkEwX6C+TXULVorS1fCmc/H4yyiYn 5HGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F6V5yAM1SpVHKXeeZyF59+0CUUWNl/wjwJ9BqX0UIXM=; b=NPd/DPRRXAYS+K5kqqxInHb9RnGdTohlNSvq+OcHQxjzVREAKp071j5/5Rgb2UgBAT zrad9KClUwaQbBG4YsvLUms9k++EbIitVIjoFOB/P+HDJNGURSFSuNv9EYwz+nXc9rxb BxI7sPPl+3JBfy5n97czheSv+4rHqAltHs/G1EQ+goSlW07mN9sBm1uvduH0qK5599Qh VXSd9xDEkPXU+f9Z5oiYL/TPnE3xTfEFh5xl04h5UKwy+H1nfW0xiPCSW+5J8yMxxfPD cxGe0xulV/+a8MlXQbMmAwhWXT+Exi8Zg6hsNwyWxlpG1GdNz+iIqr2RM/5AlfCfilTe UZqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KxP2srJr; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10-20020a63690a000000b0051f7686dfb7si1397495pgc.189.2023.06.20.03.07.14; Tue, 20 Jun 2023 03:07:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KxP2srJr; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231710AbjFTKEr (ORCPT + 59 others); Tue, 20 Jun 2023 06:04:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231723AbjFTKEe (ORCPT ); Tue, 20 Jun 2023 06:04:34 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CC3AE68 for ; Tue, 20 Jun 2023 03:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687255471; x=1718791471; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/HUDAYakNHzR01gNJQ0rWizq4vb3DPm9bHjmrZkUzn4=; b=KxP2srJr7ysgL5qQ3QIihtJjqrNKGf6uztFTBg7IW6gNAa7q7qoUL6jr eaGptDhasIIzAfnYv9mVoU3gg+ha6Kol335cJsuNGkSBYJLP2U7QaRcI6 SBD9brNL3jwCjKlg+aM1m0tBhZkLJwK8LfYS+hTxHJlWvLqEOphTe8RY4 AnmtMIplMQRbg3TKl0+CaUSt4XkYDAT98sNXjC3P51CEn/8BHhwbqJOe5 fypvR7I6L2JeRF/Xoxvi9tfY+5Xk2epTvEPNXHNRR7rhYNGpNkI7Dv2q3 fTBy8ymzq+ffc+A5uV0XZPqEopOyOBpI9t46Y+LPa3wylJetz8F3QZvKc w==; X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="359819517" X-IronPort-AV: E=Sophos;i="6.00,256,1681196400"; d="scan'208";a="359819517" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 03:04:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="838142654" X-IronPort-AV: E=Sophos;i="6.00,256,1681196400"; d="scan'208";a="838142654" Received: from rafist-mobl.ger.corp.intel.com (HELO ggreenma-mobl2.intel.com) ([10.214.208.68]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 03:04:18 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg , Gregory Greenman Subject: [PATCH 01/19] wifi: iwlwifi: pcie: refactor RB status size calculation Date: Tue, 20 Jun 2023 13:03:47 +0300 Message-Id: <20230620125813.f3e87ddd5bce.Ifefba753043b68c394590a35bc6914a0f6497fd3@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230620100405.45117-1-gregory.greenman@intel.com> References: <20230620100405.45117-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg We have three places doing this check, and even in slightly different ways (with/without an intermediate). Refactor that to a new small inline function. Signed-off-by: Johannes Berg Signed-off-by: Gregory Greenman --- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 24 ++++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c index da1a27b1d8b6..f87b28edc267 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -699,17 +699,25 @@ static void iwl_pcie_free_rxq_dma(struct iwl_trans *trans, rxq->used_bd = NULL; } +static size_t iwl_pcie_rb_stts_size(struct iwl_trans *trans) +{ + bool use_rx_td = (trans->trans_cfg->device_family >= + IWL_DEVICE_FAMILY_AX210); + + if (use_rx_td) + return sizeof(__le16); + + return sizeof(struct iwl_rb_status); +} + static int iwl_pcie_alloc_rxq_dma(struct iwl_trans *trans, struct iwl_rxq *rxq) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + size_t rb_stts_size = iwl_pcie_rb_stts_size(trans); struct device *dev = trans->dev; int i; int free_size; - bool use_rx_td = (trans->trans_cfg->device_family >= - IWL_DEVICE_FAMILY_AX210); - size_t rb_stts_size = use_rx_td ? sizeof(__le16) : - sizeof(struct iwl_rb_status); spin_lock_init(&rxq->lock); if (trans->trans_cfg->mq_rx_supported) @@ -757,11 +765,9 @@ static int iwl_pcie_alloc_rxq_dma(struct iwl_trans *trans, static int iwl_pcie_rx_alloc(struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + size_t rb_stts_size = iwl_pcie_rb_stts_size(trans); struct iwl_rb_allocator *rba = &trans_pcie->rba; int i, ret; - size_t rb_stts_size = trans->trans_cfg->device_family >= - IWL_DEVICE_FAMILY_AX210 ? - sizeof(__le16) : sizeof(struct iwl_rb_status); if (WARN_ON(trans_pcie->rxq)) return -EINVAL; @@ -1193,11 +1199,9 @@ int iwl_pcie_gen2_rx_init(struct iwl_trans *trans) void iwl_pcie_rx_free(struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + size_t rb_stts_size = iwl_pcie_rb_stts_size(trans); struct iwl_rb_allocator *rba = &trans_pcie->rba; int i; - size_t rb_stts_size = trans->trans_cfg->device_family >= - IWL_DEVICE_FAMILY_AX210 ? - sizeof(__le16) : sizeof(struct iwl_rb_status); /* * if rxq is NULL, it means that nothing has been allocated, -- 2.38.1