#include <linux/of_irq.h>
#include <linux/regulator/consumer.h>
#include <linux/of_platform.h>
+#include <linux/err.h>
#include <linux/iio/iio.h>
#include <linux/iio/machine.h>
if (!np)
return ret;
- indio_dev = iio_device_alloc(sizeof(struct exynos_adc));
+ indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct exynos_adc));
if (!indio_dev) {
dev_err(&pdev->dev, "failed allocating iio device\n");
return -ENOMEM;
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
info->regs = devm_ioremap_resource(&pdev->dev, mem);
- if (IS_ERR(info->regs)) {
- ret = PTR_ERR(info->regs);
- goto err_iio;
- }
+ if (IS_ERR(info->regs))
+ return PTR_ERR(info->regs);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
info->enable_reg = devm_ioremap_resource(&pdev->dev, mem);
- if (IS_ERR(info->enable_reg)) {
- ret = PTR_ERR(info->enable_reg);
- goto err_iio;
- }
+ if (IS_ERR(info->enable_reg))
+ return PTR_ERR(info->enable_reg);
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
dev_err(&pdev->dev, "no irq resource?\n");
- ret = irq;
- goto err_iio;
+ return irq;
}
info->irq = irq;
if (ret < 0) {
dev_err(&pdev->dev, "failed requesting irq, irq = %d\n",
info->irq);
- goto err_iio;
+ return ret;
}
writel(1, info->enable_reg);
iio_device_unregister(indio_dev);
err_irq:
free_irq(info->irq, info);
-err_iio:
- iio_device_free(indio_dev);
return ret;
}
writel(0, info->enable_reg);
iio_device_unregister(indio_dev);
free_irq(info->irq, info);
- iio_device_free(indio_dev);
return 0;
}