iio: industrialio-core: Add IIO_OUT type
authorMichael Hennerich <michael.hennerich@analog.com>
Fri, 10 Jun 2011 13:40:48 +0000 (15:40 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 28 Jun 2011 21:47:25 +0000 (14:47 -0700)
Add IIO_OUT type for DAC like devices
In case of IIO_OUT make sure the channel device attribute is writable

Ideally we add a flag to iio_chan_spec that tells the core that
the channel device attribute is writable...

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 9ca89c7d56930522b871d2b34bd00dc12013f7aa..7a6ce4d0fb7bde721c278f7be59de58ec2693d87 100644 (file)
@@ -30,6 +30,7 @@
 enum iio_chan_type {
        /* real channel types */
        IIO_IN,
+       IIO_OUT,
        IIO_CURRENT,
        IIO_POWER,
        IIO_ACCEL,
index 744153ee2edbe7d8c3852254ff5fb9446355bdd1..8fa2be6f566fec5fbab1e445c07e75304a56fe6c 100644 (file)
@@ -47,6 +47,7 @@ static const char * const iio_chan_type_name_spec_shared[] = {
        [IIO_TIMESTAMP] = "timestamp",
        [IIO_ACCEL] = "accel",
        [IIO_IN] = "in",
+       [IIO_OUT] = "out",
        [IIO_CURRENT] = "current",
        [IIO_POWER] = "power",
        [IIO_IN_DIFF] = "in-in",
@@ -675,7 +676,8 @@ static int iio_device_add_channel_sysfs(struct iio_dev *dev_info,
        else
                ret = __iio_add_chan_devattr("raw", NULL, chan,
                                             &iio_read_channel_info,
-                                            NULL,
+                                            (chan->type == IIO_OUT ?
+                                            &iio_write_channel_info : NULL),
                                             0,
                                             0,
                                             &dev_info->dev,