Skip to content

Commit 83728ff

Browse files
committed
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/[email protected] Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
1 parent ec302b1 commit 83728ff

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/pci/pcie/ptm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright (c) 2016, Intel Corporation.
55
*/
66

7+
#include <linux/bitfield.h>
78
#include <linux/module.h>
89
#include <linux/init.h>
910
#include <linux/pci.h>
@@ -53,7 +54,7 @@ void pci_ptm_init(struct pci_dev *dev)
5354
pci_add_ext_cap_save_buffer(dev, PCI_EXT_CAP_ID_PTM, sizeof(u32));
5455

5556
pci_read_config_dword(dev, ptm + PCI_PTM_CAP, &cap);
56-
dev->ptm_granularity = (cap & PCI_PTM_GRANULARITY_MASK) >> 8;
57+
dev->ptm_granularity = FIELD_GET(PCI_PTM_GRANULARITY_MASK, cap);
5758

5859
/*
5960
* 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)
146147

147148
ctrl |= PCI_PTM_CTRL_ENABLE;
148149
ctrl &= ~PCI_PTM_GRANULARITY_MASK;
149-
ctrl |= dev->ptm_granularity << 8;
150+
ctrl |= FIELD_PREP(PCI_PTM_GRANULARITY_MASK, dev->ptm_granularity);
150151
if (dev->ptm_root)
151152
ctrl |= PCI_PTM_CTRL_ROOT;
152153

0 commit comments

Comments
 (0)