Staging: iio: meter: Use devm_iio_trigger_alloc
Subsystems (4)
PATCH v2 1/1 Staging: iio: meter: Use devm_iio_trigger_alloc
Introduce use of managed resource function devm_iio_trigger_alloc instead of iio_trigger_alloc and remove corresponding calls to iio_trigger_free in the probe and remove functions. Also unnecessary label error_free_trig is dropped.
---
Changes in v2-
Use appropriate arguments in devm_iio_trigger_alloc.
drivers/staging/iio/meter/ade7758_trigger.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/staging/iio/meter/ade7758_trigger.c +5 -7
@@ -63,9 +63,10 @@ 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->dev, +"%s-dev%d" , +spi_get_device_id (st->us)->name, + indio_dev->id);if (!st->trig) { ret = -ENOMEM ; goto error_ret;
@@ -77,7 +78,7 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)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;
@@ -93,8 +94,6 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev) error_free_irq:free_irq (st->us->irq, st->trig); -error_free_trig: -iio_trigger_free (st->trig); error_ret:return ret; }
@@ -105,5 +104,4 @@ void ade7758_remove_trigger(struct iio_dev *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 4 lines · Shraddha Barke
Introduce use of managed resource function
devm_iio_trigger_allocinstead ofiio_trigger_allocand remove corresponding calls toiio_trigger_freein the probe and remove functions. Also unnecessary labelerror_free_trigis dropped.
How about doing the request_irq as well?
You have a nice example here:
http://lxr.free-electrons.com/source/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c#L119
Unfortunately, there doesn't seem to be a devm function for the unregister...
julia
Quoted 61 lines
Signed-off-by Shraddha Barke <[email protected]>---
Changes in v2-
Use appropriate arguments indevm_iio_trigger_alloc.drivers/staging/iio/meter/ade7758_trigger.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)drivers/staging/iio/meter/ade7758_trigger.c +5
-8@@ -63,9 +63,10 @@ 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->dev, +"%s-dev%d" , +spi_get_device_id (st->us)->name, + indio_dev->id);if (!st->trig) { ret = -ENOMEM ; goto error_ret;@@ -77,7 +78,7 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)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;@@ -93,8 +94,6 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev) error_free_irq:free_irq (st->us->irq, st->trig); -error_free_trig: -iio_trigger_free (st->trig); error_ret:return ret; }@@ -105,5 +104,4 @@ void ade7758_remove_trigger(struct iio_dev *indio_dev)iio_trigger_unregister (st->trig);free_irq (st->us->irq, st->trig); -iio_trigger_free (st->trig); } --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/1443892556-9121-1-git-send-email-shraddha.6596%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 7 lines · Julia Lawall
Quoted 4 lines · Shraddha Barke
Introduce use of managed resource function
devm_iio_trigger_allocinstead ofiio_trigger_allocand remove corresponding calls toiio_trigger_freein the probe and remove functions. Also unnecessary labelerror_free_trigis dropped.
Quoted 5 lines
How about doing the
request_irqas well?You have a nice example here:
http://lxr.free-electrons.com/source/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c#L119
Alright. Should I send a v3 with this change or a separate patch or patch series?
Shraddha
Quoted 68 lines
Unfortunately, there doesn't seem to be a devm function for the unregister...
julia
Quoted 61 lines
Signed-off-by Shraddha Barke <[email protected]>---
Changes in v2-
Use appropriate arguments indevm_iio_trigger_alloc.drivers/staging/iio/meter/ade7758_trigger.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)drivers/staging/iio/meter/ade7758_trigger.c +5
-8@@ -63,9 +63,10 @@ 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->dev, +"%s-dev%d" , +spi_get_device_id (st->us)->name, + indio_dev->id);if (!st->trig) { ret = -ENOMEM ; goto error_ret;@@ -77,7 +78,7 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)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;@@ -93,8 +94,6 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev) error_free_irq:free_irq (st->us->irq, st->trig); -error_free_trig: -iio_trigger_free (st->trig); error_ret:return ret; }@@ -105,5 +104,4 @@ void ade7758_remove_trigger(struct iio_dev *indio_dev)iio_trigger_unregister (st->trig);free_irq (st->us->irq, st->trig); -iio_trigger_free (st->trig); } --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/1443892556-9121-1-git-send-email-shraddha.6596%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 11 lines · Shraddha Barke
Quoted 7 lines · Julia Lawall
Quoted 4 lines · Shraddha Barke
Introduce use of managed resource function
devm_iio_trigger_allocinstead ofiio_trigger_allocand remove corresponding calls toiio_trigger_freein the probe and remove functions. Also unnecessary labelerror_free_trigis dropped.
Quoted 8 lines
Quoted 5 lines
How about doing the
request_irqas well?You have a nice example here:
http://lxr.free-electrons.com/source/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c#L119
Alright. Should I send a v3 with this change or a separate patch or patch series?
I would put it in v3. The common thing is to devmify as much of a function as possible all at once.
julia
Quoted 74 lines
Shraddha
Quoted 72 lines
Unfortunately, there doesn't seem to be a devm function for the unregister...
julia
Quoted 65 lines
Signed-off-by Shraddha Barke <[email protected]>---
Changes in v2-
Use appropriate arguments indevm_iio_trigger_alloc.drivers/staging/iio/meter/ade7758_trigger.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)drivers/staging/iio/meter/ade7758_trigger.c +5
-8@@ -63,9 +63,10 @@ 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->dev, +"%s-dev%d" , +spi_get_device_id (st->us)->name, + indio_dev->id);if (!st->trig) { ret = -ENOMEM ; goto error_ret;@@ -77,7 +78,7 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)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;@@ -93,8 +94,6 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev) error_free_irq:free_irq (st->us->irq, st->trig); -error_free_trig: -iio_trigger_free (st->trig); error_ret:return ret; }@@ -105,5 +104,4 @@ void ade7758_remove_trigger(struct iio_dev *indio_dev)iio_trigger_unregister (st->trig);free_irq (st->us->irq, st->trig); -iio_trigger_free (st->trig); } --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/1443892556-9121-1-git-send-email-shraddha.6596%40gmail.com.
For more options, visit https://groups.google.com/d/optout.