aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-11-26 12:55:17 -0500
committerJonathan Cameron <jic23@kernel.org>2014-12-12 07:28:34 -0500
commit374956600ecbedf5ca29c76bde114160eb805091 (patch)
tree2276389687295dfa2d3704795e6b8a6b1b52257b /drivers
parent8d92db2827b68206f6930e79132243416183e083 (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iio/industrialio-buffer.c11
-rw-r--r--drivers/iio/kfifo_buf.c6
-rw-r--r--drivers/staging/iio/Documentation/ring.txt4
-rw-r--r--drivers/staging/iio/accel/sca3000_ring.c8
4 files changed, 6 insertions, 23 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 4ca4c0a09923..2bd8d399f2ec 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -390,11 +390,7 @@ static ssize_t iio_buffer_read_length(struct device *dev,
390 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 390 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
391 struct iio_buffer *buffer = indio_dev->buffer; 391 struct iio_buffer *buffer = indio_dev->buffer;
392 392
393 if (buffer->access->get_length) 393 return sprintf(buf, "%d\n", buffer->length);
394 return sprintf(buf, "%d\n",
395 buffer->access->get_length(buffer));
396
397 return 0;
398} 394}
399 395
400static ssize_t iio_buffer_write_length(struct device *dev, 396static ssize_t iio_buffer_write_length(struct device *dev,
@@ -410,9 +406,8 @@ static ssize_t iio_buffer_write_length(struct device *dev,
410 if (ret) 406 if (ret)
411 return ret; 407 return ret;
412 408
413 if (buffer->access->get_length) 409 if (val == buffer->length)
414 if (val == buffer->access->get_length(buffer)) 410 return len;
415 return len;
416 411
417 mutex_lock(&indio_dev->mlock); 412 mutex_lock(&indio_dev->mlock);
418 if (iio_buffer_is_active(indio_dev->buffer)) { 413 if (iio_buffer_is_active(indio_dev->buffer)) {
diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c
index 3b0a3bc4f0ad..b20a9cfbc8ed 100644
--- a/drivers/iio/kfifo_buf.c
+++ b/drivers/iio/kfifo_buf.c
@@ -47,11 +47,6 @@ static int iio_request_update_kfifo(struct iio_buffer *r)
47 return ret; 47 return ret;
48} 48}
49 49
50static int iio_get_length_kfifo(struct iio_buffer *r)
51{
52 return r->length;
53}
54
55static int iio_mark_update_needed_kfifo(struct iio_buffer *r) 50static int iio_mark_update_needed_kfifo(struct iio_buffer *r)
56{ 51{
57 struct iio_kfifo *kf = iio_to_kfifo(r); 52 struct iio_kfifo *kf = iio_to_kfifo(r);
@@ -141,7 +136,6 @@ static const struct iio_buffer_access_funcs kfifo_access_funcs = {
141 .data_available = iio_kfifo_buf_data_available, 136 .data_available = iio_kfifo_buf_data_available,
142 .request_update = &iio_request_update_kfifo, 137 .request_update = &iio_request_update_kfifo,
143 .set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo, 138 .set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo,
144 .get_length = &iio_get_length_kfifo,
145 .set_length = &iio_set_length_kfifo, 139 .set_length = &iio_set_length_kfifo,
146 .release = &iio_kfifo_buffer_release, 140 .release = &iio_kfifo_buffer_release,
147}; 141};
diff --git a/drivers/staging/iio/Documentation/ring.txt b/drivers/staging/iio/Documentation/ring.txt
index 434d63a6123a..18718fcaf259 100644
--- a/drivers/staging/iio/Documentation/ring.txt
+++ b/drivers/staging/iio/Documentation/ring.txt
@@ -42,6 +42,6 @@ request_update
42set_bytes_per_datum 42set_bytes_per_datum
43 Set the number of bytes for a complete scan. (All samples + timestamp) 43 Set the number of bytes for a complete scan. (All samples + timestamp)
44 44
45get_length / set_length 45set_length
46 Get/set the number of complete scans that may be held by the buffer. 46 Set the number of complete scans that may be held by the buffer.
47 47
diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c
index f2f260e01550..f76a26885808 100644
--- a/drivers/staging/iio/accel/sca3000_ring.c
+++ b/drivers/staging/iio/accel/sca3000_ring.c
@@ -129,12 +129,6 @@ error_ret:
129 return ret ? ret : num_read; 129 return ret ? ret : num_read;
130} 130}
131 131
132/* This is only valid with all 3 elements enabled */
133static int sca3000_ring_get_length(struct iio_buffer *r)
134{
135 return 64;
136}
137
138static bool sca3000_ring_buf_data_available(struct iio_buffer *r) 132static bool sca3000_ring_buf_data_available(struct iio_buffer *r)
139{ 133{
140 return r->stufftoread; 134 return r->stufftoread;
@@ -248,6 +242,7 @@ static struct iio_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev)
248 ring->private = indio_dev; 242 ring->private = indio_dev;
249 buf = &ring->buf; 243 buf = &ring->buf;
250 buf->stufftoread = 0; 244 buf->stufftoread = 0;
245 buf->length = 64;
251 buf->attrs = sca3000_ring_attributes; 246 buf->attrs = sca3000_ring_attributes;
252 iio_buffer_init(buf); 247 iio_buffer_init(buf);
253 248
@@ -261,7 +256,6 @@ static void sca3000_ring_release(struct iio_buffer *r)
261 256
262static const struct iio_buffer_access_funcs sca3000_ring_access_funcs = { 257static const struct iio_buffer_access_funcs sca3000_ring_access_funcs = {
263 .read_first_n = &sca3000_read_first_n_hw_rb, 258 .read_first_n = &sca3000_read_first_n_hw_rb,
264 .get_length = &sca3000_ring_get_length,
265 .data_available = sca3000_ring_buf_data_available, 259 .data_available = sca3000_ring_buf_data_available,
266 .release = sca3000_ring_release, 260 .release = sca3000_ring_release,
267}; 261};