Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20231010204436.1000644-10-helgaas@kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>

+5 -4
+5 -4
drivers/pci/vc.c
··· 6 6 * Author: Alex Williamson <alex.williamson@redhat.com> 7 7 */ 8 8 9 + #include <linux/bitfield.h> 9 10 #include <linux/device.h> 10 11 #include <linux/kernel.h> 11 12 #include <linux/module.h> ··· 202 201 /* Extended VC Count (not counting VC0) */ 203 202 evcc = cap1 & PCI_VC_CAP1_EVCC; 204 203 /* Low Priority Extended VC Count (not counting VC0) */ 205 - lpevcc = (cap1 & PCI_VC_CAP1_LPEVCC) >> 4; 204 + lpevcc = FIELD_GET(PCI_VC_CAP1_LPEVCC, cap1); 206 205 /* Port Arbitration Table Entry Size (bits) */ 207 - parb_size = 1 << ((cap1 & PCI_VC_CAP1_ARB_SIZE) >> 10); 206 + parb_size = 1 << FIELD_GET(PCI_VC_CAP1_ARB_SIZE, cap1); 208 207 209 208 /* 210 209 * Port VC Control Register contains VC Arbitration Select, which ··· 232 231 int vcarb_offset; 233 232 234 233 pci_read_config_dword(dev, pos + PCI_VC_PORT_CAP2, &cap2); 235 - vcarb_offset = ((cap2 & PCI_VC_CAP2_ARB_OFF) >> 24) * 16; 234 + vcarb_offset = FIELD_GET(PCI_VC_CAP2_ARB_OFF, cap2) * 16; 236 235 237 236 if (vcarb_offset) { 238 237 int size, vcarb_phases = 0; ··· 278 277 279 278 pci_read_config_dword(dev, pos + PCI_VC_RES_CAP + 280 279 (i * PCI_CAP_VC_PER_VC_SIZEOF), &cap); 281 - parb_offset = ((cap & PCI_VC_RES_CAP_ARB_OFF) >> 24) * 16; 280 + parb_offset = FIELD_GET(PCI_VC_RES_CAP_ARB_OFF, cap) * 16; 282 281 if (parb_offset) { 283 282 int size, parb_phases = 0; 284 283