Commit 23e11811 authored by Vignesh Raman's avatar Vignesh Raman Committed by Vinod Koul

dma: imx-sdma: use module_platform_driver for SDMA driver

Currently there is no module_exit declared in SDMA driver, so that once
sdma module is inserted, it's shown with permanent attribute by lsmod,
and it can't be removed.
Use module_platform_driver to register/unregister SDMA driver and modify
SDMA's remove operation, to make SDMA driver possible to be removed.
Signed-off-by: default avatarJiada Wang <jiada_wang@mentor.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 7d1311b9
...@@ -1603,6 +1603,8 @@ static int __init sdma_probe(struct platform_device *pdev) ...@@ -1603,6 +1603,8 @@ static int __init sdma_probe(struct platform_device *pdev)
sdma->dma_device.dev->dma_parms = &sdma->dma_parms; sdma->dma_device.dev->dma_parms = &sdma->dma_parms;
dma_set_max_seg_size(sdma->dma_device.dev, 65535); dma_set_max_seg_size(sdma->dma_device.dev, 65535);
platform_set_drvdata(pdev, sdma);
ret = dma_async_device_register(&sdma->dma_device); ret = dma_async_device_register(&sdma->dma_device);
if (ret) { if (ret) {
dev_err(&pdev->dev, "unable to register\n"); dev_err(&pdev->dev, "unable to register\n");
...@@ -1640,7 +1642,20 @@ static int __init sdma_probe(struct platform_device *pdev) ...@@ -1640,7 +1642,20 @@ static int __init sdma_probe(struct platform_device *pdev)
static int sdma_remove(struct platform_device *pdev) static int sdma_remove(struct platform_device *pdev)
{ {
return -EBUSY; struct sdma_engine *sdma = platform_get_drvdata(pdev);
struct resource *iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
int irq = platform_get_irq(pdev, 0);
dma_async_device_unregister(&sdma->dma_device);
kfree(sdma->script_addrs);
free_irq(irq, sdma);
iounmap(sdma->regs);
release_mem_region(iores->start, resource_size(iores));
kfree(sdma);
platform_set_drvdata(pdev, NULL);
dev_info(&pdev->dev, "Removed...\n");
return 0;
} }
static struct platform_driver sdma_driver = { static struct platform_driver sdma_driver = {
...@@ -1650,13 +1665,10 @@ static struct platform_driver sdma_driver = { ...@@ -1650,13 +1665,10 @@ static struct platform_driver sdma_driver = {
}, },
.id_table = sdma_devtypes, .id_table = sdma_devtypes,
.remove = sdma_remove, .remove = sdma_remove,
.probe = sdma_probe,
}; };
static int __init sdma_module_init(void) module_platform_driver(sdma_driver);
{
return platform_driver_probe(&sdma_driver, sdma_probe);
}
module_init(sdma_module_init);
MODULE_AUTHOR("Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>"); MODULE_AUTHOR("Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>");
MODULE_DESCRIPTION("i.MX SDMA driver"); MODULE_DESCRIPTION("i.MX SDMA driver");
......
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