iio: industrialio-core: introduce IIO_VAL_INT_PLUS_NANO
authorMichael Hennerich <michael.hennerich@analog.com>
Mon, 27 Jun 2011 12:07:07 +0000 (13:07 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 28 Jun 2011 21:39:32 +0000 (14:39 -0700)
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/iio/iio.h
drivers/staging/iio/industrialio-core.c

index 38f1425f46459221ade5dd42eae8e6625afd133a..78a0927c9fdfc421ff0e955393b73ffb0b9e9604 100644 (file)
@@ -202,6 +202,7 @@ static inline s64 iio_get_time_ns(void)
  * call to iio_device_register. */
 #define IIO_VAL_INT 1
 #define IIO_VAL_INT_PLUS_MICRO 2
+#define IIO_VAL_INT_PLUS_NANO 3
 
 /**
  * struct iio_info - constant information about device
index 94d3bfaa061d8e3b0ee3002f0d85ce10bfbcda95..e5a7663613a7a66460a62470d694f5abc728780a 100644 (file)
@@ -396,6 +396,11 @@ static ssize_t iio_read_channel_info(struct device *dev,
                        return sprintf(buf, "-%d.%06u\n", val, -val2);
                else
                        return sprintf(buf, "%d.%06u\n", val, val2);
+       } else if (ret == IIO_VAL_INT_PLUS_NANO) {
+               if (val2 < 0)
+                       return sprintf(buf, "-%d.%09u\n", val, -val2);
+               else
+                       return sprintf(buf, "%d.%09u\n", val, val2);
        } else
                return 0;
 }