* [PATCH 01/16] PCI: Use FIELD_MODIFY()
2026-04-30 16:12 [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
@ 2026-04-30 16:12 ` Hans Zhang
2026-04-30 16:12 ` [PATCH 02/16] PCI/PTM: " Hans Zhang
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hans Zhang @ 2026-04-30 16:12 UTC (permalink / raw)
To: bhelgaas, lpieralisi, kwilczynski, mani, jingoohan1
Cc: robh, s32, linux-pci, linux-kernel, Hans Zhang
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/pci.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 8f7cfcc00090..942f70f6a441 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5771,8 +5771,7 @@ int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
if (v > o && (dev->bus->bus_flags & PCI_BUS_FLAGS_NO_MMRBC))
return -EIO;
- cmd &= ~PCI_X_CMD_MAX_READ;
- cmd |= FIELD_PREP(PCI_X_CMD_MAX_READ, v);
+ FIELD_MODIFY(PCI_X_CMD_MAX_READ, &cmd, v);
if (pci_write_config_word(dev, cap + PCI_X_CMD, cmd))
return -EIO;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 02/16] PCI/PTM: Use FIELD_MODIFY()
2026-04-30 16:12 [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
2026-04-30 16:12 ` [PATCH 01/16] PCI: Use FIELD_MODIFY() Hans Zhang
@ 2026-04-30 16:12 ` Hans Zhang
2026-04-30 16:12 ` [PATCH 03/16] PCI/IDE: " Hans Zhang
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hans Zhang @ 2026-04-30 16:12 UTC (permalink / raw)
To: bhelgaas, lpieralisi, kwilczynski, mani, jingoohan1
Cc: robh, s32, linux-pci, linux-kernel, Hans Zhang
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/pcie/ptm.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c
index a41ffd1914de..bd3bd39f6372 100644
--- a/drivers/pci/pcie/ptm.c
+++ b/drivers/pci/pcie/ptm.c
@@ -152,8 +152,7 @@ static int __pci_enable_ptm(struct pci_dev *dev)
pci_read_config_dword(dev, ptm + PCI_PTM_CTRL, &ctrl);
ctrl |= PCI_PTM_CTRL_ENABLE;
- ctrl &= ~PCI_PTM_GRANULARITY_MASK;
- ctrl |= FIELD_PREP(PCI_PTM_GRANULARITY_MASK, dev->ptm_granularity);
+ FIELD_MODIFY(PCI_PTM_GRANULARITY_MASK, &ctrl, dev->ptm_granularity);
if (dev->ptm_root)
ctrl |= PCI_PTM_CTRL_ROOT;
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 03/16] PCI/IDE: Use FIELD_MODIFY()
2026-04-30 16:12 [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
2026-04-30 16:12 ` [PATCH 01/16] PCI: Use FIELD_MODIFY() Hans Zhang
2026-04-30 16:12 ` [PATCH 02/16] PCI/PTM: " Hans Zhang
@ 2026-04-30 16:12 ` Hans Zhang
2026-04-30 16:12 ` [PATCH 04/16] PCI/IOV: " Hans Zhang
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hans Zhang @ 2026-04-30 16:12 UTC (permalink / raw)
To: bhelgaas, lpieralisi, kwilczynski, mani, jingoohan1
Cc: robh, s32, linux-pci, linux-kernel, Hans Zhang
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/ide.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/ide.c b/drivers/pci/ide.c
index be74e8f0ae21..beb67b8fb5c5 100644
--- a/drivers/pci/ide.c
+++ b/drivers/pci/ide.c
@@ -170,8 +170,7 @@ void pci_ide_init(struct pci_dev *pdev)
pci_read_config_dword(pdev, pos + PCI_IDE_SEL_CTL, &val);
if (val & PCI_IDE_SEL_CTL_EN)
continue;
- val &= ~PCI_IDE_SEL_CTL_ID;
- val |= FIELD_PREP(PCI_IDE_SEL_CTL_ID, PCI_IDE_RESERVED_STREAM_ID);
+ FIELD_MODIFY(PCI_IDE_SEL_CTL_ID, &val, PCI_IDE_RESERVED_STREAM_ID);
pci_write_config_dword(pdev, pos + PCI_IDE_SEL_CTL, val);
}
@@ -182,8 +181,7 @@ void pci_ide_init(struct pci_dev *pdev)
pci_read_config_dword(pdev, pos, &val);
if (val & PCI_IDE_LINK_CTL_EN)
continue;
- val &= ~PCI_IDE_LINK_CTL_ID;
- val |= FIELD_PREP(PCI_IDE_LINK_CTL_ID, PCI_IDE_RESERVED_STREAM_ID);
+ FIELD_MODIFY(PCI_IDE_LINK_CTL_ID, &val, PCI_IDE_RESERVED_STREAM_ID);
pci_write_config_dword(pdev, pos, val);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 04/16] PCI/IOV: Use FIELD_MODIFY()
2026-04-30 16:12 [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
` (2 preceding siblings ...)
2026-04-30 16:12 ` [PATCH 03/16] PCI/IDE: " Hans Zhang
@ 2026-04-30 16:12 ` Hans Zhang
2026-04-30 16:12 ` [PATCH 05/16] PCI/TPH: " Hans Zhang
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hans Zhang @ 2026-04-30 16:12 UTC (permalink / raw)
To: bhelgaas, lpieralisi, kwilczynski, mani, jingoohan1
Cc: robh, s32, linux-pci, linux-kernel, Hans Zhang
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/iov.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 91ac4e37ecb9..fdae70abe804 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -946,8 +946,7 @@ static void sriov_restore_vf_rebar_state(struct pci_dev *dev)
pci_read_config_dword(dev, pos + PCI_VF_REBAR_CTRL, &ctrl);
bar_idx = FIELD_GET(PCI_VF_REBAR_CTRL_BAR_IDX, ctrl);
size = pci_rebar_bytes_to_size(dev->sriov->barsz[bar_idx]);
- ctrl &= ~PCI_VF_REBAR_CTRL_BAR_SIZE;
- ctrl |= FIELD_PREP(PCI_VF_REBAR_CTRL_BAR_SIZE, size);
+ FIELD_MODIFY(PCI_VF_REBAR_CTRL_BAR_SIZE, &ctrl, size);
pci_write_config_dword(dev, pos + PCI_VF_REBAR_CTRL, ctrl);
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 05/16] PCI/TPH: Use FIELD_MODIFY()
2026-04-30 16:12 [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
` (3 preceding siblings ...)
2026-04-30 16:12 ` [PATCH 04/16] PCI/IOV: " Hans Zhang
@ 2026-04-30 16:12 ` Hans Zhang
2026-04-30 16:12 ` [PATCH 06/16] PCI/MSI: " Hans Zhang
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hans Zhang @ 2026-04-30 16:12 UTC (permalink / raw)
To: bhelgaas, lpieralisi, kwilczynski, mani, jingoohan1
Cc: robh, s32, linux-pci, linux-kernel, Hans Zhang
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/tph.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
index 91145e8d9d95..655ffd60e62f 100644
--- a/drivers/pci/tph.c
+++ b/drivers/pci/tph.c
@@ -139,8 +139,7 @@ static void set_ctrl_reg_req_en(struct pci_dev *pdev, u8 req_type)
pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, ®);
- reg &= ~PCI_TPH_CTRL_REQ_EN_MASK;
- reg |= FIELD_PREP(PCI_TPH_CTRL_REQ_EN_MASK, req_type);
+ FIELD_MODIFY(PCI_TPH_CTRL_REQ_EN_MASK, ®, req_type);
pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, reg);
}
@@ -427,11 +426,8 @@ int pcie_enable_tph(struct pci_dev *pdev, int mode)
/* Write them into TPH control register */
pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, ®);
- reg &= ~PCI_TPH_CTRL_MODE_SEL_MASK;
- reg |= FIELD_PREP(PCI_TPH_CTRL_MODE_SEL_MASK, pdev->tph_mode);
-
- reg &= ~PCI_TPH_CTRL_REQ_EN_MASK;
- reg |= FIELD_PREP(PCI_TPH_CTRL_REQ_EN_MASK, pdev->tph_req_type);
+ FIELD_MODIFY(PCI_TPH_CTRL_MODE_SEL_MASK, ®, pdev->tph_mode);
+ FIELD_MODIFY(PCI_TPH_CTRL_REQ_EN_MASK, ®, pdev->tph_req_type);
pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, reg);
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 06/16] PCI/MSI: Use FIELD_MODIFY()
2026-04-30 16:12 [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
` (4 preceding siblings ...)
2026-04-30 16:12 ` [PATCH 05/16] PCI/TPH: " Hans Zhang
@ 2026-04-30 16:12 ` Hans Zhang
2026-04-30 16:12 ` [PATCH 07/16] PCI/REBAR: " Hans Zhang
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hans Zhang @ 2026-04-30 16:12 UTC (permalink / raw)
To: bhelgaas, lpieralisi, kwilczynski, mani, jingoohan1
Cc: robh, s32, linux-pci, linux-kernel, Hans Zhang
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/msi/msi.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 81d24a270a79..33c8b5b98684 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -201,8 +201,7 @@ static inline void pci_write_msg_msi(struct pci_dev *dev, struct msi_desc *desc,
u16 msgctl;
pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &msgctl);
- msgctl &= ~PCI_MSI_FLAGS_QSIZE;
- msgctl |= FIELD_PREP(PCI_MSI_FLAGS_QSIZE, desc->pci.msi_attrib.multiple);
+ FIELD_MODIFY(PCI_MSI_FLAGS_QSIZE, &msgctl, desc->pci.msi_attrib.multiple);
pci_write_config_word(dev, pos + PCI_MSI_FLAGS, msgctl);
pci_write_config_dword(dev, pos + PCI_MSI_ADDRESS_LO, msg->address_lo);
@@ -532,9 +531,8 @@ void __pci_restore_msi_state(struct pci_dev *dev)
pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control);
pci_msi_update_mask(entry, 0, 0);
- control &= ~PCI_MSI_FLAGS_QSIZE;
- control |= PCI_MSI_FLAGS_ENABLE |
- FIELD_PREP(PCI_MSI_FLAGS_QSIZE, entry->pci.msi_attrib.multiple);
+ FIELD_MODIFY(PCI_MSI_FLAGS_QSIZE, &control, entry->pci.msi_attrib.multiple);
+ control |= PCI_MSI_FLAGS_ENABLE;
pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control);
}
@@ -970,8 +968,7 @@ int pci_msix_write_tph_tag(struct pci_dev *pdev, unsigned int index, u16 tag)
if (!msi_desc || msi_desc->pci.msi_attrib.is_virtual)
return -ENXIO;
- msi_desc->pci.msix_ctrl &= ~PCI_MSIX_ENTRY_CTRL_ST;
- msi_desc->pci.msix_ctrl |= FIELD_PREP(PCI_MSIX_ENTRY_CTRL_ST, tag);
+ FIELD_MODIFY(PCI_MSIX_ENTRY_CTRL_ST, &msi_desc->pci.msix_ctrl, tag);
pci_msix_write_vector_ctrl(msi_desc, msi_desc->pci.msix_ctrl);
/* Flush the write */
readl(pci_msix_desc_addr(msi_desc));
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 07/16] PCI/REBAR: Use FIELD_MODIFY()
2026-04-30 16:12 [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
` (5 preceding siblings ...)
2026-04-30 16:12 ` [PATCH 06/16] PCI/MSI: " Hans Zhang
@ 2026-04-30 16:12 ` Hans Zhang
2026-04-30 16:12 ` [PATCH 08/16] PCI/CARDBUS: " Hans Zhang
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hans Zhang @ 2026-04-30 16:12 UTC (permalink / raw)
To: bhelgaas, lpieralisi, kwilczynski, mani, jingoohan1
Cc: robh, s32, linux-pci, linux-kernel, Hans Zhang
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/rebar.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/rebar.c b/drivers/pci/rebar.c
index 39f8cf3b70d5..e3e0415fc29a 100644
--- a/drivers/pci/rebar.c
+++ b/drivers/pci/rebar.c
@@ -211,8 +211,7 @@ int pci_rebar_set_size(struct pci_dev *pdev, int bar, int size)
return pos;
pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
- ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE;
- ctrl |= FIELD_PREP(PCI_REBAR_CTRL_BAR_SIZE, size);
+ FIELD_MODIFY(PCI_REBAR_CTRL_BAR_SIZE, &ctrl, size);
pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl);
if (pci_resource_is_iov(bar))
@@ -241,8 +240,7 @@ void pci_restore_rebar_state(struct pci_dev *pdev)
bar_idx = ctrl & PCI_REBAR_CTRL_BAR_IDX;
res = pci_resource_n(pdev, bar_idx);
size = pci_rebar_bytes_to_size(resource_size(res));
- ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE;
- ctrl |= FIELD_PREP(PCI_REBAR_CTRL_BAR_SIZE, size);
+ FIELD_MODIFY(PCI_REBAR_CTRL_BAR_SIZE, &ctrl, size);
pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl);
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 08/16] PCI/CARDBUS: Use FIELD_MODIFY()
2026-04-30 16:12 [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
` (6 preceding siblings ...)
2026-04-30 16:12 ` [PATCH 07/16] PCI/REBAR: " Hans Zhang
@ 2026-04-30 16:12 ` Hans Zhang
2026-04-30 16:12 ` [PATCH 09/16] PCI: al: " Hans Zhang
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Hans Zhang @ 2026-04-30 16:12 UTC (permalink / raw)
To: bhelgaas, lpieralisi, kwilczynski, mani, jingoohan1
Cc: robh, s32, linux-pci, linux-kernel, Hans Zhang
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/setup-cardbus.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pci/setup-cardbus.c b/drivers/pci/setup-cardbus.c
index 1ebd13a1f730..f7c62054f227 100644
--- a/drivers/pci/setup-cardbus.c
+++ b/drivers/pci/setup-cardbus.c
@@ -253,8 +253,7 @@ int pci_cardbus_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,
* yenta.c forces a secondary latency timer of 176.
* Copy that behaviour here.
*/
- buses &= ~PCI_SEC_LATENCY_TIMER_MASK;
- buses |= FIELD_PREP(PCI_SEC_LATENCY_TIMER_MASK, CARDBUS_LATENCY_TIMER);
+ FIELD_MODIFY(PCI_SEC_LATENCY_TIMER_MASK, &buses, CARDBUS_LATENCY_TIMER);
/* We need to blast all three values with a single write */
pci_write_config_dword(dev, PCI_PRIMARY_BUS, buses);
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 09/16] PCI: al: Use FIELD_MODIFY()
2026-04-30 16:12 [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
` (7 preceding siblings ...)
2026-04-30 16:12 ` [PATCH 08/16] PCI/CARDBUS: " Hans Zhang
@ 2026-04-30 16:12 ` Hans Zhang
2026-04-30 16:12 ` [PATCH 10/16] PCI: eswin: " Hans Zhang
2026-04-30 16:22 ` [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
10 siblings, 0 replies; 12+ messages in thread
From: Hans Zhang @ 2026-04-30 16:12 UTC (permalink / raw)
To: bhelgaas, lpieralisi, kwilczynski, mani, jingoohan1
Cc: robh, s32, linux-pci, linux-kernel, Hans Zhang
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pcie-al.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-al.c b/drivers/pci/controller/dwc/pcie-al.c
index 345c281c74fe..ef8c8ce7c78c 100644
--- a/drivers/pci/controller/dwc/pcie-al.c
+++ b/drivers/pci/controller/dwc/pcie-al.c
@@ -253,7 +253,6 @@ static int al_pcie_config_prepare(struct al_pcie *pcie)
u8 subordinate_bus;
u8 secondary_bus;
u32 cfg_control;
- u32 reg;
ft = resource_list_first_type(&pp->bridge->windows, IORESOURCE_BUS);
if (!ft)
@@ -285,14 +284,9 @@ static int al_pcie_config_prepare(struct al_pcie *pcie)
CFG_CONTROL;
cfg_control = al_pcie_controller_readl(pcie, cfg_control_offset);
-
- reg = cfg_control &
- ~(CFG_CONTROL_SEC_BUS_MASK | CFG_CONTROL_SUBBUS_MASK);
-
- reg |= FIELD_PREP(CFG_CONTROL_SUBBUS_MASK, subordinate_bus) |
- FIELD_PREP(CFG_CONTROL_SEC_BUS_MASK, secondary_bus);
-
- al_pcie_controller_writel(pcie, cfg_control_offset, reg);
+ FIELD_MODIFY(CFG_CONTROL_SUBBUS_MASK, &cfg_control, subordinate_bus);
+ FIELD_MODIFY(CFG_CONTROL_SEC_BUS_MASK, &cfg_control, secondary_bus);
+ al_pcie_controller_writel(pcie, cfg_control_offset, cfg_control);
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 10/16] PCI: eswin: Use FIELD_MODIFY()
2026-04-30 16:12 [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
` (8 preceding siblings ...)
2026-04-30 16:12 ` [PATCH 09/16] PCI: al: " Hans Zhang
@ 2026-04-30 16:12 ` Hans Zhang
2026-04-30 16:22 ` [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
10 siblings, 0 replies; 12+ messages in thread
From: Hans Zhang @ 2026-04-30 16:12 UTC (permalink / raw)
To: bhelgaas, lpieralisi, kwilczynski, mani, jingoohan1
Cc: robh, s32, linux-pci, linux-kernel, Hans Zhang
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pcie-eswin.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-eswin.c b/drivers/pci/controller/dwc/pcie-eswin.c
index 2845832b3824..ce8d64f8a395 100644
--- a/drivers/pci/controller/dwc/pcie-eswin.c
+++ b/drivers/pci/controller/dwc/pcie-eswin.c
@@ -211,8 +211,7 @@ static int eswin_pcie_host_init(struct dw_pcie_rp *pp)
/* Configure Root Port type */
val = readl_relaxed(pci->elbi_base + PCIEELBI_CTRL0_OFFSET);
- val &= ~PCIEELBI_CTRL0_DEV_TYPE;
- val |= FIELD_PREP(PCIEELBI_CTRL0_DEV_TYPE, PCI_EXP_TYPE_ROOT_PORT);
+ FIELD_MODIFY(PCIEELBI_CTRL0_DEV_TYPE, &val, PCI_EXP_TYPE_ROOT_PORT);
writel_relaxed(val, pci->elbi_base + PCIEELBI_CTRL0_OFFSET);
list_for_each_entry(port, &pcie->ports, list) {
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations
2026-04-30 16:12 [PATCH 00/16] PCI: Use FIELD_MODIFY() to simplify bitfield operations Hans Zhang
` (9 preceding siblings ...)
2026-04-30 16:12 ` [PATCH 10/16] PCI: eswin: " Hans Zhang
@ 2026-04-30 16:22 ` Hans Zhang
10 siblings, 0 replies; 12+ messages in thread
From: Hans Zhang @ 2026-04-30 16:22 UTC (permalink / raw)
To: bhelgaas, lpieralisi, kwilczynski, mani, jingoohan1
Cc: robh, s32, linux-pci, linux-kernel
Sorry for the noise.Due to my current system issues, the remaining
patches were not sent out. I will resend them now.
Hans
On 5/1/26 00:12, Hans Zhang wrote:
> Replace open-coded bitmask clear + FIELD_PREP() sequences with the
> dedicated FIELD_MODIFY() macro. FIELD_MODIFY() performs the same
> operation but is shorter, less error-prone, and includes compile-time
> checks to prevent field overflow.
>
> This series touches the PCI core, PCIe extended capabilities (PTM, IDE,
> TPH, MSI, REBAR, IOV, CardBus), and several DesignWare-based and
> other PCI host controllers. No functional change is intended.
>
> The patches are split per subsystem or per driver to ease review:
> ---
> Hi, If the Maintainers think it's not necessary, please ignore it.
> ---
>
> Hans Zhang (16):
> PCI: Use FIELD_MODIFY()
> PCI/PTM: Use FIELD_MODIFY()
> PCI/IDE: Use FIELD_MODIFY()
> PCI/IOV: Use FIELD_MODIFY()
> PCI/TPH: Use FIELD_MODIFY()
> PCI/MSI: Use FIELD_MODIFY()
> PCI/REBAR: Use FIELD_MODIFY()
> PCI/CARDBUS: Use FIELD_MODIFY()
> PCI: al: Use FIELD_MODIFY()
> PCI: eswin: Use FIELD_MODIFY()
> PCI: s32g: Use FIELD_MODIFY()
> PCI: tegra194: Use FIELD_MODIFY()
> PCI: qcom: Use FIELD_MODIFY()
> PCI: dwc: Use FIELD_MODIFY()
> PCI: mvebu: Use FIELD_MODIFY()
> PCI: mediatek-gen3: Use FIELD_MODIFY()
>
> drivers/pci/controller/dwc/pcie-al.c | 12 ++----
> .../controller/dwc/pcie-designware-debugfs.c | 23 ++++-------
> .../pci/controller/dwc/pcie-designware-ep.c | 3 +-
> drivers/pci/controller/dwc/pcie-designware.c | 3 +-
> drivers/pci/controller/dwc/pcie-eswin.c | 3 +-
> drivers/pci/controller/dwc/pcie-nxp-s32g.c | 3 +-
> drivers/pci/controller/dwc/pcie-qcom-common.c | 40 +++++++------------
> drivers/pci/controller/dwc/pcie-qcom-ep.c | 6 +--
> drivers/pci/controller/dwc/pcie-tegra194.c | 8 ++--
> drivers/pci/controller/pci-mvebu.c | 3 +-
> drivers/pci/controller/pcie-mediatek-gen3.c | 3 +-
> drivers/pci/ide.c | 6 +--
> drivers/pci/iov.c | 3 +-
> drivers/pci/msi/msi.c | 11 ++---
> drivers/pci/pci.c | 3 +-
> drivers/pci/pcie/ptm.c | 3 +-
> drivers/pci/rebar.c | 6 +--
> drivers/pci/setup-cardbus.c | 3 +-
> drivers/pci/tph.c | 10 ++---
> 19 files changed, 51 insertions(+), 101 deletions(-)
>
>
> base-commit: 3b3bea6d4b9c162f9e555905d96b8c1da67ecd5b
^ permalink raw reply [flat|nested] 12+ messages in thread