Skip to content

Commit 641f79b

Browse files
shimodaykwilczynski
authored andcommitted
PCI: dwc: Rename .func_conf_select to .get_dbi_offset in struct dw_pcie_ep_ops
Since the struct member .func_conf_select makes the intentions behind it difficult to ascertain from its name alone, rename it to .get_dbi_offset to make the intended usage more obvious. [kwilczynski: commmit log] Suggested-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Yoshihiro Shimoda <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Serge Semin <[email protected]>
1 parent 756dcb5 commit 641f79b

File tree

4 files changed

+59
-60
lines changed

4 files changed

+59
-60
lines changed

drivers/pci/controller/dwc/pci-layerscape-ep.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no,
184184
}
185185
}
186186

187-
static unsigned int ls_pcie_ep_func_conf_select(struct dw_pcie_ep *ep,
188-
u8 func_no)
187+
static unsigned int ls_pcie_ep_get_dbi_offset(struct dw_pcie_ep *ep, u8 func_no)
189188
{
190189
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
191190
struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci);
@@ -198,7 +197,7 @@ static const struct dw_pcie_ep_ops ls_pcie_ep_ops = {
198197
.init = ls_pcie_ep_init,
199198
.raise_irq = ls_pcie_ep_raise_irq,
200199
.get_features = ls_pcie_ep_get_features,
201-
.func_conf_select = ls_pcie_ep_func_conf_select,
200+
.get_dbi_offset = ls_pcie_ep_get_dbi_offset,
202201
};
203202

204203
static const struct ls_pcie_ep_drvdata ls1_ep_drvdata = {

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

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ dw_pcie_ep_get_func_from_ep(struct dw_pcie_ep *ep, u8 func_no)
4343
return NULL;
4444
}
4545

46-
static unsigned int dw_pcie_ep_func_select(struct dw_pcie_ep *ep, u8 func_no)
46+
static unsigned int dw_pcie_ep_get_dbi_offset(struct dw_pcie_ep *ep, u8 func_no)
4747
{
48-
unsigned int func_offset = 0;
48+
unsigned int dbi_offset = 0;
4949

50-
if (ep->ops->func_conf_select)
51-
func_offset = ep->ops->func_conf_select(ep, func_no);
50+
if (ep->ops->get_dbi_offset)
51+
dbi_offset = ep->ops->get_dbi_offset(ep, func_no);
5252

53-
return func_offset;
53+
return dbi_offset;
5454
}
5555

5656
static unsigned int dw_pcie_ep_get_dbi2_offset(struct dw_pcie_ep *ep, u8 func_no)
@@ -59,23 +59,23 @@ static unsigned int dw_pcie_ep_get_dbi2_offset(struct dw_pcie_ep *ep, u8 func_no
5959

6060
if (ep->ops->get_dbi2_offset)
6161
dbi2_offset = ep->ops->get_dbi2_offset(ep, func_no);
62-
else if (ep->ops->func_conf_select) /* for backward compatibility */
63-
dbi2_offset = ep->ops->func_conf_select(ep, func_no);
62+
else if (ep->ops->get_dbi_offset) /* for backward compatibility */
63+
dbi2_offset = ep->ops->get_dbi_offset(ep, func_no);
6464

6565
return dbi2_offset;
6666
}
6767

