Skip to content

Commit 0cf985d

Browse files
kishonLorenzo Pieralisi
authored andcommitted
PCI: cadence: Simplify code to get register base address for configuring BAR
No functional change. Simplify code to get register base address for configuring PCI BAR. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kishon Vijay Abraham I <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]>
1 parent 53fd3cb commit 0cf985d

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,8 @@ static int cdns_pcie_ep_set_bar(struct pci_epc *epc, u8 fn, u8 vfn,
9797
cdns_pcie_writel(pcie, CDNS_PCIE_AT_IB_EP_FUNC_BAR_ADDR1(fn, bar),
9898
addr1);
9999

100-
if (bar < BAR_4) {
101-
reg = CDNS_PCIE_LM_EP_FUNC_BAR_CFG0(fn);
102-
b = bar;
103-
} else {
104-
reg = CDNS_PCIE_LM_EP_FUNC_BAR_CFG1(fn);
105-
b = bar - BAR_4;
106-
}
100+
reg = CDNS_PCIE_LM_EP_FUNC_BAR_CFG(bar, fn);
101+
b = (bar < BAR_4) ? bar : bar - BAR_4;
107102

108103
cfg = cdns_pcie_readl(pcie, reg);
109104
cfg &= ~(CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE_MASK(b) |
@@ -126,13 +121,8 @@ static void cdns_pcie_ep_clear_bar(struct pci_epc *epc, u8 fn, u8 vfn,
126121
enum pci_barno bar = epf_bar->barno;
127122
u32 reg, cfg, b, ctrl;
128123

129-
if (bar < BAR_4) {
130-
reg = CDNS_PCIE_LM_EP_FUNC_BAR_CFG0(fn);
131-
b = bar;
132-
} else {
133-
reg = CDNS_PCIE_LM_EP_FUNC_BAR_CFG1(fn);
134-
b = bar - BAR_4;
135-
}
124+
reg = CDNS_PCIE_LM_EP_FUNC_BAR_CFG(bar, fn);
125+
b = (bar < BAR_4) ? bar : bar - BAR_4;
136126

137127
ctrl = CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED;
138128
cfg = cdns_pcie_readl(pcie, reg);

drivers/pci/controller/cadence/pcie-cadence.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/kernel.h>
1010
#include <linux/pci.h>
11+
#include <linux/pci-epf.h>
1112
#include <linux/phy/phy.h>
1213

1314
/* Parameters for the waiting for link up routine */
@@ -46,6 +47,8 @@
4647
#define CDNS_PCIE_LM_EP_ID_BUS_SHIFT 8
4748

4849
/* Endpoint Function f BAR b Configuration Registers */
50+
#define CDNS_PCIE_LM_EP_FUNC_BAR_CFG(bar, fn) \
51+
(((bar) < BAR_4) ? CDNS_PCIE_LM_EP_FUNC_BAR_CFG0(fn) : CDNS_PCIE_LM_EP_FUNC_BAR_CFG1(fn))
4952
#define CDNS_PCIE_LM_EP_FUNC_BAR_CFG0(fn) \
5053
(CDNS_PCIE_LM_BASE + 0x0240 + (fn) * 0x0008)
5154
#define CDNS_PCIE_LM_EP_FUNC_BAR_CFG1(fn) \

0 commit comments

Comments
 (0)