[RESEND PATCH 07/16] PCI/REBAR: Use FIELD_MODIFY()

From: Hans Zhang

Date: Thu Apr 30 2026 - 12:26:38 EST


Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.

Signed-off-by: Hans Zhang <18255117159@xxxxxxx>
---
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