Skip to content

Commit cf17770

Browse files
committed
PCI/VC: Use FIELD_GET()
Use FIELD_GET() to remove dependences on the field position, i.e., the shift value. No functional change intended. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
1 parent 83728ff commit cf17770

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/pci/vc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Author: Alex Williamson <[email protected]>
77
*/
88

9+
#include <linux/bitfield.h>
910
#include <linux/device.h>
1011
#include <linux/kernel.h>
1112
#include <linux/module.h>
@@ -201,9 +202,9 @@ static int pci_vc_do_save_buffer(struct pci_dev *dev, int pos,
201202
/* Extended VC Count (not counting VC0) */
202203
evcc = cap1 & PCI_VC_CAP1_EVCC;
203204
/* Low Priority Extended VC Count (not counting VC0) */
204-
lpevcc = (cap1 & PCI_VC_CAP1_LPEVCC) >> 4;
205+
lpevcc = FIELD_GET(PCI_VC_CAP1_LPEVCC, cap1);
205206
/* Port Arbitration Table Entry Size (bits) */
206-
parb_size = 1 << ((cap1 & PCI_VC_CAP1_ARB_SIZE) >> 10);
207+
parb_size = 1 << FIELD_GET(PCI_VC_CAP1_ARB_SIZE, cap1);
207208

208209
/*
209210
* Port VC Control Register contains VC Arbitration Select, which
@@ -231,7 +232,7 @@ static int pci_vc_do_save_buffer(struct pci_dev *dev, int pos,
231232
int vcarb_offset;
232233

233234
pci_read_config_dword(dev, pos + PCI_VC_PORT_CAP2, &cap2);
234-
vcarb_offset = ((cap2 & PCI_VC_CAP2_ARB_OFF) >> 24) * 16;
235+
vcarb_offset = FIELD_GET(PCI_VC_CAP2_ARB_OFF, cap2) * 16;
235236

236237
if (vcarb_offset) {
237238
int size, vcarb_phases = 0;
@@ -277,7 +278,7 @@ static int pci_vc_do_save_buffer(struct pci_dev *dev, int pos,
277278

278279
pci_read_config_dword(dev, pos + PCI_VC_RES_CAP +
279280
(i * PCI_CAP_VC_PER_VC_SIZEOF), &cap);
280-
parb_offset = ((cap & PCI_VC_RES_CAP_ARB_OFF) >> 24) * 16;
281+
parb_offset = FIELD_GET(PCI_VC_RES_CAP_ARB_OFF, cap) * 16;
281282
if (parb_offset) {
282283
int size, parb_phases = 0;
283284

0 commit comments

Comments
 (0)