]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
include: linux: iio: add IIO_ATTR_{RO, WO, RW} and IIO_DEVICE_ATTR_{RO, WO, RW} macros
authorBrian Masney <masneyb@onstation.org>
Tue, 27 Sep 2016 00:20:16 +0000 (20:20 -0400)
committerJonathan Cameron <jic23@kernel.org>
Sat, 1 Oct 2016 13:43:59 +0000 (14:43 +0100)
Add new macros: IIO_ATTR_RO, IIO_ATTR_WO, IIO_ATTR_RW,
IIO_DEVICE_ATTR_RO, IIO_DEVICE_ATTR_WO and IIO_DEVICE_ATTR_RW to reduce
the amount of boiler plate code that is needed for creating new
attributes. This mimics the *_RO, *_WO, and *_RW macros that are found
in include/linux/device.h and include/linux/sysfs.h.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
include/linux/iio/sysfs.h

index 9cd8f747212fb75ad0f462d5ad4349fbd3eb94c9..ce9426c507fd1807cd5852055e0d9cff4aa6ef5b 100644 (file)
@@ -55,10 +55,34 @@ struct iio_const_attr {
        { .dev_attr = __ATTR(_name, _mode, _show, _store),      \
          .address = _addr }
 
+#define IIO_ATTR_RO(_name, _addr)       \
+       { .dev_attr = __ATTR_RO(_name), \
+         .address = _addr }
+
+#define IIO_ATTR_WO(_name, _addr)       \
+       { .dev_attr = __ATTR_WO(_name), \
+         .address = _addr }
+
+#define IIO_ATTR_RW(_name, _addr)       \
+       { .dev_attr = __ATTR_RW(_name), \
+         .address = _addr }
+
 #define IIO_DEVICE_ATTR(_name, _mode, _show, _store, _addr)    \
        struct iio_dev_attr iio_dev_attr_##_name                \
        = IIO_ATTR(_name, _mode, _show, _store, _addr)
 
+#define IIO_DEVICE_ATTR_RO(_name, _addr)                       \
+       struct iio_dev_attr iio_dev_attr_##_name                \
+       = IIO_ATTR_RO(_name, _addr)
+
+#define IIO_DEVICE_ATTR_WO(_name, _addr)                       \
+       struct iio_dev_attr iio_dev_attr_##_name                \
+       = IIO_ATTR_WO(_name, _addr)
+
+#define IIO_DEVICE_ATTR_RW(_name, _addr)                                   \
+       struct iio_dev_attr iio_dev_attr_##_name                            \
+       = IIO_ATTR_RW(_name, _addr)
+
 #define IIO_DEVICE_ATTR_NAMED(_vname, _name, _mode, _show, _store, _addr) \
        struct iio_dev_attr iio_dev_attr_##_vname                       \
        = IIO_ATTR(_name, _mode, _show, _store, _addr)