diff options
author | Amitoj Kaur Chawla <amitoj1606@gmail.com> | 2016-02-18 17:41:50 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-02-21 02:02:06 +0300 |
commit | bab469cdb6674cdf03b9243663cbbb8326510b41 (patch) | |
tree | 985872f5d4a62928d2193f7110bafd9050dbeda7 /drivers/staging/most/hdm-dim2/dim2_hdm.c | |
parent | 8661fca6f679996133765fa905e9a480b8c96a74 (diff) | |
download | linux-bab469cdb6674cdf03b9243663cbbb8326510b41.tar.xz |
staging: most: hdm-dim2: Switch to devm_ioremap_resource()
Devm_ functions allocate memory that is released when a driver
detaches. Replace request_mem_region and ioremap with
devm_ioremap_resource and remove corresponding freeing functions
release_mem_region and iounmap from probe and remove functions of a
platform device.
Also, an unnecessary platform_set_drvdata() has been removed since the
driver core clears the driver data to NULL after device release or on
probe failure. There is no need to manually clear the device driver
data to NULL.
Lastly, unnecessary labels have been removed.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/most/hdm-dim2/dim2_hdm.c')
-rw-r--r-- | drivers/staging/most/hdm-dim2/dim2_hdm.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/drivers/staging/most/hdm-dim2/dim2_hdm.c b/drivers/staging/most/hdm-dim2/dim2_hdm.c index 97db334e5867..708b998b953f 100644 --- a/drivers/staging/most/hdm-dim2/dim2_hdm.c +++ b/drivers/staging/most/hdm-dim2/dim2_hdm.c @@ -747,29 +747,14 @@ static int dim2_probe(struct platform_device *pdev) test_dev = dev; #else res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - pr_err("no memory region defined\n"); - ret = -ENOENT; - return ret; - } - - if (!request_mem_region(res->start, resource_size(res), pdev->name)) { - pr_err("failed to request mem region\n"); - ret = -EBUSY; - return ret; - } - - dev->io_base = ioremap(res->start, resource_size(res)); - if (!dev->io_base) { - pr_err("failed to ioremap\n"); - ret = -ENOMEM; - goto err_release_mem; - } + dev->io_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(dev->io_base)) + return PTR_ERR(dev->io_base); ret = platform_get_irq(pdev, 0); if (ret < 0) { pr_err("failed to get irq\n"); - goto err_unmap_io; + return -ENODEV; } dev->irq_ahb0 = ret; @@ -777,7 +762,7 @@ static int dim2_probe(struct platform_device *pdev) if (ret) { pr_err("failed to request IRQ: %d, err: %d\n", dev->irq_ahb0, ret); - goto err_unmap_io; + return ret; } #endif init_waitqueue_head(&dev->netinfo_waitq); @@ -858,10 +843,6 @@ err_stop_thread: err_free_irq: #if !defined(ENABLE_HDM_TEST) free_irq(dev->irq_ahb0, dev); -err_unmap_io: - iounmap(dev->io_base); -err_release_mem: - release_mem_region(res->start, resource_size(res)); #endif return ret; @@ -876,7 +857,6 @@ err_release_mem: static int dim2_remove(struct platform_device *pdev) { struct dim2_hdm *dev = platform_get_drvdata(pdev); - struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct dim2_platform_data *pdata = pdev->dev.platform_data; unsigned long flags; @@ -892,10 +872,7 @@ static int dim2_remove(struct platform_device *pdev) kthread_stop(dev->netinfo_task); #if !defined(ENABLE_HDM_TEST) free_irq(dev->irq_ahb0, dev); - iounmap(dev->io_base); - release_mem_region(res->start, resource_size(res)); #endif - platform_set_drvdata(pdev, NULL); /* * break link to local platform_device_id struct |