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

PCI/PTM: Use FIELD_GET()

Use FIELD_GET() and FIELD_PREP() to remove dependences on the field
position, i.e., the shift value. No functional change intended.

Link: https://lore.kernel.org/r/20231010204436.1000644-9-helgaas@kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>

+3 -2
+3 -2
drivers/pci/pcie/ptm.c
··· 4 4 * Copyright (c) 2016, Intel Corporation. 5 5 */ 6 6 7 + #include <linux/bitfield.h> 7 8 #include <linux/module.h> 8 9 #include <linux/init.h> 9 10 #include <linux/pci.h> ··· 54 53 pci_add_ext_cap_save_buffer(dev, PCI_EXT_CAP_ID_PTM, sizeof(u32)); 55 54 56 55 pci_read_config_dword(dev, ptm + PCI_PTM_CAP, &cap); 57 - dev->ptm_granularity = (cap & PCI_PTM_GRANULARITY_MASK) >> 8; 56 + dev->ptm_granularity = FIELD_GET(PCI_PTM_GRANULARITY_MASK, cap); 58 57 59 58 /* 60 59 * Per the spec recommendation (PCIe r6.0, sec 7.9.15.3), select the ··· 147 146 148 147 ctrl |= PCI_PTM_CTRL_ENABLE; 149 148 ctrl &= ~PCI_PTM_GRANULARITY_MASK; 150 - ctrl |= dev->ptm_granularity << 8; 149 + ctrl |= FIELD_PREP(PCI_PTM_GRANULARITY_MASK, dev->ptm_granularity); 151 150 if (dev->ptm_root) 152 151 ctrl |= PCI_PTM_CTRL_ROOT; 153 152