* [PATCH v2 07/10] scsi: esas2r: Use FIELD_GET() to extract PCIe capability fields [not found] <20230913122748.29530-1-ilpo.jarvinen@linux.intel.com> @ 2023-09-13 12:27 ` Ilpo Järvinen 2023-09-13 13:15 ` Jonathan Cameron 2023-09-14 1:02 ` Martin K. Petersen 2023-09-13 12:27 ` [PATCH v2 08/10] scsi: qla2xxx: " Ilpo Järvinen 1 sibling, 2 replies; 6+ messages in thread From: Ilpo Järvinen @ 2023-09-13 12:27 UTC (permalink / raw) To: Jonathan Cameron, linux-pci, Bjorn Helgaas, Bradley Grove, James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel Cc: Ilpo Järvinen Use FIELD_GET() to extract PCIe capability register fields instead of custom masking and shifting. Also remove the unnecessary cast to u8, the value in those fields always fits to u8. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> --- drivers/scsi/esas2r/esas2r_ioctl.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c index 055d2e87a2c8..3f7c1d131ec3 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" /* @@ -792,16 +794,10 @@ static int hba_ioctl_callback(struct esas2r_adapter *a, pcie_capability_read_dword(a->pcid, PCI_EXP_LNKCAP, &caps); - gai->pci.link_speed_curr = - (u8)(stat & PCI_EXP_LNKSTA_CLS); - gai->pci.link_speed_max = - (u8)(caps & PCI_EXP_LNKCAP_SLS); - gai->pci.link_width_curr = - (u8)((stat & PCI_EXP_LNKSTA_NLW) - >> PCI_EXP_LNKSTA_NLW_SHIFT); - gai->pci.link_width_max = - (u8)((caps & PCI_EXP_LNKCAP_MLW) - >> 4); + gai->pci.link_speed_curr = FIELD_GET(PCI_EXP_LNKSTA_CLS, stat); + gai->pci.link_speed_max = FIELD_GET(PCI_EXP_LNKCAP_SLS, caps); + gai->pci.link_width_curr = FIELD_GET(PCI_EXP_LNKSTA_NLW, stat); + gai->pci.link_width_max = FIELD_GET(PCI_EXP_LNKCAP_MLW, caps); } gai->pci.msi_vector_cnt = 1; -- 2.30.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 07/10] scsi: esas2r: Use FIELD_GET() to extract PCIe capability fields 2023-09-13 12:27 ` [PATCH v2 07/10] scsi: esas2r: Use FIELD_GET() to extract PCIe capability fields Ilpo Järvinen @ 2023-09-13 13:15 ` Jonathan Cameron 2023-09-14 1:02 ` Martin K. Petersen 1 sibling, 0 replies; 6+ messages in thread From: Jonathan Cameron @ 2023-09-13 13:15 UTC (permalink / raw) To: Ilpo Järvinen Cc: linux-pci, Bjorn Helgaas, Bradley Grove, James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel On Wed, 13 Sep 2023 15:27:45 +0300 Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> wrote: > Use FIELD_GET() to extract PCIe capability register fields instead of > custom masking and shifting. Also remove the unnecessary cast to u8, > the value in those fields always fits to u8. > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > --- > drivers/scsi/esas2r/esas2r_ioctl.c | 16 ++++++---------- > 1 file changed, 6 insertions(+), 10 deletions(-) > > diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c > index 055d2e87a2c8..3f7c1d131ec3 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" > > /* > @@ -792,16 +794,10 @@ static int hba_ioctl_callback(struct esas2r_adapter *a, > pcie_capability_read_dword(a->pcid, PCI_EXP_LNKCAP, > &caps); > > - gai->pci.link_speed_curr = > - (u8)(stat & PCI_EXP_LNKSTA_CLS); > - gai->pci.link_speed_max = > - (u8)(caps & PCI_EXP_LNKCAP_SLS); > - gai->pci.link_width_curr = > - (u8)((stat & PCI_EXP_LNKSTA_NLW) > - >> PCI_EXP_LNKSTA_NLW_SHIFT); > - gai->pci.link_width_max = > - (u8)((caps & PCI_EXP_LNKCAP_MLW) > - >> 4); > + gai->pci.link_speed_curr = FIELD_GET(PCI_EXP_LNKSTA_CLS, stat); > + gai->pci.link_speed_max = FIELD_GET(PCI_EXP_LNKCAP_SLS, caps); > + gai->pci.link_width_curr = FIELD_GET(PCI_EXP_LNKSTA_NLW, stat); > + gai->pci.link_width_max = FIELD_GET(PCI_EXP_LNKCAP_MLW, caps); > } > > gai->pci.msi_vector_cnt = 1; ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 07/10] scsi: esas2r: Use FIELD_GET() to extract PCIe capability fields 2023-09-13 12:27 ` [PATCH v2 07/10] scsi: esas2r: Use FIELD_GET() to extract PCIe capability fields Ilpo Järvinen 2023-09-13 13:15 ` Jonathan Cameron @ 2023-09-14 1:02 ` Martin K. Petersen 1 sibling, 0 replies; 6+ messages in thread From: Martin K. Petersen @ 2023-09-14 1:02 UTC (permalink / raw) To: Ilpo Järvinen Cc: Jonathan Cameron, linux-pci, Bjorn Helgaas, Bradley Grove, James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel Ilpo, > Use FIELD_GET() to extract PCIe capability register fields instead of > custom masking and shifting. Also remove the unnecessary cast to u8, > the value in those fields always fits to u8. Applied to 6.7/scsi-staging, thanks! -- Martin K. Petersen Oracle Linux Engineering ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 08/10] scsi: qla2xxx: Use FIELD_GET() to extract PCIe capability fields [not found] <20230913122748.29530-1-ilpo.jarvinen@linux.intel.com> 2023-09-13 12:27 ` [PATCH v2 07/10] scsi: esas2r: Use FIELD_GET() to extract PCIe capability fields Ilpo Järvinen @ 2023-09-13 12:27 ` Ilpo Järvinen 2023-09-13 13:16 ` Jonathan Cameron 2023-09-14 1:02 ` Martin K. Petersen 1 sibling, 2 replies; 6+ messages in thread From: Ilpo Järvinen @ 2023-09-13 12:27 UTC (permalink / raw) To: Jonathan Cameron, linux-pci, Bjorn Helgaas, Nilesh Javali, GR-QLogic-Storage-Upstream, James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel Cc: Ilpo Järvinen Use FIELD_GET() to extract PCIe capability registers field instead of custom masking and shifting. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> --- drivers/scsi/qla2xxx/qla_os.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 50db08265c51..7e103d711825 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -5,6 +5,7 @@ */ #include "qla_def.h" +#include <linux/bitfield.h> #include <linux/moduleparam.h> #include <linux/vmalloc.h> #include <linux/delay.h> @@ -633,8 +634,8 @@ qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str, size_t str_len) const char *speed_str; pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); - lspeed = lstat & PCI_EXP_LNKCAP_SLS; - lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; + lspeed = FIELD_GET(PCI_EXP_LNKCAP_SLS, lstat); + lwidth = FIELD_GET(PCI_EXP_LNKCAP_MLW, lstat); switch (lspeed) { case 1: -- 2.30.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 08/10] scsi: qla2xxx: Use FIELD_GET() to extract PCIe capability fields 2023-09-13 12:27 ` [PATCH v2 08/10] scsi: qla2xxx: " Ilpo Järvinen @ 2023-09-13 13:16 ` Jonathan Cameron 2023-09-14 1:02 ` Martin K. Petersen 1 sibling, 0 replies; 6+ messages in thread From: Jonathan Cameron @ 2023-09-13 13:16 UTC (permalink / raw) To: Ilpo Järvinen Cc: linux-pci, Bjorn Helgaas, Nilesh Javali, GR-QLogic-Storage-Upstream, James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel On Wed, 13 Sep 2023 15:27:46 +0300 Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> wrote: > Use FIELD_GET() to extract PCIe capability registers field instead of > custom masking and shifting. > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > --- > drivers/scsi/qla2xxx/qla_os.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c > index 50db08265c51..7e103d711825 100644 > --- a/drivers/scsi/qla2xxx/qla_os.c > +++ b/drivers/scsi/qla2xxx/qla_os.c > @@ -5,6 +5,7 @@ > */ > #include "qla_def.h" > > +#include <linux/bitfield.h> > #include <linux/moduleparam.h> > #include <linux/vmalloc.h> > #include <linux/delay.h> > @@ -633,8 +634,8 @@ qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str, size_t str_len) > const char *speed_str; > > pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); > - lspeed = lstat & PCI_EXP_LNKCAP_SLS; > - lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; > + lspeed = FIELD_GET(PCI_EXP_LNKCAP_SLS, lstat); > + lwidth = FIELD_GET(PCI_EXP_LNKCAP_MLW, lstat); > > switch (lspeed) { > case 1: ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 08/10] scsi: qla2xxx: Use FIELD_GET() to extract PCIe capability fields 2023-09-13 12:27 ` [PATCH v2 08/10] scsi: qla2xxx: " Ilpo Järvinen 2023-09-13 13:16 ` Jonathan Cameron @ 2023-09-14 1:02 ` Martin K. Petersen 1 sibling, 0 replies; 6+ messages in thread From: Martin K. Petersen @ 2023-09-14 1:02 UTC (permalink / raw) To: Ilpo Järvinen Cc: Jonathan Cameron, linux-pci, Bjorn Helgaas, Nilesh Javali, GR-QLogic-Storage-Upstream, James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel Ilpo, > Use FIELD_GET() to extract PCIe capability registers field instead of > custom masking and shifting. Applied to 6.7/scsi-staging, thanks! -- Martin K. Petersen Oracle Linux Engineering ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-09-14 1:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20230913122748.29530-1-ilpo.jarvinen@linux.intel.com>
2023-09-13 12:27 ` [PATCH v2 07/10] scsi: esas2r: Use FIELD_GET() to extract PCIe capability fields Ilpo Järvinen
2023-09-13 13:15 ` Jonathan Cameron
2023-09-14 1:02 ` Martin K. Petersen
2023-09-13 12:27 ` [PATCH v2 08/10] scsi: qla2xxx: " Ilpo Järvinen
2023-09-13 13:16 ` Jonathan Cameron
2023-09-14 1:02 ` Martin K. Petersen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox