summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorJonathan Cameron <jic23@cam.ac.uk>2010-09-21 14:40:47 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2010-09-21 10:34:39 -0700
commit6a36e618b4b98dc43e67b03cd01ad7a3c41a06e5 (patch)
tree5d8d300641a59b4c2924b87046e5003a62bce0de /drivers/staging
parentcf2b448852abd47cee21007b8313fbf962bf3c9a (diff)
staging: iio: lis3l02dq add _type attributes for all scan elements
Also, adds a macro to make defining such attributes simple. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/iio/accel/lis3l02dq_ring.c4
-rw-r--r--drivers/staging/iio/ring_generic.h11
2 files changed, 14 insertions, 1 deletions
diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
index f26c0fe44129..28a54f188d6e 100644
--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
@@ -84,13 +84,17 @@ static IIO_SCAN_EL_C(accel_y, 1, IIO_SIGNED(16),
static IIO_SCAN_EL_C(accel_z, 2, IIO_SIGNED(16),
LIS3L02DQ_REG_OUT_Z_L_ADDR,
&lis3l02dq_scan_el_set_state);
+static IIO_CONST_ATTR_SCAN_EL_TYPE(accel, s, 12, 16);
static IIO_SCAN_EL_TIMESTAMP(3);
+static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
static struct attribute *lis3l02dq_scan_el_attrs[] = {
&iio_scan_el_accel_x.dev_attr.attr,
&iio_scan_el_accel_y.dev_attr.attr,
&iio_scan_el_accel_z.dev_attr.attr,
+ &iio_const_attr_accel_type.dev_attr.attr,
&iio_scan_el_timestamp.dev_attr.attr,
+ &iio_const_attr_timestamp_type.dev_attr.attr,
NULL,
};
diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h
index 7b29cd5a91d2..692b967eee74 100644
--- a/drivers/staging/iio/ring_generic.h
+++ b/drivers/staging/iio/ring_generic.h
@@ -247,7 +247,7 @@ ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr,
.bit_count = _bits, \
.label = _label, \
.set_state = _controlfunc, \
- }
+ }
#define IIO_SCAN_EL_C(_name, _number, _bits, _label, _controlfunc) \
__IIO_SCAN_EL_C(_name, _number, _bits, _label, _controlfunc)
@@ -279,6 +279,15 @@ ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr,
iio_scan_el_ts_store), \
}
+/**
+ * IIO_CONST_ATTR_SCAN_EL_TYPE - attr to specify the data format of a scan el
+ * @name: the scan el name (may be more general and cover a set of scan elements
+ * @_sign: either s or u for signed or unsigned
+ * @_bits: number of actual bits occuplied by the value
+ * @_storagebits: number of bits _bits is padded to when read out of buffer
+ **/
+#define IIO_CONST_ATTR_SCAN_EL_TYPE(_name, _sign, _bits, _storagebits) \
+ IIO_CONST_ATTR(_name##_type, #_sign#_bits"/"#_storagebits);
/*
* These are mainly provided to allow for a change of implementation if a device
* has a large number of scan elements