From patchwork Tue Nov 21 12:34:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 167708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp586274vqb; Tue, 21 Nov 2023 04:36:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIY3O8Qe40d130WEGoOxnFJv/Fv9LaGTdiqQ5laoFEs2Qc7iJf82Yr4LdU5tqqBVcP704Z X-Received: by 2002:a05:6808:2e87:b0:3b2:d6ce:f582 with SMTP id gt7-20020a0568082e8700b003b2d6cef582mr16050517oib.34.1700570164588; Tue, 21 Nov 2023 04:36:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700570164; cv=none; d=google.com; s=arc-20160816; b=PujZkfXpIHzDssBOtFwItW4f/mTnSiEOQh2xO8ylAqQrGxF0NPNhJTve/noISrypKg 9O0/OADZoxlaKsgglPir0z1Ar428JmMVqg9x23yCe9M5Qhij77laZu9+oRsqM+cqQwAb AluonVFOtIqWDo2FQXrl80ogmJ5X543itD17QpVI97y0Jqe2Hgn9GLwU4DwRPqPFX9Xu ZJ3PR8GwBIdU0aJhpuKpEAxtm7f6oWQNN2bbSuYkc04WOskcO7nNbViuwPEVlPBFsAfu /6ANPXOj+sc+w2Oad0YTGRu14rKokoPHs/e/eDqEjySW1/xToxObuAKuT8aL1J1bD31K m6ew== 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=4nVltx22JZs3o9Oo8vbtC75RS3lenlK6OPXZWAz72pg=; fh=7oDCV+PgZeDh2ftCDaD0KapxBZeZQ/COfAiPb0KaTTc=; b=AZhIqC/YQHjjnFQK8wsDbTlhhBhk+24nr5N19k0z8gd+OAbKijp+AbQ3z1a9WxXgeq DnfBM7uDkavRudvzAZhaQoU78lwEfxDF/iqpO5R2GZxbhpq/oaWDX0h3O+vx7JzRyp9B JTY+inoFLeRCwdxZfloHkj9TxJoD6AtlYXRhHUqFckFMbZPAkxATAmT/gjFRNJr5Ti+o GzHjJGBllP0FRjE56l1CrijZGU16v+ZaRL9mAnEg+2ZVhbuXLO3QDwqYn/C2eL32Dt9t xU9RmvlwAJsMTxfSUxCdJJFHr8CfidjCHyJzvsrH2Jammak5oED3Oz/dlJisze4Y2RlX AE8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="D1D9DF/l"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id u20-20020a656714000000b005b902b736f3si9756977pgf.615.2023.11.21.04.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 04:36:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="D1D9DF/l"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 38A7A80784D5; Tue, 21 Nov 2023 04:35:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234762AbjKUMf2 (ORCPT + 99 others); Tue, 21 Nov 2023 07:35:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234785AbjKUMfX (ORCPT ); Tue, 21 Nov 2023 07:35:23 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5900CD65; Tue, 21 Nov 2023 04:35:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700570118; x=1732106118; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nivaZQ+9P0ZV/opmlAd8c2iOR56SU+o3ql7tnZt2R+U=; b=D1D9DF/l34RN+o4MhIIZvE1SAi13aICV6oWBa48iBCMBGm23hWQrmP6s uEhOGywmxtlqe+LnBE8YkifDTUI3ebqZh1r2Mr7go4q+r01oe7DLCEc5E 08uZl947mLlAIwL1+ItJzh4uRu1vemyWtfdYjZfOou80tDO4gR02isduV 23h8BCW6LayfdJNYYVs+dJI02YqxiJJNeFd8PHkVLbI1VNM4KuecguNCF w02XkpRkKwck2wNTi1gOH4KawTSZyvwwOKNxzZ+xK0sLMp7FG8RPrrJAQ mhfkMRAq1KktgtV2ya3+U7Z4xEoA0CfSYFkDbZkX6z7mh+3igwnmuq+tG w==; X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="458327794" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="458327794" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Nov 2023 04:35:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="837044350" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="837044350" Received: from wpastern-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.57.17]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Nov 2023 04:35:13 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: "David S. Miller" , Eric Dumazet , intel-wired-lan@lists.osuosl.org, Jakub Kicinski , Jesse Brandeburg , Jonathan Cameron , netdev@vger.kernel.org, Paolo Abeni , Tony Nguyen , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 3/3] e1000e: Use pcie_capability_read_word() for reading LNKSTA Date: Tue, 21 Nov 2023 14:34:28 +0200 Message-Id: <20231121123428.20907-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231121123428.20907-1-ilpo.jarvinen@linux.intel.com> References: <20231121123428.20907-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 21 Nov 2023 04:35:36 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783177060861247540 X-GMAIL-MSGID: 1783177060861247540 Use pcie_capability_read_word() for reading LNKSTA and remove the custom define that matches to PCI_EXP_LNKSTA. As only single user for cap_offset remains, replace it with a call to pci_pcie_cap(). Instead of e1000_adapter, make local variable out of pci_dev because both users are interested in it. Signed-off-by: Ilpo Järvinen Reviewed-by: Jonathan Cameron Reviewed-by: Simon Horman Tested-by: Naama Meir --- drivers/net/ethernet/intel/e1000e/defines.h | 1 - drivers/net/ethernet/intel/e1000e/mac.c | 11 ++++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/defines.h b/drivers/net/ethernet/intel/e1000e/defines.h index a4d29c9e03a6..23a58cada43a 100644 --- a/drivers/net/ethernet/intel/e1000e/defines.h +++ b/drivers/net/ethernet/intel/e1000e/defines.h @@ -678,7 +678,6 @@ /* PCI/PCI-X/PCI-EX Config space */ #define PCI_HEADER_TYPE_REGISTER 0x0E -#define PCIE_LINK_STATUS 0x12 #define PCI_HEADER_TYPE_MULTIFUNC 0x80 diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 5340cf73778d..694a779e718d 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -17,16 +17,13 @@ s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; struct e1000_bus_info *bus = &hw->bus; - struct e1000_adapter *adapter = hw->adapter; - u16 pcie_link_status, cap_offset; + struct pci_dev *pdev = hw->adapter->pdev; + u16 pcie_link_status; - cap_offset = adapter->pdev->pcie_cap; - if (!cap_offset) { + if (!pci_pcie_cap(pdev)) { bus->width = e1000_bus_width_unknown; } else { - pci_read_config_word(adapter->pdev, - cap_offset + PCIE_LINK_STATUS, - &pcie_link_status); + pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &pcie_link_status); bus->width = (enum e1000_bus_width)FIELD_GET(PCI_EXP_LNKSTA_NLW, pcie_link_status); }