Staging: iio: meter: Use devm functions
Subsystems (4)
PATCH v4 1/1 Staging: iio: meter: Use devm functions
Introduce use of managed resource function devm_iio_trigger_alloc instead of iio_trigger_alloc and devm_request_irq instead of request_irq Remove corresponding calls to iio_trigger_free and free_irq in the probe and remove functions.
The now unnecessary labels error_free_trig and err_free_irq are dropped.
---
Changes in v4-
Dropped the use of free_irq.Also updated commit message and changed the subject.
Changes in v3-
Used devm_request_irq instead of request_irq.Also updated commit message.
Changes in v2-
Use appropriate arguments in devm_iio_trigger_alloc.
drivers/staging/iio/meter/ade7758_trigger.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
drivers/staging/iio/meter/ade7758_trigger.c +10 -16
@@ -63,21 +63,21 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)struct ade7758_state *st =iio_priv (indio_dev);int ret; - st->trig =iio_trigger_alloc ("%s-dev%d" , -spi_get_device_id (st->us)->name, - indio_dev->id); + st->trig =devm_iio_trigger_alloc (&indio_dev->id,"%s-dev%d" , +spi_get_device_id (st->us)->name, + indio_dev->id);if (!st->trig) { ret = -ENOMEM ; goto error_ret; } - ret =request_irq (st->us->irq, - ade7758_data_rdy_trig_poll, -IRQF_TRIGGER_LOW , -spi_get_device_id (st->us)->name, - st->trig); + ret =devm_request_irq (&indio_dev->dev, st->us->irq, + ade7758_data_rdy_trig_poll, +IRQF_TRIGGER_LOW , +spi_get_device_id (st->us)->name, + st->trig);if (ret) - goto error_free_trig; + goto error_ret st->trig->dev.parent = &st->us->dev; st->trig->ops = &ade7758_trigger_ops;
@@ -87,14 +87,10 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)/* select default trigger */ indio_dev->trig =iio_trigger_get (st->trig);if (ret) - goto error_free_irq; + goto error_ret;return 0 ; -error_free_irq: -free_irq (st->us->irq, st->trig); -error_free_trig: -iio_trigger_free (st->trig); error_ret:return ret; }
@@ -104,6 +100,4 @@ void ade7758_remove_trigger(struct iio_dev *indio_dev)struct ade7758_state *st =iio_priv (indio_dev);iio_trigger_unregister (st->trig); -free_irq (st->us->irq, st->trig); -iio_trigger_free (st->trig); }
Signature · 1 line
2.1.4
Quoted 5 lines · Shraddha Barke
Introduce use of managed resource function
devm_iio_trigger_allocinstead ofiio_trigger_allocanddevm_request_irqinstead ofrequest_irqRemove corresponding calls toiio_trigger_freeandfree_irqin the probe and remove functions.
The now unnecessary labelserror_free_triganderr_free_irqare dropped.
Hmm, maybe the irq was not a good idea, because it will move turning off interrupts beyond the end of the calling remove function and that function might free some things needed by the interrupt handler. Perhaps someone else knows more.
julia
Quoted 83 lines
Signed-off-by Shraddha Barke <[email protected]>---
Changes in v4-
Dropped the use of free_irq.Also updated commit message and changed the subject.Changes in v3-
Useddevm_request_irqinstead of request_irq.Also updated commit message.Changes in v2-
Use appropriate arguments indevm_iio_trigger_alloc.drivers/staging/iio/meter/ade7758_trigger.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)drivers/staging/iio/meter/ade7758_trigger.c +10
-16@@ -63,21 +63,21 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)struct ade7758_state *st =iio_priv (indio_dev);int ret; - st->trig =iio_trigger_alloc ("%s-dev%d" , -spi_get_device_id (st->us)->name, - indio_dev->id); + st->trig =devm_iio_trigger_alloc (&indio_dev->id,"%s-dev%d" , +spi_get_device_id (st->us)->name, + indio_dev->id);if (!st->trig) { ret = -ENOMEM ; goto error_ret; } - ret =request_irq (st->us->irq, - ade7758_data_rdy_trig_poll, -IRQF_TRIGGER_LOW , -spi_get_device_id (st->us)->name, - st->trig); + ret =devm_request_irq (&indio_dev->dev, st->us->irq, + ade7758_data_rdy_trig_poll, +IRQF_TRIGGER_LOW , +spi_get_device_id (st->us)->name, + st->trig);if (ret) - goto error_free_trig; + goto error_ret st->trig->dev.parent = &st->us->dev; st->trig->ops = &ade7758_trigger_ops;@@ -87,14 +87,10 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)/* select default trigger */ indio_dev->trig =iio_trigger_get (st->trig);if (ret) - goto error_free_irq; + goto error_ret;return 0 ; -error_free_irq: -free_irq (st->us->irq, st->trig); -error_free_trig: -iio_trigger_free (st->trig); error_ret:return ret; }@@ -104,6 +100,4 @@ void ade7758_remove_trigger(struct iio_dev *indio_dev)struct ade7758_state *st =iio_priv (indio_dev);iio_trigger_unregister (st->trig); -free_irq (st->us->irq, st->trig); -iio_trigger_free (st->trig); }Signature · 8 lines
2.1.4 -- 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/1443902531-20190-1-git-send-email-shraddha.6596%40gmail.com. For more options, visit https://groups.google.com/d/optout.