From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: <linux-pci@vger.kernel.org>, Bjorn Helgaas <helgaas@kernel.org>,
"Bradley Grove" <linuxdrivers@attotech.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
<linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 7/8] scsi: esas2r: Use FIELD_GET() to extract Link Width
Date: Tue, 12 Sep 2023 11:38:17 +0100 [thread overview]
Message-ID: <20230912113817.000064db@Huawei.com> (raw)
In-Reply-To: <20230911121501.21910-8-ilpo.jarvinen@linux.intel.com>
On Mon, 11 Sep 2023 15:15:00 +0300
Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> wrote:
> Use FIELD_GET() to extract PCIe Negotiated and Maximum Link Width fields
> instead of custom masking and shifting.
>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
> drivers/scsi/esas2r/esas2r_ioctl.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c
> index 055d2e87a2c8..3252780fd099 100644
> --- a/drivers/scsi/esas2r/esas2r_ioctl.c
> +++ b/drivers/scsi/esas2r/esas2r_ioctl.c
> @@ -41,6 +41,8 @@
> * USA.
> */
>
> +#include <linux/bitfield.h>
> +
> #include "esas2r.h"
>
> /*
> @@ -797,11 +799,9 @@ static int hba_ioctl_callback(struct esas2r_adapter *a,
> gai->pci.link_speed_max =
> (u8)(caps & PCI_EXP_LNKCAP_SLS);
Better to convert the other field gets as well.
I'm curious as to why the u8 casts are here. The masking should have
kept the compiler happy that it is fine to assign these without
the casts and no chance of overflow.
> gai->pci.link_width_curr =
> - (u8)((stat & PCI_EXP_LNKSTA_NLW)
> - >> PCI_EXP_LNKSTA_NLW_SHIFT);
> + (u8)FIELD_GET(PCI_EXP_LNKSTA_NLW, stat);
> gai->pci.link_width_max =
> - (u8)((caps & PCI_EXP_LNKCAP_MLW)
> - >> 4);
> + (u8)FIELD_GET(PCI_EXP_LNKCAP_MLW, caps);
> }
>
> gai->pci.msi_vector_cnt = 1;
next prev parent reply other threads:[~2023-09-12 10:38 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 ` [PATCH 1/8] IB/hfi1: Use FIELD_GET() to extract Link Width Ilpo Järvinen
2023-09-12 10:26 ` 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 [this message]
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=20230912113817.000064db@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=helgaas@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxdrivers@attotech.com \
--cc=martin.petersen@oracle.com \
/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).