iio: refactor info mask and ext_info attribute creation.

Introduce an enum to specify whether the attribute is separate or
shared.

Factor out the bitmap handling for loop into a separate function.

Tidy up error handling and add a NULL assignment to squish a false
positive warning from GCC.

Change ext_info shared type from boolean to enum and update in all
drivers.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Jonathan Cameron
2013-09-08 14:57:00 +01:00
parent 9761696f2b
commit 3704432fb1
15 changed files with 116 additions and 86 deletions

View File

@@ -39,6 +39,11 @@ enum iio_chan_info_enum {
IIO_CHAN_INFO_INT_TIME,
};
enum iio_shared_by {
IIO_SEPARATE,
IIO_SHARED_BY_TYPE
};
enum iio_endian {
IIO_CPU,
IIO_BE,
@@ -58,7 +63,7 @@ struct iio_dev;
*/
struct iio_chan_spec_ext_info {
const char *name;
bool shared;
enum iio_shared_by shared;
ssize_t (*read)(struct iio_dev *, uintptr_t private,
struct iio_chan_spec const *, char *buf);
ssize_t (*write)(struct iio_dev *, uintptr_t private,
@@ -126,7 +131,7 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
#define IIO_ENUM_AVAILABLE(_name, _e) \
{ \
.name = (_name "_available"), \
.shared = true, \
.shared = IIO_SHARED_BY_TYPE, \
.read = iio_enum_available_read, \
.private = (uintptr_t)(_e), \
}