diff options
author | Michael Hennerich <michael.hennerich@analog.com> | 2011-05-18 09:42:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-05-19 19:14:58 -0400 |
commit | 69c272cc8edf3e5432859a9c1bcb51a64b2accb5 (patch) | |
tree | 794f8906d00d701a027b539354338d0b647dfefa /drivers | |
parent | faf290e867fd51e227165d0bef113b022520a58f (diff) |
staging:iio:meter:ade7758: Update trigger to the new API
Update trigger to the new API.
Add file comment/license header.
Some backporting needed to keep the driver building all the way
through the core changes.
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/iio/meter/ade7758_trigger.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/drivers/staging/iio/meter/ade7758_trigger.c b/drivers/staging/iio/meter/ade7758_trigger.c index 0adfcc639f21..06c921db9169 100644 --- a/drivers/staging/iio/meter/ade7758_trigger.c +++ b/drivers/staging/iio/meter/ade7758_trigger.c | |||
@@ -1,3 +1,11 @@ | |||
1 | /* | ||
2 | * ADE7758 Poly Phase Multifunction Energy Metering IC driver | ||
3 | * | ||
4 | * Copyright 2010-2011 Analog Devices Inc. | ||
5 | * | ||
6 | * Licensed under the GPL-2. | ||
7 | */ | ||
8 | |||
1 | #include <linux/interrupt.h> | 9 | #include <linux/interrupt.h> |
2 | #include <linux/irq.h> | 10 | #include <linux/irq.h> |
3 | #include <linux/mutex.h> | 11 | #include <linux/mutex.h> |
@@ -19,20 +27,10 @@ static irqreturn_t ade7758_data_rdy_trig_poll(int irq, void *private) | |||
19 | { | 27 | { |
20 | disable_irq_nosync(irq); | 28 | disable_irq_nosync(irq); |
21 | iio_trigger_poll(private, iio_get_time_ns()); | 29 | iio_trigger_poll(private, iio_get_time_ns()); |
30 | |||
22 | return IRQ_HANDLED; | 31 | return IRQ_HANDLED; |
23 | } | 32 | } |
24 | 33 | ||
25 | static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL); | ||
26 | |||
27 | static struct attribute *ade7758_trigger_attrs[] = { | ||
28 | &dev_attr_name.attr, | ||
29 | NULL, | ||
30 | }; | ||
31 | |||
32 | static const struct attribute_group ade7758_trigger_attr_group = { | ||
33 | .attrs = ade7758_trigger_attrs, | ||
34 | }; | ||
35 | |||
36 | /** | 34 | /** |
37 | * ade7758_data_rdy_trigger_set_state() set datardy interrupt state | 35 | * ade7758_data_rdy_trigger_set_state() set datardy interrupt state |
38 | **/ | 36 | **/ |
@@ -53,6 +51,7 @@ static int ade7758_data_rdy_trigger_set_state(struct iio_trigger *trig, | |||
53 | static int ade7758_trig_try_reen(struct iio_trigger *trig) | 51 | static int ade7758_trig_try_reen(struct iio_trigger *trig) |
54 | { | 52 | { |
55 | struct ade7758_state *st = trig->private_data; | 53 | struct ade7758_state *st = trig->private_data; |
54 | |||
56 | enable_irq(st->us->irq); | 55 | enable_irq(st->us->irq); |
57 | /* irq reenabled so success! */ | 56 | /* irq reenabled so success! */ |
58 | return 0; | 57 | return 0; |
@@ -62,48 +61,51 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev) | |||
62 | { | 61 | { |
63 | int ret; | 62 | int ret; |
64 | struct ade7758_state *st = indio_dev->dev_data; | 63 | struct ade7758_state *st = indio_dev->dev_data; |
64 | char *name; | ||
65 | 65 | ||
66 | name = kasprintf(GFP_KERNEL, | ||
67 | "%s-dev%d", | ||
68 | spi_get_device_id(st->us)->name, | ||
69 | indio_dev->id); | ||
70 | if (name == NULL) { | ||
71 | ret = -ENOMEM; | ||
72 | goto error_ret; | ||
73 | } | ||
66 | 74 | ||
67 | st->trig = iio_allocate_trigger(); | 75 | st->trig = iio_allocate_trigger_named(name); |
68 | if (st->trig == NULL) { | 76 | if (st->trig == NULL) { |
69 | ret = -ENOMEM; | 77 | ret = -ENOMEM; |
70 | goto error_ret; | 78 | goto error_free_name; |
71 | } | 79 | } |
80 | |||
72 | ret = request_irq(st->us->irq, | 81 | ret = request_irq(st->us->irq, |
73 | ade7758_data_rdy_trig_poll, | 82 | ade7758_data_rdy_trig_poll, |
74 | IRQF_TRIGGER_FALLING, "ade7758", | 83 | IRQF_TRIGGER_LOW, |
84 | spi_get_device_id(st->us)->name, | ||
75 | st->trig); | 85 | st->trig); |
76 | if (ret) | 86 | if (ret) |
77 | goto error_free_trig; | 87 | goto error_free_trig; |
78 | 88 | ||
79 | st->trig->name = kasprintf(GFP_KERNEL, | ||
80 | "ade7758-dev%d", | ||
81 | indio_dev->id); | ||
82 | if (!st->trig->name) { | ||
83 | ret = -ENOMEM; | ||
84 | goto error_free_irq; | ||
85 | } | ||
86 | st->trig->dev.parent = &st->us->dev; | 89 | st->trig->dev.parent = &st->us->dev; |
87 | st->trig->owner = THIS_MODULE; | 90 | st->trig->owner = THIS_MODULE; |
88 | st->trig->private_data = st; | 91 | st->trig->private_data = st; |
89 | st->trig->set_trigger_state = &ade7758_data_rdy_trigger_set_state; | 92 | st->trig->set_trigger_state = &ade7758_data_rdy_trigger_set_state; |
90 | st->trig->try_reenable = &ade7758_trig_try_reen; | 93 | st->trig->try_reenable = &ade7758_trig_try_reen; |
91 | st->trig->control_attrs = &ade7758_trigger_attr_group; | ||
92 | ret = iio_trigger_register(st->trig); | 94 | ret = iio_trigger_register(st->trig); |
93 | 95 | ||
94 | /* select default trigger */ | 96 | /* select default trigger */ |
95 | indio_dev->trig = st->trig; | 97 | indio_dev->trig = st->trig; |
96 | if (ret) | 98 | if (ret) |
97 | goto error_free_trig_name; | 99 | goto error_free_irq; |
98 | 100 | ||
99 | return 0; | 101 | return 0; |
100 | 102 | ||
101 | error_free_trig_name: | ||
102 | kfree(st->trig->name); | ||
103 | error_free_irq: | 103 | error_free_irq: |
104 | free_irq(st->us->irq, st->trig); | 104 | free_irq(st->us->irq, st->trig); |
105 | error_free_trig: | 105 | error_free_trig: |
106 | iio_free_trigger(st->trig); | 106 | iio_free_trigger(st->trig); |
107 | error_free_name: | ||
108 | kfree(name); | ||
107 | error_ret: | 109 | error_ret: |
108 | return ret; | 110 | return ret; |
109 | } | 111 | } |