Skip to content

Commit eb57671

Browse files
committed
PCI: altera: Simplify TLB_CFG_DW0 usage
All TLP_CFG_DW0() uses follow the same pattern based on the root bus number, so pull that into the macro itself to declutter the users. No functional change intended. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent 14c7b95 commit eb57671

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

drivers/pci/host/pcie-altera.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@
5555
#define TLP_PAYLOAD_SIZE 0x01
5656
#define TLP_READ_TAG 0x1d
5757
#define TLP_WRITE_TAG 0x10
58-
#define TLP_CFG_DW0(fmttype) (((fmttype) << 24) | TLP_PAYLOAD_SIZE)
58+
#define TLP_CFG_DW0(pcie, bus) \
59+
((((bus == pcie->root_bus_nr) ? TLP_FMTTYPE_CFGRD0 \
60+
: TLP_FMTTYPE_CFGRD1) << 24) | \
61+
TLP_PAYLOAD_SIZE)
5962
#define TLP_CFG_DW1(reqid, tag, be) (((reqid) << 16) | (tag << 8) | (be))
6063
#define TLP_CFG_DW2(bus, devfn, offset) \
6164
(((bus) << 24) | ((devfn) << 16) | (offset))
@@ -218,11 +221,7 @@ static int tlp_cfg_dword_read(struct altera_pcie *pcie, u8 bus, u32 devfn,
218221
{
219222
u32 headers[TLP_HDR_SIZE];
220223

221-
if (bus == pcie->root_bus_nr)
222-
headers[0] = TLP_CFG_DW0(TLP_FMTTYPE_CFGRD0);
223-
else
224-
headers[0] = TLP_CFG_DW0(TLP_FMTTYPE_CFGRD1);
225-
224+
headers[0] = TLP_CFG_DW0(pcie, bus);
226225
headers[1] = TLP_CFG_DW1(TLP_REQ_ID(pcie->root_bus_nr, RP_DEVFN),
227226
TLP_READ_TAG, byte_en);
228227
headers[2] = TLP_CFG_DW2(bus, devfn, where);
@@ -238,11 +237,7 @@ static int tlp_cfg_dword_write(struct altera_pcie *pcie, u8 bus, u32 devfn,
238237
u32 headers[TLP_HDR_SIZE];
239238
int ret;
240239

241-
if (bus == pcie->root_bus_nr)
242-
headers[0] = TLP_CFG_DW0(TLP_FMTTYPE_CFGWR0);
243-
else
244-
headers[0] = TLP_CFG_DW0(TLP_FMTTYPE_CFGWR1);
245-
240+
headers[0] = TLP_CFG_DW0(pcie, bus);
246241
headers[1] = TLP_CFG_DW1(TLP_REQ_ID(pcie->root_bus_nr, RP_DEVFN),
247242
TLP_WRITE_TAG, byte_en);
248243
headers[2] = TLP_CFG_DW2(bus, devfn, where);

0 commit comments

Comments
 (0)