[PATCH 404/437] infiniband/core: convert to read/write iterators

Jens Axboe
2024-04-11T15:42:59Z

drivers/infiniband/core/ucma.c | 3 ++-
drivers/infiniband/core/user_mad.c | 6 ++++--
drivers/infiniband/core/uverbs_main.c | 11 +++++++----
3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 5f5ad8faf86e..b9aa99083dd9 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -1746,6 +1746,7 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf,

return ret;
}
+FOPS_WRITE_ITER_HELPER(ucma_write);

static __poll_t ucma_poll(struct file *filp, struct poll_table_struct *wait)
{
@@ -1815,7 +1816,7 @@ static const struct file_operations ucma_fops = {
.owner = THIS_MODULE,
.open = ucma_open,
.release = ucma_close,
- .write = ucma_write,
+ .write_iter = ucma_write_iter,
.poll = ucma_poll,
.llseek = no_llseek,
};
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index f5feca7fa9b9..dcb065c3d8c5 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -429,6 +429,7 @@ static ssize_t ib_umad_read(struct file *filp, char __user *buf,
}
return ret;
}
+FOPS_READ_ITER_HELPER(ib_umad_read);

static int copy_rmpp_mad(struct ib_mad_send_buf *msg, const char __user *buf)
{
@@ -660,6 +661,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
kfree(packet);
return ret;
}
+FOPS_WRITE_ITER_HELPER(ib_umad_write);

static __poll_t ib_umad_poll(struct file *filp, struct poll_table_struct *wait)
{
@@ -1064,8 +1066,8 @@ static int ib_umad_close(struct inode *inode, struct file *filp)

static const struct file_operations umad_fops = {
.owner = THIS_MODULE,
- .read = ib_umad_read,
- .write = ib_umad_write,
+ .read_iter = ib_umad_read_iter,
+ .write_iter = ib_umad_write_iter,
.poll = ib_umad_poll,
.unlocked_ioctl = ib_umad_ioctl,
#ifdef CONFIG_COMPAT
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 495d5a5d0373..7834a30e182b 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -285,6 +285,7 @@ static ssize_t ib_uverbs_async_event_read(struct file *filp, char __user *buf,
return ib_uverbs_event_read(&file->ev_queue, filp, buf, count, pos,
sizeof(struct ib_uverbs_async_event_desc));
}
+FOPS_READ_ITER_HELPER(ib_uverbs_async_event_read);

static ssize_t ib_uverbs_comp_event_read(struct file *filp, char __user *buf,
size_t count, loff_t *pos)
@@ -296,6 +297,7 @@ static ssize_t ib_uverbs_comp_event_read(struct file *filp, char __user *buf,
pos,
sizeof(struct ib_uverbs_comp_event_desc));
}
+FOPS_READ_ITER_HELPER(ib_uverbs_comp_event_read);

static __poll_t ib_uverbs_event_poll(struct ib_uverbs_event_queue *ev_queue,
struct file *filp,
@@ -349,7 +351,7 @@ static int ib_uverbs_comp_event_fasync(int fd, struct file *filp, int on)

const struct file_operations uverbs_event_fops = {
.owner = THIS_MODULE,
- .read = ib_uverbs_comp_event_read,
+ .read_iter = ib_uverbs_comp_event_read_iter,
.poll = ib_uverbs_comp_event_poll,
.release = uverbs_uobject_fd_release,
.fasync = ib_uverbs_comp_event_fasync,
@@ -358,7 +360,7 @@ const struct file_operations uverbs_event_fops = {

const struct file_operations uverbs_async_event_fops = {
.owner = THIS_MODULE,
- .read = ib_uverbs_async_event_read,
+ .read_iter = ib_uverbs_async_event_read_iter,
.poll = ib_uverbs_async_event_poll,
.release = uverbs_async_event_release,
.fasync = ib_uverbs_async_event_fasync,
@@ -684,6 +686,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
return (ret) ? : count;
}
+FOPS_WRITE_ITER_HELPER(ib_uverbs_write);

static const struct vm_operations_struct rdma_umap_ops;

@@ -988,7 +991,7 @@ static int ib_uverbs_close(struct inode *inode, struct file *filp)

static const struct file_operations uverbs_fops = {
.owner = THIS_MODULE,
- .write = ib_uverbs_write,
+ .write_iter = ib_uverbs_write_iter,
.open = ib_uverbs_open,
.release = ib_uverbs_close,
.llseek = no_llseek,
@@ -998,7 +1001,7 @@ static const struct file_operations uverbs_fops = {

static const struct file_operations uverbs_mmap_fops = {
.owner = THIS_MODULE,
- .write = ib_uverbs_write,
+ .write_iter = ib_uverbs_write_iter,
.mmap = ib_uverbs_mmap,
.open = ib_uverbs_open,
.release = ib_uverbs_close,
--
2.43.0