* [PATCH v1] dmaengine: dw: Distinguish ->remove() between DW and iDMA 32-bit
@ 2019-06-14 11:06 Andy Shevchenko
2019-06-17 2:40 ` Viresh Kumar
2019-06-25 4:13 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2019-06-14 11:06 UTC (permalink / raw)
To: Viresh Kumar, dmaengine, Dan Williams, Vinod Koul; +Cc: Andy Shevchenko
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>
---
drivers/dma/dw/pci.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/drivers/dma/dw/pci.c b/drivers/dma/dw/pci.c
index e79a75db0852..6aa1355ded6c 100644
--- a/drivers/dma/dw/pci.c
+++ b/drivers/dma/dw/pci.c
@@ -15,10 +15,13 @@
struct dw_dma_pci_data {
const struct dw_dma_platform_data *pdata;
int (*probe)(struct dw_dma_chip *chip);
+ int (*remove)(struct dw_dma_chip *chip);
+ struct dw_dma_chip *chip;
};
static const struct dw_dma_pci_data dw_pci_data = {
.probe = dw_dma_probe,
+ .remove = dw_dma_remove,
};
static const struct dw_dma_platform_data idma32_pdata = {
@@ -34,11 +37,13 @@ static const struct dw_dma_platform_data idma32_pdata = {
static const struct dw_dma_pci_data idma32_pci_data = {
.pdata = &idma32_pdata,
.probe = idma32_dma_probe,
+ .remove = idma32_dma_remove,
};
static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
{
- const struct dw_dma_pci_data *data = (void *)pid->driver_data;
+ const struct dw_dma_pci_data *drv_data = (void *)pid->driver_data;
+ struct dw_dma_pci_data *data;
struct dw_dma_chip *chip;
int ret;
@@ -63,6 +68,10 @@ static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
if (ret)
return ret;
+ data = devm_kmemdup(&pdev->dev, drv_data, sizeof(*drv_data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
return -ENOMEM;
@@ -73,21 +82,24 @@ static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
chip->irq = pdev->irq;
chip->pdata = data->pdata;
+ data->chip = chip;
+
ret = data->probe(chip);
if (ret)
return ret;
- pci_set_drvdata(pdev, chip);
+ pci_set_drvdata(pdev, data);
return 0;
}
static void dw_pci_remove(struct pci_dev *pdev)
{
- struct dw_dma_chip *chip = pci_get_drvdata(pdev);
+ struct dw_dma_pci_data *data = pci_get_drvdata(pdev);
+ struct dw_dma_chip *chip = data->chip;
int ret;
- ret = dw_dma_remove(chip);
+ ret = data->remove(chip);
if (ret)
dev_warn(&pdev->dev, "can't remove device properly: %d\n", ret);
}
@@ -96,16 +108,16 @@ static void dw_pci_remove(struct pci_dev *pdev)
static int dw_pci_suspend_late(struct device *dev)
{
- struct pci_dev *pci = to_pci_dev(dev);
- struct dw_dma_chip *chip = pci_get_drvdata(pci);
+ struct dw_dma_pci_data *data = dev_get_drvdata(dev);
+ struct dw_dma_chip *chip = data->chip;
return do_dw_dma_disable(chip);
};
static int dw_pci_resume_early(struct device *dev)
{
- struct pci_dev *pci = to_pci_dev(dev);
- struct dw_dma_chip *chip = pci_get_drvdata(pci);
+ struct dw_dma_pci_data *data = dev_get_drvdata(dev);
+ struct dw_dma_chip *chip = data->chip;
return do_dw_dma_enable(chip);
};
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] dmaengine: dw: Distinguish ->remove() between DW and iDMA 32-bit
2019-06-14 11:06 [PATCH v1] dmaengine: dw: Distinguish ->remove() between DW and iDMA 32-bit Andy Shevchenko
@ 2019-06-17 2:40 ` Viresh Kumar
2019-06-25 4:13 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2019-06-17 2:40 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Viresh Kumar, dmaengine, Dan Williams, Vinod Koul
On 14-06-19, 14:06, Andy Shevchenko wrote:
> 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>
> ---
> drivers/dma/dw/pci.c | 28 ++++++++++++++++++++--------
> 1 file changed, 20 insertions(+), 8 deletions(-)
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] dmaengine: dw: Distinguish ->remove() between DW and iDMA 32-bit
2019-06-14 11:06 [PATCH v1] dmaengine: dw: Distinguish ->remove() between DW and iDMA 32-bit Andy Shevchenko
2019-06-17 2:40 ` Viresh Kumar
@ 2019-06-25 4:13 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2019-06-25 4:13 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Viresh Kumar, dmaengine, Dan Williams
On 14-06-19, 14:06, Andy Shevchenko wrote:
> 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.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-25 4:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 11:06 [PATCH v1] dmaengine: dw: Distinguish ->remove() between DW and iDMA 32-bit Andy Shevchenko
2019-06-17 2:40 ` Viresh Kumar
2019-06-25 4:13 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).