diff options
author | Vignesh Raman <Vignesh_Raman@mentor.com> | 2014-08-05 09:09:41 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2014-08-19 11:22:04 -0400 |
commit | 23e11811378259831777e8fdc8b9836faeaa72cd (patch) | |
tree | ce63996c49211c5a15a4bf277bfd0c41e6c67d52 /drivers/dma | |
parent | 7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff) |
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: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/imx-sdma.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index f7626e37d0b8..40e65a4df94d 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c | |||
@@ -1603,6 +1603,8 @@ static int __init sdma_probe(struct platform_device *pdev) | |||
1603 | sdma->dma_device.dev->dma_parms = &sdma->dma_parms; | 1603 | sdma->dma_device.dev->dma_parms = &sdma->dma_parms; |
1604 | dma_set_max_seg_size(sdma->dma_device.dev, 65535); | 1604 | dma_set_max_seg_size(sdma->dma_device.dev, 65535); |
1605 | 1605 | ||
1606 | platform_set_drvdata(pdev, sdma); | ||
1607 | |||
1606 | ret = dma_async_device_register(&sdma->dma_device); | 1608 | ret = dma_async_device_register(&sdma->dma_device); |
1607 | if (ret) { | 1609 | if (ret) { |
1608 | dev_err(&pdev->dev, "unable to register\n"); | 1610 | dev_err(&pdev->dev, "unable to register\n"); |
@@ -1640,7 +1642,20 @@ err_irq: | |||
1640 | 1642 | ||
1641 | static int sdma_remove(struct platform_device *pdev) | 1643 | static int sdma_remove(struct platform_device *pdev) |
1642 | { | 1644 | { |
1643 | return -EBUSY; | 1645 | struct sdma_engine *sdma = platform_get_drvdata(pdev); |
1646 | struct resource *iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1647 | int irq = platform_get_irq(pdev, 0); | ||
1648 | |||
1649 | dma_async_device_unregister(&sdma->dma_device); | ||
1650 | kfree(sdma->script_addrs); | ||
1651 | free_irq(irq, sdma); | ||
1652 | iounmap(sdma->regs); | ||
1653 | release_mem_region(iores->start, resource_size(iores)); | ||
1654 | kfree(sdma); | ||
1655 | |||
1656 | platform_set_drvdata(pdev, NULL); | ||
1657 | dev_info(&pdev->dev, "Removed...\n"); | ||
1658 | return 0; | ||
1644 | } | 1659 | } |
1645 | 1660 | ||
1646 | static struct platform_driver sdma_driver = { | 1661 | static struct platform_driver sdma_driver = { |
@@ -1650,13 +1665,10 @@ static struct platform_driver sdma_driver = { | |||
1650 | }, | 1665 | }, |
1651 | .id_table = sdma_devtypes, | 1666 | .id_table = sdma_devtypes, |
1652 | .remove = sdma_remove, | 1667 | .remove = sdma_remove, |
1668 | .probe = sdma_probe, | ||
1653 | }; | 1669 | }; |
1654 | 1670 | ||
1655 | static int __init sdma_module_init(void) | 1671 | module_platform_driver(sdma_driver); |
1656 | { | ||
1657 | return platform_driver_probe(&sdma_driver, sdma_probe); | ||
1658 | } | ||
1659 | module_init(sdma_module_init); | ||
1660 | 1672 | ||
1661 | MODULE_AUTHOR("Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>"); | 1673 | MODULE_AUTHOR("Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>"); |
1662 | MODULE_DESCRIPTION("i.MX SDMA driver"); | 1674 | MODULE_DESCRIPTION("i.MX SDMA driver"); |