aboutsummaryrefslogtreecommitdiff
path: root/drivers/scsi/ufs/ufshcd-pltfrm.c
diff options
context:
space:
mode:
authorSeungwon Jeon <tgih.jun@samsung.com>2013-06-27 13:31:54 +0900
committerJames Bottomley <JBottomley@Parallels.com>2013-06-28 13:11:28 -0700
commit2953f850c3b80bdca004967c83733365d8aa0aa2 (patch)
treede80e56c2a9f42ab51bb50d05c40c31ed643a454 /drivers/scsi/ufs/ufshcd-pltfrm.c
parent3ca316c582ddf11944806a27e460e7bd8f61a968 (diff)
[SCSI] ufs: use devres functions for ufshcd
This patch replaces normal calls for resource allocation with devm_*() derivative functions. It makes resource freeing simpler. Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com> Signed-off-by: Santosh Y <santoshsy@gmail.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/ufs/ufshcd-pltfrm.c')
-rw-r--r--drivers/scsi/ufs/ufshcd-pltfrm.c72
1 files changed, 20 insertions, 52 deletions
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 3db2ee1a38b..0e48827c86b 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -33,9 +33,10 @@
* this program.
*/
-#include "ufshcd.h"
#include <linux/platform_device.h>
+#include "ufshcd.h"
+
#ifdef CONFIG_PM
/**
* ufshcd_pltfrm_suspend - suspend power management function
@@ -97,62 +98,45 @@ static int ufshcd_pltfrm_probe(struct platform_device *pdev)
struct ufs_hba *hba;
void __iomem *mmio_base;
struct resource *mem_res;
- struct resource *irq_res;
- resource_size_t mem_size;
- int err;
+ int irq, err;
struct device *dev = &pdev->dev;
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem_res) {
- dev_err(&pdev->dev,
- "Memory resource not available\n");
+ dev_err(dev, "Memory resource not available\n");
err = -ENODEV;
- goto out_error;
+ goto out;
}
- mem_size = resource_size(mem_res);
- if (!request_mem_region(mem_res->start, mem_size, "ufshcd")) {
- dev_err(&pdev->dev,
- "Cannot reserve the memory resource\n");
- err = -EBUSY;
- goto out_error;
+ mmio_base = devm_ioremap_resource(dev, mem_res);
+ if (IS_ERR(mmio_base)) {
+ dev_err(dev, "memory map failed\n");
+ err = PTR_ERR(mmio_base);
+ goto out;
}
- mmio_base = ioremap_nocache(mem_res->start, mem_size);
- if (!mmio_base) {
- dev_err(&pdev->dev, "memory map failed\n");
- err = -ENOMEM;
- goto out_release_regions;
- }
-
- irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (!irq_res) {
- dev_err(&pdev->dev, "IRQ resource not available\n");
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0) {
+ dev_err(dev, "IRQ resource not available\n");
err = -ENODEV;
- goto out_iounmap;
+ goto out;
}
err = dma_set_coherent_mask(dev, dev->coherent_dma_mask);
if (err) {
- dev_err(&pdev->dev, "set dma mask failed\n");
- goto out_iounmap;
+ dev_err(dev, "set dma mask failed\n");
+ goto out;
}
- err = ufshcd_init(&pdev->dev, &hba, mmio_base, irq_res->start);
+ err = ufshcd_init(dev, &hba, mmio_base, irq);
if (err) {
- dev_err(&pdev->dev, "Intialization failed\n");
- goto out_iounmap;
+ dev_err(dev, "Intialization failed\n");
+ goto out;
}
platform_set_drvdata(pdev, hba);
- return 0;
-
-out_iounmap:
- iounmap(mmio_base);
-out_release_regions:
- release_mem_region(mem_res->start, mem_size);
-out_error:
+out:
return err;
}
@@ -164,26 +148,10 @@ out_error:
*/
static int ufshcd_pltfrm_remove(struct platform_device *pdev)
{
- struct resource *mem_res;
- resource_size_t mem_size;
struct ufs_hba *hba = platform_get_drvdata(pdev);
disable_irq(hba->irq);
-
- /* Some buggy controllers raise interrupt after
- * the resources are removed. So first we unregister the
- * irq handler and then the resources used by driver
- */
-
- free_irq(hba->irq, hba);
ufshcd_remove(hba);
- mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!mem_res)
- dev_err(&pdev->dev, "ufshcd: Memory resource not available\n");
- else {
- mem_size = resource_size(mem_res);
- release_mem_region(mem_res->start, mem_size);
- }
return 0;
}