Skip to content

Commit a183ec7

Browse files
andy-shevvinodkoul
authored andcommitted
dmaengine: dw: Distinguish ->remove() between DW and iDMA 32-bit
In the same way as done for ->probe(), call ->remove() based on the type of the hardware. While it works now due to equivalency of the two removal functions, it might be changed in the future. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 002905e commit a183ec7

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

‎drivers/dma/dw/pci.c‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
struct dw_dma_pci_data {
1616
const struct dw_dma_platform_data *pdata;
1717
int (*probe)(struct dw_dma_chip *chip);
18+
int (*remove)(struct dw_dma_chip *chip);
19+
struct dw_dma_chip *chip;
1820
};
1921

2022
static const struct dw_dma_pci_data dw_pci_data = {
2123
.probe = dw_dma_probe,
24+
.remove = dw_dma_remove,
2225
};
2326

2427
static const struct dw_dma_platform_data idma32_pdata = {
@@ -34,11 +37,13 @@ static const struct dw_dma_platform_data idma32_pdata = {
3437
static const struct dw_dma_pci_data idma32_pci_data = {
3538
.pdata = &idma32_pdata,
3639
.probe = idma32_dma_probe,
40+
.remove = idma32_dma_remove,
3741
};
3842

3943
static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
4044
{
41-
const struct dw_dma_pci_data *data = (void *)pid->driver_data;
45+
const struct dw_dma_pci_data *drv_data = (void *)pid->driver_data;
46+
struct dw_dma_pci_data *data;
4247
struct dw_dma_chip *chip;
4348
int ret;
4449

@@ -63,6 +68,10 @@ static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
6368
if (ret)
6469
return ret;
6570

71+
data = devm_kmemdup(&pdev->dev, drv_data, sizeof(*drv_data), GFP_KERNEL);
72+
if (!data)
73+
return -ENOMEM;
74+
6675
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
6776
if (!chip)
6877
return -ENOMEM;
@@ -73,21 +82,24 @@ static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
7382
chip->irq = pdev->irq;
7483
chip->pdata = data->pdata;
7584

85+
data->chip = chip;
86+
7687
ret = data->probe(chip);
7788
if (ret)
7889
return ret;
7990

80-
pci_set_drvdata(pdev, chip);
91+
pci_set_drvdata(pdev, data);
8192

8293
return 0;
8394
}
8495

8596
static void dw_pci_remove(struct pci_dev *pdev)
8697
{
87-
struct dw_dma_chip *chip = pci_get_drvdata(pdev);
98+
struct dw_dma_pci_data *data = pci_get_drvdata(pdev);
99+
struct dw_dma_chip *chip = data->chip;
88100
int ret;
89101

90-
ret = dw_dma_remove(chip);
102+
ret = data->remove(chip);
91103
if (ret)
92104
dev_warn(&pdev->dev, "can't remove device properly: %d\n", ret);
93105
}
@@ -96,16 +108,16 @@ static void dw_pci_remove(struct pci_dev *pdev)
96108

97109
static int dw_pci_suspend_late(struct device *dev)
98110
{
99-
struct pci_dev *pci = to_pci_dev(dev);
100-
struct dw_dma_chip *chip = pci_get_drvdata(pci);
111+
struct dw_dma_pci_data *data = dev_get_drvdata(dev);
112+
struct dw_dma_chip *chip = data->chip;
101113

102114
return do_dw_dma_disable(chip);
103115
};
104116

105117
static int dw_pci_resume_early(struct device *dev)
106118
{
107-
struct pci_dev *pci = to_pci_dev(dev);
108-
struct dw_dma_chip *chip = pci_get_drvdata(pci);
119+
struct dw_dma_pci_data *data = dev_get_drvdata(dev);
120+
struct dw_dma_chip *chip = data->chip;
109121

110122
return do_dw_dma_enable(chip);
111123
};

0 commit comments

Comments
 (0)