Commit f6d4033d authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron

iio: buffer: rename 'read_first_n' callback to 'read'

It is implied that 'read' will read the first n bytes and not e.g. bytes
only from offsets within the buffer that are a prime number.

This change is non-functional, mostly just a rename.
A secondary intent with this patch is to make room later to add a write
callback.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 4538c185
...@@ -476,7 +476,7 @@ static struct iio_dma_buffer_block *iio_dma_buffer_dequeue( ...@@ -476,7 +476,7 @@ static struct iio_dma_buffer_block *iio_dma_buffer_dequeue(
* @n: Number of bytes to read * @n: Number of bytes to read
* @user_buffer: Userspace buffer to copy the data to * @user_buffer: Userspace buffer to copy the data to
* *
* Should be used as the read_first_n callback for iio_buffer_access_ops * Should be used as the read callback for iio_buffer_access_ops
* struct for DMA buffers. * struct for DMA buffers.
*/ */
int iio_dma_buffer_read(struct iio_buffer *buffer, size_t n, int iio_dma_buffer_read(struct iio_buffer *buffer, size_t n,
......
...@@ -109,7 +109,7 @@ static void iio_dmaengine_buffer_release(struct iio_buffer *buf) ...@@ -109,7 +109,7 @@ static void iio_dmaengine_buffer_release(struct iio_buffer *buf)
} }
static const struct iio_buffer_access_funcs iio_dmaengine_buffer_ops = { static const struct iio_buffer_access_funcs iio_dmaengine_buffer_ops = {
.read_first_n = iio_dma_buffer_read, .read = iio_dma_buffer_read,
.set_bytes_per_datum = iio_dma_buffer_set_bytes_per_datum, .set_bytes_per_datum = iio_dma_buffer_set_bytes_per_datum,
.set_length = iio_dma_buffer_set_length, .set_length = iio_dma_buffer_set_length,
.request_update = iio_dma_buffer_request_update, .request_update = iio_dma_buffer_request_update,
......
...@@ -98,8 +98,7 @@ static int iio_store_to_kfifo(struct iio_buffer *r, ...@@ -98,8 +98,7 @@ static int iio_store_to_kfifo(struct iio_buffer *r,
return 0; return 0;
} }
static int iio_read_first_n_kfifo(struct iio_buffer *r, static int iio_read_kfifo(struct iio_buffer *r, size_t n, char __user *buf)
size_t n, char __user *buf)
{ {
int ret, copied; int ret, copied;
struct iio_kfifo *kf = iio_to_kfifo(r); struct iio_kfifo *kf = iio_to_kfifo(r);
...@@ -141,7 +140,7 @@ static void iio_kfifo_buffer_release(struct iio_buffer *buffer) ...@@ -141,7 +140,7 @@ static void iio_kfifo_buffer_release(struct iio_buffer *buffer)
static const struct iio_buffer_access_funcs kfifo_access_funcs = { static const struct iio_buffer_access_funcs kfifo_access_funcs = {
.store_to = &iio_store_to_kfifo, .store_to = &iio_store_to_kfifo,
.read_first_n = &iio_read_first_n_kfifo, .read = &iio_read_kfifo,
.data_available = iio_kfifo_buf_data_available, .data_available = iio_kfifo_buf_data_available,
.request_update = &iio_request_update_kfifo, .request_update = &iio_request_update_kfifo,
.set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo, .set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo,
......
...@@ -42,14 +42,14 @@ struct poll_table_struct; ...@@ -42,14 +42,14 @@ struct poll_table_struct;
__poll_t iio_buffer_poll(struct file *filp, __poll_t iio_buffer_poll(struct file *filp,
struct poll_table_struct *wait); struct poll_table_struct *wait);
ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, ssize_t iio_buffer_read_outer(struct file *filp, char __user *buf,
size_t n, loff_t *f_ps); size_t n, loff_t *f_ps);
int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev); int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev);
void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev); void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev);
#define iio_buffer_poll_addr (&iio_buffer_poll) #define iio_buffer_poll_addr (&iio_buffer_poll)
#define iio_buffer_read_first_n_outer_addr (&iio_buffer_read_first_n_outer) #define iio_buffer_read_outer_addr (&iio_buffer_read_outer)
void iio_disable_all_buffers(struct iio_dev *indio_dev); void iio_disable_all_buffers(struct iio_dev *indio_dev);
void iio_buffer_wakeup_poll(struct iio_dev *indio_dev); void iio_buffer_wakeup_poll(struct iio_dev *indio_dev);
...@@ -57,7 +57,7 @@ void iio_buffer_wakeup_poll(struct iio_dev *indio_dev); ...@@ -57,7 +57,7 @@ void iio_buffer_wakeup_poll(struct iio_dev *indio_dev);
#else #else
#define iio_buffer_poll_addr NULL #define iio_buffer_poll_addr NULL
#define iio_buffer_read_first_n_outer_addr NULL #define iio_buffer_read_outer_addr NULL
static inline int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev) static inline int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
{ {
......
...@@ -87,7 +87,7 @@ static bool iio_buffer_ready(struct iio_dev *indio_dev, struct iio_buffer *buf, ...@@ -87,7 +87,7 @@ static bool iio_buffer_ready(struct iio_dev *indio_dev, struct iio_buffer *buf,
} }
/** /**
* iio_buffer_read_first_n_outer() - chrdev read for buffer access * iio_buffer_read_outer() - chrdev read for buffer access
* @filp: File structure pointer for the char device * @filp: File structure pointer for the char device
* @buf: Destination buffer for iio buffer read * @buf: Destination buffer for iio buffer read
* @n: First n bytes to read * @n: First n bytes to read
...@@ -99,8 +99,8 @@ static bool iio_buffer_ready(struct iio_dev *indio_dev, struct iio_buffer *buf, ...@@ -99,8 +99,8 @@ static bool iio_buffer_ready(struct iio_dev *indio_dev, struct iio_buffer *buf,
* Return: negative values corresponding to error codes or ret != 0 * Return: negative values corresponding to error codes or ret != 0
* for ending the reading activity * for ending the reading activity
**/ **/
ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, ssize_t iio_buffer_read_outer(struct file *filp, char __user *buf,
size_t n, loff_t *f_ps) size_t n, loff_t *f_ps)
{ {
struct iio_dev *indio_dev = filp->private_data; struct iio_dev *indio_dev = filp->private_data;
struct iio_buffer *rb = indio_dev->buffer; struct iio_buffer *rb = indio_dev->buffer;
...@@ -112,7 +112,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, ...@@ -112,7 +112,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
if (!indio_dev->info) if (!indio_dev->info)
return -ENODEV; return -ENODEV;
if (!rb || !rb->access->read_first_n) if (!rb || !rb->access->read)
return -EINVAL; return -EINVAL;
datum_size = rb->bytes_per_datum; datum_size = rb->bytes_per_datum;
...@@ -147,7 +147,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, ...@@ -147,7 +147,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
continue; continue;
} }
ret = rb->access->read_first_n(rb, n, buf); ret = rb->access->read(rb, n, buf);
if (ret == 0 && (filp->f_flags & O_NONBLOCK)) if (ret == 0 && (filp->f_flags & O_NONBLOCK))
ret = -EAGAIN; ret = -EAGAIN;
} while (ret == 0); } while (ret == 0);
......
...@@ -1632,7 +1632,7 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -1632,7 +1632,7 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
} }
static const struct file_operations iio_buffer_fileops = { static const struct file_operations iio_buffer_fileops = {
.read = iio_buffer_read_first_n_outer_addr, .read = iio_buffer_read_outer_addr,
.release = iio_chrdev_release, .release = iio_chrdev_release,
.open = iio_chrdev_open, .open = iio_chrdev_open,
.poll = iio_buffer_poll_addr, .poll = iio_buffer_poll_addr,
......
...@@ -18,7 +18,7 @@ struct iio_buffer; ...@@ -18,7 +18,7 @@ struct iio_buffer;
/** /**
* struct iio_buffer_access_funcs - access functions for buffers. * struct iio_buffer_access_funcs - access functions for buffers.
* @store_to: actually store stuff to the buffer * @store_to: actually store stuff to the buffer
* @read_first_n: try to get a specified number of bytes (must exist) * @read: try to get a specified number of bytes (must exist)
* @data_available: indicates how much data is available for reading from * @data_available: indicates how much data is available for reading from
* the buffer. * the buffer.
* @request_update: if a parameter change has been marked, update underlying * @request_update: if a parameter change has been marked, update underlying
...@@ -45,9 +45,7 @@ struct iio_buffer; ...@@ -45,9 +45,7 @@ struct iio_buffer;
**/ **/
struct iio_buffer_access_funcs { struct iio_buffer_access_funcs {
int (*store_to)(struct iio_buffer *buffer, const void *data); int (*store_to)(struct iio_buffer *buffer, const void *data);
int (*read_first_n)(struct iio_buffer *buffer, int (*read)(struct iio_buffer *buffer, size_t n, char __user *buf);
size_t n,
char __user *buf);
size_t (*data_available)(struct iio_buffer *buffer); size_t (*data_available)(struct iio_buffer *buffer);
int (*request_update)(struct iio_buffer *buffer); int (*request_update)(struct iio_buffer *buffer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment