linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: linux-pci@vger.kernel.org, Bjorn Helgaas <helgaas@kernel.org>,
	Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Subject: [PATCH 1/8] IB/hfi1: Use FIELD_GET() to extract Link Width
Date: Mon, 11 Sep 2023 15:14:54 +0300	[thread overview]
Message-ID: <20230911121501.21910-2-ilpo.jarvinen@linux.intel.com> (raw)
In-Reply-To: <20230911121501.21910-1-ilpo.jarvinen@linux.intel.com>

Use FIELD_GET() to extract PCIe Negotiated Link Width field instead of
custom masking and shifting.

While at it, also fix function's comment.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/infiniband/hw/hfi1/pcie.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c
index 08732e1ac966..d497e4c623c1 100644
--- a/drivers/infiniband/hw/hfi1/pcie.c
+++ b/drivers/infiniband/hw/hfi1/pcie.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2015 - 2019 Intel Corporation.
  */
 
+#include <linux/bitfield.h>
 #include <linux/pci.h>
 #include <linux/io.h>
 #include <linux/delay.h>
@@ -210,10 +211,10 @@ static u32 extract_speed(u16 linkstat)
 	return speed;
 }
 
-/* return the PCIe link speed from the given link status */
+/* return the PCIe Link Width from the given link status */
 static u32 extract_width(u16 linkstat)
 {
-	return (linkstat & PCI_EXP_LNKSTA_NLW) >> PCI_EXP_LNKSTA_NLW_SHIFT;
+	return FIELD_GET(PCI_EXP_LNKSTA_NLW, linkstat);
 }
 
 /* read the link status and set dd->{lbus_width,lbus_speed,lbus_info} */
-- 
2.30.2


  reply	other threads:[~2023-09-11 21:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 12:14 [PATCH 0/8] PCI/treewide: PCIe Link Width field access cleanup Ilpo Järvinen
2023-09-11 12:14 ` Ilpo Järvinen [this message]
2023-09-12 10:26   ` [PATCH 1/8] IB/hfi1: Use FIELD_GET() to extract Link Width Jonathan Cameron
2023-09-11 12:14 ` [PATCH 2/8] media: cobalt: " Ilpo Järvinen
2023-09-11 12:14 ` [PATCH 3/8] igb: " Ilpo Järvinen
2023-09-12 10:34   ` Jonathan Cameron
2023-09-12 12:11     ` Ilpo Järvinen
2023-09-11 12:14 ` [PATCH 4/8] PCI: tegra194: Use FIELD_GET()/FIELD_PREP() with Link Width fields Ilpo Järvinen
2023-09-12 10:35   ` Jonathan Cameron
2023-09-11 12:14 ` [PATCH 5/8] PCI: mvebu: Use FIELD_PREP() with Link Width Ilpo Järvinen
2023-09-11 12:14 ` [PATCH 6/8] PCI: Use FIELD_GET() to extract " Ilpo Järvinen
2023-09-11 12:15 ` [PATCH 7/8] scsi: esas2r: " Ilpo Järvinen
2023-09-12 10:38   ` Jonathan Cameron
2023-09-11 12:15 ` [PATCH 8/8] scsi: qla2xxx: " Ilpo Järvinen
2023-09-12 10:39   ` Jonathan Cameron
2023-09-12 10:24 ` [PATCH 0/8] PCI/treewide: PCIe Link Width field access cleanup Jonathan Cameron

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=20230911121501.21910-2-ilpo.jarvinen@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=helgaas@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rdma@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).