Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: buffer: Drop get_length callback

We already do have the length field in the struct iio_buffer which is
expected to be in sync with the current size of the buffer. And currently
all implementations of the get_length callback either return this field or a
constant number.

This patch removes the get_length callback and replaces all occurrences in
the IIO core with directly accessing the length field of the buffer.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Lars-Peter Clausen and committed by
Jonathan Cameron
37495660 8d92db28

+6 -25
+3 -8
drivers/iio/industrialio-buffer.c
··· 390 390 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 391 391 struct iio_buffer *buffer = indio_dev->buffer; 392 392 393 - if (buffer->access->get_length) 394 - return sprintf(buf, "%d\n", 395 - buffer->access->get_length(buffer)); 396 - 397 - return 0; 393 + return sprintf(buf, "%d\n", buffer->length); 398 394 } 399 395 400 396 static ssize_t iio_buffer_write_length(struct device *dev, ··· 406 410 if (ret) 407 411 return ret; 408 412 409 - if (buffer->access->get_length) 410 - if (val == buffer->access->get_length(buffer)) 411 - return len; 413 + if (val == buffer->length) 414 + return len; 412 415 413 416 mutex_lock(&indio_dev->mlock); 414 417 if (iio_buffer_is_active(indio_dev->buffer)) {
-6
drivers/iio/kfifo_buf.c
··· 47 47 return ret; 48 48 } 49 49 50 - static int iio_get_length_kfifo(struct iio_buffer *r) 51 - { 52 - return r->length; 53 - } 54 - 55 50 static int iio_mark_update_needed_kfifo(struct iio_buffer *r) 56 51 { 57 52 struct iio_kfifo *kf = iio_to_kfifo(r); ··· 136 141 .data_available = iio_kfifo_buf_data_available, 137 142 .request_update = &iio_request_update_kfifo, 138 143 .set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo, 139 - .get_length = &iio_get_length_kfifo, 140 144 .set_length = &iio_set_length_kfifo, 141 145 .release = &iio_kfifo_buffer_release, 142 146 };
+2 -2
drivers/staging/iio/Documentation/ring.txt
··· 42 42 set_bytes_per_datum 43 43 Set the number of bytes for a complete scan. (All samples + timestamp) 44 44 45 - get_length / set_length 46 - Get/set the number of complete scans that may be held by the buffer. 45 + set_length 46 + Set the number of complete scans that may be held by the buffer. 47 47
+1 -7
drivers/staging/iio/accel/sca3000_ring.c
··· 129 129 return ret ? ret : num_read; 130 130 } 131 131 132 - /* This is only valid with all 3 elements enabled */ 133 - static int sca3000_ring_get_length(struct iio_buffer *r) 134 - { 135 - return 64; 136 - } 137 - 138 132 static bool sca3000_ring_buf_data_available(struct iio_buffer *r) 139 133 { 140 134 return r->stufftoread; ··· 242 248 ring->private = indio_dev; 243 249 buf = &ring->buf; 244 250 buf->stufftoread = 0; 251 + buf->length = 64; 245 252 buf->attrs = sca3000_ring_attributes; 246 253 iio_buffer_init(buf); 247 254 ··· 256 261 257 262 static const struct iio_buffer_access_funcs sca3000_ring_access_funcs = { 258 263 .read_first_n = &sca3000_read_first_n_hw_rb, 259 - .get_length = &sca3000_ring_get_length, 260 264 .data_available = sca3000_ring_buf_data_available, 261 265 .release = sca3000_ring_release, 262 266 };
-2
include/linux/iio/buffer.h
··· 26 26 * @request_update: if a parameter change has been marked, update underlying 27 27 * storage. 28 28 * @set_bytes_per_datum:set number of bytes per datum 29 - * @get_length: get number of datums in buffer 30 29 * @set_length: set number of datums in buffer 31 30 * @release: called when the last reference to the buffer is dropped, 32 31 * should free all resources allocated by the buffer. ··· 48 49 int (*request_update)(struct iio_buffer *buffer); 49 50 50 51 int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd); 51 - int (*get_length)(struct iio_buffer *buffer); 52 52 int (*set_length)(struct iio_buffer *buffer, int length); 53 53 54 54 void (*release)(struct iio_buffer *buffer);