Skip to content

Commit b375741

Browse files
andy-shevvinodkoul
authored andcommitted
dmaengine: dw: platform: Use struct dw_dma_chip_pdata
Now, when we have a generic structure for the chip and platform data, use it in the platform glue driver. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20190820131546.75744-5-andriy.shevchenko@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent ae923c9 commit b375741

1 file changed

Lines changed: 31 additions & 11 deletions

File tree

‎drivers/dma/dw/platform.c‎

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,22 @@ dw_dma_parse_dt(struct platform_device *pdev)
168168

169169
static int dw_probe(struct platform_device *pdev)
170170
{
171+
const struct dw_dma_chip_pdata *match;
172+
struct dw_dma_chip_pdata *data;
171173
struct dw_dma_chip *chip;
172174
struct device *dev = &pdev->dev;
173175
struct resource *mem;
174176
const struct dw_dma_platform_data *pdata;
175177
int err;
176178

179+
match = device_get_match_data(dev);
180+
if (!match)
181+
return -ENODEV;
182+
183+
data = devm_kmemdup(&pdev->dev, match, sizeof(*match), GFP_KERNEL);
184+
if (!data)
185+
return -ENOMEM;
186+
177187
chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
178188
if (!chip)
179189
return -ENOMEM;
@@ -199,6 +209,8 @@ static int dw_probe(struct platform_device *pdev)
199209
chip->id = pdev->id;
200210
chip->pdata = pdata;
201211

212+
data->chip = chip;
213+
202214
chip->clk = devm_clk_get(chip->dev, "hclk");
203215
if (IS_ERR(chip->clk))
204216
return PTR_ERR(chip->clk);
@@ -208,11 +220,11 @@ static int dw_probe(struct platform_device *pdev)
208220

209221
pm_runtime_enable(&pdev->dev);
210222

211-
err = dw_dma_probe(chip);
223+
err = data->probe(chip);
212224
if (err)
213225
goto err_dw_dma_probe;
214226

215-
platform_set_drvdata(pdev, chip);
227+
platform_set_drvdata(pdev, data);
216228

217229
if (pdev->dev.of_node) {
218230
err = of_dma_controller_register(pdev->dev.of_node,
@@ -235,12 +247,17 @@ static int dw_probe(struct platform_device *pdev)
235247

236248
static int dw_remove(struct platform_device *pdev)
237249
{
238-
struct dw_dma_chip *chip = platform_get_drvdata(pdev);
250+
struct dw_dma_chip_pdata *data = platform_get_drvdata(pdev);
251+
struct dw_dma_chip *chip = data->chip;
252+
int ret;
239253

240254
if (pdev->dev.of_node)
241255
of_dma_controller_free(pdev->dev.of_node);
242256

243-
dw_dma_remove(chip);
257+
ret = data->remove(chip);
258+
if (ret)
259+
dev_warn(chip->dev, "can't remove device properly: %d\n", ret);
260+
244261
pm_runtime_disable(&pdev->dev);
245262
clk_disable_unprepare(chip->clk);
246263

@@ -249,7 +266,8 @@ static int dw_remove(struct platform_device *pdev)
249266

250267
static void dw_shutdown(struct platform_device *pdev)
251268
{
252-
struct dw_dma_chip *chip = platform_get_drvdata(pdev);
269+
struct dw_dma_chip_pdata *data = platform_get_drvdata(pdev);
270+
struct dw_dma_chip *chip = data->chip;
253271

254272
/*
255273
* We have to call do_dw_dma_disable() to stop any ongoing transfer. On
@@ -269,17 +287,17 @@ static void dw_shutdown(struct platform_device *pdev)
269287

270288
#ifdef CONFIG_OF
271289
static const struct of_device_id dw_dma_of_id_table[] = {
272-
{ .compatible = "snps,dma-spear1340" },
290+
{ .compatible = "snps,dma-spear1340", .data = &dw_dma_chip_pdata },
273291
{}
274292
};
275293
MODULE_DEVICE_TABLE(of, dw_dma_of_id_table);
276294
#endif
277295

278296
#ifdef CONFIG_ACPI
279297
static const struct acpi_device_id dw_dma_acpi_id_table[] = {
280-
{ "INTL9C60", 0 },
281-
{ "80862286", 0 },
282-
{ "808622C0", 0 },
298+
{ "INTL9C60", (kernel_ulong_t)&dw_dma_chip_pdata },
299+
{ "80862286", (kernel_ulong_t)&dw_dma_chip_pdata },
300+
{ "808622C0", (kernel_ulong_t)&dw_dma_chip_pdata },
283301
{ }
284302
};
285303
MODULE_DEVICE_TABLE(acpi, dw_dma_acpi_id_table);
@@ -289,7 +307,8 @@ MODULE_DEVICE_TABLE(acpi, dw_dma_acpi_id_table);
289307

290308
static int dw_suspend_late(struct device *dev)
291309
{
292-
struct dw_dma_chip *chip = dev_get_drvdata(dev);
310+
struct dw_dma_chip_pdata *data = dev_get_drvdata(dev);
311+
struct dw_dma_chip *chip = data->chip;
293312

294313
do_dw_dma_disable(chip);
295314
clk_disable_unprepare(chip->clk);
@@ -299,7 +318,8 @@ static int dw_suspend_late(struct device *dev)
299318

300319
static int dw_resume_early(struct device *dev)
301320
{
302-
struct dw_dma_chip *chip = dev_get_drvdata(dev);
321+
struct dw_dma_chip_pdata *data = dev_get_drvdata(dev);
322+
struct dw_dma_chip *chip = data->chip;
303323
int ret;
304324

305325
ret = clk_prepare_enable(chip->clk);

0 commit comments

Comments
 (0)