All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: iio: accel: Replace iio_device_register with devm_iio_device_register
@ 2016-02-22 19:43 Amitoj Kaur Chawla
  2016-02-28 17:51 ` reordering remove actions in iio drivers Alison Schofield
  2016-02-29  6:37 ` [PATCH] staging: iio: accel: Replace iio_device_register with devm_iio_device_register Amitoj Kaur Chawla
  0 siblings, 2 replies; 7+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-22 19:43 UTC (permalink / raw)
  To: outreachy-kernel

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 probe and remove functions of this driver.

Also, an unnecessary label was dropped.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/staging/iio/accel/sca3000_core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
index a8f533a..f7dd359 100644
--- a/drivers/staging/iio/accel/sca3000_core.c
+++ b/drivers/staging/iio/accel/sca3000_core.c
@@ -1123,7 +1123,7 @@ static int sca3000_probe(struct spi_device *spi)
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
 	sca3000_configure_ring(indio_dev);
-	ret = iio_device_register(indio_dev);
+	ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev);
 	if (ret < 0)
 		return ret;
 
@@ -1135,7 +1135,7 @@ static int sca3000_probe(struct spi_device *spi)
 					   "sca3000",
 					   indio_dev);
 		if (ret)
-			goto error_unregister_dev;
+			return ret;
 	}
 	sca3000_register_ring_funcs(indio_dev);
 	ret = sca3000_clean_setup(st);
@@ -1146,8 +1146,6 @@ static int sca3000_probe(struct spi_device *spi)
 error_free_irq:
 	if (spi->irq)
 		free_irq(spi->irq, indio_dev);
-error_unregister_dev:
-	iio_device_unregister(indio_dev);
 	return ret;
 }
 
@@ -1178,7 +1176,6 @@ static int sca3000_remove(struct spi_device *spi)
 	sca3000_stop_all_interrupts(st);
 	if (spi->irq)
 		free_irq(spi->irq, indio_dev);
-	iio_device_unregister(indio_dev);
 	sca3000_unconfigure_ring(indio_dev);
 
 	return 0;
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-02-29  6:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-22 19:43 [PATCH] staging: iio: accel: Replace iio_device_register with devm_iio_device_register Amitoj Kaur Chawla
2016-02-28 17:51 ` reordering remove actions in iio drivers Alison Schofield
2016-02-28 17:56   ` [Outreachy kernel] " Julia Lawall
2016-02-28 18:20     ` Alison Schofield
2016-02-28 19:17       ` Julia Lawall
2016-02-29  6:15       ` Amitoj Kaur Chawla
2016-02-29  6:37 ` [PATCH] staging: iio: accel: Replace iio_device_register with devm_iio_device_register Amitoj Kaur Chawla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.