aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael Hennerich <michael.hennerich@analog.com>2011-05-18 14:42:03 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2011-05-19 16:14:58 -0700
commit69c272cc8edf3e5432859a9c1bcb51a64b2accb5 (patch)
tree794f8906d00d701a027b539354338d0b647dfefa /drivers
parentfaf290e867fd51e227165d0bef113b022520a58f (diff)
downloadkernel_samsung_aries-69c272cc8edf3e5432859a9c1bcb51a64b2accb5.zip
kernel_samsung_aries-69c272cc8edf3e5432859a9c1bcb51a64b2accb5.tar.gz
kernel_samsung_aries-69c272cc8edf3e5432859a9c1bcb51a64b2accb5.tar.bz2
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.c52
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 0adfcc6..06c921d 100644
--- a/drivers/staging/iio/meter/ade7758_trigger.c
+++ b/drivers/staging/iio/meter/ade7758_trigger.c
@@ -1,3 +1,11 @@
+/*
+ * ADE7758 Poly Phase Multifunction Energy Metering IC driver
+ *
+ * Copyright 2010-2011 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
+
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/mutex.h>
@@ -19,20 +27,10 @@ static irqreturn_t ade7758_data_rdy_trig_poll(int irq, void *private)
{
disable_irq_nosync(irq);
iio_trigger_poll(private, iio_get_time_ns());
+
return IRQ_HANDLED;
}
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
-
-static struct attribute *ade7758_trigger_attrs[] = {
- &dev_attr_name.attr,
- NULL,
-};
-
-static const struct attribute_group ade7758_trigger_attr_group = {
- .attrs = ade7758_trigger_attrs,
-};
-
/**
* ade7758_data_rdy_trigger_set_state() set datardy interrupt state
**/
@@ -53,6 +51,7 @@ static int ade7758_data_rdy_trigger_set_state(struct iio_trigger *trig,
static int ade7758_trig_try_reen(struct iio_trigger *trig)
{
struct ade7758_state *st = trig->private_data;
+
enable_irq(st->us->irq);
/* irq reenabled so success! */
return 0;
@@ -62,48 +61,51 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)
{
int ret;
struct ade7758_state *st = indio_dev->dev_data;
+ char *name;
+ name = kasprintf(GFP_KERNEL,
+ "%s-dev%d",
+ spi_get_device_id(st->us)->name,
+ indio_dev->id);
+ if (name == NULL) {
+ ret = -ENOMEM;
+ goto error_ret;
+ }
- st->trig = iio_allocate_trigger();
+ st->trig = iio_allocate_trigger_named(name);
if (st->trig == NULL) {
ret = -ENOMEM;
- goto error_ret;
+ goto error_free_name;
}
+
ret = request_irq(st->us->irq,
ade7758_data_rdy_trig_poll,
- IRQF_TRIGGER_FALLING, "ade7758",
+ IRQF_TRIGGER_LOW,
+ spi_get_device_id(st->us)->name,
st->trig);
if (ret)
goto error_free_trig;
- st->trig->name = kasprintf(GFP_KERNEL,
- "ade7758-dev%d",
- indio_dev->id);
- if (!st->trig->name) {
- ret = -ENOMEM;
- goto error_free_irq;
- }
st->trig->dev.parent = &st->us->dev;
st->trig->owner = THIS_MODULE;
st->trig->private_data = st;
st->trig->set_trigger_state = &ade7758_data_rdy_trigger_set_state;
st->trig->try_reenable = &ade7758_trig_try_reen;
- st->trig->control_attrs = &ade7758_trigger_attr_group;
ret = iio_trigger_register(st->trig);
/* select default trigger */
indio_dev->trig = st->trig;
if (ret)
- goto error_free_trig_name;
+ goto error_free_irq;
return 0;
-error_free_trig_name:
- kfree(st->trig->name);
error_free_irq:
free_irq(st->us->irq, st->trig);
error_free_trig:
iio_free_trigger(st->trig);
+error_free_name:
+ kfree(name);
error_ret:
return ret;
}