Skip to content

Commit 2612378

Browse files
Hans ZhangMani-Sadhasivam
authored andcommitted
PCI: dwc: ep: Use FIELD_GET() where applicable
Use FIELD_GET() to simplify the code extracting the register values. No functional change intended. Signed-off-by: Hans Zhang <[email protected]> [mani: commit message fixup] Signed-off-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Niklas Cassel <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 0af2f6b commit 2612378

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/pci/controller/dwc/pcie-designware-ep.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,11 @@ static unsigned int dw_pcie_ep_get_rebar_offset(struct dw_pcie *pci,
256256
return offset;
257257

258258
reg = dw_pcie_readl_dbi(pci, offset + PCI_REBAR_CTRL);
259-
nbars = (reg & PCI_REBAR_CTRL_NBAR_MASK) >> PCI_REBAR_CTRL_NBAR_SHIFT;
259+
nbars = FIELD_GET(PCI_REBAR_CTRL_NBAR_MASK, reg);
260260

261261
for (i = 0; i < nbars; i++, offset += PCI_REBAR_CTRL) {
262262
reg = dw_pcie_readl_dbi(pci, offset + PCI_REBAR_CTRL);
263-
bar_index = reg & PCI_REBAR_CTRL_BAR_IDX;
263+
bar_index = FIELD_GET(PCI_REBAR_CTRL_BAR_IDX, reg);
264264
if (bar_index == bar)
265265
return offset;
266266
}
@@ -875,8 +875,7 @@ static void dw_pcie_ep_init_non_sticky_registers(struct dw_pcie *pci)
875875

876876
if (offset) {
877877
reg = dw_pcie_readl_dbi(pci, offset + PCI_REBAR_CTRL);
878-
nbars = (reg & PCI_REBAR_CTRL_NBAR_MASK) >>
879-
PCI_REBAR_CTRL_NBAR_SHIFT;
878+
nbars = FIELD_GET(PCI_REBAR_CTRL_NBAR_MASK, reg);
880879

881880
/*
882881
* PCIe r6.0, sec 7.8.6.2 require us to support at least one
@@ -897,7 +896,7 @@ static void dw_pcie_ep_init_non_sticky_registers(struct dw_pcie *pci)
897896
* is why RESBAR_CAP_REG is written here.
898897
*/
899898
val = dw_pcie_readl_dbi(pci, offset + PCI_REBAR_CTRL);
900-
bar = val & PCI_REBAR_CTRL_BAR_IDX;
899+
bar = FIELD_GET(PCI_REBAR_CTRL_BAR_IDX, val);
901900
if (ep->epf_bar[bar])
902901
pci_epc_bar_size_to_rebar_cap(ep->epf_bar[bar]->size, &val);
903902
else

0 commit comments

Comments
 (0)