diff options
Diffstat (limited to 'drivers/staging/iio/ring_generic.h')
-rw-r--r-- | drivers/staging/iio/ring_generic.h | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h index 09044adf7327..0e443757b029 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/ring_generic.h @@ -134,19 +134,17 @@ void iio_ring_buffer_init(struct iio_ring_buffer *ring, struct iio_dev *dev_info); /** - * __iio_init_ring_buffer() - initialize common elements of ring buffers + * __iio_update_ring_buffer() - update common elements of ring buffers * @ring: ring buffer that is the event source * @bytes_per_datum: size of individual datum including timestamp * @length: number of datums in ring **/ -static inline void __iio_init_ring_buffer(struct iio_ring_buffer *ring, - int bytes_per_datum, int length) +static inline void __iio_update_ring_buffer(struct iio_ring_buffer *ring, + int bytes_per_datum, int length) { ring->bpd = bytes_per_datum; ring->length = length; ring->loopcount = 0; - ring->shared_ev_pointer.ev_p = 0; - spin_lock_init(&ring->shared_ev_pointer.lock); } /** @@ -198,25 +196,6 @@ ssize_t iio_scan_el_store(struct device *dev, struct device_attribute *attr, **/ ssize_t iio_scan_el_show(struct device *dev, struct device_attribute *attr, char *buf); -/** - * IIO_SCAN_EL - declare and initialize a scan element without control func - * @_name: identifying name. Resulting struct is iio_scan_el_##_name, - * sysfs element, scan_en_##_name. - * @_number: unique id number for the scan element. - * @_bits: number of bits in the scan element result (used in mixed bit - * length devices). - * @_label: indentification variable used by drivers. Often a reg address. - **/ -#define IIO_SCAN_EL(_name, _number, _bits, _label) \ - struct iio_scan_el iio_scan_el_##_name = { \ - .dev_attr = __ATTR(scan_en_##_name, \ - S_IRUGO | S_IWUSR, \ - iio_scan_el_show, \ - iio_scan_el_store), \ - .mask = (1 << _number), \ - .bit_count = _bits, \ - .label = _label, \ - } ssize_t iio_scan_el_ts_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len); @@ -227,7 +206,7 @@ ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr, * IIO_SCAN_EL_C - declare and initialize a scan element with a control func * * @_name: identifying name. Resulting struct is iio_scan_el_##_name, - * sysfs element, scan_en_##_name. + * sysfs element, _name##_en. * @_number: unique id number for the scan element. * @_bits: number of bits in the scan element result (used in mixed bit * length devices). @@ -236,7 +215,7 @@ ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr, **/ #define IIO_SCAN_EL_C(_name, _number, _bits, _label, _controlfunc) \ struct iio_scan_el iio_scan_el_##_name = { \ - .dev_attr = __ATTR(scan_en_##_name, \ + .dev_attr = __ATTR(_number##_##_name##_en, \ S_IRUGO | S_IWUSR, \ iio_scan_el_show, \ iio_scan_el_store), \ @@ -245,14 +224,27 @@ ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr, .label = _label, \ .set_state = _controlfunc, \ } + +#define IIO_SCAN_NAMED_EL_C(_name, _string, _number, _bits, _label, _cf) \ + struct iio_scan_el iio_scan_el_##_name = { \ + .dev_attr = __ATTR(_number##_##_string##_en, \ + S_IRUGO | S_IWUSR, \ + iio_scan_el_show, \ + iio_scan_el_store), \ + .number = _number, \ + .bit_count = _bits, \ + .label = _label, \ + .set_state = _cf, \ + } + /** * IIO_SCAN_EL_TIMESTAMP - declare a special scan element for timestamps * * Odd one out. Handled slightly differently from other scan elements. **/ -#define IIO_SCAN_EL_TIMESTAMP \ +#define IIO_SCAN_EL_TIMESTAMP(number) \ struct iio_scan_el iio_scan_el_timestamp = { \ - .dev_attr = __ATTR(scan_en_timestamp, \ + .dev_attr = __ATTR(number##_timestamp_en, \ S_IRUGO | S_IWUSR, \ iio_scan_el_ts_show, \ iio_scan_el_ts_store), \ @@ -267,7 +259,7 @@ static inline void iio_put_ring_buffer(struct iio_ring_buffer *ring) container_of(d, struct iio_ring_buffer, dev) #define access_dev_to_iio_ring_buffer(d) \ container_of(d, struct iio_ring_buffer, access_dev) -int iio_ring_buffer_register(struct iio_ring_buffer *ring); +int iio_ring_buffer_register(struct iio_ring_buffer *ring, int id); void iio_ring_buffer_unregister(struct iio_ring_buffer *ring); ssize_t iio_read_ring_length(struct device *dev, |