[PATCH v1 1/6] dmaengine: dw-edma: Pass 'struct dw_edma_chip' to irq_vector()

From: Mrinmay Sarkar
Date: Fri Jan 19 2024 - 08:01:33 EST


From: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>

eDMA client drivers defining the irq_vector() callback need to access the
members of dw_edma_chip structure. So let's pass that pointer instead.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>
Signed-off-by: Mrinmay Sarkar <quic_msarkar@xxxxxxxxxxx>
---
drivers/dma/dw-edma/dw-edma-core.c | 11 +++++------
drivers/dma/dw-edma/dw-edma-pcie.c | 4 ++--
drivers/pci/controller/dwc/pcie-designware.c | 4 ++--
include/linux/dma/edma.h | 3 ++-
4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
index 6823624..7fe1c19 100644
--- a/drivers/dma/dw-edma/dw-edma-core.c
+++ b/drivers/dma/dw-edma/dw-edma-core.c
@@ -849,7 +849,7 @@ static int dw_edma_irq_request(struct dw_edma *dw,

if (chip->nr_irqs == 1) {
/* Common IRQ shared among all channels */
- irq = chip->ops->irq_vector(dev, 0);
+ irq = chip->ops->irq_vector(chip, 0);
err = request_irq(irq, dw_edma_interrupt_common,
IRQF_SHARED, dw->name, &dw->irq[0]);
if (err) {
@@ -874,7 +874,7 @@ static int dw_edma_irq_request(struct dw_edma *dw,
dw_edma_add_irq_mask(&rd_mask, *rd_alloc, dw->rd_ch_cnt);

for (i = 0; i < (*wr_alloc + *rd_alloc); i++) {
- irq = chip->ops->irq_vector(dev, i);
+ irq = chip->ops->irq_vector(chip, i);
err = request_irq(irq,
i < *wr_alloc ?
dw_edma_interrupt_write :
@@ -895,7 +895,7 @@ static int dw_edma_irq_request(struct dw_edma *dw,

err_irq_free:
for (i--; i >= 0; i--) {
- irq = chip->ops->irq_vector(dev, i);
+ irq = chip->ops->irq_vector(chip, i);
free_irq(irq, &dw->irq[i]);
}

@@ -975,7 +975,7 @@ int dw_edma_probe(struct dw_edma_chip *chip)

err_irq_free:
for (i = (dw->nr_irqs - 1); i >= 0; i--)
- free_irq(chip->ops->irq_vector(dev, i), &dw->irq[i]);
+ free_irq(chip->ops->irq_vector(chip, i), &dw->irq[i]);

return err;
}
@@ -984,7 +984,6 @@ EXPORT_SYMBOL_GPL(dw_edma_probe);
int dw_edma_remove(struct dw_edma_chip *chip)
{
struct dw_edma_chan *chan, *_chan;
- struct device *dev = chip->dev;
struct dw_edma *dw = chip->dw;
int i;

@@ -997,7 +996,7 @@ int dw_edma_remove(struct dw_edma_chip *chip)

/* Free irqs */
for (i = (dw->nr_irqs - 1); i >= 0; i--)
- free_irq(chip->ops->irq_vector(dev, i), &dw->irq[i]);
+ free_irq(chip->ops->irq_vector(chip, i), &dw->irq[i]);

/* Deregister eDMA device */
dma_async_device_unregister(&dw->dma);
diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c
index 1c60437..2b13725 100644
--- a/drivers/dma/dw-edma/dw-edma-pcie.c
+++ b/drivers/dma/dw-edma/dw-edma-pcie.c
@@ -90,9 +90,9 @@ static const struct dw_edma_pcie_data snps_edda_data = {
.rd_ch_cnt = 2,
};

-static int dw_edma_pcie_irq_vector(struct device *dev, unsigned int nr)
+static int dw_edma_pcie_irq_vector(struct dw_edma_chip *chip, unsigned int nr)
{
- return pci_irq_vector(to_pci_dev(dev), nr);
+ return pci_irq_vector(to_pci_dev(chip->dev), nr);
}

static u64 dw_edma_pcie_address(struct device *dev, phys_addr_t cpu_addr)
diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 250cf7f..eca047a 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -858,9 +858,9 @@ static u32 dw_pcie_readl_dma(struct dw_pcie *pci, u32 reg)
return val;
}

-static int dw_pcie_edma_irq_vector(struct device *dev, unsigned int nr)
+static int dw_pcie_edma_irq_vector(struct dw_edma_chip *edma, unsigned int nr)
{
- struct platform_device *pdev = to_platform_device(dev);
+ struct platform_device *pdev = to_platform_device(edma->dev);
char name[6];
int ret;

diff --git a/include/linux/dma/edma.h b/include/linux/dma/edma.h
index 3080747..7197a58 100644
--- a/include/linux/dma/edma.h
+++ b/include/linux/dma/edma.h
@@ -16,6 +16,7 @@
#define EDMA_MAX_RD_CH 8

struct dw_edma;
+struct dw_edma_chip;

struct dw_edma_region {
u64 paddr;
@@ -41,7 +42,7 @@ struct dw_edma_region {
* automatically.
*/
struct dw_edma_plat_ops {
- int (*irq_vector)(struct device *dev, unsigned int nr);
+ int (*irq_vector)(struct dw_edma_chip *chip, unsigned int nr);
u64 (*pci_address)(struct device *dev, phys_addr_t cpu_addr);
};

--
2.7.4