Skip to content

Commit

Permalink
PCI/PTM: Use FIELD_GET()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bjorn-helgaas committed Oct 24, 2023
1 parent ec302b1 commit 83728ff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/pci/pcie/ptm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 83728ff

Please sign in to comment.