[PATCH 4/5] iio: light: gp2ap020a00f: Use devm_* APIs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch changes APIs from request_threaded_irq()
and iio_device_register() to devm_* APIs. Using them make simpler.
Signed-off-by: Beomho Seo <beomho.seo@xxxxxxxxxxx>
---
 drivers/iio/light/gp2ap020a00f.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c
index 221ed16..1745c6a 100644
--- a/drivers/iio/light/gp2ap020a00f.c
+++ b/drivers/iio/light/gp2ap020a00f.c
@@ -1562,7 +1562,7 @@ static int gp2ap020a00f_probe(struct i2c_client *client,
 	}
 
 	/* This needs to be requested here for read_raw calls to work. */
-	err = request_threaded_irq(client->irq, NULL,
+	err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
 				   &gp2ap020a00f_thresh_event_handler,
 				   IRQF_TRIGGER_FALLING |
 				   IRQF_ONESHOT,
@@ -1581,10 +1581,10 @@ static int gp2ap020a00f_probe(struct i2c_client *client,
 	err = iio_trigger_register(data->trig);
 	if (err < 0) {
 		dev_err(&client->dev, "Failed to register iio trigger.\n");
-		goto error_free_irq;
+		goto iio_uninit_buffer;
 	}
 
-	err = iio_device_register(indio_dev);
+	err = devm_iio_device_register(&client->dev, indio_dev);
 	if (err < 0)
 		goto error_trigger_unregister;
 
@@ -1592,8 +1592,6 @@ static int gp2ap020a00f_probe(struct i2c_client *client,
 
 error_trigger_unregister:
 	iio_trigger_unregister(data->trig);
-error_free_irq:
-	free_irq(client->irq, indio_dev);
 error_uninit_buffer:
 	iio_triggered_buffer_cleanup(indio_dev);
 error_regulator_disable:
@@ -1613,9 +1611,7 @@ static int gp2ap020a00f_remove(struct i2c_client *client)
 	if (err < 0)
 		dev_err(&indio_dev->dev, "Failed to power off the device.\n");
 
-	iio_device_unregister(indio_dev);
 	iio_trigger_unregister(data->trig);
-	free_irq(client->irq, indio_dev);
 	iio_triggered_buffer_cleanup(indio_dev);
 	regulator_disable(data->vled_reg);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux