Commit 3a14c66d authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Vinod Koul

dmaengine: dw: pass platform data via struct dw_dma_chip

We pass struct dw_dma_chip to dw_dma_probe() anyway, thus we may use it to
pass a platform data as well.

While here, constify the source of the platform data.
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 161c3d04
...@@ -1248,7 +1248,7 @@ static int sata_dwc_probe(struct platform_device *ofdev) ...@@ -1248,7 +1248,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
hsdev->dma->dev = &ofdev->dev; hsdev->dma->dev = &ofdev->dev;
/* Initialize AHB DMAC */ /* Initialize AHB DMAC */
err = dw_dma_probe(hsdev->dma, NULL); err = dw_dma_probe(hsdev->dma);
if (err) if (err)
goto error_dma_iomap; goto error_dma_iomap;
......
...@@ -1439,8 +1439,9 @@ EXPORT_SYMBOL(dw_dma_cyclic_free); ...@@ -1439,8 +1439,9 @@ EXPORT_SYMBOL(dw_dma_cyclic_free);
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata) int dw_dma_probe(struct dw_dma_chip *chip)
{ {
struct dw_dma_platform_data *pdata;
struct dw_dma *dw; struct dw_dma *dw;
bool autocfg = false; bool autocfg = false;
unsigned int dw_params; unsigned int dw_params;
...@@ -1460,7 +1461,7 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata) ...@@ -1460,7 +1461,7 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
pm_runtime_get_sync(chip->dev); pm_runtime_get_sync(chip->dev);
if (!pdata) { if (!chip->pdata) {
dw_params = dma_readl(dw, DW_PARAMS); dw_params = dma_readl(dw, DW_PARAMS);
dev_dbg(chip->dev, "DW_PARAMS: 0x%08x\n", dw_params); dev_dbg(chip->dev, "DW_PARAMS: 0x%08x\n", dw_params);
...@@ -1487,11 +1488,11 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata) ...@@ -1487,11 +1488,11 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
pdata->is_memcpy = true; pdata->is_memcpy = true;
pdata->chan_allocation_order = CHAN_ALLOCATION_ASCENDING; pdata->chan_allocation_order = CHAN_ALLOCATION_ASCENDING;
pdata->chan_priority = CHAN_PRIORITY_ASCENDING; pdata->chan_priority = CHAN_PRIORITY_ASCENDING;
} else if (pdata->nr_channels > DW_DMA_MAX_NR_CHANNELS) { } else if (chip->pdata->nr_channels > DW_DMA_MAX_NR_CHANNELS) {
err = -EINVAL; err = -EINVAL;
goto err_pdata; goto err_pdata;
} else { } else {
memcpy(dw->pdata, pdata, sizeof(*dw->pdata)); memcpy(dw->pdata, chip->pdata, sizeof(*dw->pdata));
/* Reassign the platform data pointer */ /* Reassign the platform data pointer */
pdata = dw->pdata; pdata = dw->pdata;
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid) static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
{ {
const struct dw_dma_platform_data *pdata = (void *)pid->driver_data;
struct dw_dma_chip *chip; struct dw_dma_chip *chip;
struct dw_dma_platform_data *pdata = (void *)pid->driver_data;
int ret; int ret;
ret = pcim_enable_device(pdev); ret = pcim_enable_device(pdev);
...@@ -49,8 +49,9 @@ static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid) ...@@ -49,8 +49,9 @@ static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
chip->dev = &pdev->dev; chip->dev = &pdev->dev;
chip->regs = pcim_iomap_table(pdev)[0]; chip->regs = pcim_iomap_table(pdev)[0];
chip->irq = pdev->irq; chip->irq = pdev->irq;
chip->pdata = pdata;
ret = dw_dma_probe(chip, pdata); ret = dw_dma_probe(chip);
if (ret) if (ret)
return ret; return ret;
......
...@@ -161,7 +161,7 @@ static int dw_probe(struct platform_device *pdev) ...@@ -161,7 +161,7 @@ static int dw_probe(struct platform_device *pdev)
struct dw_dma_chip *chip; struct dw_dma_chip *chip;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct resource *mem; struct resource *mem;
struct dw_dma_platform_data *pdata; const struct dw_dma_platform_data *pdata;
int err; int err;
chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
...@@ -186,6 +186,7 @@ static int dw_probe(struct platform_device *pdev) ...@@ -186,6 +186,7 @@ static int dw_probe(struct platform_device *pdev)
pdata = dw_dma_parse_dt(pdev); pdata = dw_dma_parse_dt(pdev);
chip->dev = dev; chip->dev = dev;
chip->pdata = pdata;
chip->clk = devm_clk_get(chip->dev, "hclk"); chip->clk = devm_clk_get(chip->dev, "hclk");
if (IS_ERR(chip->clk)) if (IS_ERR(chip->clk))
...@@ -196,7 +197,7 @@ static int dw_probe(struct platform_device *pdev) ...@@ -196,7 +197,7 @@ static int dw_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
err = dw_dma_probe(chip, pdata); err = dw_dma_probe(chip);
if (err) if (err)
goto err_dw_dma_probe; goto err_dw_dma_probe;
......
...@@ -27,6 +27,7 @@ struct dw_dma; ...@@ -27,6 +27,7 @@ struct dw_dma;
* @regs: memory mapped I/O space * @regs: memory mapped I/O space
* @clk: hclk clock * @clk: hclk clock
* @dw: struct dw_dma that is filed by dw_dma_probe() * @dw: struct dw_dma that is filed by dw_dma_probe()
* @pdata: pointer to platform data
*/ */
struct dw_dma_chip { struct dw_dma_chip {
struct device *dev; struct device *dev;
...@@ -34,10 +35,12 @@ struct dw_dma_chip { ...@@ -34,10 +35,12 @@ struct dw_dma_chip {
void __iomem *regs; void __iomem *regs;
struct clk *clk; struct clk *clk;
struct dw_dma *dw; struct dw_dma *dw;
const struct dw_dma_platform_data *pdata;
}; };
/* Export to the platform drivers */ /* Export to the platform drivers */
int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata); int dw_dma_probe(struct dw_dma_chip *chip);
int dw_dma_remove(struct dw_dma_chip *chip); int dw_dma_remove(struct dw_dma_chip *chip);
/* DMA API extensions */ /* DMA API extensions */
......
...@@ -203,7 +203,7 @@ static struct dw_dma_chip *dw_probe(struct device *dev, struct resource *mem, ...@@ -203,7 +203,7 @@ static struct dw_dma_chip *dw_probe(struct device *dev, struct resource *mem,
chip->dev = dev; chip->dev = dev;
err = dw_dma_probe(chip, NULL); err = dw_dma_probe(chip);
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment