Skip to contentSkip to conversation

Staging: iio: meter: Use devm_iio_trigger_alloc

PATCH Superseded Shraddha Barke 2 participants 4 messages Oct 3, 2015

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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
index 5b35a7f..d5a324a 100644
@@ -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
#1 lore raw
Quoted 4 lines · Shraddha Barke

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.

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

---
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 -8
index 5b35a7f..d5a324a 100644
@@ -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.

#2 lore raw
Quoted 7 lines · Julia Lawall
Quoted 4 lines · Shraddha Barke

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.

Quoted 5 lines

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

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

---
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 -8
index 5b35a7f..d5a324a 100644
@@ -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.

#3 lore raw
Quoted 11 lines · Shraddha Barke
Quoted 7 lines · Julia Lawall
Quoted 4 lines · Shraddha Barke

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.

Quoted 8 lines
Quoted 5 lines

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

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

---
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 -8
index 5b35a7f..d5a324a 100644
@@ -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.