staging:iio: trigger fixes for repeat request of same trigger and allocation failure
authorJonathan Cameron <jic23@cam.ac.uk>
Wed, 26 Oct 2011 16:27:41 +0000 (17:27 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 27 Nov 2011 00:30:30 +0000 (16:30 -0800)
Both of these are decidedly silly bugs show up whilst testing
completely different code paths.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/iio/industrialio-trigger.c

index 9412013e74592c01335f4fdbeee6919e912517a7..20dc8e87d1cd7a30b8fdb4f51830d02b99cac6bd 100644 (file)
@@ -220,8 +220,16 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig,
        ret = request_threaded_irq(pf->irq, pf->h, pf->thread,
                                   pf->type, pf->name,
                                   pf);
-       if (trig->ops && trig->ops->set_trigger_state && notinuse)
+       if (ret < 0) {
+               module_put(pf->indio_dev->info->driver_module);
+               return ret;
+       }
+
+       if (trig->ops && trig->ops->set_trigger_state && notinuse) {
                ret = trig->ops->set_trigger_state(trig, true);
+               if (ret < 0)
+                       module_put(pf->indio_dev->info->driver_module);
+       }
 
        return ret;
 }
@@ -334,6 +342,8 @@ static ssize_t iio_trigger_write_current(struct device *dev,
        mutex_unlock(&indio_dev->mlock);
 
        trig = iio_trigger_find_by_name(buf, len);
+       if (oldtrig == trig)
+               return len;
 
        if (trig && indio_dev->info->validate_trigger) {
                ret = indio_dev->info->validate_trigger(indio_dev, trig);