[PATCH 166/437] usb: host: xhci: convert to read/write iterators

From: Jens Axboe
Date: Thu Apr 11 2024 - 12:17:25 EST


Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
drivers/usb/host/xhci-debugfs.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c
index f8ba15e7c225..751e48d0b555 100644
--- a/drivers/usb/host/xhci-debugfs.c
+++ b/drivers/usb/host/xhci-debugfs.c
@@ -251,7 +251,7 @@ static int xhci_ring_open(struct inode *inode, struct file *file)

static const struct file_operations xhci_ring_fops = {
.open = xhci_ring_open,
- .read = seq_read,
+ .read_iter = seq_read_iter,
.llseek = seq_lseek,
.release = single_release,
};
@@ -336,7 +336,7 @@ static int xhci_context_open(struct inode *inode, struct file *file)

static const struct file_operations xhci_context_fops = {
.open = xhci_context_open,
- .read = seq_read,
+ .read_iter = seq_read_iter,
.llseek = seq_lseek,
.release = single_release,
};
@@ -360,17 +360,17 @@ static int xhci_port_open(struct inode *inode, struct file *file)
return single_open(file, xhci_portsc_show, inode->i_private);
}

-static ssize_t xhci_port_write(struct file *file, const char __user *ubuf,
- size_t count, loff_t *ppos)
+static ssize_t xhci_port_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct seq_file *s = file->private_data;
+ struct seq_file *s = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(from);
struct xhci_port *port = s->private;
struct xhci_hcd *xhci = hcd_to_xhci(port->rhub->hcd);
char buf[32];
u32 portsc;
unsigned long flags;

- if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+ if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
return -EFAULT;

if (!strncmp(buf, "compliance", 10)) {
@@ -397,8 +397,8 @@ static ssize_t xhci_port_write(struct file *file, const char __user *ubuf,

static const struct file_operations port_fops = {
.open = xhci_port_open,
- .write = xhci_port_write,
- .read = seq_read,
+ .write_iter = xhci_port_write,
+ .read_iter = seq_read_iter,
.llseek = seq_lseek,
.release = single_release,
};
@@ -502,10 +502,10 @@ static int xhci_stream_id_open(struct inode *inode, struct file *file)
return single_open(file, xhci_stream_id_show, inode->i_private);
}

-static ssize_t xhci_stream_id_write(struct file *file, const char __user *ubuf,
- size_t count, loff_t *ppos)
+static ssize_t xhci_stream_id_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct seq_file *s = file->private_data;
+ struct seq_file *s = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(from);
struct xhci_ep_priv *epriv = s->private;
int ret;
u16 stream_id; /* MaxPStreams + 1 <= 16 */
@@ -514,7 +514,7 @@ static ssize_t xhci_stream_id_write(struct file *file, const char __user *ubuf,
return -EPERM;

/* Decimal number */
- ret = kstrtou16_from_user(ubuf, count, 10, &stream_id);
+ ret = kstrtou16_from_iter(from, count, 10, &stream_id);
if (ret)
return ret;

@@ -529,8 +529,8 @@ static ssize_t xhci_stream_id_write(struct file *file, const char __user *ubuf,

static const struct file_operations stream_id_fops = {
.open = xhci_stream_id_open,
- .write = xhci_stream_id_write,
- .read = seq_read,
+ .write_iter = xhci_stream_id_write,
+ .read_iter = seq_read_iter,
.llseek = seq_lseek,
.release = single_release,
};
--
2.43.0