Skip to content

Commit 9a9eec4

Browse files
committed
PCI/DPC: Use FIELD_GET()
Use FIELD_GET() to remove dependencies on the field position, i.e., the shift value. No functional change intended. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent abaaac4 commit 9a9eec4

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

drivers/pci/pcie/dpc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define dev_fmt(fmt) "DPC: " fmt
1010

1111
#include <linux/aer.h>
12+
#include <linux/bitfield.h>
1213
#include <linux/delay.h>
1314
#include <linux/interrupt.h>
1415
#include <linux/init.h>
@@ -202,7 +203,7 @@ static void dpc_process_rp_pio_error(struct pci_dev *pdev)
202203

203204
/* Get First Error Pointer */
204205
pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &dpc_status);
205-
first_error = (dpc_status & 0x1f00) >> 8;
206+
first_error = FIELD_GET(PCI_EXP_DPC_RP_PIO_FEP, dpc_status);
206207

207208
for (i = 0; i < ARRAY_SIZE(rp_pio_error_string); i++) {
208209
if ((status & ~mask) & (1 << i))
@@ -338,7 +339,7 @@ void pci_dpc_init(struct pci_dev *pdev)
338339
/* Quirks may set dpc_rp_log_size if device or firmware is buggy */
339340
if (!pdev->dpc_rp_log_size) {
340341
pdev->dpc_rp_log_size =
341-
(cap & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8;
342+
FIELD_GET(PCI_EXP_DPC_RP_PIO_LOG_SIZE, cap);
342343
if (pdev->dpc_rp_log_size < 4 || pdev->dpc_rp_log_size > 9) {
343344
pci_err(pdev, "RP PIO log size %u is invalid\n",
344345
pdev->dpc_rp_log_size);

drivers/pci/quirks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6154,7 +6154,7 @@ static void dpc_log_size(struct pci_dev *dev)
61546154
if (!(val & PCI_EXP_DPC_CAP_RP_EXT))
61556155
return;
61566156

6157-
if (!((val & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8)) {
6157+
if (FIELD_GET(PCI_EXP_DPC_RP_PIO_LOG_SIZE, val) == 0) {
61586158
pci_info(dev, "Overriding RP PIO Log Size to 4\n");
61596159
dev->dpc_rp_log_size = 4;
61606160
}

include/uapi/linux/pci_regs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,7 @@
10471047
#define PCI_EXP_DPC_STATUS_INTERRUPT 0x0008 /* Interrupt Status */
10481048
#define PCI_EXP_DPC_RP_BUSY 0x0010 /* Root Port Busy */
10491049
#define PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT 0x0060 /* Trig Reason Extension */
1050+
#define PCI_EXP_DPC_RP_PIO_FEP 0x1f00 /* RP PIO First Err Ptr */
10501051

10511052
#define PCI_EXP_DPC_SOURCE_ID 0x0A /* DPC Source Identifier */
10521053

0 commit comments

Comments
 (0)