PCI/PTM: Use FIELD_GET()
authorBjorn Helgaas <bhelgaas@google.com>
Tue, 10 Oct 2023 20:44:34 +0000 (15:44 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 24 Oct 2023 21:55:45 +0000 (16:55 -0500)
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>
drivers/pci/pcie/ptm.c

index b4e5f553467c3b6fb3eb44a8a1749c946b0ba244..7cfb6c0d5dcb6de2a759b56d6877c95102b3d10f 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (c) 2016, Intel Corporation.
  */
 
+#include <linux/bitfield.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/pci.h>
@@ -53,7 +54,7 @@ void pci_ptm_init(struct pci_dev *dev)
        pci_add_ext_cap_save_buffer(dev, PCI_EXT_CAP_ID_PTM, sizeof(u32));
 
        pci_read_config_dword(dev, ptm + PCI_PTM_CAP, &cap);
-       dev->ptm_granularity = (cap & PCI_PTM_GRANULARITY_MASK) >> 8;
+       dev->ptm_granularity = FIELD_GET(PCI_PTM_GRANULARITY_MASK, cap);
 
        /*
         * Per the spec recommendation (PCIe r6.0, sec 7.9.15.3), select the
@@ -146,7 +147,7 @@ static int __pci_enable_ptm(struct pci_dev *dev)
 
        ctrl |= PCI_PTM_CTRL_ENABLE;
        ctrl &= ~PCI_PTM_GRANULARITY_MASK;
-       ctrl |= dev->ptm_granularity << 8;
+       ctrl |= FIELD_PREP(PCI_PTM_GRANULARITY_MASK, dev->ptm_granularity);
        if (dev->ptm_root)
                ctrl |= PCI_PTM_CTRL_ROOT;