Skip to contentSkip to conversation

staging: iio: adc: spear_adc: Use devm_iio_device_register

PATCH In review Amitoj Kaur Chawla 2 participants 4 messages Feb 22, 2016 – Feb 29, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
index f2c0065..0a6d0d7 100644
@@ -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
#1 lore raw
Quoted 4 lines · Amitoj Kaur Chawla

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.

There is an iounmap in the remove functon. Can that be devmified too?

julia

Quoted 37 lines
---
 drivers/staging/iio/adc/spear_adc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/iio/adc/spear_adc.c +1 -3
index f2c0065..0a6d0d7 100644
@@ -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.

#2 lore raw
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

#3 lore raw
In reply to Amitoj Kaur Chawla
Quoted 32 lines · Amitoj Kaur Chawla

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 -3
index f2c0065..0a6d0d7 100644
@@ -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