Skip to content

Commit b7dec6b

Browse files
Mani-Sadhasivamkwilczynski
authored andcommitted
PCI: dwc: ep: Remove deinit() callback from struct dw_pcie_ep_ops
deinit() callback was solely introduced for the pcie-rcar-gen4 driver where it is used to do platform specific resource deallocation. And this callback is called right at the end of the dw_pcie_ep_exit() API. So it doesn't matter whether it is called within or outside of dw_pcie_ep_exit() API. So let's remove this callback and directly call rcar_gen4_pcie_ep_deinit() in pcie-rcar-gen4 driver to do resource deallocation after the completion of dw_pcie_ep_exit() API in rcar_gen4_remove_dw_pcie_ep(). This simplifies the DWC layer. Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Frank Li <[email protected]> Reviewed-by: Niklas Cassel <[email protected]> Reviewed-by: Yoshihiro Shimoda <[email protected]>
1 parent 7cbebc8 commit b7dec6b

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,6 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep)
637637
epc->mem->window.page_size);
638638

639639
pci_epc_mem_exit(epc);
640-
641-
if (ep->ops->deinit)
642-
ep->ops->deinit(ep);
643640
}
644641
EXPORT_SYMBOL_GPL(dw_pcie_ep_exit);
645642

@@ -844,7 +841,7 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
844841
ep->page_size);
845842
if (ret < 0) {
846843
dev_err(dev, "Failed to initialize address space\n");
847-
goto err_ep_deinit;
844+
return ret;
848845
}
849846

850847
ep->msi_mem = pci_epc_mem_alloc_addr(epc, &ep->msi_mem_phys,
@@ -881,10 +878,6 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
881878
err_exit_epc_mem:
882879
pci_epc_mem_exit(epc);
883880

884-
err_ep_deinit:
885-
if (ep->ops->deinit)
886-
ep->ops->deinit(ep);
887-
888881
return ret;
889882
}
890883
EXPORT_SYMBOL_GPL(dw_pcie_ep_init);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ struct dw_pcie_rp {
333333
struct dw_pcie_ep_ops {
334334
void (*pre_init)(struct dw_pcie_ep *ep);
335335
void (*init)(struct dw_pcie_ep *ep);
336-
void (*deinit)(struct dw_pcie_ep *ep);
337336
int (*raise_irq)(struct dw_pcie_ep *ep, u8 func_no,
338337
unsigned int type, u16 interrupt_num);
339338
const struct pci_epc_features* (*get_features)(struct dw_pcie_ep *ep);

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,8 @@ static void rcar_gen4_pcie_ep_init(struct dw_pcie_ep *ep)
352352
dw_pcie_ep_reset_bar(pci, bar);
353353
}
354354

355-
static void rcar_gen4_pcie_ep_deinit(struct dw_pcie_ep *ep)
355+
static void rcar_gen4_pcie_ep_deinit(struct rcar_gen4_pcie *rcar)
356356
{
357-
struct dw_pcie *dw = to_dw_pcie_from_ep(ep);
358-
struct rcar_gen4_pcie *rcar = to_rcar_gen4_pcie(dw);
359-
360357
writel(0, rcar->base + PCIEDMAINTSTSEN);
361358
rcar_gen4_pcie_common_deinit(rcar);
362359
}
@@ -410,7 +407,6 @@ static unsigned int rcar_gen4_pcie_ep_get_dbi2_offset(struct dw_pcie_ep *ep,
410407
static const struct dw_pcie_ep_ops pcie_ep_ops = {
411408
.pre_init = rcar_gen4_pcie_ep_pre_init,
412409
.init = rcar_gen4_pcie_ep_init,
413-
.deinit = rcar_gen4_pcie_ep_deinit,
414410
.raise_irq = rcar_gen4_pcie_ep_raise_irq,
415411
.get_features = rcar_gen4_pcie_ep_get_features,
416412
.get_dbi_offset = rcar_gen4_pcie_ep_get_dbi_offset,
@@ -420,18 +416,24 @@ static const struct dw_pcie_ep_ops pcie_ep_ops = {
420416
static int rcar_gen4_add_dw_pcie_ep(struct rcar_gen4_pcie *rcar)
421417
{
422418
struct dw_pcie_ep *ep = &rcar->dw.ep;
419+
int ret;
423420

424421
if (!IS_ENABLED(CONFIG_PCIE_RCAR_GEN4_EP))
425422
return -ENODEV;
426423

427424
ep->ops = &pcie_ep_ops;
428425

429-
return dw_pcie_ep_init(ep);
426+
ret = dw_pcie_ep_init(ep);
427+
if (ret)
428+
rcar_gen4_pcie_ep_deinit(rcar);
429+
430+
return ret;
430431
}
431432

432433
static void rcar_gen4_remove_dw_pcie_ep(struct rcar_gen4_pcie *rcar)
433434
{
434435
dw_pcie_ep_exit(&rcar->dw.ep);
436+
rcar_gen4_pcie_ep_deinit(rcar);
435437
}
436438

437439
/* Common */

0 commit comments

Comments
 (0)