staging:iio: Make write_event_value callback optional
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 2 Nov 2011 08:40:00 +0000 (09:40 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 27 Nov 2011 00:39:58 +0000 (16:39 -0800)
Some devices have fixed thresholds which can not be modified so make the
write_event_value callback optional, so the drivers for these devices do not
have to implement a boilerplate no-op callback.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/iio/industrialio-core.c

index dc2339ae63d056cde37796fc9108d8696267eb04..0b671663b55d2b9d1c9d07fc566f530f9edbef13 100644 (file)
@@ -790,6 +790,9 @@ static ssize_t iio_ev_value_store(struct device *dev,
        unsigned long val;
        int ret;
 
+       if (!indio_dev->info->write_event_value)
+               return -EINVAL;
+
        ret = strict_strtoul(buf, 10, &val);
        if (ret)
                return ret;