Skip to content

Commit e0701bd

Browse files
committed
PCI/ATS: 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/[email protected] Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
1 parent d30fea2 commit e0701bd

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

drivers/pci/ats.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Copyright (C) 2011 Advanced Micro Devices,
1010
*/
1111

12+
#include <linux/bitfield.h>
1213
#include <linux/export.h>
1314
#include <linux/pci-ats.h>
1415
#include <linux/pci.h>
@@ -480,8 +481,6 @@ int pci_pasid_features(struct pci_dev *pdev)
480481
}
481482
EXPORT_SYMBOL_GPL(pci_pasid_features);
482483

483-
#define PASID_NUMBER_SHIFT 8
484-
#define PASID_NUMBER_MASK (0x1f << PASID_NUMBER_SHIFT)
485484
/**
486485
* pci_max_pasids - Get maximum number of PASIDs supported by device
487486
* @pdev: PCI device structure
@@ -503,9 +502,7 @@ int pci_max_pasids(struct pci_dev *pdev)
503502

504503
pci_read_config_word(pdev, pasid + PCI_PASID_CAP, &supported);
505504

506-
supported = (supported & PASID_NUMBER_MASK) >> PASID_NUMBER_SHIFT;
507-
508-
return (1 << supported);
505+
return (1 << FIELD_GET(PCI_PASID_CAP_WIDTH, supported));
509506
}
510507
EXPORT_SYMBOL_GPL(pci_max_pasids);
511508
#endif /* CONFIG_PCI_PASID */

include/uapi/linux/pci_regs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,7 @@
932932
#define PCI_PASID_CAP 0x04 /* PASID feature register */
933933
#define PCI_PASID_CAP_EXEC 0x0002 /* Exec permissions Supported */
934934
#define PCI_PASID_CAP_PRIV 0x0004 /* Privilege Mode Supported */
935+
#define PCI_PASID_CAP_WIDTH 0x1f00
935936
#define PCI_PASID_CTRL 0x06 /* PASID control register */
936937
#define PCI_PASID_CTRL_ENABLE 0x0001 /* Enable bit */
937938
#define PCI_PASID_CTRL_EXEC 0x0002 /* Exec permissions Enable */

0 commit comments

Comments
 (0)