]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
dmaengine: dw: platform: Switch to acpi_dma_controller_register()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 20 Aug 2019 13:15:43 +0000 (16:15 +0300)
committerVinod Koul <vkoul@kernel.org>
Wed, 21 Aug 2019 04:11:28 +0000 (09:41 +0530)
There is a possibility to have registered ACPI DMA controller
while it has been gone already.

To avoid the potential crash, move to non-managed
acpi_dma_controller_register().

Fixes: 42c91ee71d6d ("dw_dmac: add ACPI support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20190820131546.75744-8-andriy.shevchenko@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/dw/platform.c

index 8576439d003515952af0dc28f472a953fa37a546..44fec1eabccd589ff061f51d6f3c78c8d4cf645a 100644 (file)
@@ -84,13 +84,20 @@ static void dw_dma_acpi_controller_register(struct dw_dma *dw)
        dma_cap_set(DMA_SLAVE, info->dma_cap);
        info->filter_fn = dw_dma_acpi_filter;
 
-       ret = devm_acpi_dma_controller_register(dev, acpi_dma_simple_xlate,
-                                               info);
+       ret = acpi_dma_controller_register(dev, acpi_dma_simple_xlate, info);
        if (ret)
                dev_err(dev, "could not register acpi_dma_controller\n");
 }
+
+static void dw_dma_acpi_controller_free(struct dw_dma *dw)
+{
+       struct device *dev = dw->dma.dev;
+
+       acpi_dma_controller_free(dev);
+}
 #else /* !CONFIG_ACPI */
 static inline void dw_dma_acpi_controller_register(struct dw_dma *dw) {}
+static inline void dw_dma_acpi_controller_free(struct dw_dma *dw) {}
 #endif /* !CONFIG_ACPI */
 
 #ifdef CONFIG_OF
@@ -249,6 +256,9 @@ static int dw_remove(struct platform_device *pdev)
        struct dw_dma_chip *chip = data->chip;
        int ret;
 
+       if (ACPI_HANDLE(&pdev->dev))
+               dw_dma_acpi_controller_free(chip->dw);
+
        if (pdev->dev.of_node)
                of_dma_controller_free(pdev->dev.of_node);