Skip to content

Commit 5532f24

Browse files
ij-intelmartinkpetersen
authored andcommitted
scsi: esas2r: Use FIELD_GET() to extract PCIe capability fields
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jonathan Cameron <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent ccc3e13 commit 5532f24

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

drivers/scsi/esas2r/esas2r_ioctl.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
* USA.
4242
*/
4343

44+
#include <linux/bitfield.h>
45+
4446
#include "esas2r.h"
4547

4648
/*
@@ -792,16 +794,10 @@ static int hba_ioctl_callback(struct esas2r_adapter *a,
792794
pcie_capability_read_dword(a->pcid, PCI_EXP_LNKCAP,
793795
&caps);
794796

795-
gai->pci.link_speed_curr =
796-
(u8)(stat & PCI_EXP_LNKSTA_CLS);
797-
gai->pci.link_speed_max =
798-
(u8)(caps & PCI_EXP_LNKCAP_SLS);
799-
gai->pci.link_width_curr =
800-
(u8)((stat & PCI_EXP_LNKSTA_NLW)
801-
>> PCI_EXP_LNKSTA_NLW_SHIFT);
802-
gai->pci.link_width_max =
803-
(u8)((caps & PCI_EXP_LNKCAP_MLW)
804-
>> 4);
797+
gai->pci.link_speed_curr = FIELD_GET(PCI_EXP_LNKSTA_CLS, stat);
798+
gai->pci.link_speed_max = FIELD_GET(PCI_EXP_LNKCAP_SLS, caps);
799+
gai->pci.link_width_curr = FIELD_GET(PCI_EXP_LNKSTA_NLW, stat);
800+
gai->pci.link_width_max = FIELD_GET(PCI_EXP_LNKCAP_MLW, caps);
805801
}
806802

807803
gai->pci.msi_vector_cnt = 1;

0 commit comments

Comments
 (0)