All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: iio: trigger: Use devm functions
@ 2016-09-18 21:16 Bhumika Goyal
  2016-09-19  5:44 ` [Outreachy kernel] " Alison Schofield
  0 siblings, 1 reply; 6+ messages in thread
From: Bhumika Goyal @ 2016-09-18 21:16 UTC (permalink / raw)
  To: outreachy-kernel, jic23, knaack.h, lars, pmeerw, gregkh; +Cc: Bhumika Goyal

Use managed resource functions devm_iio_trigger_alloc and
devm_request_irq instead of iio_trigger_alloc and request_irq.
Remove corresponding calls to free_irq in the probe and remove
functions. Drop the now unnecessary goto labels and replace various
gotos with direct returns.
request_irq replacement done using coccinelle.

@platform@
identifier p, probefn, removefn;
@@
struct platform_driver p = {
  .probe = probefn,
  .remove = removefn,
};

@prb@
identifier platform.probefn, pdev;
expression list E;
expression e;

@@
probefn(struct platform_device *pdev, ...) {
  <+...
- e = request_irq(E);
+ e = devm_request_irq(&pdev->dev,E);
  ...
?-free_irq(...);
  ...+>
}

@rem depends on prb@
identifier platform.removefn;
expression e;
@@
removefn(...) {
  <...
- free_irq(...);
  ...>
}

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
 drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
index 38dca69..ea4845c 100644
--- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
+++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
@@ -200,7 +200,8 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
 	st->timer_num = ret;
 	st->t = &iio_bfin_timer_code[st->timer_num];
 
-	st->trig = iio_trigger_alloc("bfintmr%d", st->timer_num);
+	st->trig = devm_iio_trigger_alloc(&pdev->dev, "bfintmr%d",
+                                          st->timer_num);
 	if (!st->trig)
 		return -ENOMEM;
 
@@ -211,8 +212,8 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
 	if (ret)
 		goto out;
 
-	ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr,
-			  0, st->trig->name, st);
+	ret = devm_request_irq(&pdev->dev, st->irq, iio_bfin_tmr_trigger_isr,
+			       0, st->trig->name, st);
 	if (ret) {
 		dev_err(&pdev->dev,
 			"request IRQ-%d failed", st->irq);
@@ -229,7 +230,7 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
 
 		ret = peripheral_request(st->t->pin, st->trig->name);
 		if (ret)
-			goto out_free_irq;
+			return ret;
 
 		val = (unsigned long long)get_sclk() * pdata->duty_ns;
 		do_div(val, NSEC_PER_SEC);
@@ -255,8 +256,7 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, st);
 
 	return 0;
-out_free_irq:
-	free_irq(st->irq, st);
+
 out1:
 	iio_trigger_unregister(st->trig);
 out:
@@ -271,7 +271,6 @@ static int iio_bfin_tmr_trigger_remove(struct platform_device *pdev)
 	disable_gptimers(st->t->bit);
 	if (st->output_enable)
 		peripheral_free(st->t->pin);
-	free_irq(st->irq, st);
 	iio_trigger_unregister(st->trig);
 	iio_trigger_put(st->trig);
 
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-10-15  8:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-18 21:16 [PATCH] Staging: iio: trigger: Use devm functions Bhumika Goyal
2016-09-19  5:44 ` [Outreachy kernel] " Alison Schofield
2016-09-19  5:53   ` Bhumika Goyal
2016-09-19  9:21     ` Julia Lawall
     [not found]       ` <fc36bfeb-abae-f8ad-aca0-161cd6743137@kernel.org>
     [not found]         ` <b02b84c9-0575-d10d-6b43-d95d167a2429@metafoo.de>
2016-10-14 19:27           ` Alison Schofield
2016-10-15  8:12             ` Bhumika Goyal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.