Staging: iio: meter: Use devm_iio_trigger_alloc
Subsystems (4)
PATCH 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.
--- drivers/staging/iio/meter/ade7758_trigger.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/staging/iio/meter/ade7758_trigger.c +4 -7
@@ -63,9 +63,9 @@ 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 ("%s-dev%d" , +spi_get_device_id (st->us)->name, + indio_dev->id);if (!st->trig) { ret = -ENOMEM ; goto error_ret;
@@ -77,7 +77,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 +93,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 +103,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 15 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.Signed-off-by Shraddha Barke <[email protected]>--- drivers/staging/iio/meter/ade7758_trigger.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/staging/iio/meter/ade7758_trigger.c +0
-0
drivers/staging/iio/meter/ade7758_trigger.c int ade7758_probe_trigger(struct iio_dev *indio_dev) · line 68
Quoted 9 lines
drivers/staging/iio/meter/ade7758_trigger.c +3
-3@@ -63,9 +63,9 @@ 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 ("%s-dev%d" , +spi_get_device_id (st->us)->name, + indio_dev->id);
This should not compile.
julia
Quoted 37 lines
drivers/staging/iio/meter/ade7758_trigger.c +1
-5if (!st->trig) { ret = -ENOMEM ; goto error_ret;@@ -77,7 +77,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 +93,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 +103,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/1443890125-2419-1-git-send-email-shraddha.6596%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 15 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.Signed-off-by Shraddha Barke <[email protected]>--- drivers/staging/iio/meter/ade7758_trigger.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/staging/iio/meter/ade7758_trigger.c +0
-0
drivers/staging/iio/meter/ade7758_trigger.c int ade7758_probe_trigger(struct iio_dev *indio_dev) · line 68
Quoted 9 lines
drivers/staging/iio/meter/ade7758_trigger.c +3
-3@@ -63,9 +63,9 @@ 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 ("%s-dev%d" , +spi_get_device_id (st->us)->name, + indio_dev->id);
Function devm_iio_trigger_alloc requires something more. Please read both of the definitions carefully. And actually compiler should have warned you about the same.
drivers/staging/iio/meter/ade7758_trigger.c int ade7758_probe_trigger(struct iio_dev *indio_dev) · line 80
Quoted 9 lines
drivers/staging/iio/meter/ade7758_trigger.c +1
-1if (!st->trig) { ret = -ENOMEM ; goto error_ret;@@ -77,7 +77,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;
Also, you can use direct return here.
Quoted 26 lines
drivers/staging/iio/meter/ade7758_trigger.c +0
-4st->trig->dev.parent = &st->us->dev; st->trig->ops = &ade7758_trigger_ops;@@ -93,8 +93,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 +103,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/1443890125-2419-1-git-send-email-shraddha.6596%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Signature · 1 line
Vaishali
Quoted 30 lines · Vaishali Thakkar
Quoted 15 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.Signed-off-by Shraddha Barke <[email protected]>--- drivers/staging/iio/meter/ade7758_trigger.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/staging/iio/meter/ade7758_trigger.c +0
-0drivers/staging/iio/meter/ade7758_trigger.c int ade7758_probe_trigger(struct iio_dev *indio_dev) · line 68
Quoted 9 lines
drivers/staging/iio/meter/ade7758_trigger.c +3
-3@@ -63,9 +63,9 @@ 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 ("%s-dev%d" , +spi_get_device_id (st->us)->name, + indio_dev->id);Function
devm_iio_trigger_allocrequires something more. Please read both of the definitions carefully. And actually compiler should have warned you about the same.
Quoted 11 lines
drivers/staging/iio/meter/ade7758_trigger.c int ade7758_probe_trigger(struct iio_dev *indio_dev) · line 80
Quoted 9 lines
drivers/staging/iio/meter/ade7758_trigger.c +1
-1if (!st->trig) { ret = -ENOMEM ; goto error_ret;@@ -77,7 +77,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;Also, you can use direct return here.
Maybe since the original developer thought that it was nice to have a label for the trivial return, it is better to respct that.
julia
Quoted 39 lines
Quoted 20 lines
drivers/staging/iio/meter/ade7758_trigger.c +0
-4st->trig->dev.parent = &st->us->dev; st->trig->ops = &ade7758_trigger_ops;@@ -93,8 +93,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 +103,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
Quoted 6 lines
--
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/1443890125-2419-1-git-send-email-shraddha.6596%40gmail.com.
For more options, visit https://groups.google.com/d/optout.--
Vaishali--
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/CAK-LDbK2_tQvK62Yo9UY2X4woXckA8tAC3Cf5A8bTxcGLsnCUw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.