staging: iio: adc: spear_adc: Use devm_iio_device_register
Subsystems (3)
PATCH 1/1 staging: iio: adc: spear_adc: Use devm_iio_device_register
Devm_ functions allocate memory that is released when a driver detaches. Replace iio_device_register with the resource-managed version devm_iio_device_register. Subsequently, remove iio_device_unregister from remove function of this driver.
--- drivers/staging/iio/adc/spear_adc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/iio/adc/spear_adc.c +1 -2
@@ -346,7 +346,7 @@ static int spear_adc_probe(struct platform_device *pdev) indio_dev->channels = spear_adc_iio_channels; indio_dev->num_channels =ARRAY_SIZE (spear_adc_iio_channels); - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (indio_dev->dev.parent, indio_dev);if (ret) goto errout2;
@@ -366,7 +366,6 @@ static int spear_adc_remove(struct platform_device *pdev)struct iio_dev *indio_dev =platform_get_drvdata (pdev);struct spear_adc_state *st =iio_priv (indio_dev); -iio_device_unregister (indio_dev);clk_disable_unprepare (st->clk);iounmap (st->adc_base_spear6xx);
Signature · 1 line
1.9.1
Quoted 4 lines · Amitoj Kaur Chawla
Devm_functions allocate memory that is released when a driver detaches. Replaceiio_device_registerwith the resource-managed versiondevm_iio_device_register. Subsequently, removeiio_device_unregisterfrom remove function of this driver.
There is an iounmap in the remove functon. Can that be devmified too?
julia
Quoted 37 lines
Signed-off-by Amitoj Kaur Chawla <[email protected]>--- drivers/staging/iio/adc/spear_adc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/staging/iio/adc/spear_adc.c +1
-3@@ -346,7 +346,7 @@ static int spear_adc_probe(struct platform_device *pdev) indio_dev->channels = spear_adc_iio_channels; indio_dev->num_channels =ARRAY_SIZE (spear_adc_iio_channels); - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (indio_dev->dev.parent, indio_dev);if (ret) goto errout2;@@ -366,7 +366,6 @@ static int spear_adc_remove(struct platform_device *pdev)struct iio_dev *indio_dev =platform_get_drvdata (pdev);struct spear_adc_state *st =iio_priv (indio_dev); -iio_device_unregister (indio_dev);clk_disable_unprepare (st->clk);iounmap (st->adc_base_spear6xx); --1.9.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160222195807.GA12070%40amitoj-Inspiron-3542.
For more options, visit https://groups.google.com/d/optout.
Quoted 5 lines · Julia Lawall
There is an iounmap in the remove functon. Can that be devmified too?
julia
It can be, I believe. But I think Greg would want the change to be a separate patch.
Since the function contains an of_iomap which has the subsequent freeing iounmap that you pointed out, and as this conversation
<https://lkml.org/lkml/2013/8/13/32> suggests devm_of_iomap() is not correct usually, should I switch to devm_ioremap()?
I can send a separate patch for this if you agree.
Amitoj
Quoted 32 lines · Amitoj Kaur Chawla
Devm_functions allocate memory that is released when a driver detaches. Replaceiio_device_registerwith the resource-managed versiondevm_iio_device_register. Subsequently, removeiio_device_unregisterfrom remove function of this driver.Signed-off-by Amitoj Kaur Chawla <[email protected]>--- drivers/staging/iio/adc/spear_adc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/staging/iio/adc/spear_adc.c +1
-3@@ -346,7 +346,7 @@ static int spear_adc_probe(struct platform_device *pdev) indio_dev->channels = spear_adc_iio_channels; indio_dev->num_channels =ARRAY_SIZE (spear_adc_iio_channels); - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (indio_dev->dev.parent, indio_dev);if (ret) goto errout2;@@ -366,7 +366,6 @@ static int spear_adc_remove(struct platform_device *pdev)struct iio_dev *indio_dev =platform_get_drvdata (pdev);struct spear_adc_state *st =iio_priv (indio_dev); -iio_device_unregister (indio_dev);clk_disable_unprepare (st->clk);iounmap (st->adc_base_spear6xx); --
Quoted 2 lines
1.9.1
This patch is incorrect and should be dropped.
Amitoj