]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
staging:iio:meter:ade7758: Update trigger to the new API
authorMichael Hennerich <michael.hennerich@analog.com>
Wed, 18 May 2011 13:42:03 +0000 (14:42 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 19 May 2011 23:14:58 +0000 (16:14 -0700)
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>
drivers/staging/iio/meter/ade7758_trigger.c

index 0adfcc639f2158f1888ecbf250cfe34c7923be31..06c921db91691aa692372c31d4d6301f95af8bda 100644 (file)
@@ -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;
 }