6868
static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, u8 func_no,
6969
enum pci_barno bar, int flags)
7070
{
71-
unsigned int func_offset, dbi2_offset;
71+
unsigned int dbi_offset, dbi2_offset;
7272
struct dw_pcie_ep *ep = &pci->ep;
7373
u32 reg, reg_dbi2;
7474

75-
func_offset = dw_pcie_ep_func_select(ep, func_no);
75+
dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
7676
dbi2_offset = dw_pcie_ep_get_dbi2_offset(ep, func_no);
7777

78-
reg = func_offset + PCI_BASE_ADDRESS_0 + (4 * bar);
78+
reg = dbi_offset + PCI_BASE_ADDRESS_0 + (4 * bar);
7979
reg_dbi2 = dbi2_offset + PCI_BASE_ADDRESS_0 + (4 * bar);
8080
dw_pcie_dbi_ro_wr_en(pci);
8181
dw_pcie_writel_dbi2(pci, reg_dbi2, 0x0);
@@ -102,16 +102,16 @@ static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie_ep *ep, u8 func_no,
102102
u8 cap_ptr, u8 cap)
103103
{
104104
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
105-
unsigned int func_offset = 0;
105+
unsigned int dbi_offset = 0;
106106
u8 cap_id, next_cap_ptr;
107107
u16 reg;
108108

109109
if (!cap_ptr)
110110
return 0;
111111

112-
func_offset = dw_pcie_ep_func_select(ep, func_no);
112+
dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
113113

114-
reg = dw_pcie_readw_dbi(pci, func_offset + cap_ptr);
114+
reg = dw_pcie_readw_dbi(pci, dbi_offset + cap_ptr);
115115
cap_id = (reg & 0x00ff);
116116

117117
if (cap_id > PCI_CAP_ID_MAX)
@@ -127,13 +127,13 @@ static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie_ep *ep, u8 func_no,
127127
static u8 dw_pcie_ep_find_capability(struct dw_pcie_ep *ep, u8 func_no, u8 cap)
128128
{
129129
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
130-
unsigned int func_offset = 0;
130+
unsigned int dbi_offset = 0;
131131
u8 next_cap_ptr;
132132
u16 reg;
133133

134-
func_offset = dw_pcie_ep_func_select(ep, func_no);
134+
dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
135135

136-
reg = dw_pcie_readw_dbi(pci, func_offset + PCI_CAPABILITY_LIST);
136+
reg = dw_pcie_readw_dbi(pci, dbi_offset + PCI_CAPABILITY_LIST);
137137
next_cap_ptr = (reg & 0x00ff);
138138

139139
return __dw_pcie_ep_find_next_cap(ep, func_no, next_cap_ptr, cap);
@@ -144,23 +144,23 @@ static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
144144
{
145145
struct dw_pcie_ep *ep = epc_get_drvdata(epc);
146146
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
147-
unsigned int func_offset = 0;
147+
unsigned int dbi_offset = 0;
148148

149-
func_offset = dw_pcie_ep_func_select(ep, func_no);
149+
dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
150150

151151
dw_pcie_dbi_ro_wr_en(pci);
152-
dw_pcie_writew_dbi(pci, func_offset + PCI_VENDOR_ID, hdr->vendorid);
153-
dw_pcie_writew_dbi(pci, func_offset + PCI_DEVICE_ID, hdr->deviceid);
154-
dw_pcie_writeb_dbi(pci, func_offset + PCI_REVISION_ID, hdr->revid);
155-
dw_pcie_writeb_dbi(pci, func_offset + PCI_CLASS_PROG, hdr->progif_code);
156-
dw_pcie_writew_dbi(pci, func_offset + PCI_CLASS_DEVICE,
152+
dw_pcie_writew_dbi(pci, dbi_offset + PCI_VENDOR_ID, hdr->vendorid);
153+
dw_pcie_writew_dbi(pci, dbi_offset + PCI_DEVICE_ID, hdr->deviceid);
154+
dw_pcie_writeb_dbi(pci, dbi_offset + PCI_REVISION_ID, hdr->revid);
155+
dw_pcie_writeb_dbi(pci, dbi_offset + PCI_CLASS_PROG, hdr->progif_code);
156+
dw_pcie_writew_dbi(pci, dbi_offset + PCI_CLASS_DEVICE,
157157
hdr->subclass_code | hdr->baseclass_code << 8);
158-
dw_pcie_writeb_dbi(pci, func_offset + PCI_CACHE_LINE_SIZE,
158+
dw_pcie_writeb_dbi(pci, dbi_offset + PCI_CACHE_LINE_SIZE,
159159
hdr->cache_line_size);
160-
dw_pcie_writew_dbi(pci, func_offset + PCI_SUBSYSTEM_VENDOR_ID,
160+
dw_pcie_writew_dbi(pci, dbi_offset + PCI_SUBSYSTEM_VENDOR_ID,
161161
hdr->subsys_vendor_id);
162-
dw_pcie_writew_dbi(pci, func_offset + PCI_SUBSYSTEM_ID, hdr->subsys_id);
163-
dw_pcie_writeb_dbi(pci, func_offset + PCI_INTERRUPT_PIN,
162+
dw_pcie_writew_dbi(pci, dbi_offset + PCI_SUBSYSTEM_ID, hdr->subsys_id);
163+
dw_pcie_writeb_dbi(pci, dbi_offset + PCI_INTERRUPT_PIN,
164164
hdr->interrupt_pin);
165165
dw_pcie_dbi_ro_wr_dis(pci);
166166

@@ -243,17 +243,17 @@ static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
243243
{
244244
struct dw_pcie_ep *ep = epc_get_drvdata(epc);
245245
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
246-
unsigned int func_offset, dbi2_offset;
246+
unsigned int dbi_offset, dbi2_offset;
247247
enum pci_barno bar = epf_bar->barno;
248248
size_t size = epf_bar->size;
249249
int flags = epf_bar->flags;
250250
u32 reg, reg_dbi2;
251251
int ret, type;
252252

253-
func_offset = dw_pcie_ep_func_select(ep, func_no);
253+
dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
254254
dbi2_offset = dw_pcie_ep_get_dbi2_offset(ep, func_no);
255255

256-
reg = PCI_BASE_ADDRESS_0 + (4 * bar) + func_offset;
256+
reg = PCI_BASE_ADDRESS_0 + (4 * bar) + dbi_offset;
257257
reg_dbi2 = PCI_BASE_ADDRESS_0 + (4 * bar) + dbi2_offset;
258258

259259
if (!(flags & PCI_BASE_ADDRESS_SPACE))
@@ -337,16 +337,16 @@ static int dw_pcie_ep_get_msi(struct pci_epc *epc, u8 func_no, u8 vfunc_no)
337337
struct dw_pcie_ep *ep = epc_get_drvdata(epc);
338338
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
339339
u32 val, reg;
340-
unsigned int func_offset = 0;
340+
unsigned int dbi_offset = 0;
341341
struct dw_pcie_ep_func *ep_func;
342342

343343
ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no);
344344
if (!ep_func || !ep_func->msi_cap)
345345
return -EINVAL;
346346

347-
func_offset = dw_pcie_ep_func_select(ep, func_no);
347+
dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
348348

349-
reg = ep_func->msi_cap + func_offset + PCI_MSI_FLAGS;
349+
reg = ep_func->msi_cap + dbi_offset + PCI_MSI_FLAGS;
350350
val = dw_pcie_readw_dbi(pci, reg);
351351
if (!(val & PCI_MSI_FLAGS_ENABLE))
352352
return -EINVAL;
@@ -362,16 +362,16 @@ static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
362362
struct dw_pcie_ep *ep = epc_get_drvdata(epc);
363363
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
364364
u32 val, reg;
365-
unsigned int func_offset = 0;
365+
unsigned int dbi_offset = 0;
366366
struct dw_pcie_ep_func *ep_func;
367367

368368
ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no);
369369
if (!ep_func || !ep_func->msi_cap)
370370
return -EINVAL;
371371

372-
func_offset = dw_pcie_ep_func_select(ep, func_no);
372+
dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
373373

374-
reg = ep_func->msi_cap + func_offset + PCI_MSI_FLAGS;
374+
reg = ep_func->msi_cap + dbi_offset + PCI_MSI_FLAGS;
375375
val = dw_pcie_readw_dbi(pci, reg);
376376
val &= ~PCI_MSI_FLAGS_QMASK;
377377
val |= FIELD_PREP(PCI_MSI_FLAGS_QMASK, interrupts);
@@ -387,16 +387,16 @@ static int dw_pcie_ep_get_msix(struct pci_epc *epc, u8 func_no, u8 vfunc_no)
387387
struct dw_pcie_ep *ep = epc_get_drvdata(epc);
388388
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
389389
u32 val, reg;
390-
unsigned int func_offset = 0;
390+
unsigned int dbi_offset = 0;
391391
struct dw_pcie_ep_func *ep_func;
392392

393393
ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no);
394394
if (!ep_func || !ep_func->msix_cap)
395395
return -EINVAL;
396396

397-
func_offset = dw_pcie_ep_func_select(ep, func_no);
397+
dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
398398

399-
reg = ep_func->msix_cap + func_offset + PCI_MSIX_FLAGS;
399+
reg = ep_func->msix_cap + dbi_offset + PCI_MSIX_FLAGS;
400400
val = dw_pcie_readw_dbi(pci, reg);
401401
if (!(val & PCI_MSIX_FLAGS_ENABLE))
402402
return -EINVAL;
@@ -412,7 +412,7 @@ static int dw_pcie_ep_set_msix(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
412412
struct dw_pcie_ep *ep = epc_get_drvdata(epc);
413413
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
414414
u32 val, reg;
415-
unsigned int func_offset = 0;
415+
unsigned int dbi_offset = 0;
416416
struct dw_pcie_ep_func *ep_func;
417417

418418
ep_func = dw_pcie_ep_get_func_from_ep(ep, func_no);
@@ -421,19 +421,19 @@ static int dw_pcie_ep_set_msix(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
421421

422422
dw_pcie_dbi_ro_wr_en(pci);
423423

424-
func_offset = dw_pcie_ep_func_select(ep, func_no);
424+
dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
425425

426-
reg = ep_func->msix_cap + func_offset + PCI_MSIX_FLAGS;
426+
reg = ep_func->msix_cap + dbi_offset + PCI_MSIX_FLAGS;
427427
val = dw_pcie_readw_dbi(pci, reg);
428428
val &= ~PCI_MSIX_FLAGS_QSIZE;
429429
val |= interrupts;
430430
dw_pcie_writew_dbi(pci, reg, val);
431431

432-
reg = ep_func->msix_cap + func_offset + PCI_MSIX_TABLE;
432+
reg = ep_func->msix_cap + dbi_offset + PCI_MSIX_TABLE;
433433
val = offset | bir;
434434
dw_pcie_writel_dbi(pci, reg, val);
435435

436-
reg = ep_func->msix_cap + func_offset + PCI_MSIX_PBA;
436+
reg = ep_func->msix_cap + dbi_offset + PCI_MSIX_PBA;
437437
val = (offset + (interrupts * PCI_MSIX_ENTRY_SIZE)) | bir;
438438
dw_pcie_writel_dbi(pci, reg, val);
439439

@@ -514,7 +514,7 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,
514514
struct dw_pcie_ep_func *ep_func;
515515
struct pci_epc *epc = ep->epc;
516516
unsigned int aligned_offset;
517-
unsigned int func_offset = 0;
517+
unsigned int dbi_offset = 0;
518518
u16 msg_ctrl, msg_data;
519519
u32 msg_addr_lower, msg_addr_upper, reg;
520520
u64 msg_addr;
@@ -525,22 +525,22 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,
525525
if (!ep_func || !ep_func->msi_cap)
526526
return -EINVAL;
527527

528-
func_offset = dw_pcie_ep_func_select(ep, func_no);
528+
dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
529529

530530
/* Raise MSI per the PCI Local Bus Specification Revision 3.0, 6.8.1. */
531-
reg = ep_func->msi_cap + func_offset + PCI_MSI_FLAGS;
531+
reg = ep_func->msi_cap + dbi_offset + PCI_MSI_FLAGS;
532532
msg_ctrl = dw_pcie_readw_dbi(pci, reg);
533533
has_upper = !!(msg_ctrl & PCI_MSI_FLAGS_64BIT);
534-
reg = ep_func->msi_cap + func_offset + PCI_MSI_ADDRESS_LO;
534+
reg = ep_func->msi_cap + dbi_offset + PCI_MSI_ADDRESS_LO;
535535
msg_addr_lower = dw_pcie_readl_dbi(pci, reg);
536536
if (has_upper) {
537-
reg = ep_func->msi_cap + func_offset + PCI_MSI_ADDRESS_HI;
537+
reg = ep_func->msi_cap + dbi_offset + PCI_MSI_ADDRESS_HI;
538538
msg_addr_upper = dw_pcie_readl_dbi(pci, reg);
539-
reg = ep_func->msi_cap + func_offset + PCI_MSI_DATA_64;
539+
reg = ep_func->msi_cap + dbi_offset + PCI_MSI_DATA_64;
540540
msg_data = dw_pcie_readw_dbi(pci, reg);
541541
} else {
542542
msg_addr_upper = 0;
543-
reg = ep_func->msi_cap + func_offset + PCI_MSI_DATA_32;
543+
reg = ep_func->msi_cap + dbi_offset + PCI_MSI_DATA_32;
544544
msg_data = dw_pcie_readw_dbi(pci, reg);
545545
}
546546
aligned_offset = msg_addr_lower & (epc->mem->window.page_size - 1);
@@ -585,7 +585,7 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no,
585585
struct dw_pcie_ep_func *ep_func;
586586
struct pci_epf_msix_tbl *msix_tbl;
587587
struct pci_epc *epc = ep->epc;
588-
unsigned int func_offset = 0;
588+
unsigned int dbi_offset = 0;
589589
u32 reg, msg_data, vec_ctrl;
590590
unsigned int aligned_offset;
591591
u32 tbl_offset;
@@ -597,9 +597,9 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no,
597597
if (!ep_func || !ep_func->msix_cap)
598598
return -EINVAL;
599599

600-
func_offset = dw_pcie_ep_func_select(ep, func_no);
600+
dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
601601

602-
reg = ep_func->msix_cap + func_offset + PCI_MSIX_TABLE;
602+
reg = ep_func->msix_cap + dbi_offset + PCI_MSIX_TABLE;
603603
tbl_offset = dw_pcie_readl_dbi(pci, reg);
604604
bir = FIELD_GET(PCI_MSIX_TABLE_BIR, tbl_offset);
605605
tbl_offset &= PCI_MSIX_TABLE_OFFSET;

drivers/pci/controller/dwc/pcie-designware.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ struct dw_pcie_ep_ops {
344344
* return a 0, and implement code in callback function of platform
345345
* driver.
346346
*/
347-
unsigned int (*func_conf_select)(struct dw_pcie_ep *ep, u8 func_no);
347+
unsigned int (*get_dbi_offset)(struct dw_pcie_ep *ep, u8 func_no);
348348
unsigned int (*get_dbi2_offset)(struct dw_pcie_ep *ep, u8 func_no);
349349
};
350350

drivers/pci/controller/dwc/pcie-rcar-gen4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ rcar_gen4_pcie_ep_get_features(struct dw_pcie_ep *ep)
394394
return &rcar_gen4_pcie_epc_features;
395395
}
396396

397-
static unsigned int rcar_gen4_pcie_ep_func_conf_select(struct dw_pcie_ep *ep,
397+
static unsigned int rcar_gen4_pcie_ep_get_dbi_offset(struct dw_pcie_ep *ep,
398398
u8 func_no)
399399
{
400400
return func_no * RCAR_GEN4_PCIE_EP_FUNC_DBI_OFFSET;
@@ -412,7 +412,7 @@ static const struct dw_pcie_ep_ops pcie_ep_ops = {
412412
.deinit = rcar_gen4_pcie_ep_deinit,
413413
.raise_irq = rcar_gen4_pcie_ep_raise_irq,
414414
.get_features = rcar_gen4_pcie_ep_get_features,
415-
.func_conf_select = rcar_gen4_pcie_ep_func_conf_select,
415+
.get_dbi_offset = rcar_gen4_pcie_ep_get_dbi_offset,
416416
.get_dbi2_offset = rcar_gen4_pcie_ep_get_dbi2_offset,
417417
};
418418

0 commit comments

Comments
 (0)