Skip to content

Commit b09d0f9

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: cadence: Use FIELD_GET()
Convert open-coded variants of PCI field access into FIELD_GET() to make the code easier to understand. 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 d1f9b39 commit b09d0f9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/pci/controller/cadence/pcie-cadence-ep.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Cadence PCIe endpoint controller driver.
44
// Author: Cyrille Pitchen <[email protected]>
55

6+
#include <linux/bitfield.h>
67
#include <linux/delay.h>
78
#include <linux/kernel.h>
89
#include <linux/of.h>
@@ -262,7 +263,7 @@ static int cdns_pcie_ep_get_msi(struct pci_epc *epc, u8 fn, u8 vfn)
262263
* Get the Multiple Message Enable bitfield from the Message Control
263264
* register.
264265
*/
265-
mme = (flags & PCI_MSI_FLAGS_QSIZE) >> 4;
266+
mme = FIELD_GET(PCI_MSI_FLAGS_QSIZE, flags);
266267

267268
return mme;
268269
}
@@ -394,7 +395,7 @@ static int cdns_pcie_ep_send_msi_irq(struct cdns_pcie_ep *ep, u8 fn, u8 vfn,
394395
return -EINVAL;
395396

396397
/* Get the number of enabled MSIs */
397-
mme = (flags & PCI_MSI_FLAGS_QSIZE) >> 4;
398+
mme = FIELD_GET(PCI_MSI_FLAGS_QSIZE, flags);
398399
msi_count = 1 << mme;
399400
if (!interrupt_num || interrupt_num > msi_count)
400401
return -EINVAL;
@@ -449,7 +450,7 @@ static int cdns_pcie_ep_map_msi_irq(struct pci_epc *epc, u8 fn, u8 vfn,
449450
return -EINVAL;
450451

451452
/* Get the number of enabled MSIs */
452-
mme = (flags & PCI_MSI_FLAGS_QSIZE) >> 4;
453+
mme = FIELD_GET(PCI_MSI_FLAGS_QSIZE, flags);
453454
msi_count = 1 << mme;
454455
if (!interrupt_num || interrupt_num > msi_count)
455456
return -EINVAL;
@@ -506,7 +507,7 @@ static int cdns_pcie_ep_send_msix_irq(struct cdns_pcie_ep *ep, u8 fn, u8 vfn,
506507

507508
reg = cap + PCI_MSIX_TABLE;
508509
tbl_offset = cdns_pcie_ep_fn_readl(pcie, fn, reg);
509-
bir = tbl_offset & PCI_MSIX_TABLE_BIR;
510+
bir = FIELD_GET(PCI_MSIX_TABLE_BIR, tbl_offset);
510511
tbl_offset &= PCI_MSIX_TABLE_OFFSET;
511512

512513
msix_tbl = epf->epf_bar[bir]->addr + tbl_offset;

0 commit comments

Comments
 (0)