Commit b8466760 authored by Andrey Smirnov's avatar Andrey Smirnov Committed by Jonathan Cameron

iio: imx7d_adc: Simplify imx7d_adc_remove() with imx7d_adc_suspend()

Since imx7d_adc_remove() does exactly the same thing as
imx7d_adc_suspend() we can use the latter together with
devm_add_action_or_reset() to simplify the former. Rename
imx7d_adc_suspend() to imx7d_adc_disable() for clarity while at it.
Signed-off-by: default avatarAndrey Smirnov <andrew.smirnov@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Chris Healy <cphealy@gmail.com>
Cc: linux-iio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 4fe86cdf
...@@ -461,6 +461,24 @@ static int imx7d_adc_enable(struct device *dev) ...@@ -461,6 +461,24 @@ static int imx7d_adc_enable(struct device *dev)
return 0; return 0;
} }
static int imx7d_adc_disable(struct device *dev)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct imx7d_adc *info = iio_priv(indio_dev);
imx7d_adc_power_down(info);
clk_disable_unprepare(info->clk);
regulator_disable(info->vref);
return 0;
}
static void __imx7d_adc_disable(void *data)
{
imx7d_adc_disable(data);
}
static int imx7d_adc_probe(struct platform_device *pdev) static int imx7d_adc_probe(struct platform_device *pdev)
{ {
struct imx7d_adc *info; struct imx7d_adc *info;
...@@ -531,11 +549,13 @@ static int imx7d_adc_probe(struct platform_device *pdev) ...@@ -531,11 +549,13 @@ static int imx7d_adc_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
ret = devm_add_action_or_reset(dev, __imx7d_adc_disable,
&indio_dev->dev);
if (ret)
return ret;
ret = iio_device_register(indio_dev); ret = iio_device_register(indio_dev);
if (ret) { if (ret) {
imx7d_adc_power_down(info);
clk_disable_unprepare(info->clk);
regulator_disable(info->vref);
dev_err(&pdev->dev, "Couldn't register the device.\n"); dev_err(&pdev->dev, "Couldn't register the device.\n");
return ret; return ret;
} }
...@@ -546,32 +566,14 @@ static int imx7d_adc_probe(struct platform_device *pdev) ...@@ -546,32 +566,14 @@ static int imx7d_adc_probe(struct platform_device *pdev)
static int imx7d_adc_remove(struct platform_device *pdev) static int imx7d_adc_remove(struct platform_device *pdev)
{ {
struct iio_dev *indio_dev = platform_get_drvdata(pdev); struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct imx7d_adc *info = iio_priv(indio_dev);
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
imx7d_adc_power_down(info);
clk_disable_unprepare(info->clk);
regulator_disable(info->vref);
return 0; return 0;
} }
static int __maybe_unused imx7d_adc_suspend(struct device *dev)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct imx7d_adc *info = iio_priv(indio_dev);
imx7d_adc_power_down(info);
clk_disable_unprepare(info->clk);
regulator_disable(info->vref);
return 0;
}
static SIMPLE_DEV_PM_OPS(imx7d_adc_pm_ops, imx7d_adc_suspend, imx7d_adc_enable); static SIMPLE_DEV_PM_OPS(imx7d_adc_pm_ops, imx7d_adc_disable, imx7d_adc_enable);
static struct platform_driver imx7d_adc_driver = { static struct platform_driver imx7d_adc_driver = {
.probe = imx7d_adc_probe, .probe = imx7d_adc_probe,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment