Skip to content

Commit 3749566

Browse files
larsclausenjic23
authored andcommitted
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>
1 parent 8d92db2 commit 3749566

5 files changed

Lines changed: 6 additions & 25 deletions

File tree

‎drivers/iio/industrialio-buffer.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,7 @@ static ssize_t iio_buffer_read_length(struct device *dev,
390390
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
391391
struct iio_buffer *buffer = indio_dev->buffer;
392392

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);
398394
}
399395

400396
static ssize_t iio_buffer_write_length(struct device *dev,
@@ -410,9 +406,8 @@ static ssize_t iio_buffer_write_length(struct device *dev,
410406
if (ret)
411407
return ret;
412408

413-
if (buffer->access->get_length)
414-
if (val == buffer->access->get_length(buffer))
415-
return len;
409+
if (val == buffer->length)
410+
return len;
416411

417412
mutex_lock(&indio_dev->mlock);
418413
if (iio_buffer_is_active(indio_dev->buffer)) {

‎drivers/iio/kfifo_buf.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ static int iio_request_update_kfifo(struct iio_buffer *r)
4747
return ret;
4848
}
4949

50-
static int iio_get_length_kfifo(struct iio_buffer *r)
51-
{
52-
return r->length;
53-
}
54-
5550
static int iio_mark_update_needed_kfifo(struct iio_buffer *r)
5651
{
5752
struct iio_kfifo *kf = iio_to_kfifo(r);
@@ -141,7 +136,6 @@ static const struct iio_buffer_access_funcs kfifo_access_funcs = {
141136
.data_available = iio_kfifo_buf_data_available,
142137
.request_update = &iio_request_update_kfifo,
143138
.set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo,
144-
.get_length = &iio_get_length_kfifo,
145139
.set_length = &iio_set_length_kfifo,
146140
.release = &iio_kfifo_buffer_release,
147141
};

‎drivers/staging/iio/Documentation/ring.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ request_update
4242
set_bytes_per_datum
4343
Set the number of bytes for a complete scan. (All samples + timestamp)
4444

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.
4747

‎drivers/staging/iio/accel/sca3000_ring.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,6 @@ static int sca3000_read_first_n_hw_rb(struct iio_buffer *r,
129129
return ret ? ret : num_read;
130130
}
131131

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-
138132
static bool sca3000_ring_buf_data_available(struct iio_buffer *r)
139133
{
140134
return r->stufftoread;
@@ -248,6 +242,7 @@ static struct iio_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev)
248242
ring->private = indio_dev;
249243
buf = &ring->buf;
250244
buf->stufftoread = 0;
245+
buf->length = 64;
251246
buf->attrs = sca3000_ring_attributes;
252247
iio_buffer_init(buf);
253248

@@ -261,7 +256,6 @@ static void sca3000_ring_release(struct iio_buffer *r)
261256

262257
static const struct iio_buffer_access_funcs sca3000_ring_access_funcs = {
263258
.read_first_n = &sca3000_read_first_n_hw_rb,
264-
.get_length = &sca3000_ring_get_length,
265259
.data_available = sca3000_ring_buf_data_available,
266260
.release = sca3000_ring_release,
267261
};

‎include/linux/iio/buffer.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ struct iio_buffer;
2626
* @request_update: if a parameter change has been marked, update underlying
2727
* storage.
2828
* @set_bytes_per_datum:set number of bytes per datum
29-
* @get_length: get number of datums in buffer
3029
* @set_length: set number of datums in buffer
3130
* @release: called when the last reference to the buffer is dropped,
3231
* should free all resources allocated by the buffer.
@@ -49,7 +48,6 @@ struct iio_buffer_access_funcs {
4948
int (*request_update)(struct iio_buffer *buffer);
5049

5150
int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
52-
int (*get_length)(struct iio_buffer *buffer);
5351
int (*set_length)(struct iio_buffer *buffer, int length);
5452

5553
void (*release)(struct iio_buffer *buffer);

0 commit comments

Comments
 (0)