summaryrefslogtreecommitdiff
path: root/drivers/staging/iio
diff options
context:
space:
mode:
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>2016-02-29 07:33:46 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-03-12 06:09:09 (GMT)
commit09b9da3399c8fee4ec7fc393b2d1aeaef4607caf (patch)
tree30bece2183fe910cddc9812ddd6adef1ee4daa60 /drivers/staging/iio
parenta04b4e5005d95d80248fdec66180cbb9f020afea (diff)
downloadlinux-09b9da3399c8fee4ec7fc393b2d1aeaef4607caf.tar.xz
staging: iio: adc: Replace of_iomap() with devm_ioremap_resource()
The adc driver uses of_iomap() which doesn't request the resource and isn't device managed so error handling is needed. of_iomap() is mainly used in cases where there is no driver or struct device so a switch to devm_ functions is required. This patch switches to use devm_ioremap_resource() instead which automatically requests the resource and is freed when the driver detaches. Removed the error handling to unmap I/O registers i.e. iounmap() in probe and remove functions of this driver and consequently removed an unnecessary label. Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/iio')
-rw-r--r--drivers/staging/iio/adc/spear_adc.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c
index f2c0065..5dd61f6 100644
--- a/drivers/staging/iio/adc/spear_adc.c
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -262,6 +262,7 @@ static int spear_adc_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node;
struct device *dev = &pdev->dev;
struct spear_adc_state *st;
+ struct resource *res;
struct iio_dev *indio_dev = NULL;
int ret = -ENODEV;
int irq;
@@ -280,24 +281,24 @@ static int spear_adc_probe(struct platform_device *pdev)
* (e.g. SPEAr3xx). Let's provide two register base addresses
* to support multi-arch kernels.
*/
- st->adc_base_spear6xx = of_iomap(np, 0);
- if (!st->adc_base_spear6xx) {
- dev_err(dev, "failed mapping memory\n");
- return -ENOMEM;
- }
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ st->adc_base_spear6xx = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(st->adc_base_spear6xx))
+ return PTR_ERR(st->adc_base_spear6xx);
+
st->adc_base_spear3xx =
(struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx;
st->clk = devm_clk_get(dev, NULL);
if (IS_ERR(st->clk)) {
dev_err(dev, "failed getting clock\n");
- goto errout1;
+ return PTR_ERR(st->clk);
}
ret = clk_prepare_enable(st->clk);
if (ret) {
dev_err(dev, "failed enabling clock\n");
- goto errout1;
+ return ret;
}
irq = platform_get_irq(pdev, 0);
@@ -356,8 +357,6 @@ static int spear_adc_probe(struct platform_device *pdev)
errout2:
clk_disable_unprepare(st->clk);
-errout1:
- iounmap(st->adc_base_spear6xx);
return ret;
}
@@ -368,7 +367,6 @@ static int spear_adc_remove(struct platform_device *pdev)
iio_device_unregister(indio_dev);
clk_disable_unprepare(st->clk);
- iounmap(st->adc_base_spear6xx);
return 0;
}