i.MX7D ADC improvements
v2 cover i.MX7D ADC improvements
Everyone:
This series is a number of small improvements I made to i.MX7D ADC driver. Hopefully each patch is self-explanatory.
Feedback is welcome!
Thanks,
Andrey Smirnov
Changes [v1]:
- Renamed imx7d_adc_resume() to imx7d_adc_enable()
- Renamed imx7d_adc_suspend() to imx7d_adc_disable()
- Reordered the series to have "iio: imx7d_adc: Use devm_iio_device_register()" as the last patch to avoid concurrency problems during removal
[v1] lore.kernel.org/lkml/[email protected]
Andrey Smirnov (6):
iio: imx7d_adc: Add local struct device pointer in imx7d_adc_probe()
iio: imx7d_adc: Replace pr_err with dev_err
iio: imx7d_adc: Use devm_platform_ioremap_resource()
iio: imx7d_adc: Simplify imx7d_adc_probe() with imx7d_adc_resume()
iio: imx7d_adc: Simplify imx7d_adc_remove() with imx7d_adc_suspend()
iio: imx7d_adc: Use devm_iio_device_register()
drivers/iio/adc/imx7d_adc.c | 175 +++++++++++++++--------------------- 1 file changed, 74 insertions(+), 101 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/6 iio: imx7d_adc: Add local struct device pointer in imx7d_adc_probe()
Use a local "struct device *dev" in imx7d_adc_probe() for brevity. No functional change intended.
--- drivers/iio/adc/imx7d_adc.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-)
drivers/iio/adc/imx7d_adc.c +18 -19
@@ -438,51 +438,51 @@ static int imx7d_adc_probe(struct platform_device *pdev)struct imx7d_adc *info;struct iio_dev *indio_dev;struct resource *mem; +struct device *dev = &pdev->dev;int irq;int ret; - indio_dev =devm_iio_device_alloc (&pdev->dev,sizeof (*info)); + indio_dev =devm_iio_device_alloc (dev,sizeof (*info));if (!indio_dev) {dev_err (&pdev->dev,"Failed allocating iio device\n" );return -ENOMEM ; } info =iio_priv (indio_dev); - info->dev = &pdev->dev; + info->dev = dev; mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - info->regs =devm_ioremap_resource (&pdev->dev, mem); + info->regs =devm_ioremap_resource (dev, mem);if (IS_ERR (info->regs)) { ret =PTR_ERR (info->regs); -dev_err (&pdev->dev, -"Failed to remap adc memory, err = %d\n" , ret); +dev_err (dev,"Failed to remap adc memory, err = %d\n" , ret);return ret; } irq =platform_get_irq (pdev,0 );if (irq <0 ) { -dev_err (&pdev->dev,"No irq resource?\n" ); +dev_err (dev,"No irq resource?\n" );return irq; } - info->clk =devm_clk_get (&pdev->dev,"adc" ); + info->clk =devm_clk_get (dev,"adc" );if (IS_ERR (info->clk)) { ret =PTR_ERR (info->clk); -dev_err (&pdev->dev,"Failed getting clock, err = %d\n" , ret); +dev_err (dev,"Failed getting clock, err = %d\n" , ret);return ret; } - info->vref =devm_regulator_get (&pdev->dev,"vref" ); + info->vref =devm_regulator_get (dev,"vref" );if (IS_ERR (info->vref)) { ret =PTR_ERR (info->vref); -dev_err (&pdev->dev, +dev_err (dev,"Failed getting reference voltage, err = %d\n" , ret);return ret; } ret =regulator_enable (info->vref);if (ret) { -dev_err (&pdev->dev, +dev_err (dev,"Can't enable adc reference top voltage, err = %d\n" , ret);return ret;
@@ -492,8 +492,8 @@ static int imx7d_adc_probe(struct platform_device *pdev)init_completion (&info->completion); - indio_dev->name =dev_name (&pdev->dev); - indio_dev->dev.parent = &pdev->dev; + indio_dev->name =dev_name (dev); + indio_dev->dev.parent = dev; indio_dev->info = &imx7d_adc_iio_info; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->channels = imx7d_adc_iio_channels;
@@ -501,16 +501,15 @@ static int imx7d_adc_probe(struct platform_device *pdev) ret =clk_prepare_enable (info->clk);if (ret) { -dev_err (&pdev->dev, -"Could not prepare or enable the clock.\n" ); +dev_err (dev,"Could not prepare or enable the clock.\n" ); goto error_adc_clk_enable; } - ret =devm_request_irq (info->dev, irq, - imx7d_adc_isr,0 , -dev_name (&pdev->dev), info); + ret =devm_request_irq (dev, irq, + imx7d_adc_isr,0 , +dev_name (dev), info);if (ret <0 ) { -dev_err (&pdev->dev,"Failed requesting irq, irq = %d\n" , irq); +dev_err (dev,"Failed requesting irq, irq = %d\n" , irq); goto error_iio_device_register; }
Signature · 1 line
2.20.1
Re: [PATCH v2 1/6] iio: imx7d_adc: Add local struct device pointer in imx7d_adc_probe()
Quoted 11 lines · On Sun, 14 Apr 2019 11:34:59 -0700 Andrey Smirnov <[email protected]>…
Use a local "struct device *dev" in
imx7d_adc_probe()for brevity. No functional change intended.Signed-off-by Andrey Smirnov <[email protected]>Cc Jonathan Cameron <[email protected]>Cc Hartmut Knaack <[email protected]>Cc Lars-Peter Clausen <[email protected]>Cc Peter Meerwald-Stadler <[email protected]>Cc Chris Healy <[email protected]>
I applied some of these from V1. Please be sure to only send updates of patches that were not applied.
Thanks
Jonathan
Quoted 104 lines
--- drivers/iio/adc/imx7d_adc.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-)drivers/iio/adc/imx7d_adc.c +18
-19@@ -438,51 +438,51 @@ static int imx7d_adc_probe(struct platform_device *pdev)struct imx7d_adc *info;struct iio_dev *indio_dev;struct resource *mem; +struct device *dev = &pdev->dev;int irq;int ret; - indio_dev =devm_iio_device_alloc (&pdev->dev,sizeof (*info)); + indio_dev =devm_iio_device_alloc (dev,sizeof (*info));if (!indio_dev) {dev_err (&pdev->dev,"Failed allocating iio device\n" );return -ENOMEM ; } info =iio_priv (indio_dev); - info->dev = &pdev->dev; + info->dev = dev; mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - info->regs =devm_ioremap_resource (&pdev->dev, mem); + info->regs =devm_ioremap_resource (dev, mem);if (IS_ERR (info->regs)) { ret =PTR_ERR (info->regs); -dev_err (&pdev->dev, -"Failed to remap adc memory, err = %d\n" , ret); +dev_err (dev,"Failed to remap adc memory, err = %d\n" , ret);return ret; } irq =platform_get_irq (pdev,0 );if (irq <0 ) { -dev_err (&pdev->dev,"No irq resource?\n" ); +dev_err (dev,"No irq resource?\n" );return irq; } - info->clk =devm_clk_get (&pdev->dev,"adc" ); + info->clk =devm_clk_get (dev,"adc" );if (IS_ERR (info->clk)) { ret =PTR_ERR (info->clk); -dev_err (&pdev->dev,"Failed getting clock, err = %d\n" , ret); +dev_err (dev,"Failed getting clock, err = %d\n" , ret);return ret; } - info->vref =devm_regulator_get (&pdev->dev,"vref" ); + info->vref =devm_regulator_get (dev,"vref" );if (IS_ERR (info->vref)) { ret =PTR_ERR (info->vref); -dev_err (&pdev->dev, +dev_err (dev,"Failed getting reference voltage, err = %d\n" , ret);return ret; } ret =regulator_enable (info->vref);if (ret) { -dev_err (&pdev->dev, +dev_err (dev,"Can't enable adc reference top voltage, err = %d\n" , ret);return ret;@@ -492,8 +492,8 @@ static int imx7d_adc_probe(struct platform_device *pdev)init_completion (&info->completion); - indio_dev->name =dev_name (&pdev->dev); - indio_dev->dev.parent = &pdev->dev; + indio_dev->name =dev_name (dev); + indio_dev->dev.parent = dev; indio_dev->info = &imx7d_adc_iio_info; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->channels = imx7d_adc_iio_channels;@@ -501,16 +501,15 @@ static int imx7d_adc_probe(struct platform_device *pdev) ret =clk_prepare_enable (info->clk);if (ret) { -dev_err (&pdev->dev, -"Could not prepare or enable the clock.\n" ); +dev_err (dev,"Could not prepare or enable the clock.\n" ); goto error_adc_clk_enable; } - ret =devm_request_irq (info->dev, irq, - imx7d_adc_isr,0 , -dev_name (&pdev->dev), info); + ret =devm_request_irq (dev, irq, + imx7d_adc_isr,0 , +dev_name (dev), info);if (ret <0 ) { -dev_err (&pdev->dev,"Failed requesting irq, irq = %d\n" , irq); +dev_err (dev,"Failed requesting irq, irq = %d\n" , irq); goto error_iio_device_register; }
PATCH v2 2/6 iio: imx7d_adc: Replace pr_err with dev_err
In reply to Andrey SmirnovReplace combination of pr_err()/dev_name() with an equivalent call for dev_err().
--- drivers/iio/adc/imx7d_adc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/adc/imx7d_adc.c +3 -2
@@ -388,8 +388,9 @@ static irqreturn_t imx7d_adc_isr(int irq, void *dev_id)* timeout flags. */ if (status &IMX7D_REG_ADC_INT_STATUS_CHANNEL_CONV_TIME_OUT ) { -pr_err ("%s: ADC got conversion time out interrupt: 0x%08x\n" , -dev_name (info->dev), status); +dev_err (info->dev, +"ADC got conversion time out interrupt: 0x%08x\n" , + status); status &= ~IMX7D_REG_ADC_INT_STATUS_CHANNEL_CONV_TIME_OUT ;writel (status, info->regs +IMX7D_REG_ADC_INT_STATUS ); }
Signature · 1 line
2.20.1
PATCH v2 3/6 iio: imx7d_adc: Use devm_platform_ioremap_resource()
In reply to Andrey SmirnovUse devm_platform_ioremap_resource() to be able to drop a bit of explicit boilerplate code.
--- drivers/iio/adc/imx7d_adc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/adc/imx7d_adc.c +1 -3
@@ -438,7 +438,6 @@ static int imx7d_adc_probe(struct platform_device *pdev) {struct imx7d_adc *info;struct iio_dev *indio_dev; -struct resource *mem;struct device *dev = &pdev->dev;int irq;int ret;
@@ -452,8 +451,7 @@ static int imx7d_adc_probe(struct platform_device *pdev) info =iio_priv (indio_dev); info->dev = dev; - mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - info->regs =devm_ioremap_resource (dev, mem); + info->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (info->regs)) { ret =PTR_ERR (info->regs);dev_err (dev,"Failed to remap adc memory, err = %d\n" , ret);
Signature · 1 line
2.20.1
PATCH v2 4/6 iio: imx7d_adc: Simplify imx7d_adc_probe() with imx7d_adc_resume()
In reply to Andrey SmirnovInitialization sequence performed in imx7d_adc_resume() is exactly the same as the one being done in imx7d_adc_probe(). Make use of the former in the latter to avoid code duplication. Rename imx7d_adc_resume() to imx7d_adc_enable() for clarity while at it.
--- drivers/iio/adc/imx7d_adc.c | 88 +++++++++++++++---------------------- 1 file changed, 36 insertions(+), 52 deletions(-)
drivers/iio/adc/imx7d_adc.c +36 -52
@@ -434,6 +434,33 @@ static void imx7d_adc_power_down(struct imx7d_adc *info)writel (adc_cfg, info->regs +IMX7D_REG_ADC_ADC_CFG ); } +static int imx7d_adc_enable (struct device *dev) +{ +struct iio_dev *indio_dev =dev_get_drvdata (dev); +struct imx7d_adc *info =iio_priv (indio_dev); +int ret; + + ret =regulator_enable (info->vref); +if (ret) { +dev_err (info->dev, +"Can't enable adc reference top voltage, err = %d\n" , + ret); +return ret; + } + + ret =clk_prepare_enable (info->clk); +if (ret) { +dev_err (info->dev, +"Could not prepare or enable clock.\n" ); +regulator_disable (info->vref); +return ret; + } + +imx7d_adc_hw_init (info); + +return 0 ; +} +static int imx7d_adc_probe (struct platform_device *pdev) {struct imx7d_adc *info;
@@ -479,14 +506,6 @@ static int imx7d_adc_probe(struct platform_device *pdev)return ret; } - ret =regulator_enable (info->vref); -if (ret) { -dev_err (dev, -"Can't enable adc reference top voltage, err = %d\n" , - ret); -return ret; - } -platform_set_drvdata (pdev, indio_dev);init_completion (&info->completion);
@@ -498,38 +517,30 @@ static int imx7d_adc_probe(struct platform_device *pdev) indio_dev->channels = imx7d_adc_iio_channels; indio_dev->num_channels =ARRAY_SIZE (imx7d_adc_iio_channels); - ret =clk_prepare_enable (info->clk); -if (ret) { -dev_err (dev,"Could not prepare or enable the clock.\n" ); - goto error_adc_clk_enable; - } - ret =devm_request_irq (dev, irq, imx7d_adc_isr,0 ,dev_name (dev), info);if (ret <0 ) {dev_err (dev,"Failed requesting irq, irq = %d\n" , irq); - goto error_iio_device_register; +return ret; }imx7d_adc_feature_config (info); -imx7d_adc_hw_init (info); + + ret =imx7d_adc_enable (&indio_dev->dev); +if (ret) +return ret; ret =iio_device_register (indio_dev);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" ); - goto error_iio_device_register; +return ret; }return 0 ; - -error_iio_device_register: -clk_disable_unprepare (info->clk); -error_adc_clk_enable: -regulator_disable (info->vref); - -return ret; }static int imx7d_adc_remove (struct platform_device *pdev)
@@ -560,34 +571,7 @@ static int __maybe_unused imx7d_adc_suspend(struct device *dev)return 0 ; } -static int __maybe_unused imx7d_adc_resume (struct device *dev) -{ -struct iio_dev *indio_dev =dev_get_drvdata (dev); -struct imx7d_adc *info =iio_priv (indio_dev); -int ret; - - ret =regulator_enable (info->vref); -if (ret) { -dev_err (info->dev, -"Can't enable adc reference top voltage, err = %d\n" , - ret); -return ret; - } - - ret =clk_prepare_enable (info->clk); -if (ret) { -dev_err (info->dev, -"Could not prepare or enable clock.\n" ); -regulator_disable (info->vref); -return ret; - } - -imx7d_adc_hw_init (info); - -return 0 ; -} - -static SIMPLE_DEV_PM_OPS(imx7d_adc_pm_ops, imx7d_adc_suspend, imx7d_adc_resume); +static SIMPLE_DEV_PM_OPS(imx7d_adc_pm_ops, imx7d_adc_suspend, imx7d_adc_enable);static struct platform_driver imx7d_adc_driver = { .probe = imx7d_adc_probe,
Signature · 1 line
2.20.1
Jonathan Cameron
maintainerRe: [PATCH v2 4/6] iio: imx7d_adc: Simplify imx7d_adc_probe() with imx7d_adc_resume()
Quoted 5 lines · On Sun, 14 Apr 2019 11:35:02 -0700 Andrey Smirnov <[email protected]>…
Initialization sequence performed in
imx7d_adc_resume()is exactly the same as the one being done inimx7d_adc_probe(). Make use of the former in the latter to avoid code duplication. Renameimx7d_adc_resume()toimx7d_adc_enable()for clarity while at it.
Quoted 8 lines
Signed-off-by Andrey Smirnov <[email protected]>Cc Jonathan Cameron <[email protected]>Cc Hartmut Knaack <[email protected]>Cc Lars-Peter Clausen <[email protected]>Cc Peter Meerwald-Stadler <[email protected]>Cc Chris Healy <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 140 lines
--- drivers/iio/adc/imx7d_adc.c | 88 +++++++++++++++---------------------- 1 file changed, 36 insertions(+), 52 deletions(-)drivers/iio/adc/imx7d_adc.c +36
-52@@ -434,6 +434,33 @@ static void imx7d_adc_power_down(struct imx7d_adc *info)writel (adc_cfg, info->regs +IMX7D_REG_ADC_ADC_CFG ); } +static int imx7d_adc_enable (struct device *dev) +{ +struct iio_dev *indio_dev =dev_get_drvdata (dev); +struct imx7d_adc *info =iio_priv (indio_dev); +int ret; + + ret =regulator_enable (info->vref); +if (ret) { +dev_err (info->dev, +"Can't enable adc reference top voltage, err = %d\n" , + ret); +return ret; + } + + ret =clk_prepare_enable (info->clk); +if (ret) { +dev_err (info->dev, +"Could not prepare or enable clock.\n" ); +regulator_disable (info->vref); +return ret; + } + +imx7d_adc_hw_init (info); + +return 0 ; +} +static int imx7d_adc_probe (struct platform_device *pdev) {struct imx7d_adc *info;@@ -479,14 +506,6 @@ static int imx7d_adc_probe(struct platform_device *pdev)return ret; } - ret =regulator_enable (info->vref); -if (ret) { -dev_err (dev, -"Can't enable adc reference top voltage, err = %d\n" , - ret); -return ret; - } -platform_set_drvdata (pdev, indio_dev);init_completion (&info->completion);@@ -498,38 +517,30 @@ static int imx7d_adc_probe(struct platform_device *pdev) indio_dev->channels = imx7d_adc_iio_channels; indio_dev->num_channels =ARRAY_SIZE (imx7d_adc_iio_channels); - ret =clk_prepare_enable (info->clk); -if (ret) { -dev_err (dev,"Could not prepare or enable the clock.\n" ); - goto error_adc_clk_enable; - } - ret =devm_request_irq (dev, irq, imx7d_adc_isr,0 ,dev_name (dev), info);if (ret <0 ) {dev_err (dev,"Failed requesting irq, irq = %d\n" , irq); - goto error_iio_device_register; +return ret; }imx7d_adc_feature_config (info); -imx7d_adc_hw_init (info); + + ret =imx7d_adc_enable (&indio_dev->dev); +if (ret) +return ret; ret =iio_device_register (indio_dev);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" ); - goto error_iio_device_register; +return ret; }return 0 ; - -error_iio_device_register: -clk_disable_unprepare (info->clk); -error_adc_clk_enable: -regulator_disable (info->vref); - -return ret; }static int imx7d_adc_remove (struct platform_device *pdev)@@ -560,34 +571,7 @@ static int __maybe_unused imx7d_adc_suspend(struct device *dev)return 0 ; } -static int __maybe_unused imx7d_adc_resume (struct device *dev) -{ -struct iio_dev *indio_dev =dev_get_drvdata (dev); -struct imx7d_adc *info =iio_priv (indio_dev); -int ret; - - ret =regulator_enable (info->vref); -if (ret) { -dev_err (info->dev, -"Can't enable adc reference top voltage, err = %d\n" , - ret); -return ret; - } - - ret =clk_prepare_enable (info->clk); -if (ret) { -dev_err (info->dev, -"Could not prepare or enable clock.\n" ); -regulator_disable (info->vref); -return ret; - } - -imx7d_adc_hw_init (info); - -return 0 ; -} - -static SIMPLE_DEV_PM_OPS(imx7d_adc_pm_ops, imx7d_adc_suspend, imx7d_adc_resume); +static SIMPLE_DEV_PM_OPS(imx7d_adc_pm_ops, imx7d_adc_suspend, imx7d_adc_enable);static struct platform_driver imx7d_adc_driver = { .probe = imx7d_adc_probe,
PATCH v2 5/6 iio: imx7d_adc: Simplify imx7d_adc_remove() with imx7d_adc_suspend()
In reply to Andrey SmirnovSince 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.
--- drivers/iio/adc/imx7d_adc.c | 46 +++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-)
drivers/iio/adc/imx7d_adc.c +24 -22
@@ -461,6 +461,24 @@ static int imx7d_adc_enable(struct device *dev)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) {struct imx7d_adc *info;
@@ -531,11 +549,13 @@ static int imx7d_adc_probe(struct platform_device *pdev)if (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);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" );return ret; }
@@ -546,32 +566,14 @@ static int imx7d_adc_probe(struct platform_device *pdev)static int imx7d_adc_remove (struct platform_device *pdev) {struct iio_dev *indio_dev =platform_get_drvdata (pdev); -struct imx7d_adc *info =iio_priv (indio_dev);iio_device_unregister (indio_dev); -imx7d_adc_power_down (info); - -clk_disable_unprepare (info->clk); -regulator_disable (info->vref); -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 = { .probe = imx7d_adc_probe,
Signature · 1 line
2.20.1
Jonathan Cameron
maintainerRe: [PATCH v2 5/6] iio: imx7d_adc: Simplify imx7d_adc_remove() with imx7d_adc_suspend()
Quoted 5 lines · On Sun, 14 Apr 2019 11:35:03 -0700 Andrey Smirnov <[email protected]>…
Since
imx7d_adc_remove()does exactly the same thing asimx7d_adc_suspend()we can use the latter together withdevm_add_action_or_reset()to simplify the former. Renameimx7d_adc_suspend()toimx7d_adc_disable()for clarity while at it.
Quoted 8 lines
Signed-off-by Andrey Smirnov <[email protected]>Cc Jonathan Cameron <[email protected]>Cc Hartmut Knaack <[email protected]>Cc Lars-Peter Clausen <[email protected]>Cc Peter Meerwald-Stadler <[email protected]>Cc Chris Healy <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to see if they can find anything we missed.
Thanks,
Jonathan
Quoted 84 lines
--- drivers/iio/adc/imx7d_adc.c | 46 +++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-)drivers/iio/adc/imx7d_adc.c +24
-22@@ -461,6 +461,24 @@ static int imx7d_adc_enable(struct device *dev)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) {struct imx7d_adc *info;@@ -531,11 +549,13 @@ static int imx7d_adc_probe(struct platform_device *pdev)if (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);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" );return ret; }@@ -546,32 +566,14 @@ static int imx7d_adc_probe(struct platform_device *pdev)static int imx7d_adc_remove (struct platform_device *pdev) {struct iio_dev *indio_dev =platform_get_drvdata (pdev); -struct imx7d_adc *info =iio_priv (indio_dev);iio_device_unregister (indio_dev); -imx7d_adc_power_down (info); - -clk_disable_unprepare (info->clk); -regulator_disable (info->vref); -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 = { .probe = imx7d_adc_probe,
PATCH v2 6/6 iio: imx7d_adc: Use devm_iio_device_register()
In reply to Andrey SmirnovUse devm_iio_device_register() and drop imx7d_adc_remove().
--- drivers/iio/adc/imx7d_adc.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/iio/adc/imx7d_adc.c +1 -12
@@ -554,7 +554,7 @@ static int imx7d_adc_probe(struct platform_device *pdev)if (ret)return ret; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (dev, indio_dev);if (ret) {dev_err (&pdev->dev,"Couldn't register the device.\n" );return ret;
@@ -563,21 +563,10 @@ static int imx7d_adc_probe(struct platform_device *pdev)return 0 ; } -static int imx7d_adc_remove (struct platform_device *pdev) -{ -struct iio_dev *indio_dev =platform_get_drvdata (pdev); - -iio_device_unregister (indio_dev); - -return 0 ; -} - - static SIMPLE_DEV_PM_OPS(imx7d_adc_pm_ops, imx7d_adc_disable, imx7d_adc_enable);static struct platform_driver imx7d_adc_driver = { .probe = imx7d_adc_probe, - .remove = imx7d_adc_remove, .driver = { .name ="imx7d_adc" , .of_match_table = imx7d_adc_match,
Signature · 1 line
2.20.1
Jonathan Cameron
maintainerRe: [PATCH v2 6/6] iio: imx7d_adc: Use devm_iio_device_register()
Quoted 10 lines · On Sun, 14 Apr 2019 11:35:04 -0700 Andrey Smirnov <[email protected]>…
Use
devm_iio_device_register()and dropimx7d_adc_remove().Signed-off-by Andrey Smirnov <[email protected]>Cc Jonathan Cameron <[email protected]>Cc Hartmut Knaack <[email protected]>Cc Lars-Peter Clausen <[email protected]>Cc Peter Meerwald-Stadler <[email protected]>Cc Chris Healy <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to poke at it.
Thanks,
Jonathan
Quoted 39 lines
--- drivers/iio/adc/imx7d_adc.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)drivers/iio/adc/imx7d_adc.c +1
-12@@ -554,7 +554,7 @@ static int imx7d_adc_probe(struct platform_device *pdev)if (ret)return ret; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (dev, indio_dev);if (ret) {dev_err (&pdev->dev,"Couldn't register the device.\n" );return ret;@@ -563,21 +563,10 @@ static int imx7d_adc_probe(struct platform_device *pdev)return 0 ; } -static int imx7d_adc_remove (struct platform_device *pdev) -{ -struct iio_dev *indio_dev =platform_get_drvdata (pdev); - -iio_device_unregister (indio_dev); - -return 0 ; -} - - static SIMPLE_DEV_PM_OPS(imx7d_adc_pm_ops, imx7d_adc_disable, imx7d_adc_enable);static struct platform_driver imx7d_adc_driver = { .probe = imx7d_adc_probe, - .remove = imx7d_adc_remove, .driver = { .name ="imx7d_adc" , .of_match_table = imx7d_adc_match,