Skip to contentSkip to conversation

Kill off old fops ->read() and ->write()

RFC PATCH In review Jens Axboe 4 participants 451 messages Apr 11, 2024 – May 5, 2024 Page 3 of 5

Subsystems (424)
lore
Share & tools
lore
author maintainer
#189 lore raw

PATCH 183/437 drivers/platform: convert to ->read_iter and ->write_iter

In reply to Jens Axboe
---
 drivers/platform/chrome/cros_ec_chardev.c     | 20 +++++------
 drivers/platform/chrome/cros_ec_debugfs.c     | 33 ++++++++-----------
 drivers/platform/chrome/wilco_ec/debugfs.c    | 19 +++++------
 drivers/platform/chrome/wilco_ec/event.c      | 18 +++++-----
 drivers/platform/chrome/wilco_ec/telemetry.c  | 20 +++++------
 drivers/platform/goldfish/goldfish_pipe.c     |  6 ++--
 drivers/platform/olpc/olpc-ec.c               | 15 ++++-----
 .../surface/surface_aggregator_cdev.c         |  3 +-
 drivers/platform/surface/surface_dtx.c        |  3 +-
 drivers/platform/x86/amd/pmc/pmc.c            | 21 ++++++------
 drivers/platform/x86/amd/pmf/tee-if.c         | 10 +++---
 drivers/platform/x86/apple-gmux.c             | 25 +++++++-------
 drivers/platform/x86/asus-wmi.c               |  2 +-
 drivers/platform/x86/dell/dell-smbios-wmi.c   | 11 +++----
 drivers/platform/x86/dell/dell-smo8800.c      |  3 +-
 drivers/platform/x86/intel/pmc/core.c         | 24 +++++++-------
 drivers/platform/x86/intel/pmc/core.h         |  4 +--
 .../platform/x86/intel/telemetry/debugfs.c    | 24 +++++++-------
 drivers/platform/x86/intel/tpmi.c             | 11 ++++---
 drivers/platform/x86/sony-laptop.c            |  3 +-
 20 files changed, 136 insertions(+), 139 deletions(-)
drivers/platform/chrome/cros_ec_chardev.c +10 -10
index 81950bb2c6da..527588147a2f 100644
@@ -197,13 +197,13 @@ static __poll_t cros_ec_chardev_poll(struct file *filp, poll_table *wait)
 	return EPOLLIN | EPOLLRDNORM;
 }
 
-static ssize_t cros_ec_chardev_read(struct file *filp, char __user *buffer,
-				     size_t length, loff_t *offset)
+static ssize_t cros_ec_chardev_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char msg[sizeof(struct ec_response_get_version) +
 		 sizeof(CROS_EC_DEV_VERSION)];
-	struct chardev_priv *priv = filp->private_data;
+	struct chardev_priv *priv = iocb->ki_filp->private_data;
 	struct cros_ec_dev *ec_dev = priv->ec_dev;
+	size_t length = iov_iter_count(to);
 	size_t count;
 	int ret;
 
@@ -211,7 +211,7 @@ static ssize_t cros_ec_chardev_read(struct file *filp, char __user *buffer,
 		struct ec_event *event;
 
 		event = cros_ec_chardev_fetch_event(priv, length != 0,
-						!(filp->f_flags & O_NONBLOCK));
+					!(iocb->ki_filp->f_flags & O_NONBLOCK));
 		if (IS_ERR(event))
 			return PTR_ERR(event);
 		/*
@@ -223,18 +223,18 @@ static ssize_t cros_ec_chardev_read(struct file *filp, char __user *buffer,
 
 		/* The event is 1 byte of type plus the payload */
 		count = min(length, event->size + 1);
-		ret = copy_to_user(buffer, &event->event_type, count);
+		ret = !copy_to_iter_full(&event->event_type, count, to);
 		kfree(event);
 		if (ret) /* the copy failed */
 			return -EFAULT;
-		*offset = count;
+		iocb->ki_pos = count;
 		return count;
 	}
 
 	/*
 	 * Legacy behavior if no event mask is defined
 	 */
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	ret = ec_get_version(ec_dev, msg, sizeof(msg));
@@ -243,10 +243,10 @@ static ssize_t cros_ec_chardev_read(struct file *filp, char __user *buffer,
 
 	count = min(length, strlen(msg));
 
-	if (copy_to_user(buffer, msg, count))
+	if (!copy_to_iter_full(msg, count, to))
 		return -EFAULT;
 
-	*offset = count;
+	iocb->ki_pos = count;
 	return count;
 }
 
@@ -366,7 +366,7 @@ static long cros_ec_chardev_ioctl(struct file *filp, unsigned int cmd,
 static const struct file_operations chardev_fops = {
 	.open		= cros_ec_chardev_open,
 	.poll		= cros_ec_chardev_poll,
-	.read		= cros_ec_chardev_read,
+	.read_iter	= cros_ec_chardev_read,
 	.release	= cros_ec_chardev_release,
 	.unlocked_ioctl	= cros_ec_chardev_ioctl,
 #ifdef CONFIG_COMPAT
drivers/platform/chrome/cros_ec_debugfs.c +14 -19
index 6bf6f0e7b597..d4a00fc8f958 100644
@@ -128,17 +128,17 @@ static int cros_ec_console_log_open(struct inode *inode, struct file *file)
 	return stream_open(inode, file);
 }
 
-static ssize_t cros_ec_console_log_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t cros_ec_console_log_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct cros_ec_debugfs *debug_info = file->private_data;
+	struct cros_ec_debugfs *debug_info = iocb->ki_filp->private_data;
 	struct circ_buf *cb = &debug_info->log_buffer;
+	size_t count = iov_iter_count(to);
 	ssize_t ret;
 
 	mutex_lock(&debug_info->log_mutex);
 
 	while (!CIRC_CNT(cb->head, cb->tail, LOG_SIZE)) {
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			ret = -EAGAIN;
 			goto error;
 		}
@@ -159,7 +159,7 @@ static ssize_t cros_ec_console_log_read(struct file *file, char __user *buf,
 	ret = min_t(size_t, CIRC_CNT_TO_END(cb->head, cb->tail, LOG_SIZE),
 		    count);
 
-	if (copy_to_user(buf, cb->buf + cb->tail, ret)) {
+	if (!copy_to_iter_full(cb->buf + cb->tail, ret, to)) {
 		ret = -EFAULT;
 		goto error;
 	}
@@ -194,13 +194,10 @@ static int cros_ec_console_log_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t cros_ec_pdinfo_read(struct file *file,
-				   char __user *user_buf,
-				   size_t count,
-				   loff_t *ppos)
+static ssize_t cros_ec_pdinfo_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char read_buf[EC_USB_PD_MAX_PORTS * 40], *p = read_buf;
-	struct cros_ec_debugfs *debug_info = file->private_data;
+	struct cros_ec_debugfs *debug_info = iocb->ki_filp->private_data;
 	struct cros_ec_device *ec_dev = debug_info->ec->ec_dev;
 	struct {
 		struct cros_ec_command msg;
@@ -242,8 +239,7 @@ static ssize_t cros_ec_pdinfo_read(struct file *file,
 			       resp->polarity);
 	}
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       read_buf, p - read_buf);
+	return simple_copy_to_iter(read_buf, &iocb->ki_pos, p - read_buf, to);
 }
 
 static bool cros_ec_uptime_is_supported(struct cros_ec_device *ec_dev)
@@ -265,10 +261,9 @@ static bool cros_ec_uptime_is_supported(struct cros_ec_device *ec_dev)
 	return true;
 }
 
-static ssize_t cros_ec_uptime_read(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t cros_ec_uptime_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct cros_ec_debugfs *debug_info = file->private_data;
+	struct cros_ec_debugfs *debug_info = iocb->ki_filp->private_data;
 	struct cros_ec_device *ec_dev = debug_info->ec->ec_dev;
 	struct {
 		struct cros_ec_command cmd;
@@ -290,13 +285,13 @@ static ssize_t cros_ec_uptime_read(struct file *file, char __user *user_buf,
 	ret = scnprintf(read_buf, sizeof(read_buf), "%u\n",
 			resp->time_since_ec_boot_ms);
 
-	return simple_read_from_buffer(user_buf, count, ppos, read_buf, ret);
+	return simple_copy_to_iter(read_buf, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations cros_ec_console_log_fops = {
 	.owner = THIS_MODULE,
 	.open = cros_ec_console_log_open,
-	.read = cros_ec_console_log_read,
+	.read_iter = cros_ec_console_log_read,
 	.llseek = no_llseek,
 	.poll = cros_ec_console_log_poll,
 	.release = cros_ec_console_log_release,
@@ -305,14 +300,14 @@ static const struct file_operations cros_ec_console_log_fops = {
 static const struct file_operations cros_ec_pdinfo_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = cros_ec_pdinfo_read,
+	.read_iter = cros_ec_pdinfo_read,
 	.llseek = default_llseek,
 };
 
 static const struct file_operations cros_ec_uptime_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = cros_ec_uptime_read,
+	.read_iter = cros_ec_uptime_read,
 	.llseek = default_llseek,
 };
 
drivers/platform/chrome/wilco_ec/debugfs.c +9 -10
index 93c11f81ca45..b3e1850a1dbc 100644
@@ -92,10 +92,10 @@ static int parse_hex_sentence(const char *in, int isize, u8 *out, int osize)
 /* The message type takes up two bytes*/
 #define TYPE_AND_DATA_SIZE ((EC_MAILBOX_DATA_SIZE) + 2)
 
-static ssize_t raw_write(struct file *file, const char __user *user_buf,
-			 size_t count, loff_t *ppos)
+static ssize_t raw_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char *buf = debug_info->formatted_data;
+	size_t count = iov_iter_count(from);
 	struct wilco_ec_message msg;
 	u8 request_data[TYPE_AND_DATA_SIZE];
 	ssize_t kcount;
@@ -104,8 +104,8 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf,
 	if (count > FORMATTED_BUFFER_SIZE)
 		return -EINVAL;
 
-	kcount = simple_write_to_buffer(buf, FORMATTED_BUFFER_SIZE, ppos,
-					user_buf, count);
+	kcount = simple_copy_from_iter(buf, &iocb->ki_pos, FORMATTED_BUFFER_SIZE,
+					from);
 	if (kcount < 0)
 		return kcount;
 
@@ -132,8 +132,7 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf,
 	return count;
 }
 
-static ssize_t raw_read(struct file *file, char __user *user_buf, size_t count,
-			loff_t *ppos)
+static ssize_t raw_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int fmt_len = 0;
 
@@ -147,14 +146,14 @@ static ssize_t raw_read(struct file *file, char __user *user_buf, size_t count,
 		debug_info->response_size = 0;
 	}
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       debug_info->formatted_data, fmt_len);
+	return simple_copy_to_iter(debug_info->formatted_data, &iocb->ki_pos,
+					fmt_len, to);
 }
 
 static const struct file_operations fops_raw = {
 	.owner = THIS_MODULE,
-	.read = raw_read,
-	.write = raw_write,
+	.read_iter = raw_read,
+	.write_iter = raw_write,
 	.llseek = no_llseek,
 };
 
drivers/platform/chrome/wilco_ec/event.c +8 -10
index 13291fb4214e..581a4c13847c 100644
@@ -335,10 +335,8 @@ static __poll_t event_poll(struct file *filp, poll_table *wait)
 
 /**
  * event_read() - Callback for passing event data to userspace via read().
- * @filp: The file we are reading from.
- * @buf: Pointer to userspace buffer to fill with one event.
- * @count: Number of bytes requested. Must be at least EC_ACPI_MAX_EVENT_SIZE.
- * @pos: File position pointer, irrelevant since we don't support seeking.
+ * @iocb: Metadata for IO
+ * @to: Pointer to userspace buffer to fill with one event.
  *
  * Removes the first event from the queue, places it in the passed buffer.
  *
@@ -349,10 +347,10 @@ static __poll_t event_poll(struct file *filp, poll_table *wait)
  *
  * Return: Number of bytes placed in buffer, negative error code on failure.
  */
-static ssize_t event_read(struct file *filp, char __user *buf, size_t count,
-			  loff_t *pos)
+static ssize_t event_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct event_device_data *dev_data = filp->private_data;
+	struct event_device_data *dev_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct ec_event *event;
 	ssize_t n_bytes_written = 0;
 	int err;
@@ -364,7 +362,7 @@ static ssize_t event_read(struct file *filp, char __user *buf, size_t count,
 	spin_lock(&dev_data->queue_lock);
 	while (event_queue_empty(dev_data->events)) {
 		spin_unlock(&dev_data->queue_lock);
-		if (filp->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		err = wait_event_interruptible(dev_data->wq,
@@ -381,7 +379,7 @@ static ssize_t event_read(struct file *filp, char __user *buf, size_t count,
 	event = event_queue_pop(dev_data->events);
 	spin_unlock(&dev_data->queue_lock);
 	n_bytes_written = ec_event_size(event);
-	if (copy_to_user(buf, event, n_bytes_written))
+	if (!copy_to_iter_full(event, n_bytes_written, to))
 		n_bytes_written = -EFAULT;
 	kfree(event);
 
@@ -401,7 +399,7 @@ static int event_release(struct inode *inode, struct file *filp)
 static const struct file_operations event_fops = {
 	.open = event_open,
 	.poll  = event_poll,
-	.read = event_read,
+	.read_iter = event_read,
 	.release = event_release,
 	.llseek = no_llseek,
 	.owner = THIS_MODULE,
drivers/platform/chrome/wilco_ec/telemetry.c +10 -10
index b7c616f3d179..dbb937382cef 100644
@@ -261,17 +261,17 @@ static int telem_open(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t telem_write(struct file *filp, const char __user *buf,
-			   size_t count, loff_t *pos)
+static ssize_t telem_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct telem_session_data *sess_data = filp->private_data;
+	struct telem_session_data *sess_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wilco_ec_message msg = {};
 	int ret;
 
 	if (count > sizeof(sess_data->request))
 		return -EMSGSIZE;
 	memset(&sess_data->request, 0, sizeof(sess_data->request));
-	if (copy_from_user(&sess_data->request, buf, count))
+	if (!copy_from_iter_full(&sess_data->request, count, from))
 		return -EFAULT;
 	ret = check_telem_request(&sess_data->request, count);
 	if (ret < 0)
@@ -295,17 +295,17 @@ static ssize_t telem_write(struct file *filp, const char __user *buf,
 	return count;
 }
 
-static ssize_t telem_read(struct file *filp, char __user *buf, size_t count,
-			  loff_t *pos)
+static ssize_t telem_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct telem_session_data *sess_data = filp->private_data;
+	struct telem_session_data *sess_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 
 	if (!sess_data->has_msg)
 		return -ENODATA;
 	if (count > sizeof(sess_data->response))
 		return -EINVAL;
 
-	if (copy_to_user(buf, sess_data->response, count))
+	if (!copy_to_iter_full(sess_data->response, count, to))
 		return -EFAULT;
 
 	sess_data->has_msg = false;
@@ -326,8 +326,8 @@ static int telem_release(struct inode *inode, struct file *filp)
 
 static const struct file_operations telem_fops = {
 	.open = telem_open,
-	.write = telem_write,
-	.read = telem_read,
+	.write_iter = telem_write,
+	.read_iter = telem_read,
 	.release = telem_release,
 	.llseek = no_llseek,
 	.owner = THIS_MODULE,
drivers/platform/goldfish/goldfish_pipe.c +4 -2
index 061aa9647c19..8a75fa0b139b 100644
@@ -475,6 +475,7 @@ static ssize_t goldfish_pipe_read(struct file *filp, char __user *buffer,
 	return goldfish_pipe_read_write(filp, buffer, bufflen,
 					/* is_write */ 0);
 }
+FOPS_READ_ITER_HELPER(goldfish_pipe_read);
 
 static ssize_t goldfish_pipe_write(struct file *filp,
 				   const char __user *buffer, size_t bufflen,
@@ -486,6 +487,7 @@ static ssize_t goldfish_pipe_write(struct file *filp,
 	return goldfish_pipe_read_write(filp, no_const_buffer, bufflen,
 					/* is_write */ 1);
 }
+FOPS_WRITE_ITER_HELPER(goldfish_pipe_write);
 
 static __poll_t goldfish_pipe_poll(struct file *filp, poll_table *wait)
 {
@@ -779,8 +781,8 @@ static int goldfish_pipe_release(struct inode *inode, struct file *filp)
 
 static const struct file_operations goldfish_pipe_fops = {
 	.owner = THIS_MODULE,
-	.read = goldfish_pipe_read,
-	.write = goldfish_pipe_write,
+	.read_iter = goldfish_pipe_read_iter,
+	.write_iter = goldfish_pipe_write_iter,
 	.poll = goldfish_pipe_poll,
 	.open = goldfish_pipe_open,
 	.release = goldfish_pipe_release,
drivers/platform/olpc/olpc-ec.c +7 -8
index 921520475ff6..89cf016e0767 100644
@@ -258,10 +258,10 @@ static DEFINE_MUTEX(ec_dbgfs_lock);
 static unsigned char ec_dbgfs_resp[EC_MAX_CMD_REPLY];
 static unsigned int ec_dbgfs_resp_bytes;
 
-static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,
-		size_t size, loff_t *ppos)
+static ssize_t ec_dbgfs_cmd_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int i, m;
+	size_t size = iov_iter_count(from);
 	unsigned char ec_cmd[EC_MAX_CMD_ARGS];
 	unsigned int ec_cmd_int[EC_MAX_CMD_ARGS];
 	char cmdbuf[64] = "";
@@ -269,7 +269,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,
 
 	mutex_lock(&ec_dbgfs_lock);
 
-	size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf), ppos, buf, size);
+	size = simple_copy_from_iter(cmdbuf, &iocb->ki_pos, sizeof(cmdbuf), from);
 
 	m = sscanf(cmdbuf, "%x:%u %x %x %x %x %x", &ec_cmd_int[0],
 			&ec_dbgfs_resp_bytes, &ec_cmd_int[1], &ec_cmd_int[2],
@@ -303,8 +303,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,
 	return size;
 }
 
-static ssize_t ec_dbgfs_cmd_read(struct file *file, char __user *buf,
-		size_t size, loff_t *ppos)
+static ssize_t ec_dbgfs_cmd_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	unsigned int i, r;
 	char *rp;
@@ -319,12 +318,12 @@ static ssize_t ec_dbgfs_cmd_read(struct file *file, char __user *buf,
 	rp += sprintf(rp, "\n");
 
 	r = rp - respbuf;
-	return simple_read_from_buffer(buf, size, ppos, respbuf, r);
+	return simple_copy_to_iter(respbuf, &iocb->ki_pos, r, to);
 }
 
 static const struct file_operations ec_dbgfs_ops = {
-	.write = ec_dbgfs_cmd_write,
-	.read = ec_dbgfs_cmd_read,
+	.write_iter = ec_dbgfs_cmd_write,
+	.read_iter = ec_dbgfs_cmd_read,
 };
 
 static struct dentry *olpc_ec_setup_debugfs(void)
drivers/platform/surface/surface_aggregator_cdev.c +2 -1
index 07e065b9159f..232f487c3eaf 100644
@@ -637,6 +637,7 @@ static ssize_t ssam_cdev_read(struct file *file, char __user *buf, size_t count,
 	up_read(&cdev->lock);
 	return copied;
 }
+FOPS_READ_ITER_HELPER(ssam_cdev_read);
 
 static __poll_t ssam_cdev_poll(struct file *file, struct poll_table_struct *pt)
 {
@@ -665,7 +666,7 @@ static const struct file_operations ssam_controller_fops = {
 	.owner          = THIS_MODULE,
 	.open           = ssam_cdev_device_open,
 	.release        = ssam_cdev_device_release,
-	.read           = ssam_cdev_read,
+	.read_iter      = ssam_cdev_read_iter,
 	.poll           = ssam_cdev_poll,
 	.fasync         = ssam_cdev_fasync,
 	.unlocked_ioctl = ssam_cdev_device_ioctl,
drivers/platform/surface/surface_dtx.c +2 -1
index 2de843b7ea70..f2b3fe8dcd72 100644
@@ -522,6 +522,7 @@ static ssize_t surface_dtx_read(struct file *file, char __user *buf, size_t coun
 	up_read(&ddev->lock);
 	return copied;
 }
+FOPS_READ_ITER_HELPER(surface_dtx_read);
 
 static __poll_t surface_dtx_poll(struct file *file, struct poll_table_struct *pt)
 {
@@ -550,7 +551,7 @@ static const struct file_operations surface_dtx_fops = {
 	.owner          = THIS_MODULE,
 	.open           = surface_dtx_open,
 	.release        = surface_dtx_release,
-	.read           = surface_dtx_read,
+	.read_iter      = surface_dtx_read_iter,
 	.poll           = surface_dtx_poll,
 	.fasync         = surface_dtx_fasync,
 	.unlocked_ioctl = surface_dtx_ioctl,
drivers/platform/x86/amd/pmc/pmc.c +10 -11
index 108e12fd580f..c4342280e43d 100644
@@ -214,14 +214,13 @@ static int amd_pmc_stb_debugfs_open(struct inode *inode, struct file *filp)
 	return rc;
 }
 
-static ssize_t amd_pmc_stb_debugfs_read(struct file *filp, char __user *buf, size_t size,
-					loff_t *pos)
+static ssize_t amd_pmc_stb_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	if (!filp->private_data)
+	if (!iocb->ki_filp->private_data)
 		return -EINVAL;
 
-	return simple_read_from_buffer(buf, size, pos, filp->private_data,
-				       FIFO_SIZE * sizeof(u32));
+	return simple_copy_to_iter(iocb->ki_filp->private_data, &iocb->ki_pos,
+				   FIFO_SIZE * sizeof(u32), to);
 }
 
 static int amd_pmc_stb_debugfs_release(struct inode *inode, struct file *filp)
@@ -233,7 +232,7 @@ static int amd_pmc_stb_debugfs_release(struct inode *inode, struct file *filp)
 static const struct file_operations amd_pmc_stb_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = amd_pmc_stb_debugfs_open,
-	.read = amd_pmc_stb_debugfs_read,
+	.read_iter = amd_pmc_stb_debugfs_read,
 	.release = amd_pmc_stb_debugfs_release,
 };
 
@@ -321,12 +320,12 @@ static int amd_pmc_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t amd_pmc_stb_debugfs_read_v2(struct file *filp, char __user *buf, size_t size,
-					   loff_t *pos)
+static ssize_t amd_pmc_stb_debugfs_read_v2(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct amd_pmc_stb_v2_data *data = filp->private_data;
+	struct amd_pmc_stb_v2_data *data = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(buf, size, pos, data->data, data->size);
+	return simple_copy_to_iter(data->data, &iocb->ki_pos, data->size, to);
 }
 
 static int amd_pmc_stb_debugfs_release_v2(struct inode *inode, struct file *filp)
@@ -338,7 +337,7 @@ static int amd_pmc_stb_debugfs_release_v2(struct inode *inode, struct file *filp
 static const struct file_operations amd_pmc_stb_debugfs_fops_v2 = {
 	.owner = THIS_MODULE,
 	.open = amd_pmc_stb_debugfs_open_v2,
-	.read = amd_pmc_stb_debugfs_read_v2,
+	.read_iter = amd_pmc_stb_debugfs_read_v2,
 	.release = amd_pmc_stb_debugfs_release_v2,
 };
 
drivers/platform/x86/amd/pmf/tee-if.c +5 -5
index b438de4d6bfc..3b6bf12a31c4 100644
@@ -289,10 +289,10 @@ static void amd_pmf_hex_dump_pb(struct amd_pmf_dev *dev)
 			     dev->policy_sz, false);
 }
 
-static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
-				   size_t length, loff_t *pos)
+static ssize_t amd_pmf_get_pb_data(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct amd_pmf_dev *dev = filp->private_data;
+	struct amd_pmf_dev *dev = iocb->ki_filp->private_data;
+	size_t length = iov_iter_count(from);
 	unsigned char *new_policy_buf;
 	int ret;
 
@@ -305,7 +305,7 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
 	if (!new_policy_buf)
 		return -ENOMEM;
 
-	if (copy_from_user(new_policy_buf, buf, length)) {
+	if (!copy_from_iter_full(new_policy_buf, length, from)) {
 		kfree(new_policy_buf);
 		return -EFAULT;
 	}
@@ -323,7 +323,7 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
 }
 
 static const struct file_operations pb_fops = {
-	.write = amd_pmf_get_pb_data,
+	.write_iter = amd_pmf_get_pb_data,
 	.open = simple_open,
 };
 
drivers/platform/x86/apple-gmux.c +13 -12
index 1417e230edbd..7c078a27c67b 100644
@@ -691,25 +691,26 @@ static void gmux_notify_handler(acpi_handle device, u32 value, void *context)
  * 1 and 4 byte writes are also allowed.
  */
 
-static ssize_t gmux_selected_port_data_write(struct file *file,
-		const char __user *userbuf, size_t count, loff_t *ppos)
+static ssize_t gmux_selected_port_data_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct apple_gmux_data *gmux_data = file->private_data;
+	struct apple_gmux_data *gmux_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return -EINVAL;
 
 	if (count == 1) {
 		u8 data;
 
-		if (copy_from_user(&data, userbuf, 1))
+		if (!copy_from_iter_full(&data, 1, from))
 			return -EFAULT;
 
 		gmux_write8(gmux_data, gmux_data->selected_port, data);
 	} else if (count == 4) {
 		u32 data;
 
-		if (copy_from_user(&data, userbuf, 4))
+		if (!copy_from_iter_full(&data, 4, from))
 			return -EFAULT;
 
 		gmux_write32(gmux_data, gmux_data->selected_port, data);
@@ -719,21 +720,21 @@ static ssize_t gmux_selected_port_data_write(struct file *file,
 	return count;
 }
 
-static ssize_t gmux_selected_port_data_read(struct file *file,
-		char __user *userbuf, size_t count, loff_t *ppos)
+static ssize_t gmux_selected_port_data_read(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct apple_gmux_data *gmux_data = file->private_data;
+	struct apple_gmux_data *gmux_data = iocb->ki_filp->private_data;
 	u32 data;
 
 	data = gmux_read32(gmux_data, gmux_data->selected_port);
 
-	return simple_read_from_buffer(userbuf, count, ppos, &data, sizeof(data));
+	return simple_copy_to_iter(&data, &iocb->ki_pos, sizeof(data), to);
 }
 
 static const struct file_operations gmux_port_data_ops = {
 	.open = simple_open,
-	.write = gmux_selected_port_data_write,
-	.read = gmux_selected_port_data_read
+	.write_iter = gmux_selected_port_data_write,
+	.read_iter = gmux_selected_port_data_read
 };
 
 static void gmux_init_debugfs(struct apple_gmux_data *gmux_data)
drivers/platform/x86/asus-wmi.c +1 -1
index 3f07bbf809ef..02d874c4d30c 100644
@@ -4367,7 +4367,7 @@ static int asus_wmi_debugfs_open(struct inode *inode, struct file *file)
 static const struct file_operations asus_wmi_debugfs_io_ops = {
 	.owner = THIS_MODULE,
 	.open = asus_wmi_debugfs_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
drivers/platform/x86/dell/dell-smbios-wmi.c +5 -6
index ae9012549560..89deb76c0d5e 100644
@@ -123,13 +123,12 @@ static int dell_smbios_wmi_open(struct inode *inode, struct file *filp)
 	return nonseekable_open(inode, filp);
 }
 
-static ssize_t dell_smbios_wmi_read(struct file *filp, char __user *buffer, size_t length,
-				    loff_t *offset)
+static ssize_t dell_smbios_wmi_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wmi_smbios_priv *priv = filp->private_data;
+	struct wmi_smbios_priv *priv = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(buffer, length, offset, &priv->req_buf_size,
-				       sizeof(priv->req_buf_size));
+	return simple_copy_to_iter(&priv->req_buf_size, &iocb->ki_pos,
+				   sizeof(priv->req_buf_size), to);
 }
 
 static long dell_smbios_wmi_do_ioctl(struct wmi_smbios_priv *priv,
@@ -189,7 +188,7 @@ static long dell_smbios_wmi_ioctl(struct file *filp, unsigned int cmd, unsigned
 static const struct file_operations dell_smbios_wmi_fops = {
 	.owner		= THIS_MODULE,
 	.open		= dell_smbios_wmi_open,
-	.read		= dell_smbios_wmi_read,
+	.read_iter	= dell_smbios_wmi_read,
 	.unlocked_ioctl	= dell_smbios_wmi_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 };
drivers/platform/x86/dell/dell-smo8800.c +2 -1
index f7ec17c56833..b8fa22b0b6bd 100644
@@ -74,6 +74,7 @@ static ssize_t smo8800_misc_read(struct file *file, char __user *buf,
 
 	return retval;
 }
+FOPS_READ_ITER_HELPER(smo8800_misc_read);
 
 static int smo8800_misc_open(struct inode *inode, struct file *file)
 {
@@ -98,7 +99,7 @@ static int smo8800_misc_release(struct inode *inode, struct file *file)
 
 static const struct file_operations smo8800_misc_fops = {
 	.owner = THIS_MODULE,
-	.read = smo8800_misc_read,
+	.read_iter = smo8800_misc_read_iter,
 	.open = smo8800_misc_open,
 	.release = smo8800_misc_release,
 };
drivers/platform/x86/intel/pmc/core.c +12 -12
index 10c96c1a850a..f419cc485411 100644
@@ -525,18 +525,18 @@ int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value, int ignore)
 	return 0;
 }
 
-static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-					 const char __user *userbuf,
-					 size_t count, loff_t *ppos)
+static ssize_t pmc_core_ltr_ignore_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct pmc_dev *pmcdev = s->private;
+	size_t count = iov_iter_count(from);
 	u32 buf_size, value;
 	int err;
 
 	buf_size = min_t(u32, count, 64);
 
-	err = kstrtou32_from_user(userbuf, buf_size, 10, &value);
+	err = kstrtou32_from_iter(from, buf_size, 10, &value);
 	if (err)
 		return err;
 
@@ -557,8 +557,8 @@ static int pmc_core_ltr_ignore_open(struct inode *inode, struct file *file)
 
 static const struct file_operations pmc_core_ltr_ignore_ops = {
 	.open           = pmc_core_ltr_ignore_open,
-	.read           = seq_read,
-	.write          = pmc_core_ltr_ignore_write,
+	.read_iter      = seq_read_iter,
+	.write_iter     = pmc_core_ltr_ignore_write,
 	.llseek         = seq_lseek,
 	.release        = single_release,
 };
@@ -911,11 +911,11 @@ static int pmc_core_lpm_latch_mode_show(struct seq_file *s, void *unused)
 	return 0;
 }
 
-static ssize_t pmc_core_lpm_latch_mode_write(struct file *file,
-					     const char __user *userbuf,
-					     size_t count, loff_t *ppos)
+static ssize_t pmc_core_lpm_latch_mode_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 pmc_dev *pmcdev = s->private;
 	struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN];
 	bool clear = false, c10 = false;
@@ -925,7 +925,7 @@ static ssize_t pmc_core_lpm_latch_mode_write(struct file *file,
 
 	if (count > sizeof(buf) - 1)
 		return -EINVAL;
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 	buf[count] = '\0';
 
drivers/platform/x86/intel/pmc/core.h +2 -2
index 83504c49a0e3..5e4d1bef58e8 100644
@@ -609,8 +609,8 @@ static int __name ## _open(struct inode *inode, struct file *file)	\
 static const struct file_operations __name ## _fops = {			\
 	.owner		= THIS_MODULE,					\
 	.open		= __name ## _open,				\
-	.read		= seq_read,					\
-	.write		= __name ## _write,				\
+	.read_iter	= seq_read_iter,				\
+	.write_iter	= __name ## _write,				\
 	.release	= single_release,				\
 }
 
drivers/platform/x86/intel/telemetry/debugfs.c +12 -12
index 1d4d0fbfd63c..1c2b05418345 100644
@@ -679,14 +679,14 @@ static int telem_pss_trc_verb_show(struct seq_file *s, void *unused)
 	return 0;
 }
 
-static ssize_t telem_pss_trc_verb_write(struct file *file,
-					const char __user *userbuf,
-					size_t count, loff_t *ppos)
+static ssize_t telem_pss_trc_verb_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	u32 verbosity;
 	int err;
 
-	err = kstrtou32_from_user(userbuf, count, 0, &verbosity);
+	err = kstrtou32_from_iter(from, count, 0, &verbosity);
 	if (err)
 		return err;
 
@@ -706,8 +706,8 @@ static int telem_pss_trc_verb_open(struct inode *inode, struct file *file)
 
 static const struct file_operations telem_pss_trc_verb_ops = {
 	.open		= telem_pss_trc_verb_open,
-	.read		= seq_read,
-	.write		= telem_pss_trc_verb_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= telem_pss_trc_verb_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -727,14 +727,14 @@ static int telem_ioss_trc_verb_show(struct seq_file *s, void *unused)
 	return 0;
 }
 
-static ssize_t telem_ioss_trc_verb_write(struct file *file,
-					 const char __user *userbuf,
-					 size_t count, loff_t *ppos)
+static ssize_t telem_ioss_trc_verb_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	u32 verbosity;
 	int err;
 
-	err = kstrtou32_from_user(userbuf, count, 0, &verbosity);
+	err = kstrtou32_from_iter(from, count, 0, &verbosity);
 	if (err)
 		return err;
 
@@ -754,8 +754,8 @@ static int telem_ioss_trc_verb_open(struct inode *inode, struct file *file)
 
 static const struct file_operations telem_ioss_trc_verb_ops = {
 	.open		= telem_ioss_trc_verb_open,
-	.read		= seq_read,
-	.write		= telem_ioss_trc_verb_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= telem_ioss_trc_verb_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
drivers/platform/x86/intel/tpmi.c +6 -5
index 910df7c654f4..1de0ecfcf1e7 100644
@@ -438,10 +438,11 @@ static int tpmi_mem_dump_show(struct seq_file *s, void *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(tpmi_mem_dump);
 
-static ssize_t mem_write(struct file *file, const char __user *userbuf, size_t len, loff_t *ppos)
+static ssize_t mem_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct intel_tpmi_pm_feature *pfs = m->private;
+	size_t len = iov_iter_count(from);
 	u32 addr, value, punit, size;
 	u32 num_elems, *array;
 	void __iomem *mem;
@@ -451,7 +452,7 @@ static ssize_t mem_write(struct file *file, const char __user *userbuf, size_t l
 	if (!size)
 		return -EIO;
 
-	ret = parse_int_array_user(userbuf, len, (int **)&array);
+	ret = parse_int_array_iter(from, (int **)&array);
 	if (ret < 0)
 		return ret;
 
@@ -510,8 +511,8 @@ static int mem_write_open(struct inode *inode, struct file *file)
 
 static const struct file_operations mem_write_ops = {
 	.open           = mem_write_open,
-	.read           = seq_read,
-	.write          = mem_write,
+	.read_iter      = seq_read_iter,
+	.write_iter     = mem_write,
 	.llseek         = seq_lseek,
 	.release        = single_release,
 };
drivers/platform/x86/sony-laptop.c +2 -1
index 40878e327afd..6308feb23665 100644
@@ -4097,6 +4097,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(sonypi_misc_read);
 
 static __poll_t sonypi_misc_poll(struct file *file, poll_table *wait)
 {
@@ -4249,7 +4250,7 @@ static long sonypi_misc_ioctl(struct file *fp, unsigned int cmd,
 
 static const struct file_operations sonypi_misc_fops = {
 	.owner		= THIS_MODULE,
-	.read		= sonypi_misc_read,
+	.read_iter	= sonypi_misc_read_iter,
 	.poll		= sonypi_misc_poll,
 	.open		= sonypi_misc_open,
 	.release	= sonypi_misc_release,
Signature · 1 line
2.43.0
author maintainer
#190 lore raw

PATCH 184/437 drivers/mtd: convert to ->read_iter and ->write_iter

In reply to Jens Axboe
---
 drivers/mtd/mtdchar.c   | 52 ++++++++++++++++++------------------
 drivers/mtd/ubi/cdev.c  | 58 ++++++++++++++++++++---------------------
 drivers/mtd/ubi/debug.c | 38 ++++++++++++---------------
 drivers/mtd/ubi/ubi.h   |  4 +--
 drivers/mtd/ubi/upd.c   | 24 ++++++++---------
 5 files changed, 83 insertions(+), 93 deletions(-)
drivers/mtd/mtdchar.c +25 -27
index 8dc4f5c493fc..0e3b6674f081 100644
@@ -124,10 +124,10 @@ static int mtdchar_close(struct inode *inode, struct file *file)
  * alignment requirements are not met in the NAND subdriver.
  */
 
-static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
-			loff_t *ppos)
+static ssize_t mtdchar_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mtd_file_info *mfi = file->private_data;
+	struct mtd_file_info *mfi = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct mtd_info *mtd = mfi->mtd;
 	size_t retlen;
 	size_t total_retlen=0;
@@ -138,9 +138,9 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
 
 	pr_debug("MTD_read\n");
 
-	if (*ppos + count > mtd->size) {
-		if (*ppos < mtd->size)
-			count = mtd->size - *ppos;
+	if (iocb->ki_pos + count > mtd->size) {
+		if (iocb->ki_pos < mtd->size)
+			count = mtd->size - iocb->ki_pos;
 		else
 			count = 0;
 	}
@@ -157,11 +157,11 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
 
 		switch (mfi->mode) {
 		case MTD_FILE_MODE_OTP_FACTORY:
-			ret = mtd_read_fact_prot_reg(mtd, *ppos, len,
+			ret = mtd_read_fact_prot_reg(mtd, iocb->ki_pos, len,
 						     &retlen, kbuf);
 			break;
 		case MTD_FILE_MODE_OTP_USER:
-			ret = mtd_read_user_prot_reg(mtd, *ppos, len,
+			ret = mtd_read_user_prot_reg(mtd, iocb->ki_pos, len,
 						     &retlen, kbuf);
 			break;
 		case MTD_FILE_MODE_RAW:
@@ -173,12 +173,12 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
 			ops.oobbuf = NULL;
 			ops.len = len;
 
-			ret = mtd_read_oob(mtd, *ppos, &ops);
+			ret = mtd_read_oob(mtd, iocb->ki_pos, &ops);
 			retlen = ops.retlen;
 			break;
 		}
 		default:
-			ret = mtd_read(mtd, *ppos, len, &retlen, kbuf);
+			ret = mtd_read(mtd, iocb->ki_pos, len, &retlen, kbuf);
 		}
 		/* Nand returns -EBADMSG on ECC errors, but it returns
 		 * the data. For our userspace tools it is important
@@ -190,8 +190,8 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
 		 * must be aware of the fact that it deals with NAND
 		 */
 		if (!ret || mtd_is_bitflip_or_eccerr(ret)) {
-			*ppos += retlen;
-			if (copy_to_user(buf, kbuf, retlen)) {
+			iocb->ki_pos += retlen;
+			if (!copy_to_iter_full(kbuf, retlen, to)) {
 				kfree(kbuf);
 				return -EFAULT;
 			}
@@ -199,7 +199,6 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
 				total_retlen += retlen;
 
 			count -= retlen;
-			buf += retlen;
 			if (retlen == 0)
 				count = 0;
 		}
@@ -214,10 +213,10 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
 	return total_retlen;
 } /* mtdchar_read */
 
-static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t count,
-			loff_t *ppos)
+static ssize_t mtdchar_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mtd_file_info *mfi = file->private_data;
+	struct mtd_file_info *mfi = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct mtd_info *mtd = mfi->mtd;
 	size_t size = count;
 	char *kbuf;
@@ -228,11 +227,11 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
 
 	pr_debug("MTD_write\n");
 
-	if (*ppos >= mtd->size)
+	if (iocb->ki_pos >= mtd->size)
 		return -ENOSPC;
 
-	if (*ppos + count > mtd->size)
-		count = mtd->size - *ppos;
+	if (iocb->ki_pos + count > mtd->size)
+		count = mtd->size - iocb->ki_pos;
 
 	if (!count)
 		return 0;
@@ -244,7 +243,7 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
 	while (count) {
 		len = min_t(size_t, count, size);
 
-		if (copy_from_user(kbuf, buf, len)) {
+		if (!copy_from_iter_full(kbuf, len, from)) {
 			kfree(kbuf);
 			return -EFAULT;
 		}
@@ -254,7 +253,7 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
 			ret = -EROFS;
 			break;
 		case MTD_FILE_MODE_OTP_USER:
-			ret = mtd_write_user_prot_reg(mtd, *ppos, len,
+			ret = mtd_write_user_prot_reg(mtd, iocb->ki_pos, len,
 						      &retlen, kbuf);
 			break;
 
@@ -268,13 +267,13 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
 			ops.ooboffs = 0;
 			ops.len = len;
 
-			ret = mtd_write_oob(mtd, *ppos, &ops);
+			ret = mtd_write_oob(mtd, iocb->ki_pos, &ops);
 			retlen = ops.retlen;
 			break;
 		}
 
 		default:
-			ret = mtd_write(mtd, *ppos, len, &retlen, kbuf);
+			ret = mtd_write(mtd, iocb->ki_pos, len, &retlen, kbuf);
 		}
 
 		/*
@@ -286,10 +285,9 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
 			break;
 
 		if (!ret) {
-			*ppos += retlen;
+			iocb->ki_pos += retlen;
 			total_retlen += retlen;
 			count -= retlen;
-			buf += retlen;
 		}
 		else {
 			kfree(kbuf);
@@ -1401,8 +1399,8 @@ static int mtdchar_mmap(struct file *file, struct vm_area_struct *vma)
 static const struct file_operations mtd_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= mtdchar_lseek,
-	.read		= mtdchar_read,
-	.write		= mtdchar_write,
+	.read_iter	= mtdchar_read,
+	.write_iter	= mtdchar_write,
 	.unlocked_ioctl	= mtdchar_unlocked_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= mtdchar_compat_ioctl,
drivers/mtd/ubi/cdev.c +28 -30

158 lines not on this page · raw message

drivers/mtd/ubi/debug.c +17 -21
index d57f52bd2ff3..2b364dd8e92e 100644
@@ -325,11 +325,11 @@ void ubi_debugfs_exit(void)
 }
 
 /* Read an UBI debugfs file */
-static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t dfs_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	unsigned long ubi_num = (unsigned long)file->private_data;
-	struct dentry *dent = file->f_path.dentry;
+	unsigned long ubi_num = (unsigned long)iocb->ki_filp->private_data;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
+	size_t count = iov_iter_count(to);
 	struct ubi_device *ubi;
 	struct ubi_debug_info *d;
 	char buf[16];
@@ -354,23 +354,19 @@ static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
 		val = d->emulate_io_failures;
 	else if (dent == d->dfs_emulate_failures) {
 		snprintf(buf, sizeof(buf), "0x%04x\n", d->emulate_failures);
-		count = simple_read_from_buffer(user_buf, count, ppos,
-						buf, strlen(buf));
+		count = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 		goto out;
 	} else if (dent == d->dfs_emulate_power_cut) {
 		snprintf(buf, sizeof(buf), "%u\n", d->emulate_power_cut);
-		count = simple_read_from_buffer(user_buf, count, ppos,
-						buf, strlen(buf));
+		count = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 		goto out;
 	} else if (dent == d->dfs_power_cut_min) {
 		snprintf(buf, sizeof(buf), "%u\n", d->power_cut_min);
-		count = simple_read_from_buffer(user_buf, count, ppos,
-						buf, strlen(buf));
+		count = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 		goto out;
 	} else if (dent == d->dfs_power_cut_max) {
 		snprintf(buf, sizeof(buf), "%u\n", d->power_cut_max);
-		count = simple_read_from_buffer(user_buf, count, ppos,
-						buf, strlen(buf));
+		count = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 		goto out;
 	} else {
 		count = -EINVAL;
@@ -384,7 +380,7 @@ static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
 	buf[1] = '\n';
 	buf[2] = 0x00;
 
-	count = simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	count = simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 
 out:
 	ubi_put_device(ubi);
@@ -392,11 +388,11 @@ static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
 }
 
 /* Write an UBI debugfs file */
-static ssize_t dfs_file_write(struct file *file, const char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t dfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	unsigned long ubi_num = (unsigned long)file->private_data;
-	struct dentry *dent = file->f_path.dentry;
+	unsigned long ubi_num = (unsigned long)iocb->ki_filp->private_data;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
+	size_t count = iov_iter_count(from);
 	struct ubi_device *ubi;
 	struct ubi_debug_info *d;
 	size_t buf_size;
@@ -409,7 +405,7 @@ static ssize_t dfs_file_write(struct file *file, const char __user *user_buf,
 	d = &ubi->dbg;
 
 	buf_size = min_t(size_t, count, (sizeof(buf) - 1));
-	if (copy_from_user(buf, user_buf, buf_size)) {
+	if (!copy_from_iter_full(buf, buf_size, from)) {
 		count = -EFAULT;
 		goto out;
 	}
@@ -467,8 +463,8 @@ static ssize_t dfs_file_write(struct file *file, const char __user *user_buf,
  * detailed_erase_block_info
  */
 static const struct file_operations dfs_fops = {
-	.read   = dfs_file_read,
-	.write  = dfs_file_write,
+	.read_iter   = dfs_file_read,
+	.write_iter  = dfs_file_write,
 	.open	= simple_open,
 	.llseek = no_llseek,
 	.owner  = THIS_MODULE,
@@ -576,7 +572,7 @@ static int eraseblk_count_release(struct inode *inode, struct file *f)
 static const struct file_operations eraseblk_count_fops = {
 	.owner = THIS_MODULE,
 	.open = eraseblk_count_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = eraseblk_count_release,
 };
drivers/mtd/ubi/ubi.h +2 -2
index 32009a24869e..c932b1d31e6b 100644
@@ -852,11 +852,11 @@ void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol);
 int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
 		     long long bytes);
 int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
-			 const void __user *buf, int count);
+			 struct iov_iter *from);
 int ubi_start_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
 			 const struct ubi_leb_change_req *req);
 int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
-			     const void __user *buf, int count);
+			     struct iov_iter *from);
 
 /* misc.c */
 int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf,
drivers/mtd/ubi/upd.c +11 -13
index 962f693cf882..6fa6e5b67631 100644
@@ -253,8 +253,7 @@ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
  * ubi_more_update_data - write more update data.
  * @ubi: UBI device description object
  * @vol: volume description object
- * @buf: write data (user-space memory buffer)
- * @count: how much bytes to write
+ * @from: write data (user-space memory buffer)
  *
  * This function writes more data to the volume which is being updated. It may
  * be called arbitrary number of times until all the update data arriveis. This
@@ -263,11 +262,12 @@ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
  * negative error code in case of failure.
  */
 int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
-			 const void __user *buf, int count)
+			 struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	int lnum, offs, err = 0, len, to_write = count;
 
-	dbg_gen("write %d of %lld bytes, %lld already passed",
+	dbg_gen("write %zd of %lld bytes, %lld already passed",
 		count, vol->upd_bytes, vol->upd_received);
 
 	if (ubi->ro_mode)
@@ -293,7 +293,7 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
 		if (len > count)
 			len = count;
 
-		err = copy_from_user(vol->upd_buf + offs, buf, len);
+		err = !copy_from_iter_full(vol->upd_buf + offs, len, from);
 		if (err)
 			return -EFAULT;
 
@@ -314,7 +314,6 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
 
 		vol->upd_received += len;
 		count -= len;
-		buf += len;
 		lnum += 1;
 	}
 
@@ -328,7 +327,7 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
 		else
 			len = count;
 
-		err = copy_from_user(vol->upd_buf, buf, len);
+		err = !copy_from_iter_full(vol->upd_buf, len, from);
 		if (err)
 			return -EFAULT;
 
@@ -343,7 +342,6 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
 		vol->upd_received += len;
 		count -= len;
 		lnum += 1;
-		buf += len;
 	}
 
 	ubi_assert(vol->upd_received <= vol->upd_bytes);
@@ -367,8 +365,7 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
  * ubi_more_leb_change_data - accept more data for atomic LEB change.
  * @ubi: UBI device description object
  * @vol: volume description object
- * @buf: write data (user-space memory buffer)
- * @count: how much bytes to write
+ * @from: write data (user-space memory buffer)
  *
  * This function accepts more data to the volume which is being under the
  * "atomic LEB change" operation. It may be called arbitrary number of times
@@ -378,11 +375,12 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
  * of failure.
  */
 int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
-			     const void __user *buf, int count)
+			     struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	int err;
 
-	dbg_gen("write %d of %lld bytes, %lld already passed",
+	dbg_gen("write %zd of %lld bytes, %lld already passed",
 		count, vol->upd_bytes, vol->upd_received);
 
 	if (ubi->ro_mode)
@@ -391,7 +389,7 @@ int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
 	if (vol->upd_received + count > vol->upd_bytes)
 		count = vol->upd_bytes - vol->upd_received;
 
-	err = copy_from_user(vol->upd_buf + vol->upd_received, buf, count);
+	err = !copy_from_iter_full(vol->upd_buf + vol->upd_received, count, from);
 	if (err)
 		return -EFAULT;
 
Signature · 1 line
2.43.0
author maintainer
#191 lore raw

PATCH 185/437 scsi: bfa: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/bfa/bfad_debugfs.c | 51 ++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 27 deletions(-)
drivers/scsi/bfa/bfad_debugfs.c +24 -27
index 52db147d9979..f9e1842e3a59 100644
@@ -167,17 +167,15 @@ bfad_debugfs_lseek(struct file *file, loff_t offset, int orig)
 				debug->buffer_len);
 }
 
-static ssize_t
-bfad_debugfs_read(struct file *file, char __user *buf,
-			size_t nbytes, loff_t *pos)
+static ssize_t bfad_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct bfad_debug_info *debug = file->private_data;
+	struct bfad_debug_info *debug = iocb->ki_filp->private_data;
 
 	if (!debug || !debug->debug_buffer)
 		return 0;
 
-	return simple_read_from_buffer(buf, nbytes, pos,
-				debug->debug_buffer, debug->buffer_len);
+	return simple_copy_to_iter(debug->debug_buffer, &iocb->ki_pos,
+					debug->buffer_len, to);
 }
 
 #define BFA_REG_CT_ADDRSZ	(0x40000)
@@ -210,22 +208,21 @@ bfad_reg_offset_check(struct bfa_s *bfa, u32 offset, u32 len)
 	return BFA_STATUS_OK;
 }
 
-static ssize_t
-bfad_debugfs_read_regrd(struct file *file, char __user *buf,
-		size_t nbytes, loff_t *pos)
+static ssize_t bfad_debugfs_read_regrd(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct bfad_debug_info *regrd_debug = file->private_data;
+	struct bfad_debug_info *regrd_debug = iocb->ki_filp->private_data;
 	struct bfad_port_s *port = (struct bfad_port_s *)regrd_debug->i_private;
+	size_t nbytes = iov_iter_count(to);
 	struct bfad_s *bfad = port->bfad;
 	ssize_t rc;
 
 	if (!bfad->regdata)
 		return 0;
 
-	rc = simple_read_from_buffer(buf, nbytes, pos,
-			bfad->regdata, bfad->reglen);
+	rc = simple_copy_to_iter(bfad->regdata, &iocb->ki_pos, bfad->reglen,
+					to);
 
-	if ((*pos + nbytes) >= bfad->reglen) {
+	if ((iocb->ki_pos + nbytes) >= bfad->reglen) {
 		kfree(bfad->regdata);
 		bfad->regdata = NULL;
 		bfad->reglen = 0;
@@ -235,11 +232,11 @@ bfad_debugfs_read_regrd(struct file *file, char __user *buf,
 }
 
 static ssize_t
-bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
-		size_t nbytes, loff_t *ppos)
+bfad_debugfs_write_regrd(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct bfad_debug_info *regrd_debug = file->private_data;
+	struct bfad_debug_info *regrd_debug = iocb->ki_filp->private_data;
 	struct bfad_port_s *port = (struct bfad_port_s *)regrd_debug->i_private;
+	size_t nbytes  = iov_iter_count(from);
 	struct bfad_s *bfad = port->bfad;
 	struct bfa_s *bfa = &bfad->bfa;
 	struct bfa_ioc_s *ioc = &bfa->ioc;
@@ -250,7 +247,7 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
 	unsigned long flags;
 	void *kern_buf;
 
-	kern_buf = memdup_user(buf, nbytes);
+	kern_buf = iterdup(from, nbytes);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
@@ -304,11 +301,11 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
 }
 
 static ssize_t
-bfad_debugfs_write_regwr(struct file *file, const char __user *buf,
-		size_t nbytes, loff_t *ppos)
+bfad_debugfs_write_regwr(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct bfad_debug_info *debug = file->private_data;
+	struct bfad_debug_info *debug = iocb->ki_filp->private_data;
 	struct bfad_port_s *port = (struct bfad_port_s *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	struct bfad_s *bfad = port->bfad;
 	struct bfa_s *bfa = &bfad->bfa;
 	struct bfa_ioc_s *ioc = &bfa->ioc;
@@ -317,7 +314,7 @@ bfad_debugfs_write_regwr(struct file *file, const char __user *buf,
 	unsigned long flags;
 	void *kern_buf;
 
-	kern_buf = memdup_user(buf, nbytes);
+	kern_buf = iterdup(from, nbytes);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
@@ -382,7 +379,7 @@ static const struct file_operations bfad_debugfs_op_drvtrc = {
 	.owner		=	THIS_MODULE,
 	.open		=	bfad_debugfs_open_drvtrc,
 	.llseek		=	bfad_debugfs_lseek,
-	.read		=	bfad_debugfs_read,
+	.read_iter	=	bfad_debugfs_read,
 	.release	=	bfad_debugfs_release,
 };
 
@@ -390,7 +387,7 @@ static const struct file_operations bfad_debugfs_op_fwtrc = {
 	.owner		=	THIS_MODULE,
 	.open		=	bfad_debugfs_open_fwtrc,
 	.llseek		=	bfad_debugfs_lseek,
-	.read		=	bfad_debugfs_read,
+	.read_iter	=	bfad_debugfs_read,
 	.release	=	bfad_debugfs_release_fwtrc,
 };
 
@@ -398,7 +395,7 @@ static const struct file_operations bfad_debugfs_op_fwsave = {
 	.owner		=	THIS_MODULE,
 	.open		=	bfad_debugfs_open_fwsave,
 	.llseek		=	bfad_debugfs_lseek,
-	.read		=	bfad_debugfs_read,
+	.read_iter	=	bfad_debugfs_read,
 	.release	=	bfad_debugfs_release_fwtrc,
 };
 
@@ -406,8 +403,8 @@ static const struct file_operations bfad_debugfs_op_regrd = {
 	.owner		=	THIS_MODULE,
 	.open		=	bfad_debugfs_open_reg,
 	.llseek		=	bfad_debugfs_lseek,
-	.read		=	bfad_debugfs_read_regrd,
-	.write		=	bfad_debugfs_write_regrd,
+	.read_iter	=	bfad_debugfs_read_regrd,
+	.write_iter	=	bfad_debugfs_write_regrd,
 	.release	=	bfad_debugfs_release,
 };
 
@@ -415,7 +412,7 @@ static const struct file_operations bfad_debugfs_op_regwr = {
 	.owner		=	THIS_MODULE,
 	.open		=	bfad_debugfs_open_reg,
 	.llseek		=	bfad_debugfs_lseek,
-	.write		=	bfad_debugfs_write_regwr,
+	.write_iter	=	bfad_debugfs_write_regwr,
 	.release	=	bfad_debugfs_release,
 };
 
Signature · 1 line
2.43.0
author maintainer
#192 lore raw

PATCH 186/437 scsi: csiostor: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/csiostor/csio_init.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/scsi/csiostor/csio_init.c +8 -8
index d649b7a2a879..177d485975e1 100644
@@ -59,13 +59,14 @@ static struct scsi_transport_template *csio_fcoe_transport_vport;
 /*
  * debugfs support
  */
-static ssize_t
-csio_mem_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t csio_mem_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	loff_t pos = *ppos;
+	loff_t pos = iocb->ki_pos;
+	struct file *file = iocb->ki_filp;
 	loff_t avail = file_inode(file)->i_size;
 	unsigned int mem = (uintptr_t)file->private_data & 3;
 	struct csio_hw *hw = file->private_data - mem;
+	size_t count = iov_iter_count(to);
 
 	if (pos < 0)
 		return -EINVAL;
@@ -90,22 +91,21 @@ csio_mem_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
 		ofst = pos % sizeof(data);
 		len = min(count, sizeof(data) - ofst);
-		if (copy_to_user(buf, (u8 *)data + ofst, len))
+		if (!copy_to_iter_full((u8 *)data + ofst, len, to))
 			return -EFAULT;
 
-		buf += len;
 		pos += len;
 		count -= len;
 	}
-	count = pos - *ppos;
-	*ppos = pos;
+	count = pos - iocb->ki_pos;
+	iocb->ki_pos = pos;
 	return count;
 }
 
 static const struct file_operations csio_mem_debugfs_fops = {
 	.owner   = THIS_MODULE,
 	.open    = simple_open,
-	.read    = csio_mem_read,
+	.read_iter = csio_mem_read,
 	.llseek  = default_llseek,
 };
 
Signature · 1 line
2.43.0
author maintainer
#193 lore raw

PATCH 187/437 scsi: fnic: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/fnic/fnic_debugfs.c | 82 +++++++++++++-------------------
 1 file changed, 33 insertions(+), 49 deletions(-)
drivers/scsi/fnic/fnic_debugfs.c +33 -49
index 2619a2d4f5f1..2b2315e239f6 100644
@@ -95,15 +95,13 @@ void fnic_debugfs_terminate(void)
  * Returns:
  * This function returns the amount of data that was read.
  */
-static ssize_t fnic_trace_ctrl_read(struct file *filp,
-				  char __user *ubuf,
-				  size_t cnt, loff_t *ppos)
+static ssize_t fnic_trace_ctrl_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[64];
 	int len;
 	u8 *trace_type;
 	len = 0;
-	trace_type = (u8 *)filp->private_data;
+	trace_type = (u8 *)iocb->ki_filp->private_data;
 	if (*trace_type == fc_trc_flag->fnic_trace)
 		len = sprintf(buf, "%d\n", fnic_tracing_enabled);
 	else if (*trace_type == fc_trc_flag->fc_trace)
@@ -113,7 +111,7 @@ static ssize_t fnic_trace_ctrl_read(struct file *filp,
 	else
 		pr_err("fnic: Cannot read to any debugfs file\n");
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 /*
@@ -133,20 +131,19 @@ static ssize_t fnic_trace_ctrl_read(struct file *filp,
  * Returns:
  * This function returns the amount of data that was written.
  */
-static ssize_t fnic_trace_ctrl_write(struct file *filp,
-				  const char __user *ubuf,
-				  size_t cnt, loff_t *ppos)
+static ssize_t fnic_trace_ctrl_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char buf[64];
 	unsigned long val;
 	int ret;
 	u8 *trace_type;
-	trace_type = (u8 *)filp->private_data;
+	size_t cnt = iov_iter_count(from);
+	trace_type = (u8 *)iocb->ki_filp->private_data;
 
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -164,16 +161,15 @@ static ssize_t fnic_trace_ctrl_write(struct file *filp,
 	else
 		pr_err("fnic: cannot write to any debugfs file\n");
 
-	(*ppos)++;
-
+	iocb->ki_pos++;
 	return cnt;
 }
 
 static const struct file_operations fnic_trace_ctrl_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = fnic_trace_ctrl_read,
-	.write = fnic_trace_ctrl_write,
+	.read_iter = fnic_trace_ctrl_read,
+	.write_iter = fnic_trace_ctrl_write,
 };
 
 /*
@@ -267,17 +263,12 @@ static loff_t fnic_trace_debugfs_lseek(struct file *file,
  * This function returns the amount of data that was read (this could be
  * less than @nbytes if the end of the file was reached).
  */
-static ssize_t fnic_trace_debugfs_read(struct file *file,
-					char __user *ubuf,
-					size_t nbytes,
-					loff_t *pos)
+static ssize_t fnic_trace_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	fnic_dbgfs_t *fnic_dbg_prt = file->private_data;
-	int rc = 0;
-	rc = simple_read_from_buffer(ubuf, nbytes, pos,
-				  fnic_dbg_prt->buffer,
-				  fnic_dbg_prt->buffer_len);
-	return rc;
+	fnic_dbgfs_t *fnic_dbg_prt = iocb->ki_filp->private_data;
+
+	return simple_copy_to_iter(fnic_dbg_prt->buffer, &iocb->ki_pos,
+					fnic_dbg_prt->buffer_len, to);
 }
 
 /*
@@ -307,7 +298,7 @@ static const struct file_operations fnic_trace_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = fnic_trace_debugfs_open,
 	.llseek = fnic_trace_debugfs_lseek,
-	.read = fnic_trace_debugfs_read,
+	.read_iter = fnic_trace_debugfs_read,
 	.release = fnic_trace_debugfs_release,
 };
 
@@ -459,18 +450,16 @@ static int fnic_reset_stats_open(struct inode *inode, struct file *file)
  * Returns:
  * This function returns the amount of data that was read.
  */
-static ssize_t fnic_reset_stats_read(struct file *file,
-					char __user *ubuf,
-					size_t cnt, loff_t *ppos)
+static ssize_t fnic_reset_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct stats_debug_info *debug = file->private_data;
+	struct stats_debug_info *debug = iocb->ki_filp->private_data;
 	struct fnic *fnic = (struct fnic *)debug->i_private;
 	char buf[64];
 	int len;
 
 	len = sprintf(buf, "%u\n", fnic->reset_stats);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 /*
@@ -487,15 +476,15 @@ static ssize_t fnic_reset_stats_read(struct file *file,
  * Returns:
  * This function returns the amount of data that was written.
  */
-static ssize_t fnic_reset_stats_write(struct file *file,
-					const char __user *ubuf,
-					size_t cnt, loff_t *ppos)
+static ssize_t fnic_reset_stats_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct stats_debug_info *debug = file->private_data;
+	struct stats_debug_info *debug = iocb->ki_filp->private_data;
 	struct fnic *fnic = (struct fnic *)debug->i_private;
 	struct fnic_stats *stats = &fnic->fnic_stats;
 	u64 *io_stats_p = (u64 *)&stats->io_stats;
 	u64 *fw_stats_p = (u64 *)&stats->fw_stats;
+	size_t cnt = iov_iter_count(from);
 	char buf[64];
 	unsigned long val;
 	int ret;
@@ -503,7 +492,7 @@ static ssize_t fnic_reset_stats_write(struct file *file,
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -534,7 +523,7 @@ static ssize_t fnic_reset_stats_write(struct file *file,
 		ktime_get_real_ts64(&stats->stats_timestamps.last_reset_time);
 	}
 
-	(*ppos)++;
+	iocb->ki_pos++;
 	return cnt;
 }
 
@@ -615,17 +604,12 @@ static int fnic_stats_debugfs_open(struct inode *inode,
  * This function returns the amount of data that was read (this could be
  * less than @nbytes if the end of the file was reached).
  */
-static ssize_t fnic_stats_debugfs_read(struct file *file,
-					char __user *ubuf,
-					size_t nbytes,
-					loff_t *pos)
+static ssize_t fnic_stats_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct stats_debug_info *debug = file->private_data;
-	int rc = 0;
-	rc = simple_read_from_buffer(ubuf, nbytes, pos,
-					debug->debug_buffer,
-					debug->buffer_len);
-	return rc;
+	struct stats_debug_info *debug = iocb->ki_filp->private_data;
+
+	return simple_copy_to_iter(debug->debug_buffer, &iocb->ki_pos,
+					debug->buffer_len, to);
 }
 
 /*
@@ -653,15 +637,15 @@ static int fnic_stats_debugfs_release(struct inode *inode,
 static const struct file_operations fnic_stats_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = fnic_stats_debugfs_open,
-	.read = fnic_stats_debugfs_read,
+	.read_iter = fnic_stats_debugfs_read,
 	.release = fnic_stats_debugfs_release,
 };
 
 static const struct file_operations fnic_reset_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = fnic_reset_stats_open,
-	.read = fnic_reset_stats_read,
-	.write = fnic_reset_stats_write,
+	.read_iter = fnic_reset_stats_read,
+	.write_iter = fnic_reset_stats_write,
 	.release = fnic_reset_stats_release,
 };
 
Signature · 1 line
2.43.0
author maintainer
#194 lore raw

PATCH 188/437 scsi: hisi_sas: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 105 ++++++++++++-------------
 1 file changed, 52 insertions(+), 53 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +52 -53
index 7d2a33514538..79ad1662f601 100644
@@ -3858,17 +3858,17 @@ static void debugfs_create_files_v3_hw(struct hisi_hba *hisi_hba)
 			    &debugfs_ras_v3_hw_fops);
 }
 
-static ssize_t debugfs_trigger_dump_v3_hw_write(struct file *file,
-						const char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t debugfs_trigger_dump_v3_hw_write(struct kiocb *iocb,
+						struct iov_iter *from)
 {
-	struct hisi_hba *hisi_hba = file->f_inode->i_private;
+	struct hisi_hba *hisi_hba = iocb->ki_filp->f_inode->i_private;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 
 	if (count > 8)
 		return -EFAULT;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	if (buf[0] != '1')
@@ -3885,7 +3885,7 @@ static ssize_t debugfs_trigger_dump_v3_hw_write(struct file *file,
 }
 
 static const struct file_operations debugfs_trigger_dump_v3_hw_fops = {
-	.write = &debugfs_trigger_dump_v3_hw_write,
+	.write_iter = debugfs_trigger_dump_v3_hw_write,
 	.owner = THIS_MODULE,
 };
 
@@ -3923,12 +3923,12 @@ static int debugfs_bist_linkrate_v3_hw_show(struct seq_file *s, void *p)
 	return 0;
 }
 
-static ssize_t debugfs_bist_linkrate_v3_hw_write(struct file *filp,
-						 const char __user *buf,
-						 size_t count, loff_t *ppos)
+static ssize_t debugfs_bist_linkrate_v3_hw_write_iter(struct kiocb *iocb,
+						      struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct hisi_hba *hisi_hba = m->private;
+	size_t count = iov_iter_count(from);
 	char kbuf[16] = {}, *pkbuf;
 	bool found = false;
 	int i;
@@ -3939,7 +3939,7 @@ static ssize_t debugfs_bist_linkrate_v3_hw_write(struct file *filp,
 	if (count >= sizeof(kbuf))
 		return -EOVERFLOW;
 
-	if (copy_from_user(kbuf, buf, count))
+	if (!copy_from_iter_full(kbuf, count, from))
 		return -EINVAL;
 
 	pkbuf = strstrip(kbuf);
@@ -3997,12 +3997,11 @@ static int debugfs_bist_code_mode_v3_hw_show(struct seq_file *s, void *p)
 	return 0;
 }
 
-static ssize_t debugfs_bist_code_mode_v3_hw_write(struct file *filp,
-						  const char __user *buf,
-						  size_t count,
-						  loff_t *ppos)
+static ssize_t debugfs_bist_code_mode_v3_hw_write_iter(struct kiocb *iocb,
+						       struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct hisi_hba *hisi_hba = m->private;
 	char kbuf[16] = {}, *pkbuf;
 	bool found = false;
@@ -4014,7 +4013,7 @@ static ssize_t debugfs_bist_code_mode_v3_hw_write(struct file *filp,
 	if (count >= sizeof(kbuf))
 		return -EINVAL;
 
-	if (copy_from_user(kbuf, buf, count))
+	if (!copy_from_iter_full(kbuf, count, from))
 		return -EOVERFLOW;
 
 	pkbuf = strstrip(kbuf);
@@ -4036,19 +4035,19 @@ static ssize_t debugfs_bist_code_mode_v3_hw_write(struct file *filp,
 }
 DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_code_mode_v3_hw);
 
-static ssize_t debugfs_bist_phy_v3_hw_write(struct file *filp,
-					    const char __user *buf,
-					    size_t count, loff_t *ppos)
+static ssize_t debugfs_bist_phy_v3_hw_write_iter(struct kiocb *iocb,
+						 struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct hisi_hba *hisi_hba = m->private;
+	size_t count = iov_iter_count(from);
 	unsigned int phy_no;
 	int val;
 
 	if (hisi_hba->debugfs_bist_enable)
 		return -EPERM;
 
-	val = kstrtouint_from_user(buf, count, 0, &phy_no);
+	val = kstrtouint_from_iter(from, count, 0, &phy_no);
 	if (val)
 		return val;
 
@@ -4070,19 +4069,19 @@ static int debugfs_bist_phy_v3_hw_show(struct seq_file *s, void *p)
 }
 DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_phy_v3_hw);
 
-static ssize_t debugfs_bist_cnt_v3_hw_write(struct file *filp,
-					const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t debugfs_bist_cnt_v3_hw_write_iter(struct kiocb *iocb,
+						 struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct hisi_hba *hisi_hba = m->private;
+	size_t count = iov_iter_count(from);
 	unsigned int cnt;
 	int val;
 
 	if (hisi_hba->debugfs_bist_enable)
 		return -EPERM;
 
-	val = kstrtouint_from_user(buf, count, 0, &cnt);
+	val = kstrtouint_from_iter(from, count, 0, &cnt);
 	if (val)
 		return val;
 
@@ -4130,12 +4129,12 @@ static int debugfs_bist_mode_v3_hw_show(struct seq_file *s, void *p)
 	return 0;
 }
 
-static ssize_t debugfs_bist_mode_v3_hw_write(struct file *filp,
-					     const char __user *buf,
-					     size_t count, loff_t *ppos)
+static ssize_t debugfs_bist_mode_v3_hw_write_iter(struct kiocb *iocb,
+						  struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct hisi_hba *hisi_hba = m->private;
+	size_t count = iov_iter_count(from);
 	char kbuf[16] = {}, *pkbuf;
 	bool found = false;
 	int i;
@@ -4146,7 +4145,7 @@ static ssize_t debugfs_bist_mode_v3_hw_write(struct file *filp,
 	if (count >= sizeof(kbuf))
 		return -EINVAL;
 
-	if (copy_from_user(kbuf, buf, count))
+	if (!copy_from_iter_full(kbuf, count, from))
 		return -EOVERFLOW;
 
 	pkbuf = strstrip(kbuf);
@@ -4167,16 +4166,16 @@ static ssize_t debugfs_bist_mode_v3_hw_write(struct file *filp,
 }
 DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_mode_v3_hw);
 
-static ssize_t debugfs_bist_enable_v3_hw_write(struct file *filp,
-					       const char __user *buf,
-					       size_t count, loff_t *ppos)
+static ssize_t debugfs_bist_enable_v3_hw_write_iter(struct kiocb *iocb,
+						    struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct hisi_hba *hisi_hba = m->private;
+	size_t count = iov_iter_count(from);
 	unsigned int enable;
 	int val;
 
-	val = kstrtouint_from_user(buf, count, 0, &enable);
+	val = kstrtouint_from_iter(from, count, 0, &enable);
 	if (val)
 		return val;
 
@@ -4218,15 +4217,15 @@ static const struct {
 	{ "SATA_6_0_GBPS" },
 };
 
-static ssize_t debugfs_v3_hw_write(struct file *filp,
-				   const char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t debugfs_v3_hw_write_iter(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 *val = m->private;
 	int res;
 
-	res = kstrtouint_from_user(buf, count, 0, val);
+	res = kstrtouint_from_iter(from, count, 0, val);
 	if (res)
 		return res;
 
@@ -4243,16 +4242,16 @@ static int debugfs_v3_hw_show(struct seq_file *s, void *p)
 }
 DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_v3_hw);
 
-static ssize_t debugfs_phy_down_cnt_v3_hw_write(struct file *filp,
-						const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t debugfs_phy_down_cnt_v3_hw_write_iter(struct kiocb *iocb,
+						     struct iov_iter *from)
 {
-	struct seq_file *s = filp->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct hisi_sas_phy *phy = s->private;
+	size_t count = iov_iter_count(from);
 	unsigned int set_val;
 	int res;
 
-	res = kstrtouint_from_user(buf, count, 0, &set_val);
+	res = kstrtouint_from_iter(from, count, 0, &set_val);
 	if (res)
 		return res;
 
@@ -4370,15 +4369,15 @@ static int debugfs_update_fifo_config_v3_hw(struct hisi_sas_phy *phy)
 	return 0;
 }
 
-static ssize_t debugfs_fifo_update_cfg_v3_hw_write(struct file *filp,
-						   const char __user *buf,
-						   size_t count, loff_t *ppos)
+static ssize_t debugfs_fifo_update_cfg_v3_hw_write(struct kiocb *iocb,
+						   struct iov_iter *from)
 {
-	struct hisi_sas_phy *phy = filp->private_data;
+	struct hisi_sas_phy *phy = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	bool update;
 	int val;
 
-	val = kstrtobool_from_user(buf, count, &update);
+	val = kstrtobool_from_iter(from, count, &update);
 	if (val)
 		return val;
 
@@ -4394,7 +4393,7 @@ static ssize_t debugfs_fifo_update_cfg_v3_hw_write(struct file *filp,
 
 static const struct file_operations debugfs_fifo_update_cfg_v3_hw_fops = {
 	.open = simple_open,
-	.write = debugfs_fifo_update_cfg_v3_hw_write,
+	.write_iter = debugfs_fifo_update_cfg_v3_hw_write,
 	.owner = THIS_MODULE,
 };
 
Signature · 1 line
2.43.0
author maintainer
#195 lore raw

PATCH 189/437 scsi: lpfc: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/lpfc/lpfc_debugfs.c | 427 ++++++++++++++-----------------
 1 file changed, 187 insertions(+), 240 deletions(-)
drivers/scsi/lpfc/lpfc_debugfs.c +187 -240
index a2d2b02b3418..bc75753d6c4a 100644
@@ -2146,11 +2146,11 @@ lpfc_debugfs_lockstat_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf,
-			    size_t nbytes, loff_t *ppos)
+lpfc_debugfs_lockstat_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	struct lpfc_sli4_hdw_queue *qp;
 	char mybuf[64];
 	char *pbuf;
@@ -2161,7 +2161,7 @@ lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf,
 
 	bsize = min(nbytes, (sizeof(mybuf) - 1));
 
-	if (copy_from_user(mybuf, buf, bsize))
+	if (!copy_from_iter_full(mybuf, bsize, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 
@@ -2371,12 +2371,10 @@ lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file)
 	return rc;
 }
 
-static ssize_t
-lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
-	size_t nbytes, loff_t *ppos)
+static ssize_t lpfc_debugfs_dif_err_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dentry *dent = file->f_path.dentry;
-	struct lpfc_hba *phba = file->private_data;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
+	struct lpfc_hba *phba = iocb->ki_filp->private_data;
 	char cbuf[32];
 	uint64_t tmp = 0;
 	int cnt = 0;
@@ -2410,22 +2408,22 @@ lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
 		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
 			 "0547 Unknown debugfs error injection entry\n");
 
-	return simple_read_from_buffer(buf, nbytes, ppos, &cbuf, cnt);
+	return simple_copy_to_iter(&cbuf, &iocb->ki_pos, cnt, to);
 }
 
 static ssize_t
-lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
-	size_t nbytes, loff_t *ppos)
+lpfc_debugfs_dif_err_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct dentry *dent = file->f_path.dentry;
-	struct lpfc_hba *phba = file->private_data;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
+	struct lpfc_hba *phba = iocb->ki_filp->private_data;
+	size_t nbytes = iov_iter_count(from);
 	char dstbuf[33];
 	uint64_t tmp = 0;
 	int size;
 
 	memset(dstbuf, 0, 33);
 	size = (nbytes < 32) ? nbytes : 32;
-	if (copy_from_user(dstbuf, buf, size))
+	if (!copy_from_iter_full(dstbuf, size, from))
 		return -EFAULT;
 
 	if (dent == phba->debug_InjErrLBA) {
@@ -2537,10 +2535,8 @@ lpfc_debugfs_lseek(struct file *file, loff_t off, int whence)
 
 /**
  * lpfc_debugfs_read - Read a debugfs file
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the data to.
  *
  * Description:
  * This routine reads data from from the buffer indicated in the private_data
@@ -2552,13 +2548,12 @@ lpfc_debugfs_lseek(struct file *file, loff_t off, int whence)
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
 static ssize_t
-lpfc_debugfs_read(struct file *file, char __user *buf,
-		  size_t nbytes, loff_t *ppos)
+lpfc_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(buf, nbytes, ppos, debug->buffer,
-				       debug->len);
+	return simple_copy_to_iter(debug->buffer, &iocb->ki_pos, debug->len,
+					to);
 }
 
 /**
@@ -2586,10 +2581,8 @@ lpfc_debugfs_release(struct inode *inode, struct file *file)
 
 /**
  * lpfc_debugfs_multixripools_write - Clear multi-XRI pools statistics
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * Description:
  * This routine clears multi-XRI pools statistics when buf contains "clear".
@@ -2600,10 +2593,10 @@ lpfc_debugfs_release(struct inode *inode, struct file *file)
  * space.
  **/
 static ssize_t
-lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf,
-				 size_t nbytes, loff_t *ppos)
+lpfc_debugfs_multixripools_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
+	size_t nbytes = iov_iter_count(from);
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	char mybuf[64];
 	char *pbuf;
@@ -2617,7 +2610,7 @@ lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf,
 
 	memset(mybuf, 0, sizeof(mybuf));
 
-	if (copy_from_user(mybuf, buf, nbytes))
+	if (!copy_from_iter_full(mybuf, nbytes, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 
@@ -2680,12 +2673,12 @@ lpfc_debugfs_nvmestat_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,
-			    size_t nbytes, loff_t *ppos)
+lpfc_debugfs_nvmestat_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
 	struct lpfc_hba   *phba = vport->phba;
+	size_t nbytes = iov_iter_count(from);
 	struct lpfc_nvmet_tgtport *tgtp;
 	char mybuf[64];
 	char *pbuf;
@@ -2698,7 +2691,7 @@ lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,
 
 	memset(mybuf, 0, sizeof(mybuf));
 
-	if (copy_from_user(mybuf, buf, nbytes))
+	if (!copy_from_iter_full(mybuf, nbytes, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 
@@ -2768,17 +2761,17 @@ lpfc_debugfs_scsistat_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_debugfs_scsistat_write(struct file *file, const char __user *buf,
-			    size_t nbytes, loff_t *ppos)
+lpfc_debugfs_scsistat_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	struct lpfc_hba *phba = vport->phba;
 	char mybuf[6] = {0};
 	int i;
 
-	if (copy_from_user(mybuf, buf, (nbytes >= sizeof(mybuf)) ?
-				       (sizeof(mybuf) - 1) : nbytes))
+	if (!copy_from_iter_full(mybuf, (nbytes >= sizeof(mybuf)) ?
+				       (sizeof(mybuf) - 1) : nbytes, from))
 		return -EFAULT;
 
 	if ((strncmp(&mybuf[0], "reset", strlen("reset")) == 0) ||
@@ -2822,12 +2815,12 @@ lpfc_debugfs_ioktime_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_debugfs_ioktime_write(struct file *file, const char __user *buf,
-			   size_t nbytes, loff_t *ppos)
+lpfc_debugfs_ioktime_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
 	struct lpfc_hba   *phba = vport->phba;
+	size_t nbytes = iov_iter_count(from);
 	char mybuf[64];
 	char *pbuf;
 
@@ -2836,7 +2829,7 @@ lpfc_debugfs_ioktime_write(struct file *file, const char __user *buf,
 
 	memset(mybuf, 0, sizeof(mybuf));
 
-	if (copy_from_user(mybuf, buf, nbytes))
+	if (!copy_from_iter_full(mybuf, nbytes, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 
@@ -2949,11 +2942,11 @@ lpfc_debugfs_nvmeio_trc_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
-			      size_t nbytes, loff_t *ppos)
+lpfc_debugfs_nvmeio_trc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	int i;
 	unsigned long sz;
 	char mybuf[64];
@@ -2964,7 +2957,7 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
 
 	memset(mybuf, 0, sizeof(mybuf));
 
-	if (copy_from_user(mybuf, buf, nbytes))
+	if (!copy_from_iter_full(mybuf, nbytes, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 
@@ -3054,12 +3047,12 @@ lpfc_debugfs_hdwqstat_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf,
-			    size_t nbytes, loff_t *ppos)
+lpfc_debugfs_hdwqstat_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
 	struct lpfc_hba   *phba = vport->phba;
+	size_t nbytes = iov_iter_count(from);
 	struct lpfc_hdwq_stat *c_stat;
 	char mybuf[64];
 	char *pbuf;
@@ -3070,7 +3063,7 @@ lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf,
 
 	memset(mybuf, 0, sizeof(mybuf));
 
-	if (copy_from_user(mybuf, buf, nbytes))
+	if (!copy_from_iter_full(mybuf, nbytes, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 
@@ -3139,9 +3132,10 @@ lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf,
  * This routine returns 0 when successful, it returns proper error code
  * back to the user space in error conditions.
  */
-static int lpfc_idiag_cmd_get(const char __user *buf, size_t nbytes,
+static int lpfc_idiag_cmd_get(struct iov_iter *from,
 			      struct lpfc_idiag_cmd *idiag_cmd)
 {
+	size_t nbytes = iov_iter_count(from);
 	char mybuf[64];
 	char *pbuf, *step_str;
 	int i;
@@ -3151,7 +3145,7 @@ static int lpfc_idiag_cmd_get(const char __user *buf, size_t nbytes,
 	memset(idiag_cmd, 0, sizeof(*idiag_cmd));
 	bsize = min(nbytes, (sizeof(mybuf)-1));
 
-	if (copy_from_user(mybuf, buf, bsize))
+	if (!copy_from_iter_full(mybuf, bsize, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 	step_str = strsep(&pbuf, "\t ");
@@ -3273,10 +3267,8 @@ lpfc_idiag_cmd_release(struct inode *inode, struct file *file)
 
 /**
  * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the data to.
  *
  * Description:
  * This routine reads data from the @phba pci config space according to the
@@ -3289,11 +3281,9 @@ lpfc_idiag_cmd_release(struct inode *inode, struct file *file)
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+static ssize_t lpfc_idiag_pcicfg_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	int offset_label, offset, len = 0, index = LPFC_PCI_CFG_RD_SIZE;
 	int where, count;
@@ -3316,7 +3306,7 @@ lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
 		return 0;
 	pbuffer = debug->buffer;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) {
@@ -3349,7 +3339,7 @@ lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
 		len = 0;
 		break;
 	}
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 
 pcicfg_browse:
 
@@ -3389,15 +3379,13 @@ lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
 	} else
 		idiag.offset.last_rd = 0;
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
  * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and
  * then perform the syntax check for PCI config space read or write command
@@ -3411,11 +3399,11 @@ lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
  * space.
  */
 static ssize_t
-lpfc_idiag_pcicfg_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_pcicfg_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	uint32_t where, value, count;
 	uint32_t u32val;
 	uint16_t u16val;
@@ -3430,7 +3418,7 @@ lpfc_idiag_pcicfg_write(struct file *file, const char __user *buf,
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -3571,10 +3559,8 @@ lpfc_idiag_pcicfg_write(struct file *file, const char __user *buf,
 
 /**
  * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the data to.
  *
  * Description:
  * This routine reads data from the @phba pci bar memory mapped space
@@ -3584,11 +3570,9 @@ lpfc_idiag_pcicfg_write(struct file *file, const char __user *buf,
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+static ssize_t lpfc_idiag_baracc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	int offset_label, offset, offset_run, len = 0, index;
 	int bar_num, acc_range, bar_size;
@@ -3611,7 +3595,7 @@ lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
 		return 0;
 	pbuffer = debug->buffer;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_RD) {
@@ -3652,7 +3636,7 @@ lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
 	} else
 		goto baracc_browse;
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 
 baracc_browse:
 
@@ -3713,15 +3697,13 @@ lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
 			idiag.offset.last_rd = offset;
 	}
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
  * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and
  * then perform the syntax check for PCI bar memory mapped space read or
@@ -3736,12 +3718,12 @@ lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
  * space.
  */
 static ssize_t
-lpfc_idiag_baracc_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_baracc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	uint32_t bar_num, bar_size, offset, value, acc_range;
+	size_t nbytes = iov_iter_count(from);
 	struct pci_dev *pdev;
 	void __iomem *mem_mapped_bar;
 	uint32_t if_type;
@@ -3755,7 +3737,7 @@ lpfc_idiag_baracc_write(struct file *file, const char __user *buf,
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -4024,10 +4006,8 @@ __lpfc_idiag_print_eq(struct lpfc_queue *qp, char *eqtype,
 
 /**
  * lpfc_idiag_queinfo_read - idiag debugfs read queue information
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the data to.
  *
  * Description:
  * This routine reads data from the @phba SLI4 PCI function queue information,
@@ -4040,11 +4020,9 @@ __lpfc_idiag_print_eq(struct lpfc_queue *qp, char *eqtype,
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_queinfo_read(struct file *file, char __user *buf, size_t nbytes,
-			loff_t *ppos)
+static ssize_t lpfc_idiag_queinfo_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	char *pbuffer;
 	int max_cnt, rc, x, len = 0;
@@ -4057,7 +4035,7 @@ lpfc_idiag_queinfo_read(struct file *file, char __user *buf, size_t nbytes,
 	pbuffer = debug->buffer;
 	max_cnt = LPFC_QUE_INFO_GET_BUF_SIZE - 256;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	spin_lock_irq(&phba->hbalock);
@@ -4152,14 +4130,14 @@ lpfc_idiag_queinfo_read(struct file *file, char __user *buf, size_t nbytes,
 	}
 
 	spin_unlock_irq(&phba->hbalock);
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 
 too_big:
 	len +=  scnprintf(pbuffer + len,
 		LPFC_QUE_INFO_GET_BUF_SIZE - len, "Truncated ...\n");
 out:
 	spin_unlock_irq(&phba->hbalock);
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
@@ -4249,11 +4227,9 @@ lpfc_idiag_queacc_read_qe(char *pbuffer, int len, struct lpfc_queue *pque,
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+static ssize_t lpfc_idiag_queacc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	uint32_t last_index, index, count;
 	struct lpfc_queue *pque = NULL;
 	char *pbuffer;
@@ -4268,7 +4244,7 @@ lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
 		return 0;
 	pbuffer = debug->buffer;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) {
@@ -4285,7 +4261,7 @@ lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
 	/* Read a single entry from the queue */
 	len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index);
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 
 que_browse:
 
@@ -4305,15 +4281,13 @@ lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
 		index = 0;
 	idiag.offset.last_rd = index;
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
  * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and then
  * perform the syntax check for port queue read (dump) or write (set) command
@@ -4327,12 +4301,12 @@ lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
  * space.
  **/
 static ssize_t
-lpfc_idiag_queacc_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_queacc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	uint32_t qidx, quetp, queid, index, count, offset, value;
+	size_t nbytes = iov_iter_count(from);
 	uint32_t *pentry;
 	struct lpfc_queue *pque, *qp;
 	int rc;
@@ -4340,7 +4314,7 @@ lpfc_idiag_queacc_write(struct file *file, const char __user *buf,
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -4608,10 +4582,8 @@ lpfc_idiag_drbacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
 
 /**
  * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: the buffer to write to
  *
  * Description:
  * This routine reads data from the @phba device doorbell register according
@@ -4623,11 +4595,9 @@ lpfc_idiag_drbacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+static ssize_t lpfc_idiag_drbacc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	uint32_t drb_reg_id, i;
 	char *pbuffer;
@@ -4642,7 +4612,7 @@ lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes,
 		return 0;
 	pbuffer = debug->buffer;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD)
@@ -4658,15 +4628,13 @@ lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes,
 		len = lpfc_idiag_drbacc_read_reg(phba,
 						 pbuffer, len, drb_reg_id);
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
  * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and then
  * perform the syntax check for port doorbell register read (dump) or write
@@ -4680,11 +4648,11 @@ lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes,
  * space.
  **/
 static ssize_t
-lpfc_idiag_drbacc_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_drbacc_write( struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	uint32_t drb_reg_id, value, reg_val = 0;
 	void __iomem *drb_reg;
 	int rc;
@@ -4692,7 +4660,7 @@ lpfc_idiag_drbacc_write(struct file *file, const char __user *buf,
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -4828,10 +4796,8 @@ lpfc_idiag_ctlacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
 
 /**
  * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the data to.
  *
  * Description:
  * This routine reads data from the @phba port and device registers according
@@ -4842,10 +4808,9 @@ lpfc_idiag_ctlacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
 static ssize_t
-lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+lpfc_idiag_ctlacc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	uint32_t ctl_reg_id, i;
 	char *pbuffer;
@@ -4860,7 +4825,7 @@ lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes,
 		return 0;
 	pbuffer = debug->buffer;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD)
@@ -4876,15 +4841,13 @@ lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes,
 		len = lpfc_idiag_ctlacc_read_reg(phba,
 						 pbuffer, len, ctl_reg_id);
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
  * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and then
  * perform the syntax check for port and device control register read (dump)
@@ -4895,11 +4858,11 @@ lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes,
  * space.
  **/
 static ssize_t
-lpfc_idiag_ctlacc_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_ctlacc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	uint32_t ctl_reg_id, value, reg_val = 0;
 	void __iomem *ctl_reg;
 	int rc;
@@ -4907,7 +4870,7 @@ lpfc_idiag_ctlacc_write(struct file *file, const char __user *buf,
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -5022,10 +4985,8 @@ lpfc_idiag_mbxacc_get_setup(struct lpfc_hba *phba, char *pbuffer)
 
 /**
  * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the user data to.
  *
  * Description:
  * This routine reads data from the @phba driver mailbox access debugfs setup
@@ -5035,11 +4996,9 @@ lpfc_idiag_mbxacc_get_setup(struct lpfc_hba *phba, char *pbuffer)
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+static ssize_t lpfc_idiag_mbxacc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	char *pbuffer;
 	int len = 0;
@@ -5053,7 +5012,7 @@ lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes,
 		return 0;
 	pbuffer = debug->buffer;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if ((idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP) &&
@@ -5062,15 +5021,13 @@ lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes,
 
 	len = lpfc_idiag_mbxacc_get_setup(phba, pbuffer);
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
  * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and then
  * perform the syntax check for driver mailbox command (dump) and sets up the
@@ -5081,17 +5038,17 @@ lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes,
  * space.
  **/
 static ssize_t
-lpfc_idiag_mbxacc_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_mbxacc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd;
+	size_t nbytes = iov_iter_count(from);
 	int rc;
 
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -5341,10 +5298,8 @@ lpfc_idiag_extacc_drivr_get(struct lpfc_hba *phba, char *pbuffer, int len)
 
 /**
  * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and then
  * perform the syntax check for extent information access commands and sets
@@ -5355,17 +5310,17 @@ lpfc_idiag_extacc_drivr_get(struct lpfc_hba *phba, char *pbuffer, int len)
  * space.
  **/
 static ssize_t
-lpfc_idiag_extacc_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_extacc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
+	size_t nbytes = iov_iter_count(from);
 	uint32_t ext_map;
 	int rc;
 
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -5387,10 +5342,8 @@ lpfc_idiag_extacc_write(struct file *file, const char __user *buf,
 
 /**
  * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the user data to.
  *
  * Description:
  * This routine reads data from the proper extent information according to
@@ -5400,11 +5353,9 @@ lpfc_idiag_extacc_write(struct file *file, const char __user *buf,
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_extacc_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+static ssize_t lpfc_idiag_extacc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	char *pbuffer;
 	uint32_t ext_map;
@@ -5418,7 +5369,7 @@ lpfc_idiag_extacc_read(struct file *file, char __user *buf, size_t nbytes,
 	if (!debug->buffer)
 		return 0;
 	pbuffer = debug->buffer;
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 	if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD)
 		return 0;
@@ -5431,7 +5382,7 @@ lpfc_idiag_extacc_read(struct file *file, char __user *buf, size_t nbytes,
 	if (ext_map & LPFC_EXT_ACC_DRIVR)
 		len = lpfc_idiag_extacc_drivr_get(phba, pbuffer, len);
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 static int
@@ -5458,11 +5409,9 @@ lpfc_cgn_buffer_open(struct inode *inode, struct file *file)
 	return rc;
 }
 
-static ssize_t
-lpfc_cgn_buffer_read(struct file *file, char __user *buf, size_t nbytes,
-		     loff_t *ppos)
+static ssize_t lpfc_cgn_buffer_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	char *buffer = debug->buffer;
 	uint32_t *ptr;
@@ -5512,7 +5461,7 @@ lpfc_cgn_buffer_read(struct file *file, char __user *buf, size_t nbytes,
 			 "%08x %08x %08x %08x\n",
 			 *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3));
 out:
-	return simple_read_from_buffer(buf, nbytes, ppos, buffer, len);
+	return simple_copy_to_iter(buffer, &iocb->ki_pos, len, to);
 }
 
 static int
@@ -5551,10 +5500,9 @@ lpfc_rx_monitor_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_rx_monitor_read(struct file *file, char __user *buf, size_t nbytes,
-		     loff_t *ppos)
+lpfc_rx_monitor_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_rx_monitor_debug *debug = file->private_data;
+	struct lpfc_rx_monitor_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	char *buffer = debug->buffer;
 
@@ -5567,8 +5515,7 @@ lpfc_rx_monitor_read(struct file *file, char __user *buf, size_t nbytes,
 				       LPFC_MAX_RXMONITOR_ENTRY);
 	}
 
-	return simple_read_from_buffer(buf, nbytes, ppos, buffer,
-				       strlen(buffer));
+	return simple_copy_to_iter(buffer, &iocb->ki_pos, strlen(buffer), to);
 }
 
 static int
@@ -5587,7 +5534,7 @@ static const struct file_operations lpfc_debugfs_op_disc_trc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_disc_trc_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5596,7 +5543,7 @@ static const struct file_operations lpfc_debugfs_op_nodelist = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_nodelist_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5605,8 +5552,8 @@ static const struct file_operations lpfc_debugfs_op_multixripools = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_multixripools_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =	lpfc_debugfs_multixripools_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =	lpfc_debugfs_multixripools_write,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5615,7 +5562,7 @@ static const struct file_operations lpfc_debugfs_op_hbqinfo = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_hbqinfo_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5625,8 +5572,8 @@ static const struct file_operations lpfc_debugfs_op_lockstat = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_lockstat_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =        lpfc_debugfs_lockstat_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =   lpfc_debugfs_lockstat_iter,
 	.release =      lpfc_debugfs_release,
 };
 #endif
@@ -5636,7 +5583,7 @@ static const struct file_operations lpfc_debugfs_ras_log = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_ras_log_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_ras_log_release,
 };
 
@@ -5645,7 +5592,7 @@ static const struct file_operations lpfc_debugfs_op_dumpHBASlim = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_dumpHBASlim_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5654,7 +5601,7 @@ static const struct file_operations lpfc_debugfs_op_dumpHostSlim = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_dumpHostSlim_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5663,8 +5610,8 @@ static const struct file_operations lpfc_debugfs_op_nvmestat = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_nvmestat_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =	lpfc_debugfs_nvmestat_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =	lpfc_debugfs_nvmestat_write,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5673,8 +5620,8 @@ static const struct file_operations lpfc_debugfs_op_scsistat = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_scsistat_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =	lpfc_debugfs_scsistat_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =	lpfc_debugfs_scsistat_write,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5683,8 +5630,8 @@ static const struct file_operations lpfc_debugfs_op_ioktime = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_ioktime_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =	lpfc_debugfs_ioktime_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =	lpfc_debugfs_ioktime_write,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5693,8 +5640,8 @@ static const struct file_operations lpfc_debugfs_op_nvmeio_trc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_nvmeio_trc_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =	lpfc_debugfs_nvmeio_trc_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =	lpfc_debugfs_nvmeio_trc_write,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5703,8 +5650,8 @@ static const struct file_operations lpfc_debugfs_op_hdwqstat = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_hdwqstat_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =	lpfc_debugfs_hdwqstat_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =	lpfc_debugfs_hdwqstat_write,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5713,8 +5660,8 @@ static const struct file_operations lpfc_debugfs_op_dif_err = {
 	.owner =	THIS_MODULE,
 	.open =		simple_open,
 	.llseek =	lpfc_debugfs_lseek,
-	.read =		lpfc_debugfs_dif_err_read,
-	.write =	lpfc_debugfs_dif_err_write,
+	.read_iter =	lpfc_debugfs_dif_err_read,
+	.write_iter =	lpfc_debugfs_dif_err_write,
 	.release =	lpfc_debugfs_dif_err_release,
 };
 
@@ -5723,7 +5670,7 @@ static const struct file_operations lpfc_debugfs_op_slow_ring_trc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_slow_ring_trc_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5738,8 +5685,8 @@ static const struct file_operations lpfc_idiag_op_pciCfg = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_pcicfg_read,
-	.write =        lpfc_idiag_pcicfg_write,
+	.read_iter =    lpfc_idiag_pcicfg_read,
+	.write_iter =   lpfc_idiag_pcicfg_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 
@@ -5748,8 +5695,8 @@ static const struct file_operations lpfc_idiag_op_barAcc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_baracc_read,
-	.write =        lpfc_idiag_baracc_write,
+	.read_iter =    lpfc_idiag_baracc_read,
+	.write_iter =   lpfc_idiag_baracc_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 
@@ -5757,7 +5704,7 @@ static const struct file_operations lpfc_idiag_op_barAcc = {
 static const struct file_operations lpfc_idiag_op_queInfo = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
-	.read =         lpfc_idiag_queinfo_read,
+	.read_iter =    lpfc_idiag_queinfo_read,
 	.release =      lpfc_idiag_release,
 };
 
@@ -5766,8 +5713,8 @@ static const struct file_operations lpfc_idiag_op_queAcc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_queacc_read,
-	.write =        lpfc_idiag_queacc_write,
+	.read_iter =    lpfc_idiag_queacc_read,
+	.write_iter =   lpfc_idiag_queacc_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 
@@ -5776,8 +5723,8 @@ static const struct file_operations lpfc_idiag_op_drbAcc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_drbacc_read,
-	.write =        lpfc_idiag_drbacc_write,
+	.read_iter =    lpfc_idiag_drbacc_read,
+	.write_iter =   lpfc_idiag_drbacc_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 
@@ -5786,8 +5733,8 @@ static const struct file_operations lpfc_idiag_op_ctlAcc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_ctlacc_read,
-	.write =        lpfc_idiag_ctlacc_write,
+	.read_iter =    lpfc_idiag_ctlacc_read,
+	.write_iter =   lpfc_idiag_ctlacc_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 
@@ -5796,8 +5743,8 @@ static const struct file_operations lpfc_idiag_op_mbxAcc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_mbxacc_read,
-	.write =        lpfc_idiag_mbxacc_write,
+	.read_iter =    lpfc_idiag_mbxacc_read,
+	.write_iter =   lpfc_idiag_mbxacc_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 
@@ -5806,8 +5753,8 @@ static const struct file_operations lpfc_idiag_op_extAcc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_extacc_read,
-	.write =        lpfc_idiag_extacc_write,
+	.read_iter =    lpfc_idiag_extacc_read,
+	.write_iter =   lpfc_idiag_extacc_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 #undef lpfc_cgn_buffer_op
@@ -5815,7 +5762,7 @@ static const struct file_operations lpfc_cgn_buffer_op = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_cgn_buffer_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_cgn_buffer_read,
+	.read_iter =    lpfc_cgn_buffer_read,
 	.release =      lpfc_cgn_buffer_release,
 };
 
@@ -5824,7 +5771,7 @@ static const struct file_operations lpfc_rx_monitor_op = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_rx_monitor_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_rx_monitor_read,
+	.read_iter =    lpfc_rx_monitor_read,
 	.release =      lpfc_rx_monitor_release,
 };
 #endif
Signature · 1 line
2.43.0
author maintainer
#196 lore raw

PATCH 190/437 scsi: megaraid: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/megaraid/megaraid_sas_debugfs.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/scsi/megaraid/megaraid_sas_debugfs.c +4 -5
index c69760775efa..d0b8626eebd8 100644
@@ -45,15 +45,14 @@
 struct dentry *megasas_debugfs_root;
 
 static ssize_t
-megasas_debugfs_read(struct file *filp, char __user *ubuf, size_t cnt,
-		      loff_t *ppos)
+megasas_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct megasas_debugfs_buffer *debug = filp->private_data;
+	struct megasas_debugfs_buffer *debug = iocb->ki_filp->private_data;
 
 	if (!debug || !debug->buf)
 		return 0;
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, debug->buf, debug->len);
+	return simple_copy_to_iter(debug->buf, &iocb->ki_pos, debug->len, to);
 }
 
 static int
@@ -92,7 +91,7 @@ megasas_debugfs_release(struct inode *inode, struct file *file)
 static const struct file_operations megasas_debugfs_raidmap_fops = {
 	.owner		= THIS_MODULE,
 	.open           = megasas_debugfs_raidmap_open,
-	.read           = megasas_debugfs_read,
+	.read_iter      = megasas_debugfs_read,
 	.release        = megasas_debugfs_release,
 };
 
Signature · 1 line
2.43.0
author maintainer
#197 lore raw

PATCH 191/437 scsi: mpt3sas: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/mpt3sas/mpt3sas_debugfs.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_debugfs.c +4 -6
index a6ab1db81167..2cb768bcf5c2 100644
@@ -36,17 +36,15 @@ static struct dentry *mpt3sas_debugfs_root;
  * @ppos:	Offset in the file
  */
 
-static ssize_t
-_debugfs_iocdump_read(struct file *filp, char __user *ubuf, size_t cnt,
-	loff_t *ppos)
+static ssize_t _debugfs_iocdump_read(struct kiocb *iocb, struct iov_iter *to)
 
 {
-	struct mpt3sas_debugfs_buffer *debug = filp->private_data;
+	struct mpt3sas_debugfs_buffer *debug = iocb->ki_filp->private_data;
 
 	if (!debug || !debug->buf)
 		return 0;
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, debug->buf, debug->len);
+	return simple_copy_to_iter(debug->buf, &iocb->ki_pos, debug->len, to);
 }
 
 /*
@@ -89,7 +87,7 @@ _debugfs_iocdump_release(struct inode *inode, struct file *file)
 static const struct file_operations mpt3sas_debugfs_iocdump_fops = {
 	.owner		= THIS_MODULE,
 	.open           = _debugfs_iocdump_open,
-	.read           = _debugfs_iocdump_read,
+	.read_iter      = _debugfs_iocdump_read,
 	.release        = _debugfs_iocdump_release,
 };
 
Signature · 1 line
2.43.0
author maintainer
#198 lore raw

PATCH 192/437 scsi: qedf: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/qedf/qedf_dbg.h     |  6 +--
 drivers/scsi/qedf/qedf_debugfs.c | 76 +++++++++++++-------------------
 2 files changed, 34 insertions(+), 48 deletions(-)
drivers/scsi/qedf/qedf_dbg.h +3 -3
index 5ec2b817c694..802cbb5353f7 100644
@@ -133,8 +133,8 @@ struct qedf_list_of_funcs {
 { \
 	.owner  = THIS_MODULE, \
 	.open   = simple_open, \
-	.read   = drv##_dbg_##ops##_cmd_read, \
-	.write  = drv##_dbg_##ops##_cmd_write \
+	.read_iter   = drv##_dbg_##ops##_cmd_read, \
+	.write_iter  = drv##_dbg_##ops##_cmd_write \
 }
 
 /* Used for debugfs sequential files */
@@ -142,7 +142,7 @@ struct qedf_list_of_funcs {
 { \
 	.owner = THIS_MODULE, \
 	.open = drv##_dbg_##ops##_open, \
-	.read = seq_read, \
+	.read_iter = seq_read_iter, \
 	.llseek = seq_lseek, \
 	.release = single_release, \
 }
drivers/scsi/qedf/qedf_debugfs.c +31 -45

169 lines not on this page · raw message

Signature · 1 line
2.43.0
author maintainer
#199 lore raw

PATCH 193/437 scsi: qedi: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/qedi/qedi_dbg.h     |  6 +++---
 drivers/scsi/qedi/qedi_debugfs.c | 20 ++++++++++++++++----
 2 files changed, 19 insertions(+), 7 deletions(-)
drivers/scsi/qedi/qedi_dbg.h +3 -3
index fdda12ef13b0..2b05de656aa8 100644
@@ -114,8 +114,8 @@ struct qedi_debugfs_ops {
 { \
 	.owner  = THIS_MODULE, \
 	.open   = simple_open, \
-	.read   = drv##_dbg_##ops##_cmd_read, \
-	.write  = drv##_dbg_##ops##_cmd_write \
+	.read_iter   = drv##_dbg_##ops##_cmd_read, \
+	.write_iter  = drv##_dbg_##ops##_cmd_write \
 }
 
 /* Used for debugfs sequential files */
@@ -123,7 +123,7 @@ struct qedi_debugfs_ops {
 { \
 	.owner = THIS_MODULE, \
 	.open = drv##_dbg_##ops##_open, \
-	.read = seq_read, \
+	.read_iter = seq_read_iter, \
 	.llseek = seq_lseek, \
 	.release = single_release, \
 }
drivers/scsi/qedi/qedi_debugfs.c +16 -4
index 8deb2001dc2f..28fbbea694d5 100644
@@ -91,8 +91,8 @@ const struct qedi_debugfs_ops qedi_debugfs_ops[] = {
 };
 
 static ssize_t
-qedi_dbg_do_not_recover_cmd_write(struct file *filp, const char __user *buffer,
-				  size_t count, loff_t *ppos)
+__qedi_dbg_do_not_recover_cmd_write(struct file *filp, const char __user *buffer,
+				    size_t count, loff_t *ppos)
 {
 	size_t cnt = 0;
 	struct qedi_dbg_ctx *qedi_dbg =
@@ -117,8 +117,14 @@ qedi_dbg_do_not_recover_cmd_write(struct file *filp, const char __user *buffer,
 }
 
 static ssize_t
-qedi_dbg_do_not_recover_cmd_read(struct file *filp, char __user *buffer,
-				 size_t count, loff_t *ppos)
+qedi_dbg_do_not_recover_cmd_write(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, __qedi_dbg_do_not_recover_cmd_write);
+}
+
+static ssize_t
+__qedi_dbg_do_not_recover_cmd_read(struct file *filp, char __user *buffer,
+				   size_t count, loff_t *ppos)
 {
 	size_t cnt = 0;
 
@@ -131,6 +137,12 @@ qedi_dbg_do_not_recover_cmd_read(struct file *filp, char __user *buffer,
 	return cnt;
 }
 
+static ssize_t
+qedi_dbg_do_not_recover_cmd_read(struct kiocb *iocb, struct iov_iter *to)
+{
+	return vfs_read_iter(iocb, to, __qedi_dbg_do_not_recover_cmd_read);
+}
+
 static int
 qedi_gbl_ctx_show(struct seq_file *s, void *unused)
 {
Signature · 1 line
2.43.0
author maintainer
#200 lore raw

PATCH 194/437 scsi: qla2xxx: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/qla2xxx/qla_dfs.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/qla2xxx/qla_dfs.c +6 -6
index 55ff3d7482b3..6aacdb5c65aa 100644
@@ -490,7 +490,7 @@ qla2x00_dfs_fce_release(struct inode *inode, struct file *file)
 
 static const struct file_operations dfs_fce_ops = {
 	.open		= qla2x00_dfs_fce_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= qla2x00_dfs_fce_release,
 };
@@ -569,13 +569,13 @@ qla_dfs_naqp_show(struct seq_file *s, void *unused)
 		}							\
 	} while (0)
 
-static ssize_t
-qla_dfs_naqp_write(struct file *file, const char __user *buffer,
-    size_t count, loff_t *pos)
+static ssize_t qla_dfs_naqp_write_iter(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct scsi_qla_host *vha = s->private;
 	struct qla_hw_data *ha = vha->hw;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int rc = 0;
 	unsigned long num_act_qp;
@@ -591,7 +591,7 @@ qla_dfs_naqp_write(struct file *file, const char __user *buffer,
 		    vha->host_no);
 		return -EINVAL;
 	}
-	buf = memdup_user_nul(buffer, count);
+	buf = iterdup_nul(from, count);
 	if (IS_ERR(buf)) {
 		pr_err("host%ld: fail to copy user buffer.",
 		    vha->host_no);
Signature · 1 line
2.43.0
author maintainer
#201 lore raw

PATCH 195/437 scsi: snic: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/snic/snic_debugfs.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)
drivers/scsi/snic/snic_debugfs.c +10 -15
index 9dd975b36b5b..0e81688746f1 100644
@@ -69,18 +69,15 @@ snic_reset_stats_open(struct inode *inode, struct file *filp)
  * This function returns the amount of data that was read.
  */
 static ssize_t
-snic_reset_stats_read(struct file *filp,
-		      char __user *ubuf,
-		      size_t cnt,
-		      loff_t *ppos)
+snic_reset_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snic *snic = (struct snic *) filp->private_data;
+	struct snic *snic = iocb->ki_filp->private_data;
 	char buf[64];
 	int len;
 
 	len = sprintf(buf, "%u\n", snic->reset_stats);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 /*
@@ -98,15 +95,13 @@ snic_reset_stats_read(struct file *filp,
  * This function returns the amount of data that was written.
  */
 static ssize_t
-snic_reset_stats_write(struct file *filp,
-		       const char __user *ubuf,
-		       size_t cnt,
-		       loff_t *ppos)
+snic_reset_stats_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct snic *snic = (struct snic *) filp->private_data;
+	struct snic *snic = iocb->ki_filp->private_data;
 	struct snic_stats *stats = &snic->s_stats;
 	u64 *io_stats_p = (u64 *) &stats->io;
 	u64 *fw_stats_p = (u64 *) &stats->fw;
+	size_t cnt = iov_iter_count(from);
 	char buf[64];
 	unsigned long val;
 	int ret;
@@ -114,7 +109,7 @@ snic_reset_stats_write(struct file *filp,
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = '\0';
@@ -143,7 +138,7 @@ snic_reset_stats_write(struct file *filp,
 			sizeof(struct snic_fw_stats) - sizeof(u64));
 	}
 
-	(*ppos)++;
+	iocb->ki_pos++;
 
 	SNIC_HOST_INFO(snic->shost, "Reset Op: Driver statistics.\n");
 
@@ -325,8 +320,8 @@ DEFINE_SHOW_ATTRIBUTE(snic_stats);
 static const struct file_operations snic_reset_stats_fops = {
 	.owner = THIS_MODULE,
 	.open = snic_reset_stats_open,
-	.read = snic_reset_stats_read,
-	.write = snic_reset_stats_write,
+	.read_iter = snic_reset_stats_read,
+	.write_iter = snic_reset_stats_write,
 	.release = snic_reset_stats_release,
 };
 
Signature · 1 line
2.43.0
author maintainer
#202 lore raw

PATCH 196/437 scsi: cxlflash: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/cxlflash/ocxl_hw.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/scsi/cxlflash/ocxl_hw.c +8 -9
index 6542818e595a..40fef6f919db 100644
@@ -1010,10 +1010,9 @@ static unsigned int afu_poll(struct file *file, struct poll_table_struct *poll)
  *
  * Return: size of the data read on success, -errno on failure
  */
-static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
-			loff_t *off)
+static ssize_t afu_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ocxlflash_context *ctx = file->private_data;
+	struct ocxlflash_context *ctx = iocb->ki_filp->private_data;
 	struct device *dev = ctx->hw_afu->dev;
 	struct cxl_event event;
 	ulong lock_flags;
@@ -1022,9 +1021,9 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 	int bit;
 	DEFINE_WAIT(event_wait);
 
-	if (*off != 0) {
+	if (iocb->ki_pos != 0) {
 		dev_err(dev, "%s: Non-zero offset not supported, off=%lld\n",
-			__func__, *off);
+			__func__, iocb->ki_pos);
 		rc = -EINVAL;
 		goto out;
 	}
@@ -1037,7 +1036,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 		if (ctx_event_pending(ctx) || (ctx->state == CLOSED))
 			break;
 
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			dev_err(dev, "%s: File cannot be blocked on I/O\n",
 				__func__);
 			rc = -EAGAIN;
@@ -1081,7 +1080,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 
 	spin_unlock_irqrestore(&ctx->slock, lock_flags);
 
-	if (copy_to_user(buf, &event, event.header.size)) {
+	if (!copy_to_iter_full(&event, event.header.size, to)) {
 		dev_err(dev, "%s: copy_to_user failed\n", __func__);
 		rc = -EFAULT;
 		goto out;
@@ -1176,7 +1175,7 @@ static int afu_mmap(struct file *file, struct vm_area_struct *vma)
 static const struct file_operations ocxl_afu_fops = {
 	.owner		= THIS_MODULE,
 	.poll		= afu_poll,
-	.read		= afu_read,
+	.read_iter	= afu_read,
 	.release	= afu_release,
 	.mmap		= afu_mmap,
 };
@@ -1224,7 +1223,7 @@ static struct file *ocxlflash_get_fd(void *ctx_cookie,
 	/* Patch the file ops that are not defined */
 	if (fops) {
 		PATCH_FOPS(poll);
-		PATCH_FOPS(read);
+		PATCH_FOPS(read_iter);
 		PATCH_FOPS(release);
 		PATCH_FOPS(mmap);
 	} else /* Use default ops */
Signature · 1 line
2.43.0
author maintainer
#203 lore raw

PATCH 197/437 scsi: scsi_debug: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/scsi_debug.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/scsi/scsi_debug.c +13 -13
index acf0592d63da..0ce291a5e8fa 100644
@@ -1022,19 +1022,19 @@ static int sdebug_error_open(struct inode *inode, struct file *file)
 	return single_open(file, sdebug_error_show, inode->i_private);
 }
 
-static ssize_t sdebug_error_write(struct file *file, const char __user *ubuf,
-		size_t count, loff_t *ppos)
+static ssize_t sdebug_error_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char *buf;
 	unsigned int inject_type;
 	struct sdebug_err_inject *inject;
-	struct scsi_device *sdev = (struct scsi_device *)file->f_inode->i_private;
+	struct scsi_device *sdev = iocb->ki_filp->f_inode->i_private;
+	size_t count = iov_iter_count(from);
 
 	buf = kzalloc(count + 1, GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 
-	if (copy_from_user(buf, ubuf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		kfree(buf);
 		return -EFAULT;
 	}
@@ -1095,8 +1095,8 @@ static ssize_t sdebug_error_write(struct file *file, const char __user *ubuf,
 
 static const struct file_operations sdebug_error_fops = {
 	.open	= sdebug_error_open,
-	.read	= seq_read,
-	.write	= sdebug_error_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= sdebug_error_write,
 	.release = single_release,
 };
 
@@ -1117,17 +1117,17 @@ static int sdebug_target_reset_fail_open(struct inode *inode, struct file *file)
 	return single_open(file, sdebug_target_reset_fail_show, inode->i_private);
 }
 
-static ssize_t sdebug_target_reset_fail_write(struct file *file,
-		const char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t sdebug_target_reset_fail_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
 	int ret;
-	struct scsi_target *starget =
-		(struct scsi_target *)file->f_inode->i_private;
+	struct scsi_target *starget = iocb->ki_filp->f_inode->i_private;
 	struct sdebug_target_info *targetip =
 		(struct sdebug_target_info *)starget->hostdata;
+	size_t count = iov_iter_count(from);
 
 	if (targetip) {
-		ret = kstrtobool_from_user(ubuf, count, &targetip->reset_fail);
+		ret = kstrtobool_from_iter(from, count, &targetip->reset_fail);
 		return ret < 0 ? ret : count;
 	}
 	return -ENODEV;
@@ -1135,8 +1135,8 @@ static ssize_t sdebug_target_reset_fail_write(struct file *file,
 
 static const struct file_operations sdebug_target_reset_fail_fops = {
 	.open	= sdebug_target_reset_fail_open,
-	.read	= seq_read,
-	.write	= sdebug_target_reset_fail_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= sdebug_target_reset_fail_write,
 	.release = single_release,
 };
 
Signature · 1 line
2.43.0
author maintainer
#204 lore raw

PATCH 198/437 scsi: sg: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/sg.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/sg.c +4 -2
index 386981c6976a..c8047981eb9e 100644
@@ -553,6 +553,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
 	kfree(old_hdr);
 	return retval;
 }
+FOPS_READ_ITER_HELPER(sg_read);
 
 static ssize_t
 sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp)
@@ -707,6 +708,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
 	k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking);
 	return (k < 0) ? k : count;
 }
+FOPS_WRITE_ITER_HELPER(sg_write);
 
 static ssize_t
 sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf,
@@ -1412,8 +1414,8 @@ sg_rq_end_io(struct request *rq, blk_status_t status)
 
 static const struct file_operations sg_fops = {
 	.owner = THIS_MODULE,
-	.read = sg_read,
-	.write = sg_write,
+	.read_iter = sg_read_iter,
+	.write_iter = sg_write_iter,
 	.poll = sg_poll,
 	.unlocked_ioctl = sg_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
Signature · 1 line
2.43.0
author maintainer
#205 lore raw

PATCH 199/437 scsi: st: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/scsi/st.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/scsi/st.c +5 -5
index 5a9bcf8e0792..e96eb3607a82 100644
@@ -1891,7 +1891,8 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
 
 	return retval;
 }
-
+FOPS_WRITE_ITER_HELPER(st_write);
+
 /* Read data from the tape. Returns zero in the normal case, one if the
    eof status has changed, and the negative error code in case of a
    fatal error. Otherwise updates the buffer and the eof state.
@@ -2238,8 +2239,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
 
 	return retval;
 }
-
-
+FOPS_READ_ITER_HELPER(st_read);
 
 DEB(
 /* Set the driver options */
@@ -4146,8 +4146,8 @@ __setup("st=", st_setup);
 static const struct file_operations st_fops =
 {
 	.owner =	THIS_MODULE,
-	.read =		st_read,
-	.write =	st_write,
+	.read_iter =	st_read_iter,
+	.write_iter =	st_write_iter,
 	.unlocked_ioctl = st_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = st_compat_ioctl,
Signature · 1 line
2.43.0
author maintainer
#206 lore raw

PATCH 200/437 staging: axis: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/staging/axis-fifo/axis-fifo.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/staging/axis-fifo/axis-fifo.c +5 -8
index ba8e08be0daf..9c9f0716e5f7 100644
@@ -33,6 +33,7 @@
 #include <linux/uaccess.h>
 #include <linux/jiffies.h>
 #include <linux/miscdevice.h>
+#include <linux/uio.h>
 
 /* ----------------------------
  *       driver parameters
@@ -332,10 +333,8 @@ static void reset_ip_core(struct axis_fifo *fifo)
 
 /**
  * axis_fifo_read() - Read a packet from AXIS-FIFO character device.
- * @f: Open file.
- * @buf: User space buffer to read to.
- * @len: User space buffer length.
- * @off: Buffer offset.
+ * @iocb: Metadata for IO.
+ * @to: User space buffer to read to.
  *
  * As defined by the device's documentation, we need to check the device's
  * occupancy before reading the length register and then the data. All these
@@ -451,10 +450,8 @@ static ssize_t axis_fifo_read(struct kiocb *iocb, struct iov_iter *to)
 
 /**
  * axis_fifo_write() - Write buffer to AXIS-FIFO character device.
- * @f: Open file.
- * @buf: User space buffer to write to the device.
- * @len: User space buffer length.
- * @off: Buffer offset.
+ * @iocb: Metadata for IO.
+ * @from: User space buffer to write to the device.
  *
  * As defined by the device's documentation, we need to write to the device's
  * data buffer then to the device's packet length register atomically. Also,
Signature · 1 line
2.43.0
author maintainer
#207 lore raw

PATCH 201/437 staging: fieldbus: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/staging/fieldbus/dev_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/fieldbus/dev_core.c +4 -2
index 0053ebd91442..4a9e211640db 100644
@@ -194,6 +194,7 @@ static ssize_t fieldbus_read(struct file *filp, char __user *buf, size_t size,
 	of->dc_event = fbdev->dc_event;
 	return fbdev->read_area(fbdev, buf, size, offset);
 }
+FOPS_READ_ITER_HELPER(fieldbus_read);
 
 static ssize_t fieldbus_write(struct file *filp, const char __user *buf,
 			      size_t size, loff_t *offset)
@@ -203,6 +204,7 @@ static ssize_t fieldbus_write(struct file *filp, const char __user *buf,
 
 	return fbdev->write_area(fbdev, buf, size, offset);
 }
+FOPS_WRITE_ITER_HELPER(fieldbus_write);
 
 static __poll_t fieldbus_poll(struct file *filp, poll_table *wait)
 {
@@ -220,8 +222,8 @@ static __poll_t fieldbus_poll(struct file *filp, poll_table *wait)
 static const struct file_operations fieldbus_fops = {
 	.open		= fieldbus_open,
 	.release	= fieldbus_release,
-	.read		= fieldbus_read,
-	.write		= fieldbus_write,
+	.read_iter	= fieldbus_read_iter,
+	.write_iter	= fieldbus_write_iter,
 	.poll		= fieldbus_poll,
 	.llseek		= generic_file_llseek,
 	.owner		= THIS_MODULE,
Signature · 1 line
2.43.0
author maintainer
#208 lore raw

PATCH 202/437 staging: greybus: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/greybus/es2.c            | 29 ++++++++++++++---------------
 drivers/greybus/svc.c            | 27 ++++++++++++---------------
 drivers/staging/greybus/camera.c | 22 ++++++++++------------
 drivers/staging/greybus/raw.c    |  6 ++++--
 4 files changed, 40 insertions(+), 44 deletions(-)
drivers/greybus/es2.c +14 -15
index 1ee78d0d90b4..ef9c68ef8632 100644
@@ -1109,10 +1109,10 @@ static int apb_log_poll(void *data)
 	return 0;
 }
 
-static ssize_t apb_log_read(struct file *f, char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t apb_log_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct es2_ap_dev *es2 = file_inode(f)->i_private;
+	struct es2_ap_dev *es2 = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(to);
 	ssize_t ret;
 	size_t copied;
 	char *tmp_buf;
@@ -1125,7 +1125,7 @@ static ssize_t apb_log_read(struct file *f, char __user *buf,
 		return -ENOMEM;
 
 	copied = kfifo_out(&es2->apb_log_fifo, tmp_buf, count);
-	ret = simple_read_from_buffer(buf, count, ppos, tmp_buf, copied);
+	ret = simple_copy_to_iter(tmp_buf, &iocb->ki_pos, copied, to);
 
 	kfree(tmp_buf);
 
@@ -1133,7 +1133,7 @@ static ssize_t apb_log_read(struct file *f, char __user *buf,
 }
 
 static const struct file_operations apb_log_fops = {
-	.read	= apb_log_read,
+	.read_iter	= apb_log_read,
 };
 
 static void usb_log_enable(struct es2_ap_dev *es2)
@@ -1163,25 +1163,24 @@ static void usb_log_disable(struct es2_ap_dev *es2)
 	es2->apb_log_task = NULL;
 }
 
-static ssize_t apb_log_enable_read(struct file *f, char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t apb_log_enable_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct es2_ap_dev *es2 = file_inode(f)->i_private;
+	struct es2_ap_dev *es2 = file_inode(iocb->ki_filp)->i_private;
 	int enable = !IS_ERR_OR_NULL(es2->apb_log_task);
 	char tmp_buf[3];
 
 	sprintf(tmp_buf, "%d\n", enable);
-	return simple_read_from_buffer(buf, count, ppos, tmp_buf, 2);
+	return simple_copy_to_iter(tmp_buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t apb_log_enable_write(struct file *f, const char __user *buf,
-				    size_t count, loff_t *ppos)
+static ssize_t apb_log_enable_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int enable;
 	ssize_t retval;
-	struct es2_ap_dev *es2 = file_inode(f)->i_private;
+	struct es2_ap_dev *es2 = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 
-	retval = kstrtoint_from_user(buf, count, 10, &enable);
+	retval = kstrtoint_from_iter(from, count, 10, &enable);
 	if (retval)
 		return retval;
 
@@ -1194,8 +1193,8 @@ static ssize_t apb_log_enable_write(struct file *f, const char __user *buf,
 }
 
 static const struct file_operations apb_log_enable_fops = {
-	.read	= apb_log_enable_read,
-	.write	= apb_log_enable_write,
+	.read_iter	= apb_log_enable_read,
+	.write_iter	= apb_log_enable_write,
 };
 
 static int apb_get_cport_count(struct usb_device *udev)
drivers/greybus/svc.c +12 -15
index 4256467fcd35..989ee7a3ac17 100644
@@ -673,11 +673,10 @@ static int gb_svc_version_request(struct gb_operation *op)
 	return 0;
 }
 
-static ssize_t pwr_debugfs_voltage_read(struct file *file, char __user *buf,
-					size_t len, loff_t *offset)
+static ssize_t pwr_debugfs_voltage_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct svc_debugfs_pwrmon_rail *pwrmon_rails =
-		file_inode(file)->i_private;
+		file_inode(iocb->ki_filp)->i_private;
 	struct gb_svc *svc = pwrmon_rails->svc;
 	int ret, desc;
 	u32 value;
@@ -694,14 +693,13 @@ static ssize_t pwr_debugfs_voltage_read(struct file *file, char __user *buf,
 
 	desc = scnprintf(buff, sizeof(buff), "%u\n", value);
 
-	return simple_read_from_buffer(buf, len, offset, buff, desc);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 }
 
-static ssize_t pwr_debugfs_current_read(struct file *file, char __user *buf,
-					size_t len, loff_t *offset)
+static ssize_t pwr_debugfs_current_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct svc_debugfs_pwrmon_rail *pwrmon_rails =
-		file_inode(file)->i_private;
+		file_inode(iocb->ki_filp)->i_private;
 	struct gb_svc *svc = pwrmon_rails->svc;
 	int ret, desc;
 	u32 value;
@@ -718,14 +716,13 @@ static ssize_t pwr_debugfs_current_read(struct file *file, char __user *buf,
 
 	desc = scnprintf(buff, sizeof(buff), "%u\n", value);
 
-	return simple_read_from_buffer(buf, len, offset, buff, desc);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 }
 
-static ssize_t pwr_debugfs_power_read(struct file *file, char __user *buf,
-				      size_t len, loff_t *offset)
+static ssize_t pwr_debugfs_power_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct svc_debugfs_pwrmon_rail *pwrmon_rails =
-		file_inode(file)->i_private;
+		file_inode(iocb->ki_filp)->i_private;
 	struct gb_svc *svc = pwrmon_rails->svc;
 	int ret, desc;
 	u32 value;
@@ -741,19 +738,19 @@ static ssize_t pwr_debugfs_power_read(struct file *file, char __user *buf,
 
 	desc = scnprintf(buff, sizeof(buff), "%u\n", value);
 
-	return simple_read_from_buffer(buf, len, offset, buff, desc);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 }
 
 static const struct file_operations pwrmon_debugfs_voltage_fops = {
-	.read		= pwr_debugfs_voltage_read,
+	.read_iter	= pwr_debugfs_voltage_read,
 };
 
 static const struct file_operations pwrmon_debugfs_current_fops = {
-	.read		= pwr_debugfs_current_read,
+	.read_iter	= pwr_debugfs_current_read,
 };
 
 static const struct file_operations pwrmon_debugfs_power_fops = {
-	.read		= pwr_debugfs_power_read,
+	.read_iter	= pwr_debugfs_power_read,
 };
 
 static void gb_svc_pwrmon_debugfs_init(struct gb_svc *svc)
drivers/staging/greybus/camera.c +10 -12
index a8173aa3a995..f18f690a31ee 100644
@@ -1086,10 +1086,9 @@ static const struct gb_camera_debugfs_entry gb_camera_debugfs_entries[] = {
 	},
 };
 
-static ssize_t gb_camera_debugfs_read(struct file *file, char __user *buf,
-				      size_t len, loff_t *offset)
+static ssize_t gb_camera_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	const struct gb_camera_debugfs_entry *op = file->private_data;
+	const struct gb_camera_debugfs_entry *op = iocb->ki_filp->private_data;
 	struct gb_camera *gcam = file_inode(file)->i_private;
 	struct gb_camera_debugfs_buffer *buffer;
 	ssize_t ret;
@@ -1103,23 +1102,22 @@ static ssize_t gb_camera_debugfs_read(struct file *file, char __user *buf,
 
 	buffer = &gcam->debugfs.buffers[op->buffer];
 
-	return simple_read_from_buffer(buf, len, offset, buffer->data,
-				       buffer->length);
+	return simple_copy_to_iter(buffer->data, &iocb->ki_pos, buffer->length,
+					to);
 }
 
-static ssize_t gb_camera_debugfs_write(struct file *file,
-				       const char __user *buf, size_t len,
-				       loff_t *offset)
+static ssize_t gb_camera_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	const struct gb_camera_debugfs_entry *op = file->private_data;
+	const struct gb_camera_debugfs_entry *op = iocb->ki_filp->private_data;
 	struct gb_camera *gcam = file_inode(file)->i_private;
+	size_t len = iov_iter_count(from);
 	ssize_t ret;
 	char *kbuf;
 
 	if (len > 1024)
 		return -EINVAL;
 
-	kbuf = memdup_user_nul(buf, len);
+	kbuf = iterdup_nul(buf, len);
 	if (IS_ERR(kbuf))
 		return PTR_ERR(kbuf);
 
@@ -1149,8 +1147,8 @@ static int gb_camera_debugfs_open(struct inode *inode, struct file *file)
 
 static const struct file_operations gb_camera_debugfs_ops = {
 	.open = gb_camera_debugfs_open,
-	.read = gb_camera_debugfs_read,
-	.write = gb_camera_debugfs_write,
+	.read_iter = gb_camera_debugfs_read,
+	.write_iter = gb_camera_debugfs_write,
 };
 
 static int gb_camera_debugfs_init(struct gb_camera *gcam)
drivers/staging/greybus/raw.c +4 -2
index 836d35e5fa85..44b85032b755 100644
@@ -284,6 +284,7 @@ static ssize_t raw_write(struct file *file, const char __user *buf,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(raw_write);
 
 static ssize_t raw_read(struct file *file, char __user *buf, size_t count,
 			loff_t *ppos)
@@ -316,11 +317,12 @@ static ssize_t raw_read(struct file *file, char __user *buf, size_t count,
 	mutex_unlock(&raw->list_lock);
 	return retval;
 }
+FOPS_READ_ITER_HELPER(raw_read);
 
 static const struct file_operations raw_fops = {
 	.owner		= THIS_MODULE,
-	.write		= raw_write,
-	.read		= raw_read,
+	.write_iter	= raw_write_iter,
+	.read_iter	= raw_read_iter,
 	.open		= raw_open,
 	.llseek		= noop_llseek,
 };
Signature · 1 line
2.43.0
author maintainer
#209 lore raw

PATCH 203/437 staging: av7110: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/staging/media/av7110/av7110_av.c | 6 ++++--
 drivers/staging/media/av7110/av7110_ca.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/staging/media/av7110/av7110_av.c +4 -2
index 00dd6a7fea64..eb3ad2eae2d0 100644
@@ -974,6 +974,7 @@ static ssize_t dvb_video_write(struct file *file, const char __user *buf,
 	else
 		return dvb_play(av7110, buf, count, file->f_flags & O_NONBLOCK, 1);
 }
+FOPS_WRITE_ITER_HELPER(dvb_video_write);
 
 static __poll_t dvb_audio_poll(struct file *file, poll_table *wait)
 {
@@ -1015,6 +1016,7 @@ static ssize_t dvb_audio_write(struct file *file, const char __user *buf,
 	else
 		return dvb_aplay(av7110, buf, count, file->f_flags & O_NONBLOCK, 0);
 }
+FOPS_WRITE_ITER_HELPER(dvb_audio_write);
 
 static u8 iframe_header[] = { 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00 };
 
@@ -1572,7 +1574,7 @@ static int dvb_audio_release(struct inode *inode, struct file *file)
 
 static const struct file_operations dvb_video_fops = {
 	.owner		= THIS_MODULE,
-	.write		= dvb_video_write,
+	.write_iter	= dvb_video_write_iter,
 	.unlocked_ioctl	= dvb_generic_ioctl,
 	.compat_ioctl	= dvb_generic_ioctl,
 	.open		= dvb_video_open,
@@ -1592,7 +1594,7 @@ static struct dvb_device dvbdev_video = {
 
 static const struct file_operations dvb_audio_fops = {
 	.owner		= THIS_MODULE,
-	.write		= dvb_audio_write,
+	.write_iter	= dvb_audio_write_iter,
 	.unlocked_ioctl	= dvb_generic_ioctl,
 	.compat_ioctl	= dvb_generic_ioctl,
 	.open		= dvb_audio_open,
drivers/staging/media/av7110/av7110_ca.c +4 -2
index c1338e074a3d..6b9c90562228 100644
@@ -327,6 +327,7 @@ static ssize_t dvb_ca_write(struct file *file, const char __user *buf,
 	dprintk(8, "av7110:%p\n",av7110);
 	return ci_ll_write(&av7110->ci_wbuffer, file, buf, count, ppos);
 }
+FOPS_WRITE_ITER_HELPER(dvb_ca_write);
 
 static ssize_t dvb_ca_read(struct file *file, char __user *buf,
 			   size_t count, loff_t *ppos)
@@ -337,11 +338,12 @@ static ssize_t dvb_ca_read(struct file *file, char __user *buf,
 	dprintk(8, "av7110:%p\n",av7110);
 	return ci_ll_read(&av7110->ci_rbuffer, file, buf, count, ppos);
 }
+FOPS_READ_ITER_HELPER(dvb_ca_read);
 
 static const struct file_operations dvb_ca_fops = {
 	.owner		= THIS_MODULE,
-	.read		= dvb_ca_read,
-	.write		= dvb_ca_write,
+	.read_iter	= dvb_ca_read_iter,
+	.write_iter	= dvb_ca_write_iter,
 	.unlocked_ioctl	= dvb_generic_ioctl,
 	.open		= dvb_ca_open,
 	.release	= dvb_generic_release,
Signature · 1 line
2.43.0
author maintainer
#210 lore raw

PATCH 204/437 staging: vc04_services: convert to read/write iterators

In reply to Jens Axboe
---
 .../interface/vchiq_arm/vchiq_debugfs.c          | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +7 -9
index d833e4e2973a..0e18e2020654 100644
@@ -52,15 +52,14 @@ static int debugfs_trace_open(struct inode *inode, struct file *file)
 	return single_open(file, debugfs_trace_show, inode->i_private);
 }
 
-static ssize_t debugfs_trace_write(struct file *file,
-	const char __user *buffer,
-	size_t count, loff_t *ppos)
+static ssize_t debugfs_trace_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *f = (struct seq_file *)file->private_data;
+	struct seq_file *f = iocb->ki_filp->private_data;
 	struct vchiq_instance *instance = f->private;
+	size_t count = iov_iter_count(from);
 	char firstchar;
 
-	if (copy_from_user(&firstchar, buffer, 1))
+	if (!copy_from_iter_full(&firstchar, 1, from))
 		return -EFAULT;
 
 	switch (firstchar) {
@@ -78,16 +77,15 @@ static ssize_t debugfs_trace_write(struct file *file,
 		break;
 	}
 
-	*ppos += count;
-
+	iocb->ki_pos += count;
 	return count;
 }
 
 static const struct file_operations debugfs_trace_fops = {
 	.owner		= THIS_MODULE,
 	.open		= debugfs_trace_open,
-	.write		= debugfs_trace_write,
-	.read		= seq_read,
+	.write_iter	= debugfs_trace_write,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
Signature · 1 line
2.43.0
author maintainer
#211 lore raw

PATCH 205/437 drivers/xen: convert to ->read_iter and ->write_iter

In reply to Jens Axboe
---
 drivers/xen/evtchn.c                     | 25 ++++++++++++------------
 drivers/xen/mcelog.c                     | 17 ++++++++--------
 drivers/xen/xenbus/xenbus_dev_frontend.c | 24 +++++++++++------------
 drivers/xen/xenfs/super.c                |  7 +++----
 drivers/xen/xenfs/xenstored.c            | 11 +++++------
 drivers/xen/xenfs/xensyms.c              |  2 +-
 6 files changed, 42 insertions(+), 44 deletions(-)
drivers/xen/evtchn.c +13 -12
index f6a2216c2c87..06af1a458e44 100644
@@ -51,6 +51,7 @@
 #include <linux/cpu.h>
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
+#include <linux/uio.h>
 
 #include <xen/xen.h>
 #include <xen/events.h>
@@ -197,12 +198,12 @@ static irqreturn_t evtchn_interrupt(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static ssize_t evtchn_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *ppos)
+static ssize_t evtchn_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int rc;
 	unsigned int c, p, bytes1 = 0, bytes2 = 0;
-	struct per_user_data *u = file->private_data;
+	struct per_user_data *u = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 
 	/* Whole number of ports. */
 	count &= ~(sizeof(evtchn_port_t)-1);
@@ -227,7 +228,7 @@ static ssize_t evtchn_read(struct file *file, char __user *buf,
 
 		mutex_unlock(&u->ring_cons_mutex);
 
-		if (file->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		rc = wait_event_interruptible(u->evtchn_wait,
@@ -256,9 +257,9 @@ static ssize_t evtchn_read(struct file *file, char __user *buf,
 
 	rc = -EFAULT;
 	smp_rmb(); /* Ensure that we see the port before we copy it. */
-	if (copy_to_user(buf, evtchn_ring_entry(u, c), bytes1) ||
+	if (!copy_to_iter_full(evtchn_ring_entry(u, c), bytes1, to) ||
 	    ((bytes2 != 0) &&
-	     copy_to_user(&buf[bytes1], &u->ring[0], bytes2)))
+	     !copy_to_iter_full(&u->ring[0], bytes2, to)))
 		goto unlock_out;
 
 	WRITE_ONCE(u->ring_cons, c + (bytes1 + bytes2) / sizeof(evtchn_port_t));
@@ -269,12 +270,12 @@ static ssize_t evtchn_read(struct file *file, char __user *buf,
 	return rc;
 }
 
-static ssize_t evtchn_write(struct file *file, const char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t evtchn_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int rc, i;
 	evtchn_port_t *kbuf = (evtchn_port_t *)__get_free_page(GFP_KERNEL);
-	struct per_user_data *u = file->private_data;
+	struct per_user_data *u = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
 	if (kbuf == NULL)
 		return -ENOMEM;
@@ -290,7 +291,7 @@ static ssize_t evtchn_write(struct file *file, const char __user *buf,
 		count = PAGE_SIZE;
 
 	rc = -EFAULT;
-	if (copy_from_user(kbuf, buf, count) != 0)
+	if (!copy_from_iter_full(kbuf, count, from) != 0)
 		goto out;
 
 	mutex_lock(&u->bind_mutex);
@@ -687,8 +688,8 @@ static int evtchn_release(struct inode *inode, struct file *filp)
 
 static const struct file_operations evtchn_fops = {
 	.owner   = THIS_MODULE,
-	.read    = evtchn_read,
-	.write   = evtchn_write,
+	.read_iter    = evtchn_read,
+	.write_iter   = evtchn_write,
 	.unlocked_ioctl = evtchn_ioctl,
 	.poll    = evtchn_poll,
 	.fasync  = evtchn_fasync,
drivers/xen/mcelog.c +9 -8
index e9ac3b8c4167..610b5f746ca4 100644
@@ -103,10 +103,10 @@ static int xen_mce_chrdev_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t xen_mce_chrdev_read(struct file *filp, char __user *ubuf,
-				size_t usize, loff_t *off)
+static ssize_t xen_mce_chrdev_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	char __user *buf = ubuf;
+	size_t usize = iov_iter_count(to);
+	ssize_t copied;
 	unsigned num;
 	int i, err;
 
@@ -116,15 +116,16 @@ static ssize_t xen_mce_chrdev_read(struct file *filp, char __user *ubuf,
 
 	/* Only supports full reads right now */
 	err = -EINVAL;
-	if (*off != 0 || usize < XEN_MCE_LOG_LEN*sizeof(struct xen_mce))
+	if (iocb->ki_pos != 0 || usize < XEN_MCE_LOG_LEN*sizeof(struct xen_mce))
 		goto out;
 
 	err = 0;
+	copied = 0;
 	for (i = 0; i < num; i++) {
 		struct xen_mce *m = &xen_mcelog.entry[i];
 
-		err |= copy_to_user(buf, m, sizeof(*m));
-		buf += sizeof(*m);
+		err |= !copy_to_iter_full(m, sizeof(*m), to);
+		copied += sizeof(*m);
 	}
 
 	memset(xen_mcelog.entry, 0, num * sizeof(struct xen_mce));
@@ -136,7 +137,7 @@ static ssize_t xen_mce_chrdev_read(struct file *filp, char __user *ubuf,
 out:
 	mutex_unlock(&mcelog_lock);
 
-	return err ? err : buf - ubuf;
+	return err ? err : copied;
 }
 
 static __poll_t xen_mce_chrdev_poll(struct file *file, poll_table *wait)
@@ -179,7 +180,7 @@ static long xen_mce_chrdev_ioctl(struct file *f, unsigned int cmd,
 static const struct file_operations xen_mce_chrdev_ops = {
 	.open			= xen_mce_chrdev_open,
 	.release		= xen_mce_chrdev_release,
-	.read			= xen_mce_chrdev_read,
+	.read_iter		= xen_mce_chrdev_read,
 	.poll			= xen_mce_chrdev_poll,
 	.unlocked_ioctl		= xen_mce_chrdev_ioctl,
 	.llseek			= no_llseek,
drivers/xen/xenbus/xenbus_dev_frontend.c +11 -13
index 6f56640092a9..3da823abfdc0 100644
@@ -122,11 +122,10 @@ struct xenbus_file_priv {
 };
 
 /* Read out any raw xenbus messages queued up. */
-static ssize_t xenbus_file_read(struct file *filp,
-			       char __user *ubuf,
-			       size_t len, loff_t *ppos)
+static ssize_t xenbus_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct xenbus_file_priv *u = filp->private_data;
+	struct xenbus_file_priv *u = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	struct read_buffer *rb;
 	ssize_t i;
 	int ret;
@@ -135,7 +134,7 @@ static ssize_t xenbus_file_read(struct file *filp,
 again:
 	while (list_empty(&u->read_buffers)) {
 		mutex_unlock(&u->reply_mutex);
-		if (filp->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		ret = wait_event_interruptible(u->read_waitq,
@@ -150,7 +149,7 @@ static ssize_t xenbus_file_read(struct file *filp,
 	while (i < len) {
 		size_t sz = min_t(size_t, len - i, rb->len - rb->cons);
 
-		ret = copy_to_user(ubuf + i, &rb->msg[rb->cons], sz);
+		ret = !copy_to_iter_full(&rb->msg[rb->cons], sz, to);
 
 		i += sz - ret;
 		rb->cons += sz - ret;
@@ -547,11 +546,10 @@ static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
 	return rc;
 }
 
-static ssize_t xenbus_file_write(struct file *filp,
-				const char __user *ubuf,
-				size_t len, loff_t *ppos)
+static ssize_t xenbus_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct xenbus_file_priv *u = filp->private_data;
+	struct xenbus_file_priv *u = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	uint32_t msg_type;
 	int rc = len;
 	int ret;
@@ -585,7 +583,7 @@ static ssize_t xenbus_file_write(struct file *filp,
 		goto out;
 	}
 
-	ret = copy_from_user(u->u.buffer + u->len, ubuf, len);
+	ret = !copy_from_iter_full(u->u.buffer + u->len, len, from);
 
 	if (ret != 0) {
 		rc = -EFAULT;
@@ -695,8 +693,8 @@ static __poll_t xenbus_file_poll(struct file *file, poll_table *wait)
 }
 
 const struct file_operations xen_xenbus_fops = {
-	.read = xenbus_file_read,
-	.write = xenbus_file_write,
+	.read_iter = xenbus_file_read,
+	.write_iter = xenbus_file_write,
 	.open = xenbus_file_open,
 	.release = xenbus_file_release,
 	.poll = xenbus_file_poll,
drivers/xen/xenfs/super.c +3 -4
index d7d64235010d..54e4e4702572 100644
@@ -28,19 +28,18 @@
 MODULE_DESCRIPTION("Xen filesystem");
 MODULE_LICENSE("GPL");
 
-static ssize_t capabilities_read(struct file *file, char __user *buf,
-				 size_t size, loff_t *off)
+static ssize_t capabilities_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *tmp = "";
 
 	if (xen_initial_domain())
 		tmp = "control_d\n";
 
-	return simple_read_from_buffer(buf, size, off, tmp, strlen(tmp));
+	return simple_copy_to_iter(tmp, &iocb->ki_pos, strlen(tmp), to);
 }
 
 static const struct file_operations capabilities_file_ops = {
-	.read = capabilities_read,
+	.read_iter = capabilities_read,
 	.llseek = default_llseek,
 };
 
drivers/xen/xenfs/xenstored.c +5 -6
index f59235f9f8a2..c4e8692deac2 100644
@@ -9,11 +9,10 @@
 
 #include "xenfs.h"
 
-static ssize_t xsd_read(struct file *file, char __user *buf,
-			    size_t size, loff_t *off)
+static ssize_t xsd_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	const char *str = (const char *)file->private_data;
-	return simple_read_from_buffer(buf, size, off, str, strlen(str));
+	const char *str = (const char *)iocb->ki_filp->private_data;
+	return simple_copy_to_iter(str, &iocb->ki_pos, strlen(str), to);
 }
 
 static int xsd_release(struct inode *inode, struct file *file)
@@ -49,7 +48,7 @@ static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
 const struct file_operations xsd_kva_file_ops = {
 	.open = xsd_kva_open,
 	.mmap = xsd_kva_mmap,
-	.read = xsd_read,
+	.read_iter = xsd_read,
 	.release = xsd_release,
 };
 
@@ -64,6 +63,6 @@ static int xsd_port_open(struct inode *inode, struct file *file)
 
 const struct file_operations xsd_port_file_ops = {
 	.open = xsd_port_open,
-	.read = xsd_read,
+	.read_iter = xsd_read,
 	.release = xsd_release,
 };
drivers/xen/xenfs/xensyms.c +1 -1
index b799bc759c15..ec30aa09620f 100644
@@ -146,7 +146,7 @@ static int xensyms_release(struct inode *inode, struct file *file)
 
 const struct file_operations xensyms_ops = {
 	.open = xensyms_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = xensyms_release
 };
Signature · 1 line
2.43.0
author maintainer
#212 lore raw

PATCH 206/437 virt: convert to ->read_iter and ->write_iter

In reply to Jens Axboe
---
 virt/kvm/kvm_main.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
virt/kvm/kvm_main.c +6 -4
index fb49c2a60200..9530584af843 100644
@@ -4373,6 +4373,7 @@ static ssize_t kvm_vcpu_stats_read(struct file *file, char __user *user_buffer,
 			&kvm_vcpu_stats_desc[0], &vcpu->stat,
 			sizeof(vcpu->stat), user_buffer, size, offset);
 }
+FOPS_READ_ITER_HELPER(kvm_vcpu_stats_read);
 
 static int kvm_vcpu_stats_release(struct inode *inode, struct file *file)
 {
@@ -4384,7 +4385,7 @@ static int kvm_vcpu_stats_release(struct inode *inode, struct file *file)
 
 static const struct file_operations kvm_vcpu_stats_fops = {
 	.owner = THIS_MODULE,
-	.read = kvm_vcpu_stats_read,
+	.read_iter = kvm_vcpu_stats_read_iter,
 	.release = kvm_vcpu_stats_release,
 	.llseek = noop_llseek,
 };
@@ -5064,6 +5065,7 @@ static ssize_t kvm_vm_stats_read(struct file *file, char __user *user_buffer,
 				&kvm_vm_stats_desc[0], &kvm->stat,
 				sizeof(kvm->stat), user_buffer, size, offset);
 }
+FOPS_READ_ITER_HELPER(kvm_vm_stats_read);
 
 static int kvm_vm_stats_release(struct inode *inode, struct file *file)
 {
@@ -5075,7 +5077,7 @@ static int kvm_vm_stats_release(struct inode *inode, struct file *file)
 
 static const struct file_operations kvm_vm_stats_fops = {
 	.owner = THIS_MODULE,
-	.read = kvm_vm_stats_read,
+	.read_iter = kvm_vm_stats_read_iter,
 	.release = kvm_vm_stats_release,
 	.llseek = noop_llseek,
 };
@@ -6153,8 +6155,8 @@ static const struct file_operations stat_fops_per_vm = {
 	.owner = THIS_MODULE,
 	.open = kvm_stat_data_open,
 	.release = kvm_debugfs_release,
-	.read = simple_attr_read,
-	.write = simple_attr_write,
+	.read_iter = simple_attr_read_iter,
+	.write_iter = simple_attr_write_iter,
 	.llseek = no_llseek,
 };
 
Signature · 1 line
2.43.0
author maintainer
#213 lore raw

PATCH 207/437 virt: fsl_hypervisor: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/virt/fsl_hypervisor.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/virt/fsl_hypervisor.c +6 -8
index e92e2ceb12a4..dc84e0006201 100644
@@ -590,11 +590,10 @@ static __poll_t fsl_hv_poll(struct file *filp, struct poll_table_struct *p)
  * return them to the caller as an array of 32-bit integers.  Otherwise,
  * block until there is at least one handle to return.
  */
-static ssize_t fsl_hv_read(struct file *filp, char __user *buf, size_t len,
-			   loff_t *off)
+static ssize_t fsl_hv_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct doorbell_queue *dbq = filp->private_data;
-	uint32_t __user *p = (uint32_t __user *) buf; /* for put_user() */
+	struct doorbell_queue *dbq = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	unsigned long flags;
 	ssize_t count = 0;
 
@@ -613,7 +612,7 @@ static ssize_t fsl_hv_read(struct file *filp, char __user *buf, size_t len,
 			spin_unlock_irqrestore(&dbq->lock, flags);
 			if (count)
 				break;
-			if (filp->f_flags & O_NONBLOCK)
+			if (iocb->ki_filp->f_flags & O_NONBLOCK)
 				return -EAGAIN;
 			if (wait_event_interruptible(dbq->wait,
 						     dbq->head != dbq->tail))
@@ -639,9 +638,8 @@ static ssize_t fsl_hv_read(struct file *filp, char __user *buf, size_t len,
 
 		spin_unlock_irqrestore(&dbq->lock, flags);
 
-		if (put_user(dbell, p))
+		if (put_iter(dbell, to))
 			return -EFAULT;
-		p++;
 		count += sizeof(uint32_t);
 		len -= sizeof(uint32_t);
 	}
@@ -700,7 +698,7 @@ static const struct file_operations fsl_hv_fops = {
 	.open = fsl_hv_open,
 	.release = fsl_hv_close,
 	.poll = fsl_hv_poll,
-	.read = fsl_hv_read,
+	.read_iter = fsl_hv_read,
 	.unlocked_ioctl = fsl_hv_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 };
Signature · 1 line
2.43.0
author maintainer
#214 lore raw

PATCH 208/437 drivers/video: convert to ->read_iter and ->write_iter

In reply to Jens Axboe
---
 drivers/video/fbdev/core/fb_chrdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/video/fbdev/core/fb_chrdev.c +4 -2
index 4ebd16b7e3b8..161f781912c3 100644
@@ -42,6 +42,7 @@ static ssize_t fb_read(struct file *file, char __user *buf, size_t count, loff_t
 
 	return info->fbops->fb_read(info, buf, count, ppos);
 }
+FOPS_READ_ITER_HELPER(fb_read);
 
 static ssize_t fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
@@ -58,6 +59,7 @@ static ssize_t fb_write(struct file *file, const char __user *buf, size_t count,
 
 	return info->fbops->fb_write(info, buf, count, ppos);
 }
+FOPS_WRITE_ITER_HELPER(fb_write);
 
 static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
 			unsigned long arg)
@@ -405,8 +407,8 @@ static unsigned long get_fb_unmapped_area(struct file *filp,
 
 static const struct file_operations fb_fops = {
 	.owner = THIS_MODULE,
-	.read = fb_read,
-	.write = fb_write,
+	.read_iter = fb_read_iter,
+	.write_iter = fb_write_iter,
 	.unlocked_ioctl = fb_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = fb_compat_ioctl,
Signature · 1 line
2.43.0
author maintainer
#215 lore raw

PATCH 209/437 video: fbdev: pxa3xx-gcu: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/video/fbdev/pxa3xx-gcu.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/video/fbdev/pxa3xx-gcu.c +5 -7
index 43c80316d84b..0890cea32df4 100644
@@ -372,15 +372,13 @@ static int pxa3xx_gcu_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t
-pxa3xx_gcu_write(struct file *file, const char *buff,
-		 size_t count, loff_t *offp)
+static ssize_t pxa3xx_gcu_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int ret;
 	unsigned long flags;
 	struct pxa3xx_gcu_batch	*buffer;
-	struct pxa3xx_gcu_priv *priv = to_pxa3xx_gcu_priv(file);
-
+	struct pxa3xx_gcu_priv *priv = to_pxa3xx_gcu_priv(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	size_t words = count / 4;
 
 	/* Does not need to be atomic. There's a lock in user space,
@@ -409,7 +407,7 @@ pxa3xx_gcu_write(struct file *file, const char *buff,
 
 
 	/* Copy data from user into buffer */
-	ret = copy_from_user(buffer->ptr, buff, words * 4);
+	ret = !copy_from_iter_full(buffer->ptr, words * 4, from);
 	if (ret) {
 		spin_lock_irqsave(&priv->spinlock, flags);
 		buffer->next = priv->free;
@@ -569,7 +567,7 @@ pxa3xx_gcu_free_buffers(struct device *dev,
 static const struct file_operations pxa3xx_gcu_miscdev_fops = {
 	.owner =		THIS_MODULE,
 	.open =			pxa3xx_gcu_open,
-	.write =		pxa3xx_gcu_write,
+	.write_iter =		pxa3xx_gcu_write,
 	.unlocked_ioctl =	pxa3xx_gcu_ioctl,
 	.mmap =			pxa3xx_gcu_mmap,
 };
Signature · 1 line
2.43.0
author maintainer
#216 lore raw

PATCH 210/437 drivers/iommu: convert intel iommu to read/write iterators

In reply to Jens Axboe
---
 drivers/iommu/intel/debugfs.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/iommu/intel/debugfs.c +7 -7
index 86b506af7daa..8655098a3a17 100644
@@ -679,19 +679,19 @@ static int dmar_perf_latency_open(struct inode *inode, struct file *filp)
 	return single_open(filp, latency_show, NULL);
 }
 
-static ssize_t dmar_perf_latency_write(struct file *filp,
-				       const char __user *ubuf,
-				       size_t cnt, loff_t *ppos)
+static ssize_t dmar_perf_latency_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
 	struct dmar_drhd_unit *drhd;
 	struct intel_iommu *iommu;
+	size_t cnt = iov_iter_count(from);
 	int counting;
 	char buf[64];
 
 	if (cnt > 63)
 		cnt = 63;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -738,14 +738,14 @@ static ssize_t dmar_perf_latency_write(struct file *filp,
 		return -EINVAL;
 	}
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 	return cnt;
 }
 
 static const struct file_operations dmar_perf_latency_fops = {
 	.open		= dmar_perf_latency_open,
-	.write		= dmar_perf_latency_write,
-	.read		= seq_read,
+	.write_iter	= dmar_perf_latency_write,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
Signature · 1 line
2.43.0
author maintainer
#217 lore raw

PATCH 211/437 drivers/iommu: convert omap to read/write iterators

In reply to Jens Axboe
---
 drivers/iommu/omap-iommu-debug.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/iommu/omap-iommu-debug.c +6 -5
index 259f65291d90..46798b7584b5 100644
@@ -11,6 +11,7 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/uio.h>
 #include <linux/pm_runtime.h>
 #include <linux/debugfs.h>
 #include <linux/platform_data/iommu-omap.h>
@@ -80,10 +81,10 @@ static ssize_t omap_iommu_dump_ctx(struct omap_iommu *obj, char *buf,
 	return bytes;
 }
 
-static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
-			       size_t count, loff_t *ppos)
+static ssize_t debug_read_regs(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct omap_iommu *obj = file->private_data;
+	struct omap_iommu *obj = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	char *p, *buf;
 	ssize_t bytes;
 
@@ -100,7 +101,7 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
 	bytes = omap_iommu_dump_ctx(obj, p, count);
 	if (bytes < 0)
 		goto err;
-	bytes = simple_read_from_buffer(userbuf, count, ppos, buf, bytes);
+	bytes = simple_copy_to_iter(buf, &iocb->ki_pos, bytes, to);
 
 err:
 	mutex_unlock(&iommu_debug_lock);
@@ -231,7 +232,7 @@ static int pagetable_show(struct seq_file *s, void *data)
 #define DEBUG_FOPS_RO(name)						\
 	static const struct file_operations name##_fops = {	        \
 		.open = simple_open,					\
-		.read = debug_read_##name,				\
+		.read_iter = debug_read_##name,				\
 		.llseek = generic_file_llseek,				\
 	}
 
Signature · 1 line
2.43.0
author maintainer
#218 lore raw

PATCH 212/437 misc: bcm_vk: convert to iterators

In reply to Jens Axboe
---
 drivers/misc/bcm-vk/bcm_vk.h     |  6 ++----
 drivers/misc/bcm-vk/bcm_vk_dev.c |  4 ++--
 drivers/misc/bcm-vk/bcm_vk_msg.c | 23 ++++++++++-------------
 3 files changed, 14 insertions(+), 19 deletions(-)
drivers/misc/bcm-vk/bcm_vk.h +2 -4
index 386884c2a263..efc91635fa42 100644
@@ -487,10 +487,8 @@ static inline bool bcm_vk_msgq_marker_valid(struct bcm_vk *vk)
 }
 
 int bcm_vk_open(struct inode *inode, struct file *p_file);
-ssize_t bcm_vk_read(struct file *p_file, char __user *buf, size_t count,
-		    loff_t *f_pos);
-ssize_t bcm_vk_write(struct file *p_file, const char __user *buf,
-		     size_t count, loff_t *f_pos);
+ssize_t bcm_vk_read(struct kiocb *iocb, struct iov_iter *to);
+ssize_t bcm_vk_write(struct kiocb *iocb, struct iov_iter *from);
 __poll_t bcm_vk_poll(struct file *p_file, struct poll_table_struct *wait);
 int bcm_vk_release(struct inode *inode, struct file *p_file);
 void bcm_vk_release_data(struct kref *kref);
drivers/misc/bcm-vk/bcm_vk_dev.c +2 -2
index d4a96137728d..1fadb7b2dec1 100644
@@ -1258,8 +1258,8 @@ static long bcm_vk_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations bcm_vk_fops = {
 	.owner = THIS_MODULE,
 	.open = bcm_vk_open,
-	.read = bcm_vk_read,
-	.write = bcm_vk_write,
+	.read_iter = bcm_vk_read,
+	.write_iter = bcm_vk_write,
 	.poll = bcm_vk_poll,
 	.release = bcm_vk_release,
 	.mmap = bcm_vk_mmap,
drivers/misc/bcm-vk/bcm_vk_msg.c +10 -13
index 1f42d1d5a630..31418a677ecd 100644
@@ -13,6 +13,7 @@
 #include <linux/sizes.h>
 #include <linux/spinlock.h>
 #include <linux/timer.h>
+#include <linux/uio.h>
 
 #include "bcm_vk.h"
 #include "bcm_vk_msg.h"
@@ -998,18 +999,16 @@ int bcm_vk_open(struct inode *inode, struct file *p_file)
 	return rc;
 }
 
-ssize_t bcm_vk_read(struct file *p_file,
-		    char __user *buf,
-		    size_t count,
-		    loff_t *f_pos)
+ssize_t bcm_vk_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t rc = -ENOMSG;
-	struct bcm_vk_ctx *ctx = p_file->private_data;
+	struct bcm_vk_ctx *ctx = iocb->ki_filp->private_data;
 	struct bcm_vk *vk = container_of(ctx->miscdev, struct bcm_vk,
 					 miscdev);
 	struct device *dev = &vk->pdev->dev;
 	struct bcm_vk_msg_chan *chan = &vk->to_h_msg_chan;
 	struct bcm_vk_wkent *entry = NULL, *iter;
+	size_t count = iov_iter_count(to);
 	u32 q_num;
 	u32 rsp_length;
 
@@ -1047,7 +1046,7 @@ ssize_t bcm_vk_read(struct file *p_file,
 		/* retrieve the passed down msg_id */
 		set_msg_id(&entry->to_h_msg[0], entry->usr_msg_id);
 		rsp_length = entry->to_h_blks * VK_MSGQ_BLK_SIZE;
-		if (copy_to_user(buf, entry->to_h_msg, rsp_length) == 0)
+		if (!copy_to_iter_full(entry->to_h_msg, rsp_length, to))
 			rc = rsp_length;
 
 		bcm_vk_free_wkent(dev, entry);
@@ -1060,7 +1059,7 @@ ssize_t bcm_vk_read(struct file *p_file,
 		 */
 		set_msg_id(&tmp_msg, entry->usr_msg_id);
 		tmp_msg.size = entry->to_h_blks - 1;
-		if (copy_to_user(buf, &tmp_msg, VK_MSGQ_BLK_SIZE) != 0) {
+		if (!copy_to_iter_full(&tmp_msg, VK_MSGQ_BLK_SIZE, to)) {
 			dev_err(dev, "Error return 1st block in -EMSGSIZE\n");
 			rc = -EFAULT;
 		}
@@ -1068,17 +1067,15 @@ ssize_t bcm_vk_read(struct file *p_file,
 	return rc;
 }
 
-ssize_t bcm_vk_write(struct file *p_file,
-		     const char __user *buf,
-		     size_t count,
-		     loff_t *f_pos)
+ssize_t bcm_vk_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	ssize_t rc;
-	struct bcm_vk_ctx *ctx = p_file->private_data;
+	struct bcm_vk_ctx *ctx = iocb->ki_filp->private_data;
 	struct bcm_vk *vk = container_of(ctx->miscdev, struct bcm_vk,
 					 miscdev);
 	struct bcm_vk_msgq __iomem *msgq;
 	struct device *dev = &vk->pdev->dev;
+	size_t count = iov_iter_count(from);
 	struct bcm_vk_wkent *entry;
 	u32 sgl_extra_blks;
 	u32 q_num;
@@ -1107,7 +1104,7 @@ ssize_t bcm_vk_write(struct file *p_file,
 	}
 
 	/* now copy msg from user space, and then formulate the work entry */
-	if (copy_from_user(&entry->to_v_msg[0], buf, count)) {
+	if (!copy_from_iter_full(&entry->to_v_msg[0], count, from)) {
 		rc = -EFAULT;
 		goto write_free_ent;
 	}
Signature · 1 line
2.43.0
author maintainer
#219 lore raw

PATCH 213/437 misc: lis3lv02d: convert to iterators

In reply to Jens Axboe
---
 drivers/misc/lis3lv02d/lis3lv02d.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/misc/lis3lv02d/lis3lv02d.c +7 -6
index 49868a45c0ad..e12677611146 100644
@@ -27,6 +27,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/atomic.h>
 #include <linux/of.h>
+#include <linux/uio.h>
 #include "lis3lv02d.h"
 
 #define DRIVER_NAME     "lis3lv02d"
@@ -596,12 +597,12 @@ static int lis3lv02d_misc_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
-				size_t count, loff_t *pos)
+static ssize_t lis3lv02d_misc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lis3lv02d *lis3 = container_of(file->private_data,
+	struct lis3lv02d *lis3 = container_of(iocb->ki_filp->private_data,
 					      struct lis3lv02d, miscdev);
 
+	size_t count = iov_iter_count(to);
 	DECLARE_WAITQUEUE(wait, current);
 	u32 data;
 	unsigned char byte_data;
@@ -617,7 +618,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
 		if (data)
 			break;
 
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
 			goto out;
 		}
@@ -638,7 +639,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
 	/* make sure we are not going into copy_to_user() with
 	 * TASK_INTERRUPTIBLE state */
 	set_current_state(TASK_RUNNING);
-	if (copy_to_user(buf, &byte_data, sizeof(byte_data)))
+	if (!copy_to_iter_full(&byte_data, sizeof(byte_data), to))
 		retval = -EFAULT;
 
 out:
@@ -670,7 +671,7 @@ static int lis3lv02d_misc_fasync(int fd, struct file *file, int on)
 static const struct file_operations lis3lv02d_misc_fops = {
 	.owner   = THIS_MODULE,
 	.llseek  = no_llseek,
-	.read    = lis3lv02d_misc_read,
+	.read_iter    = lis3lv02d_misc_read,
 	.open    = lis3lv02d_misc_open,
 	.release = lis3lv02d_misc_release,
 	.poll    = lis3lv02d_misc_poll,
Signature · 1 line
2.43.0
author maintainer
#220 lore raw

PATCH 214/437 misc: eeprom/idt_89hpesx: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/misc/eeprom/idt_89hpesx.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/misc/eeprom/idt_89hpesx.c +10 -11
index 327afb866b21..dfb68c0cc999 100644
@@ -900,20 +900,20 @@ static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
  * "<reg addr>:<value>". Register address must be aligned within 4 bytes
  * (one DWORD).
  */
-static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf,
-				   size_t count, loff_t *offp)
+static ssize_t idt_dbgfs_csr_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct idt_89hpesx_dev *pdev = filep->private_data;
+	struct idt_89hpesx_dev *pdev = iocb->ki_filp->private_data;
 	char *colon_ch, *csraddr_str, *csrval_str;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u32 csraddr, csrval;
 	char *buf;
 
-	if (*offp)
+	if (iocb->ki_pos)
 		return 0;
 
 	/* Copy data from User-space */
-	buf = memdup_user_nul(ubuf, count);
+	buf = iterdup(from, count);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -987,10 +987,9 @@ static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf,
  * It just prints the pair "0x<reg addr>:0x<value>" to passed buffer.
  */
 #define CSRBUF_SIZE	((size_t)32)
-static ssize_t idt_dbgfs_csr_read(struct file *filep, char __user *ubuf,
-				  size_t count, loff_t *offp)
+static ssize_t idt_dbgfs_csr_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct idt_89hpesx_dev *pdev = filep->private_data;
+	struct idt_89hpesx_dev *pdev = iocb->ki_filp->private_data;
 	u32 csraddr, csrval;
 	char buf[CSRBUF_SIZE];
 	int ret, size;
@@ -1008,7 +1007,7 @@ static ssize_t idt_dbgfs_csr_read(struct file *filep, char __user *ubuf,
 		(unsigned int)csraddr, (unsigned int)csrval);
 
 	/* Copy data to User-space */
-	return simple_read_from_buffer(ubuf, count, offp, buf, size);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, size, to);
 }
 
 /*
@@ -1025,8 +1024,8 @@ static BIN_ATTR_RW(eeprom, EEPROM_DEF_SIZE);
 static const struct file_operations csr_dbgfs_ops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = idt_dbgfs_csr_write,
-	.read = idt_dbgfs_csr_read
+	.write_iter = idt_dbgfs_csr_write,
+	.read_iter = idt_dbgfs_csr_read
 };
 
 /*===========================================================================
Signature · 1 line
2.43.0
author maintainer
#221 lore raw

PATCH 215/437 misc: hpilo: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/misc/hpilo.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/misc/hpilo.c +11 -10
index 04bd34c8c506..27282629e383 100644
@@ -23,6 +23,7 @@
 #include <linux/wait.h>
 #include <linux/poll.h>
 #include <linux/slab.h>
+#include <linux/uio.h>
 #include "hpilo.h"
 
 static const struct class ilo_class = {
@@ -431,13 +432,13 @@ static void ilo_set_reset(struct ilo_hwinfo *hw)
 	}
 }
 
-static ssize_t ilo_read(struct file *fp, char __user *buf,
-			size_t len, loff_t *off)
+static ssize_t ilo_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int err, found, cnt, pkt_id, pkt_len;
-	struct ccb_data *data = fp->private_data;
+	struct ccb_data *data = iocb->ki_filp->private_data;
 	struct ccb *driver_ccb = &data->driver_ccb;
 	struct ilo_hwinfo *hw = data->ilo_hw;
+	size_t len = iov_iter_count(to);
 	void *pkt;
 
 	if (is_channel_reset(driver_ccb)) {
@@ -473,7 +474,7 @@ static ssize_t ilo_read(struct file *fp, char __user *buf,
 	if (pkt_len < len)
 		len = pkt_len;
 
-	err = copy_to_user(buf, pkt, len);
+	err = !copy_to_iter_full(pkt, len, to);
 
 	/* return the received packet to the queue */
 	ilo_pkt_enqueue(hw, driver_ccb, RECVQ, pkt_id, desc_mem_sz(1));
@@ -481,13 +482,13 @@ static ssize_t ilo_read(struct file *fp, char __user *buf,
 	return err ? -EFAULT : len;
 }
 
-static ssize_t ilo_write(struct file *fp, const char __user *buf,
-			 size_t len, loff_t *off)
+static ssize_t ilo_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int err, pkt_id, pkt_len;
-	struct ccb_data *data = fp->private_data;
+	struct ccb_data *data = iocb->ki_filp->private_data;
 	struct ccb *driver_ccb = &data->driver_ccb;
 	struct ilo_hwinfo *hw = data->ilo_hw;
+	size_t len = iov_iter_count(from);
 	void *pkt;
 
 	if (is_channel_reset(driver_ccb))
@@ -502,7 +503,7 @@ static ssize_t ilo_write(struct file *fp, const char __user *buf,
 		len = pkt_len;
 
 	/* on failure, set the len to 0 to return empty packet to the device */
-	err = copy_from_user(pkt, buf, len);
+	err = !copy_from_iter_full(pkt, len, from);
 	if (err)
 		len = 0;
 
@@ -635,8 +636,8 @@ static int ilo_open(struct inode *ip, struct file *fp)
 
 static const struct file_operations ilo_fops = {
 	.owner		= THIS_MODULE,
-	.read		= ilo_read,
-	.write		= ilo_write,
+	.read_iter	= ilo_read,
+	.write_iter	= ilo_write,
 	.poll		= ilo_poll,
 	.open 		= ilo_open,
 	.release 	= ilo_close,
Signature · 1 line
2.43.0
author maintainer
#222 lore raw

PATCH 216/437 misc: lkdtm: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/misc/lkdtm/core.c | 40 +++++++++++++++++----------------------
 1 file changed, 17 insertions(+), 23 deletions(-)
drivers/misc/lkdtm/core.c +17 -23
index 5732fd59a227..12f02713f39c 100644
@@ -27,20 +27,17 @@
 #include <linux/slab.h>
 #include <linux/debugfs.h>
 #include <linux/utsname.h>
+#include <linux/uio.h>
 
 #define DEFAULT_COUNT 10
 
 static int lkdtm_debugfs_open(struct inode *inode, struct file *file);
-static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
-		size_t count, loff_t *off);
-static ssize_t direct_entry(struct file *f, const char __user *user_buf,
-			    size_t count, loff_t *off);
+static ssize_t lkdtm_debugfs_read(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t direct_entry(struct kiocb *iocb, struct iov_iter *from);
 
 #ifdef CONFIG_KPROBES
 static int lkdtm_kprobe_handler(struct kprobe *kp, struct pt_regs *regs);
-static ssize_t lkdtm_debugfs_entry(struct file *f,
-				   const char __user *user_buf,
-				   size_t count, loff_t *off);
+static ssize_t lkdtm_debugfs_entry(struct kiocb *iocb, struct iov_iter *from);
 # define CRASHPOINT_KPROBE(_symbol)				\
 		.kprobe = {					\
 			.symbol_name = (_symbol),		\
@@ -64,10 +61,10 @@ struct crashpoint {
 	{							\
 		.name = _name,					\
 		.fops = {					\
-			.read	= lkdtm_debugfs_read,		\
+			.read_iter= lkdtm_debugfs_read,		\
 			.llseek	= generic_file_llseek,		\
 			.open	= lkdtm_debugfs_open,		\
-			.write	= CRASHPOINT_WRITE(_symbol)	\
+			.write_iter = CRASHPOINT_WRITE(_symbol)	\
 		},						\
 		CRASHPOINT_KPROBE(_symbol)			\
 	}
@@ -224,12 +221,11 @@ static int lkdtm_kprobe_handler(struct kprobe *kp, struct pt_regs *regs)
 	return 0;
 }
 
-static ssize_t lkdtm_debugfs_entry(struct file *f,
-				   const char __user *user_buf,
-				   size_t count, loff_t *off)
+static ssize_t lkdtm_debugfs_entry(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct crashpoint *crashpoint = file_inode(f)->i_private;
+	struct crashpoint *crashpoint = file_inode(iocb->ki_filp)->i_private;
 	const struct crashtype *crashtype = NULL;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int err;
 
@@ -239,7 +235,7 @@ static ssize_t lkdtm_debugfs_entry(struct file *f,
 	buf = (char *)__get_free_page(GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
-	if (copy_from_user(buf, user_buf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		free_page((unsigned long) buf);
 		return -EFAULT;
 	}
@@ -257,15 +253,14 @@ static ssize_t lkdtm_debugfs_entry(struct file *f,
 	if (err < 0)
 		return err;
 
-	*off += count;
+	iocb->ki_pos += count;
 
 	return count;
 }
 #endif
 
 /* Generic read callback that just prints out the available crash types */
-static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
-		size_t count, loff_t *off)
+static ssize_t lkdtm_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int n, cat, idx;
 	ssize_t out;
@@ -288,8 +283,7 @@ static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
 	}
 	buf[n] = '\0';
 
-	out = simple_read_from_buffer(user_buf, count, off,
-				      buf, n);
+	out = simple_copy_to_iter(buf, &iocb->ki_pos, n, to);
 	free_page((unsigned long) buf);
 
 	return out;
@@ -301,10 +295,10 @@ static int lkdtm_debugfs_open(struct inode *inode, struct file *file)
 }
 
 /* Special entry to just crash directly. Available without KPROBEs */
-static ssize_t direct_entry(struct file *f, const char __user *user_buf,
-		size_t count, loff_t *off)
+static ssize_t direct_entry(struct kiocb *iocb, struct iov_iter *from)
 {
 	const struct crashtype *crashtype;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int err;
 
@@ -316,7 +310,7 @@ static ssize_t direct_entry(struct file *f, const char __user *user_buf,
 	buf = (char *)__get_free_page(GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
-	if (copy_from_user(buf, user_buf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		free_page((unsigned long) buf);
 		return -EFAULT;
 	}
@@ -331,7 +325,7 @@ static ssize_t direct_entry(struct file *f, const char __user *user_buf,
 
 	pr_info("Performing direct entry %s\n", crashtype->name);
 	err = lkdtm_do_action(crashtype);
-	*off += count;
+	iocb->ki_pos += count;
 
 	if (err)
 		return err;
Signature · 1 line
2.43.0
author maintainer
#223 lore raw

PATCH 217/437 misc: open-dice: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/misc/open-dice.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/misc/open-dice.c +9 -10
index 1e3eb2aa44d9..0fe66a17f27d 100644
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
+#include <linux/uio.h>
 
 #define DRIVER_NAME "open-dice"
 
@@ -61,26 +62,24 @@ static int open_dice_wipe(struct open_dice_drvdata *drvdata)
 /*
  * Copies the size of the reserved memory region to the user-provided buffer.
  */
-static ssize_t open_dice_read(struct file *filp, char __user *ptr, size_t len,
-			      loff_t *off)
+static ssize_t open_dice_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	unsigned long val = to_open_dice_drvdata(filp)->rmem->size;
+	unsigned long val = to_open_dice_drvdata(iocb->ki_filp)->rmem->size;
 
-	return simple_read_from_buffer(ptr, len, off, &val, sizeof(val));
+	return simple_copy_to_iter(&val, &iocb->ki_pos, sizeof(val), to);
 }
 
 /*
  * Triggers a wipe of the reserved memory region. The user-provided pointer
  * is never dereferenced.
  */
-static ssize_t open_dice_write(struct file *filp, const char __user *ptr,
-			       size_t len, loff_t *off)
+static ssize_t open_dice_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	if (open_dice_wipe(to_open_dice_drvdata(filp)))
+	if (open_dice_wipe(to_open_dice_drvdata(iocb->ki_filp)))
 		return -EIO;
 
 	/* Consume the input buffer. */
-	return len;
+	return iov_iter_count(from);
 }
 
 /*
@@ -106,8 +105,8 @@ static int open_dice_mmap(struct file *filp, struct vm_area_struct *vma)
 
 static const struct file_operations open_dice_fops = {
 	.owner = THIS_MODULE,
-	.read = open_dice_read,
-	.write = open_dice_write,
+	.read_iter = open_dice_read,
+	.write_iter = open_dice_write,
 	.mmap = open_dice_mmap,
 };
 
Signature · 1 line
2.43.0
author maintainer
#224 lore raw

PATCH 218/437 misc: tps6594-pfsm: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/misc/tps6594-pfsm.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)
drivers/misc/tps6594-pfsm.c +14 -16
index 88dcac814892..3e3da7b4bb7e 100644
@@ -45,11 +45,11 @@ struct tps6594_pfsm {
 	struct regmap *regmap;
 };
 
-static ssize_t tps6594_pfsm_read(struct file *f, char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t tps6594_pfsm_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tps6594_pfsm *pfsm = TPS6594_FILE_TO_PFSM(f);
-	loff_t pos = *ppos;
+	struct tps6594_pfsm *pfsm = TPS6594_FILE_TO_PFSM(iocb->ki_filp);
+	size_t count = iov_iter_count(to);
+	loff_t pos = iocb->ki_pos;
 	unsigned int val;
 	int ret;
 	int i;
@@ -66,20 +66,19 @@ static ssize_t tps6594_pfsm_read(struct file *f, char __user *buf,
 		if (ret)
 			return ret;
 
-		if (put_user(val, buf + i))
+		if (put_iter(val, to))
 			return -EFAULT;
 	}
 
-	*ppos = pos + count;
-
+	iocb->ki_pos = pos + count;
 	return count;
 }
 
-static ssize_t tps6594_pfsm_write(struct file *f, const char __user *buf,
-				  size_t count, loff_t *ppos)
+static ssize_t tps6594_pfsm_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tps6594_pfsm *pfsm = TPS6594_FILE_TO_PFSM(f);
-	loff_t pos = *ppos;
+	struct tps6594_pfsm *pfsm = TPS6594_FILE_TO_PFSM(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
+	loff_t pos = iocb->ki_pos;
 	char val;
 	int ret;
 	int i;
@@ -92,7 +91,7 @@ static ssize_t tps6594_pfsm_write(struct file *f, const char __user *buf,
 		count = TPS6594_PMIC_MAX_POS - pos;
 
 	for (i = 0 ; i < count ; i++) {
-		if (get_user(val, buf + i))
+		if (get_iter(val, from))
 			return -EFAULT;
 
 		ret = regmap_write(pfsm->regmap, pos + i, val);
@@ -100,8 +99,7 @@ static ssize_t tps6594_pfsm_write(struct file *f, const char __user *buf,
 			return ret;
 	}
 
-	*ppos = pos + count;
-
+	iocb->ki_pos = pos + count;
 	return count;
 }
 
@@ -221,8 +219,8 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a
 static const struct file_operations tps6594_pfsm_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= generic_file_llseek,
-	.read		= tps6594_pfsm_read,
-	.write		= tps6594_pfsm_write,
+	.read_iter	= tps6594_pfsm_read,
+	.write_iter	= tps6594_pfsm_write,
 	.unlocked_ioctl	= tps6594_pfsm_ioctl,
 	.compat_ioctl   = compat_ptr_ioctl,
 };
Signature · 1 line
2.43.0
author maintainer
#225 lore raw

PATCH 219/437 misc: ibmvmc: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/misc/ibmvmc.c | 40 +++++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 23 deletions(-)
drivers/misc/ibmvmc.c +17 -23
index e5f935b5249d..545739f1f342 100644
@@ -900,21 +900,20 @@ static int ibmvmc_close(struct inode *inode, struct file *file)
  *	0 - Success
  *	Non-zero - Failure
  */
-static ssize_t ibmvmc_read(struct file *file, char *buf, size_t nbytes,
-			   loff_t *ppos)
+static ssize_t ibmvmc_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct ibmvmc_file_session *session;
 	struct ibmvmc_hmc *hmc;
 	struct crq_server_adapter *adapter;
 	struct ibmvmc_buffer *buffer;
+	size_t nbytes = iov_iter_count(to);
 	ssize_t n;
 	ssize_t retval = 0;
 	unsigned long flags;
 	DEFINE_WAIT(wait);
 
-	pr_debug("ibmvmc: read: file = 0x%lx, buf = 0x%lx, nbytes = 0x%lx\n",
-		 (unsigned long)file, (unsigned long)buf,
-		 (unsigned long)nbytes);
+	pr_debug("ibmvmc: read: file = 0x%lx, nbytes = 0x%lx\n",
+		 (unsigned long)iocb->ki_filp, (unsigned long)nbytes);
 
 	if (nbytes == 0)
 		return 0;
@@ -925,7 +924,7 @@ static ssize_t ibmvmc_read(struct file *file, char *buf, size_t nbytes,
 		return -EINVAL;
 	}
 
-	session = file->private_data;
+	session = iocb->ki_filp->private_data;
 	if (!session) {
 		pr_warn("ibmvmc: read: no session\n");
 		return -EIO;
@@ -957,7 +956,7 @@ static ssize_t ibmvmc_read(struct file *file, char *buf, size_t nbytes,
 			retval = -EBADFD;
 			goto out;
 		}
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
 			goto out;
 		}
@@ -977,7 +976,7 @@ static ssize_t ibmvmc_read(struct file *file, char *buf, size_t nbytes,
 	spin_unlock_irqrestore(&hmc->lock, flags);
 
 	nbytes = min_t(size_t, nbytes, buffer->msg_len);
-	n = copy_to_user((void *)buf, buffer->real_addr_local, nbytes);
+	n = !copy_to_iter_full(buffer->real_addr_local, nbytes, to);
 	dev_dbg(adapter->dev, "read: copy to user nbytes = 0x%lx.\n", nbytes);
 	ibmvmc_free_hmc_buffer(hmc, buffer);
 	retval = nbytes;
@@ -1027,27 +1026,25 @@ static unsigned int ibmvmc_poll(struct file *file, poll_table *wait)
 /**
  * ibmvmc_write - Write
  *
- * @file:	file struct
- * @buffer:	Character buffer
- * @count:	Count field
- * @ppos:	Offset
+ * @iocb:	metadata for IO
+ * @from:	Character buffer
  *
  * Return:
  *	0 - Success
  *	Non-zero - Failure
  */
-static ssize_t ibmvmc_write(struct file *file, const char *buffer,
-			    size_t count, loff_t *ppos)
+static ssize_t ibmvmc_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	struct file *file = iocb->ki_filp;
 	struct inode *inode;
 	struct ibmvmc_buffer *vmc_buffer;
 	struct ibmvmc_file_session *session;
 	struct crq_server_adapter *adapter;
+	size_t count = iov_iter_count(from);
 	struct ibmvmc_hmc *hmc;
 	unsigned char *buf;
 	unsigned long flags;
 	size_t bytes;
-	const char *p = buffer;
 	size_t c = count;
 	int ret = 0;
 
@@ -1109,19 +1106,17 @@ static ssize_t ibmvmc_write(struct file *file, const char *buffer,
 	}
 	buf = vmc_buffer->real_addr_local;
 
+	ret = 0;
 	while (c > 0) {
 		bytes = min_t(size_t, c, vmc_buffer->size);
 
-		bytes -= copy_from_user(buf, p, bytes);
-		if (!bytes) {
+		if (!copy_from_iter_full(buf, bytes, from)) {
 			ret = -EFAULT;
 			goto out;
 		}
 		c -= bytes;
-		p += bytes;
+		ret += bytes;
 	}
-	if (p == buffer)
-		goto out;
 
 	inode = file_inode(file);
 	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
@@ -1131,7 +1126,6 @@ static ssize_t ibmvmc_write(struct file *file, const char *buffer,
 		(unsigned long)file, (unsigned long)count);
 
 	ibmvmc_send_msg(adapter, vmc_buffer, hmc, count);
-	ret = p - buffer;
  out:
 	spin_unlock_irqrestore(&hmc->lock, flags);
 	return (ssize_t)(ret);
@@ -1387,8 +1381,8 @@ static long ibmvmc_ioctl(struct file *file,
 
 static const struct file_operations ibmvmc_fops = {
 	.owner		= THIS_MODULE,
-	.read		= ibmvmc_read,
-	.write		= ibmvmc_write,
+	.read_iter	= ibmvmc_read,
+	.write_iter	= ibmvmc_write,
 	.poll		= ibmvmc_poll,
 	.unlocked_ioctl	= ibmvmc_ioctl,
 	.open           = ibmvmc_open,
Signature · 1 line
2.43.0
author maintainer
#226 lore raw

PATCH 220/437 misc: cxl: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/misc/cxl/api.c  |  7 +++----
 drivers/misc/cxl/cxl.h  |  2 +-
 drivers/misc/cxl/file.c | 23 +++++++++++------------
 include/misc/cxl.h      |  3 +--
 4 files changed, 16 insertions(+), 19 deletions(-)
drivers/misc/cxl/api.c +3 -4
index d85c56530863..54e1f5b917e2 100644
@@ -375,10 +375,9 @@ __poll_t cxl_fd_poll(struct file *file, struct poll_table_struct *poll)
 	return afu_poll(file, poll);
 }
 EXPORT_SYMBOL_GPL(cxl_fd_poll);
-ssize_t cxl_fd_read(struct file *file, char __user *buf, size_t count,
-			loff_t *off)
+ssize_t cxl_fd_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return afu_read(file, buf, count, off);
+	return afu_read(iocb, to);
 }
 EXPORT_SYMBOL_GPL(cxl_fd_read);
 
@@ -410,7 +409,7 @@ struct file *cxl_get_fd(struct cxl_context *ctx, struct file_operations *fops,
 	if (fops) {
 		PATCH_FOPS(open);
 		PATCH_FOPS(poll);
-		PATCH_FOPS(read);
+		PATCH_FOPS(read_iter);
 		PATCH_FOPS(release);
 		PATCH_FOPS(unlocked_ioctl);
 		PATCH_FOPS(compat_ioctl);
drivers/misc/cxl/cxl.h +1 -1
index 6ad0ab892675..6b6738b28f69 100644
@@ -1045,7 +1045,7 @@ int afu_release(struct inode *inode, struct file *file);
 long afu_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 int afu_mmap(struct file *file, struct vm_area_struct *vm);
 __poll_t afu_poll(struct file *file, struct poll_table_struct *poll);
-ssize_t afu_read(struct file *file, char __user *buf, size_t count, loff_t *off);
+ssize_t afu_read(struct kiocb *iocb, struct iov_iter *to);
 extern const struct file_operations afu_fops;
 
 struct cxl *cxl_guest_init_adapter(struct device_node *np, struct platform_device *dev);
drivers/misc/cxl/file.c +11 -12
index 012e11b959bc..c911bd785f26 100644
@@ -385,7 +385,7 @@ __poll_t afu_poll(struct file *file, struct poll_table_struct *poll)
 }
 
 static ssize_t afu_driver_event_copy(struct cxl_context *ctx,
-				     char __user *buf,
+				     struct iov_iter *to,
 				     struct cxl_event *event,
 				     struct cxl_event_afu_driver_reserved *pl)
 {
@@ -403,14 +403,13 @@ static ssize_t afu_driver_event_copy(struct cxl_context *ctx,
 	}
 
 	/* Copy event header */
-	if (copy_to_user(buf, event, sizeof(struct cxl_event_header))) {
+	if (!copy_to_iter_full(event, sizeof(struct cxl_event_header), to)) {
 		ctx->afu_driver_ops->event_delivered(ctx, pl, -EFAULT);
 		return -EFAULT;
 	}
 
 	/* Copy event data */
-	buf += sizeof(struct cxl_event_header);
-	if (copy_to_user(buf, &pl->data, pl->data_size)) {
+	if (!copy_to_iter_full(&pl->data, pl->data_size, to)) {
 		ctx->afu_driver_ops->event_delivered(ctx, pl, -EFAULT);
 		return -EFAULT;
 	}
@@ -419,11 +418,11 @@ static ssize_t afu_driver_event_copy(struct cxl_context *ctx,
 	return event->header.size;
 }
 
-ssize_t afu_read(struct file *file, char __user *buf, size_t count,
-			loff_t *off)
+ssize_t afu_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct cxl_context *ctx = file->private_data;
+	struct cxl_context *ctx = iocb->ki_filp->private_data;
 	struct cxl_event_afu_driver_reserved *pl = NULL;
+	size_t count = iov_iter_count(to);
 	struct cxl_event event;
 	unsigned long flags;
 	int rc;
@@ -447,7 +446,7 @@ ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 			goto out;
 		}
 
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			rc = -EAGAIN;
 			goto out;
 		}
@@ -505,9 +504,9 @@ ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 	spin_unlock_irqrestore(&ctx->lock, flags);
 
 	if (event.header.type == CXL_EVENT_AFU_DRIVER)
-		return afu_driver_event_copy(ctx, buf, &event, pl);
+		return afu_driver_event_copy(ctx, to, &event, pl);
 
-	if (copy_to_user(buf, &event, event.header.size))
+	if (!copy_to_iter_full(&event, event.header.size, to))
 		return -EFAULT;
 	return event.header.size;
 
@@ -525,7 +524,7 @@ const struct file_operations afu_fops = {
 	.owner		= THIS_MODULE,
 	.open           = afu_open,
 	.poll		= afu_poll,
-	.read		= afu_read,
+	.read_iter	= afu_read,
 	.release        = afu_release,
 	.unlocked_ioctl = afu_ioctl,
 	.compat_ioctl   = afu_compat_ioctl,
@@ -536,7 +535,7 @@ static const struct file_operations afu_master_fops = {
 	.owner		= THIS_MODULE,
 	.open           = afu_master_open,
 	.poll		= afu_poll,
-	.read		= afu_read,
+	.read_iter	= afu_read,
 	.release        = afu_release,
 	.unlocked_ioctl = afu_ioctl,
 	.compat_ioctl   = afu_compat_ioctl,
include/misc/cxl.h +1 -2
index d8044299d654..3758f9c8f83f 100644
@@ -196,8 +196,7 @@ int cxl_fd_release(struct inode *inode, struct file *file);
 long cxl_fd_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 int cxl_fd_mmap(struct file *file, struct vm_area_struct *vm);
 __poll_t cxl_fd_poll(struct file *file, struct poll_table_struct *poll);
-ssize_t cxl_fd_read(struct file *file, char __user *buf, size_t count,
-			   loff_t *off);
+ssize_t cxl_fd_read(struct kiocb *iocb, struct iov_iter *to);
 
 /*
  * For EEH, a driver may want to assert a PERST will reload the same image
Signature · 1 line
2.43.0
author maintainer
#227 lore raw

PATCH 221/437 misc: ocxl: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/misc/ocxl/file.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/misc/ocxl/file.c +10 -10
index 7eb74711ac96..09ed5f0eee8a 100644
@@ -352,7 +352,7 @@ static unsigned int afu_poll(struct file *file, struct poll_table_struct *wait)
  */
 static ssize_t append_xsl_error(struct ocxl_context *ctx,
 				struct ocxl_kernel_event_header *header,
-				char __user *buf)
+				struct iov_iter *to)
 {
 	struct ocxl_kernel_event_xsl_fault_error body;
 
@@ -376,7 +376,7 @@ static ssize_t append_xsl_error(struct ocxl_context *ctx,
 
 	header->type = OCXL_AFU_EVENT_XSL_FAULT_ERROR;
 
-	if (copy_to_user(buf, &body, sizeof(body)))
+	if (!copy_to_iter(&body, sizeof(body), to))
 		return -EFAULT;
 
 	return sizeof(body);
@@ -391,11 +391,11 @@ static ssize_t append_xsl_error(struct ocxl_context *ctx,
  *	Body (struct ocxl_kernel_event_*)
  *	Header...
  */
-static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
-			loff_t *off)
+static ssize_t afu_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ocxl_context *ctx = file->private_data;
+	struct ocxl_context *ctx = iocb->ki_filp->private_data;
 	struct ocxl_kernel_event_header header;
+	size_t count = iov_iter_count(to);
 	ssize_t rc;
 	ssize_t used = 0;
 	DEFINE_WAIT(event_wait);
@@ -403,7 +403,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 	memset(&header, 0, sizeof(header));
 
 	/* Require offset to be 0 */
-	if (*off != 0)
+	if (iocb->ki_pos != 0)
 		return -EINVAL;
 
 	if (count < (sizeof(struct ocxl_kernel_event_header) +
@@ -420,7 +420,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 		if (ctx->status == CLOSED)
 			break;
 
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			finish_wait(&ctx->events_wq, &event_wait);
 			return -EAGAIN;
 		}
@@ -436,7 +436,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 	finish_wait(&ctx->events_wq, &event_wait);
 
 	if (has_xsl_error(ctx)) {
-		used = append_xsl_error(ctx, &header, buf + sizeof(header));
+		used = append_xsl_error(ctx, &header, to);
 		if (used < 0)
 			return used;
 	}
@@ -444,7 +444,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 	if (!afu_events_pending(ctx))
 		header.flags |= OCXL_KERNEL_EVENT_FLAG_LAST;
 
-	if (copy_to_user(buf, &header, sizeof(header)))
+	if (!copy_to_iter_full(&header, sizeof(header), to))
 		return -EFAULT;
 
 	used += sizeof(header);
@@ -476,7 +476,7 @@ static const struct file_operations ocxl_afu_fops = {
 	.compat_ioctl   = afu_compat_ioctl,
 	.mmap           = afu_mmap,
 	.poll           = afu_poll,
-	.read           = afu_read,
+	.read_iter      = afu_read,
 	.release        = afu_release,
 };
 
Signature · 1 line
2.43.0
author maintainer
#228 lore raw

PATCH 222/437 drivers/isdn: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/isdn/capi/capi.c      | 22 +++++++++++-----------
 drivers/isdn/mISDN/timerdev.c | 16 ++++++++--------
 2 files changed, 19 insertions(+), 19 deletions(-)
drivers/isdn/capi/capi.c +11 -11
index 3ed257334562..6b613e03d85b 100644
@@ -648,10 +648,10 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb)
 
 /* -------- file_operations for capidev ----------------------------- */
 
-static ssize_t
-capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t capi_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct capidev *cdev = file->private_data;
+	struct capidev *cdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct sk_buff *skb;
 	size_t copied;
 	int err;
@@ -661,7 +661,7 @@ capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
 	skb = skb_dequeue(&cdev->recvqueue);
 	if (!skb) {
-		if (file->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 		err = wait_event_interruptible(cdev->recvwait,
 					       (skb = skb_dequeue(&cdev->recvqueue)));
@@ -672,7 +672,7 @@ capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 		skb_queue_head(&cdev->recvqueue, skb);
 		return -EMSGSIZE;
 	}
-	if (copy_to_user(buf, skb->data, skb->len)) {
+	if (!copy_to_iter_full(skb->data, skb->len, to)) {
 		skb_queue_head(&cdev->recvqueue, skb);
 		return -EFAULT;
 	}
@@ -683,10 +683,10 @@ capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 	return copied;
 }
 
-static ssize_t
-capi_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
+static ssize_t capi_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct capidev *cdev = file->private_data;
+	struct capidev *cdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct sk_buff *skb;
 	u16 mlen;
 
@@ -700,7 +700,7 @@ capi_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos
 	if (!skb)
 		return -ENOMEM;
 
-	if (copy_from_user(skb_put(skb, count), buf, count)) {
+	if (!copy_from_iter_full(skb_put(skb, count), count, from)) {
 		kfree_skb(skb);
 		return -EFAULT;
 	}
@@ -1025,8 +1025,8 @@ static const struct file_operations capi_fops =
 {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= capi_read,
-	.write		= capi_write,
+	.read_iter	= capi_read,
+	.write_iter	= capi_write,
 	.poll		= capi_poll,
 	.unlocked_ioctl	= capi_unlocked_ioctl,
 #ifdef CONFIG_COMPAT
drivers/isdn/mISDN/timerdev.c +8 -8
index 83d6b484d3c6..cf52b08e2fad 100644
@@ -89,17 +89,17 @@ mISDN_close(struct inode *ino, struct file *filep)
 	return 0;
 }
 
-static ssize_t
-mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off)
+static ssize_t mISDN_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mISDNtimerdev	*dev = filep->private_data;
+	struct mISDNtimerdev	*dev = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(to);
 	struct list_head *list = &dev->expired;
 	struct mISDNtimer	*timer;
 	int	ret = 0;
 
 	if (*debug & DEBUG_TIMER)
-		printk(KERN_DEBUG "%s(%p, %p, %d, %p)\n", __func__,
-		       filep, buf, (int)count, off);
+		printk(KERN_DEBUG "%s(%p, %d)\n", __func__,
+		       iocb->ki_filp, (int)count);
 
 	if (count < sizeof(int))
 		return -ENOSPC;
@@ -107,7 +107,7 @@ mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off)
 	spin_lock_irq(&dev->lock);
 	while (list_empty(list) && (dev->work == 0)) {
 		spin_unlock_irq(&dev->lock);
-		if (filep->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 		wait_event_interruptible(dev->wait, (dev->work ||
 						     !list_empty(list)));
@@ -121,7 +121,7 @@ mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off)
 		timer = list_first_entry(list, struct mISDNtimer, list);
 		list_del(&timer->list);
 		spin_unlock_irq(&dev->lock);
-		if (put_user(timer->id, (int __user *)buf))
+		if (put_iter(timer->id, to))
 			ret = -EFAULT;
 		else
 			ret = sizeof(int);
@@ -261,7 +261,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
 
 static const struct file_operations mISDN_fops = {
 	.owner		= THIS_MODULE,
-	.read		= mISDN_read,
+	.read_iter	= mISDN_read,
 	.poll		= mISDN_poll,
 	.unlocked_ioctl	= mISDN_ioctl,
 	.open		= mISDN_open,
Signature · 1 line
2.43.0
author maintainer
#229 lore raw

PATCH 223/437 drivers/leds: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/leds/uleds.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/leds/uleds.c +18 -15
index 3d361c920030..b1fa00407364 100644
@@ -70,10 +70,10 @@ static int uleds_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t uleds_write(struct file *file, const char __user *buffer,
-			   size_t count, loff_t *ppos)
+static ssize_t uleds_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct uleds_device *udev = file->private_data;
+	struct uleds_device *udev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	const char *name;
 	int ret;
 
@@ -94,8 +94,8 @@ static ssize_t uleds_write(struct file *file, const char __user *buffer,
 		goto out;
 	}
 
-	if (copy_from_user(&udev->user_dev, buffer,
-			   sizeof(struct uleds_user_dev))) {
+	if (!copy_from_iter_full(&udev->user_dev, sizeof(struct uleds_user_dev),
+				 from)) {
 		ret = -EFAULT;
 		goto out;
 	}
@@ -128,10 +128,10 @@ static ssize_t uleds_write(struct file *file, const char __user *buffer,
 	return ret;
 }
 
-static ssize_t uleds_read(struct file *file, char __user *buffer, size_t count,
-			  loff_t *ppos)
+static ssize_t uleds_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct uleds_device *udev = file->private_data;
+	struct uleds_device *udev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	ssize_t retval;
 
 	if (count < sizeof(udev->brightness))
@@ -144,13 +144,16 @@ static ssize_t uleds_read(struct file *file, char __user *buffer, size_t count,
 
 		if (udev->state != ULEDS_STATE_REGISTERED) {
 			retval = -ENODEV;
-		} else if (!udev->new_data && (file->f_flags & O_NONBLOCK)) {
+		} else if (!udev->new_data && (iocb->ki_filp->f_flags & O_NONBLOCK)) {
 			retval = -EAGAIN;
 		} else if (udev->new_data) {
-			retval = copy_to_user(buffer, &udev->brightness,
-					      sizeof(udev->brightness));
+			retval = !copy_to_iter_full(&udev->brightness,
+					      sizeof(udev->brightness), to);
 			udev->new_data = false;
-			retval = sizeof(udev->brightness);
+			if (retval)
+				retval = -EFAULT;
+			else
+				retval = sizeof(udev->brightness);
 		}
 
 		mutex_unlock(&udev->mutex);
@@ -158,7 +161,7 @@ static ssize_t uleds_read(struct file *file, char __user *buffer, size_t count,
 		if (retval)
 			break;
 
-		if (!(file->f_flags & O_NONBLOCK))
+		if (!(iocb->ki_filp->f_flags & O_NONBLOCK))
 			retval = wait_event_interruptible(udev->waitq,
 					udev->new_data ||
 					udev->state != ULEDS_STATE_REGISTERED);
@@ -197,8 +200,8 @@ static const struct file_operations uleds_fops = {
 	.owner		= THIS_MODULE,
 	.open		= uleds_open,
 	.release	= uleds_release,
-	.read		= uleds_read,
-	.write		= uleds_write,
+	.read_iter	= uleds_read,
+	.write_iter	= uleds_write,
 	.poll		= uleds_poll,
 	.llseek		= no_llseek,
 };
Signature · 1 line
2.43.0
author maintainer
#230 lore raw

PATCH 224/437 drivers/mailbox: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/mailbox/bcm-pdc-mailbox.c |  9 ++++----
 drivers/mailbox/mailbox-test.c    | 37 ++++++++++++++-----------------
 2 files changed, 21 insertions(+), 25 deletions(-)
drivers/mailbox/bcm-pdc-mailbox.c +4 -5
index 1768d3d5aaa0..4fd840cd7193 100644
@@ -420,8 +420,7 @@ static struct pdc_globals pdcg;
 /* top level debug FS directory for PDC driver */
 static struct dentry *debugfs_dir;
 
-static ssize_t pdc_debugfs_read(struct file *filp, char __user *ubuf,
-				size_t count, loff_t *offp)
+static ssize_t pdc_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct pdc_state *pdcs;
 	char *buf;
@@ -433,7 +432,7 @@ static ssize_t pdc_debugfs_read(struct file *filp, char __user *ubuf,
 	if (!buf)
 		return -ENOMEM;
 
-	pdcs = filp->private_data;
+	pdcs = iocb->ki_filp->private_data;
 	out_offset = 0;
 	out_offset += scnprintf(buf + out_offset, out_count - out_offset,
 			       "SPU %u stats:\n", pdcs->pdc_idx);
@@ -469,7 +468,7 @@ static ssize_t pdc_debugfs_read(struct file *filp, char __user *ubuf,
 	if (out_offset > out_count)
 		out_offset = out_count;
 
-	ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, out_offset, to);
 	kfree(buf);
 	return ret;
 }
@@ -477,7 +476,7 @@ static ssize_t pdc_debugfs_read(struct file *filp, char __user *ubuf,
 static const struct file_operations pdc_debugfs_stats = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = pdc_debugfs_read,
+	.read_iter = pdc_debugfs_read,
 };
 
 /**
drivers/mailbox/mailbox-test.c +17 -20
index 3386b4e72551..27176797770b 100644
@@ -46,11 +46,10 @@ struct mbox_test_device {
 	struct dentry		*root_debugfs_dir;
 };
 
-static ssize_t mbox_test_signal_write(struct file *filp,
-				       const char __user *userbuf,
-				       size_t count, loff_t *ppos)
+static ssize_t mbox_test_signal_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mbox_test_device *tdev = filp->private_data;
+	struct mbox_test_device *tdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
 	if (!tdev->tx_channel) {
 		dev_err(tdev->dev, "Channel cannot do Tx\n");
@@ -71,7 +70,7 @@ static ssize_t mbox_test_signal_write(struct file *filp,
 			return -ENOMEM;
 	}
 
-	if (copy_from_user(tdev->signal, userbuf, count)) {
+	if (!copy_from_iter_full(tdev->signal, count, from)) {
 		kfree(tdev->signal);
 		tdev->signal = NULL;
 		return -EFAULT;
@@ -81,7 +80,7 @@ static ssize_t mbox_test_signal_write(struct file *filp,
 }
 
 static const struct file_operations mbox_test_signal_ops = {
-	.write	= mbox_test_signal_write,
+	.write_iter	= mbox_test_signal_write,
 	.open	= simple_open,
 	.llseek	= generic_file_llseek,
 };
@@ -93,11 +92,11 @@ static int mbox_test_message_fasync(int fd, struct file *filp, int on)
 	return fasync_helper(fd, filp, on, &tdev->async_queue);
 }
 
-static ssize_t mbox_test_message_write(struct file *filp,
-				       const char __user *userbuf,
-				       size_t count, loff_t *ppos)
+static ssize_t mbox_test_message_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct mbox_test_device *tdev = filp->private_data;
+	struct mbox_test_device *tdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *message;
 	void *data;
 	int ret;
@@ -121,7 +120,7 @@ static ssize_t mbox_test_message_write(struct file *filp,
 	mutex_lock(&tdev->mutex);
 
 	tdev->message = message;
-	ret = copy_from_user(tdev->message, userbuf, count);
+	ret = !copy_from_iter_full(tdev->message, count, from);
 	if (ret) {
 		ret = -EFAULT;
 		goto out;
@@ -168,10 +167,9 @@ static bool mbox_test_message_data_ready(struct mbox_test_device *tdev)
 	return data_ready;
 }
 
-static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf,
-				      size_t count, loff_t *ppos)
+static ssize_t mbox_test_message_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mbox_test_device *tdev = filp->private_data;
+	struct mbox_test_device *tdev = iocb->ki_filp->private_data;
 	unsigned long flags;
 	char *touser, *ptr;
 	int l = 0;
@@ -185,8 +183,7 @@ static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf,
 
 	if (!tdev->rx_channel) {
 		ret = snprintf(touser, 20, "<NO RX CAPABILITY>\n");
-		ret = simple_read_from_buffer(userbuf, count, ppos,
-					      touser, ret);
+		ret = simple_copy_to_iter(touser, &iocb->ki_pos, ret, to);
 		goto kfree_err;
 	}
 
@@ -198,7 +195,7 @@ static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf,
 		if (mbox_test_message_data_ready(tdev))
 			break;
 
-		if (filp->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			ret = -EAGAIN;
 			goto waitq_err;
 		}
@@ -231,7 +228,7 @@ static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf,
 
 	spin_unlock_irqrestore(&tdev->lock, flags);
 
-	ret = simple_read_from_buffer(userbuf, count, ppos, touser, MBOX_HEXDUMP_MAX_LEN);
+	ret = simple_copy_to_iter(touser, &iocb->ki_pos, MBOX_HEXDUMP_MAX_LEN, to);
 waitq_err:
 	__set_current_state(TASK_RUNNING);
 	remove_wait_queue(&tdev->waitq, &wait);
@@ -253,8 +250,8 @@ mbox_test_message_poll(struct file *filp, struct poll_table_struct *wait)
 }
 
 static const struct file_operations mbox_test_message_ops = {
-	.write	= mbox_test_message_write,
-	.read	= mbox_test_message_read,
+	.write_iter	= mbox_test_message_write,
+	.read_iter	= mbox_test_message_read,
 	.fasync	= mbox_test_message_fasync,
 	.poll	= mbox_test_message_poll,
 	.open	= simple_open,
Signature · 1 line
2.43.0
author maintainer
#231 lore raw

PATCH 225/437 drivers/mfd: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/mfd/aat2870-core.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/mfd/aat2870-core.c +9 -11
index 2fee62f1016c..78a8809908ff 100644
@@ -248,10 +248,9 @@ static ssize_t aat2870_dump_reg(struct aat2870_data *aat2870, char *buf)
 	return count;
 }
 
-static ssize_t aat2870_reg_read_file(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t aat2870_reg_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct aat2870_data *aat2870 = file->private_data;
+	struct aat2870_data *aat2870 = iocb->ki_filp->private_data;
 	char *buf;
 	ssize_t ret;
 
@@ -261,18 +260,17 @@ static ssize_t aat2870_reg_read_file(struct file *file, char __user *user_buf,
 
 	ret = aat2870_dump_reg(aat2870, buf);
 	if (ret >= 0)
-		ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+		ret = simple_copy_from_iter(buf, &iocb->ki_pos, ret, to);
 
 	kfree(buf);
 
 	return ret;
 }
 
-static ssize_t aat2870_reg_write_file(struct file *file,
-				      const char __user *user_buf, size_t count,
-				      loff_t *ppos)
+static ssize_t aat2870_reg_write_file(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct aat2870_data *aat2870 = file->private_data;
+	struct aat2870_data *aat2870 = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	ssize_t buf_size;
 	char *start = buf;
@@ -280,7 +278,7 @@ static ssize_t aat2870_reg_write_file(struct file *file,
 	int ret;
 
 	buf_size = min(count, (size_t)(sizeof(buf)-1));
-	if (copy_from_user(buf, user_buf, buf_size)) {
+	if (!copy_from_iter_full(buf, buf_size, from)) {
 		dev_err(aat2870->dev, "Failed to copy from user\n");
 		return -EFAULT;
 	}
@@ -314,8 +312,8 @@ static ssize_t aat2870_reg_write_file(struct file *file,
 
 static const struct file_operations aat2870_reg_fops = {
 	.open = simple_open,
-	.read = aat2870_reg_read_file,
-	.write = aat2870_reg_write_file,
+	.read_iter = aat2870_reg_read_file,
+	.write_iter = aat2870_reg_write_file,
 };
 
 static void aat2870_init_debugfs(struct aat2870_data *aat2870)
Signature · 1 line
2.43.0
author maintainer
#232 lore raw

PATCH 226/437 drivers/misc/mei: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/misc/mei/main.c | 53 ++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 30 deletions(-)
drivers/misc/mei/main.c +23 -30
index 79e6f3c1341f..2bab5b317b99 100644
@@ -159,20 +159,19 @@ static int mei_release(struct inode *inode, struct file *file)
 /**
  * mei_read - the read function.
  *
- * @file: pointer to file structure
- * @ubuf: pointer to user buffer
- * @length: buffer length
- * @offset: data offset in buffer
+ * @iocb: metadata for IO
+ * @to: pointer to user buffer
  *
  * Return: >=0 data length on success , <0 on error
  */
-static ssize_t mei_read(struct file *file, char __user *ubuf,
-			size_t length, loff_t *offset)
+static ssize_t mei_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	struct file *file = iocb->ki_filp;
 	struct mei_cl *cl = file->private_data;
 	struct mei_device *dev;
 	struct mei_cl_cb *cb = NULL;
-	bool nonblock = !!(file->f_flags & O_NONBLOCK);
+	bool nonblock = !!(iocb->ki_filp->f_flags & O_NONBLOCK);
+	size_t length = iov_iter_count(to);
 	ssize_t rets;
 
 	if (WARN_ON(!cl || !cl->dev))
@@ -192,17 +191,12 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
 		goto out;
 	}
 
-	if (ubuf == NULL) {
-		rets = -EMSGSIZE;
-		goto out;
-	}
-
 	cb = mei_cl_read_cb(cl, file);
 	if (cb)
 		goto copy_buffer;
 
-	if (*offset > 0)
-		*offset = 0;
+	if (iocb->ki_pos > 0)
+		iocb->ki_pos = 0;
 
 	rets = mei_cl_read_start(cl, length, file);
 	if (rets && rets != -EBUSY) {
@@ -245,31 +239,31 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
 	}
 
 	cl_dbg(dev, cl, "buf.size = %zu buf.idx = %zu offset = %lld\n",
-	       cb->buf.size, cb->buf_idx, *offset);
-	if (*offset >= cb->buf_idx) {
+	       cb->buf.size, cb->buf_idx, iocb->ki_pos);
+	if (iocb->ki_pos  >= cb->buf_idx) {
 		rets = 0;
 		goto free;
 	}
 
 	/* length is being truncated to PAGE_SIZE,
 	 * however buf_idx may point beyond that */
-	length = min_t(size_t, length, cb->buf_idx - *offset);
+	length = min_t(size_t, length, cb->buf_idx - iocb->ki_pos);
 
-	if (copy_to_user(ubuf, cb->buf.data + *offset, length)) {
+	if (!copy_to_iter(cb->buf.data + iocb->ki_pos, length, to)) {
 		dev_dbg(dev->dev, "failed to copy data to userland\n");
 		rets = -EFAULT;
 		goto free;
 	}
 
 	rets = length;
-	*offset += length;
+	iocb->ki_pos += length;
 	/* not all data was read, keep the cb */
-	if (*offset < cb->buf_idx)
+	if (iocb->ki_pos < cb->buf_idx)
 		goto out;
 
 free:
 	mei_cl_del_rd_completed(cl, cb);
-	*offset = 0;
+	iocb->ki_pos = 0;
 
 out:
 	cl_dbg(dev, cl, "end mei read rets = %zd\n", rets);
@@ -301,17 +295,16 @@ static u8 mei_cl_vtag_by_fp(const struct mei_cl *cl, const struct file *fp)
 /**
  * mei_write - the write function.
  *
- * @file: pointer to file structure
- * @ubuf: pointer to user buffer
- * @length: buffer length
- * @offset: data offset in buffer
+ * @iocb: metadata for IO
+ * @from: pointer to user buffer
  *
  * Return: >=0 data length on success , <0 on error
  */
-static ssize_t mei_write(struct file *file, const char __user *ubuf,
-			 size_t length, loff_t *offset)
+static ssize_t mei_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	struct file *file = iocb->ki_filp;
 	struct mei_cl *cl = file->private_data;
+	size_t length = iov_iter_count(from);
 	struct mei_cl_cb *cb;
 	struct mei_device *dev;
 	ssize_t rets;
@@ -377,7 +370,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 	}
 	cb->vtag = mei_cl_vtag_by_fp(cl, file);
 
-	rets = copy_from_user(cb->buf.data, ubuf, length);
+	rets = !copy_from_iter_full(cb->buf.data, length, from);
 	if (rets) {
 		dev_dbg(dev->dev, "failed to copy data from userland\n");
 		rets = -EFAULT;
@@ -1167,12 +1160,12 @@ ATTRIBUTE_GROUPS(mei);
  */
 static const struct file_operations mei_fops = {
 	.owner = THIS_MODULE,
-	.read = mei_read,
+	.read_iter = mei_read,
 	.unlocked_ioctl = mei_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 	.open = mei_open,
 	.release = mei_release,
-	.write = mei_write,
+	.write_iter = mei_write,
 	.poll = mei_poll,
 	.fsync = mei_fsync,
 	.fasync = mei_fasync,
Signature · 1 line
2.43.0
author maintainer
#233 lore raw

PATCH 227/437 misc: ibmasm: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/misc/ibmasm/ibmasmfs.c | 94 ++++++++++++++++++----------------
 1 file changed, 50 insertions(+), 44 deletions(-)
drivers/misc/ibmasm/ibmasmfs.c +50 -44
index c44de892a61e..8f7ea4214d20 100644
@@ -256,18 +256,19 @@ static int command_file_close(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t command_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
+static ssize_t command_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ibmasmfs_command_data *command_data = file->private_data;
+	struct ibmasmfs_command_data *command_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct command *cmd;
 	int len;
 	unsigned long flags;
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count == 0 || count > IBMASM_CMD_MAX_BUFFER_SIZE)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	spin_lock_irqsave(&command_data->sp->lock, flags);
@@ -284,7 +285,7 @@ static ssize_t command_file_read(struct file *file, char __user *buf, size_t cou
 		return -EIO;
 	}
 	len = min(count, cmd->buffer_size);
-	if (copy_to_user(buf, cmd->buffer, len)) {
+	if (!copy_to_iter_full(cmd->buffer, len, to)) {
 		command_put(cmd);
 		return -EFAULT;
 	}
@@ -293,17 +294,18 @@ static ssize_t command_file_read(struct file *file, char __user *buf, size_t cou
 	return len;
 }
 
-static ssize_t command_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset)
+static ssize_t command_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ibmasmfs_command_data *command_data = file->private_data;
+	struct ibmasmfs_command_data *command_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct command *cmd;
 	unsigned long flags;
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count == 0 || count > IBMASM_CMD_MAX_BUFFER_SIZE)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	/* commands are executed sequentially, only one command at a time */
@@ -314,7 +316,7 @@ static ssize_t command_file_write(struct file *file, const char __user *ubuff, s
 	if (!cmd)
 		return -ENOMEM;
 
-	if (copy_from_user(cmd->buffer, ubuff, count)) {
+	if (!copy_from_iter_full(cmd->buffer, count, from)) {
 		command_put(cmd);
 		return -EFAULT;
 	}
@@ -365,19 +367,20 @@ static int event_file_close(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t event_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
+static ssize_t event_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ibmasmfs_event_data *event_data = file->private_data;
+	struct ibmasmfs_event_data *event_data = iocb->ki_filp->private_data;
 	struct event_reader *reader = &event_data->reader;
 	struct service_processor *sp = event_data->sp;
+	size_t count = iov_iter_count(to);
 	int ret;
 	unsigned long flags;
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count == 0 || count > IBMASM_EVENT_MAX_SIZE)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	spin_lock_irqsave(&sp->lock, flags);
@@ -397,7 +400,7 @@ static ssize_t event_file_read(struct file *file, char __user *buf, size_t count
 		goto out;
 	}
 
-        if (copy_to_user(buf, reader->data, reader->data_size)) {
+        if (!copy_to_iter_full(reader->data, reader->data_size, to)) {
 		ret = -EFAULT;
 		goto out;
 	}
@@ -408,15 +411,16 @@ static ssize_t event_file_read(struct file *file, char __user *buf, size_t count
 	return ret;
 }
 
-static ssize_t event_file_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
+static ssize_t event_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ibmasmfs_event_data *event_data = file->private_data;
+	struct ibmasmfs_event_data *event_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count != 1)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	ibmasm_cancel_next_event(&event_data->reader);
@@ -449,17 +453,18 @@ static int r_heartbeat_file_close(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t r_heartbeat_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
+static ssize_t r_heartbeat_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ibmasmfs_heartbeat_data *rhbeat = file->private_data;
+	struct ibmasmfs_heartbeat_data *rhbeat = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	unsigned long flags;
 	int result;
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count == 0 || count > 1024)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	/* allow only one reverse heartbeat per process */
@@ -477,15 +482,16 @@ static ssize_t r_heartbeat_file_read(struct file *file, char __user *buf, size_t
 	return result;
 }
 
-static ssize_t r_heartbeat_file_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
+static ssize_t r_heartbeat_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ibmasmfs_heartbeat_data *rhbeat = file->private_data;
+	struct ibmasmfs_heartbeat_data *rhbeat = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count != 1)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (rhbeat->active)
@@ -499,9 +505,9 @@ static int remote_settings_file_close(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t remote_settings_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
+static ssize_t remote_settings_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	void __iomem *address = (void __iomem *)file->private_data;
+	void __iomem *address = (void __iomem *)iocb->ki_filp->private_data;
 	int len = 0;
 	unsigned int value;
 	char lbuf[20];
@@ -509,28 +515,28 @@ static ssize_t remote_settings_file_read(struct file *file, char __user *buf, si
 	value = readl(address);
 	len = snprintf(lbuf, sizeof(lbuf), "%d\n", value);
 
-	return simple_read_from_buffer(buf, count, offset, lbuf, len);
+	return simple_copy_to_iter(lbuf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t remote_settings_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset)
+static ssize_t remote_settings_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	void __iomem *address = (void __iomem *)file->private_data;
+	void __iomem *address = (void __iomem *)iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buff;
 	unsigned int value;
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count == 0 || count > 1024)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	buff = kzalloc (count + 1, GFP_KERNEL);
 	if (!buff)
 		return -ENOMEM;
 
-
-	if (copy_from_user(buff, ubuff, count)) {
+	if (!copy_from_iter_full(buff, count, from)) {
 		kfree(buff);
 		return -EFAULT;
 	}
@@ -545,32 +551,32 @@ static ssize_t remote_settings_file_write(struct file *file, const char __user *
 static const struct file_operations command_fops = {
 	.open =		command_file_open,
 	.release =	command_file_close,
-	.read =		command_file_read,
-	.write =	command_file_write,
+	.read_iter =	command_file_read,
+	.write_iter =	command_file_write,
 	.llseek =	generic_file_llseek,
 };
 
 static const struct file_operations event_fops = {
 	.open =		event_file_open,
 	.release =	event_file_close,
-	.read =		event_file_read,
-	.write =	event_file_write,
+	.read_iter =	event_file_read,
+	.write_iter =	event_file_write,
 	.llseek =	generic_file_llseek,
 };
 
 static const struct file_operations r_heartbeat_fops = {
 	.open =		r_heartbeat_file_open,
 	.release =	r_heartbeat_file_close,
-	.read =		r_heartbeat_file_read,
-	.write =	r_heartbeat_file_write,
+	.read_iter =	r_heartbeat_file_read,
+	.write_iter =	r_heartbeat_file_write,
 	.llseek =	generic_file_llseek,
 };
 
 static const struct file_operations remote_settings_fops = {
 	.open =		simple_open,
 	.release =	remote_settings_file_close,
-	.read =		remote_settings_file_read,
-	.write =	remote_settings_file_write,
+	.read_iter =	remote_settings_file_read,
+	.write_iter =	remote_settings_file_write,
 	.llseek =	generic_file_llseek,
 };
 
Signature · 1 line
2.43.0
author maintainer
#234 lore raw

PATCH 228/437 drivers/spi: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/spi/spidev.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)
drivers/spi/spidev.c +17 -16
index 95fb5f1c91c1..1b5e13492b4d 100644
@@ -154,27 +154,28 @@ spidev_sync_read(struct spidev_data *spidev, size_t len)
 
 /* Read-only message with current device setup */
 static ssize_t
-spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
+spidev_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct spidev_data	*spidev;
 	ssize_t			status;
+	size_t			count = iov_iter_count(to);
 
 	/* chipselect only toggles at start or end of operation */
 	if (count > bufsiz)
 		return -EMSGSIZE;
 
-	spidev = filp->private_data;
+	spidev = iocb->ki_filp->private_data;
 
 	mutex_lock(&spidev->buf_lock);
 	status = spidev_sync_read(spidev, count);
 	if (status > 0) {
-		unsigned long	missing;
+		unsigned long	copied;
 
-		missing = copy_to_user(buf, spidev->rx_buffer, status);
-		if (missing == status)
+		copied = copy_to_iter(spidev->rx_buffer, status, to);
+		if (!copied)
 			status = -EFAULT;
 		else
-			status = status - missing;
+			status = status - copied;
 	}
 	mutex_unlock(&spidev->buf_lock);
 
@@ -183,25 +184,25 @@ spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
 
 /* Write-only message with current device setup */
 static ssize_t
-spidev_write(struct file *filp, const char __user *buf,
-		size_t count, loff_t *f_pos)
+spidev_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct spidev_data	*spidev;
 	ssize_t			status;
-	unsigned long		missing;
+	unsigned long		copied;
+	size_t			count = iov_iter_count(from);
 
 	/* chipselect only toggles at start or end of operation */
 	if (count > bufsiz)
 		return -EMSGSIZE;
 
-	spidev = filp->private_data;
+	spidev = iocb->ki_filp->private_data;
 
 	mutex_lock(&spidev->buf_lock);
-	missing = copy_from_user(spidev->tx_buffer, buf, count);
-	if (missing == 0)
-		status = spidev_sync_write(spidev, count);
-	else
+	copied = copy_from_iter(spidev->tx_buffer, count, from);
+	if (copied == 0)
 		status = -EFAULT;
+	else
+		status = spidev_sync_write(spidev, count);
 	mutex_unlock(&spidev->buf_lock);
 
 	return status;
@@ -679,8 +680,8 @@ static const struct file_operations spidev_fops = {
 	 * gets more complete API coverage.  It'll simplify things
 	 * too, except for the locking.
 	 */
-	.write =	spidev_write,
-	.read =		spidev_read,
+	.write_iter =	spidev_write,
+	.read_iter =	spidev_read,
 	.unlocked_ioctl = spidev_ioctl,
 	.compat_ioctl = spidev_compat_ioctl,
 	.open =		spidev_open,
Signature · 1 line
2.43.0
author maintainer
#235 lore raw

PATCH 229/437 drivers/nfc: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/nfc/virtual_ncidev.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/nfc/virtual_ncidev.c +10 -11
index 590b038e449e..59c75de758d7 100644
@@ -79,10 +79,10 @@ static const struct nci_ops virtual_nci_ops = {
 	.send = virtual_nci_send
 };
 
-static ssize_t virtual_ncidev_read(struct file *file, char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t virtual_ncidev_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct virtual_nci_dev *vdev = file->private_data;
+	struct virtual_nci_dev *vdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	size_t actual_len;
 
 	mutex_lock(&vdev->mtx);
@@ -95,7 +95,7 @@ static ssize_t virtual_ncidev_read(struct file *file, char __user *buf,
 
 	actual_len = min_t(size_t, count, vdev->send_buff->len);
 
-	if (copy_to_user(buf, vdev->send_buff->data, actual_len)) {
+	if (!copy_to_iter_full(vdev->send_buff->data, actual_len, to)) {
 		mutex_unlock(&vdev->mtx);
 		return -EFAULT;
 	}
@@ -110,18 +110,17 @@ static ssize_t virtual_ncidev_read(struct file *file, char __user *buf,
 	return actual_len;
 }
 
-static ssize_t virtual_ncidev_write(struct file *file,
-				    const char __user *buf,
-				    size_t count, loff_t *ppos)
+static ssize_t virtual_ncidev_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct virtual_nci_dev *vdev = file->private_data;
+	struct virtual_nci_dev *vdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct sk_buff *skb;
 
 	skb = alloc_skb(count, GFP_KERNEL);
 	if (!skb)
 		return -ENOMEM;
 
-	if (copy_from_user(skb_put(skb, count), buf, count)) {
+	if (!copy_from_iter_full(skb_put(skb, count), count, from)) {
 		kfree_skb(skb);
 		return -EFAULT;
 	}
@@ -191,8 +190,8 @@ static long virtual_ncidev_ioctl(struct file *file, unsigned int cmd,
 
 static const struct file_operations virtual_ncidev_fops = {
 	.owner = THIS_MODULE,
-	.read = virtual_ncidev_read,
-	.write = virtual_ncidev_write,
+	.read_iter = virtual_ncidev_read,
+	.write_iter = virtual_ncidev_write,
 	.open = virtual_ncidev_open,
 	.release = virtual_ncidev_close,
 	.unlocked_ioctl = virtual_ncidev_ioctl
Signature · 1 line
2.43.0
author maintainer
#236 lore raw

PATCH 230/437 drivers/nvme: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/nvme/host/fabrics.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/nvme/host/fabrics.c +6 -6
index 1f0ea1f32d22..6d0251cc4bf3 100644
@@ -1326,10 +1326,10 @@ static const struct class nvmf_class = {
 static struct device *nvmf_device;
 static DEFINE_MUTEX(nvmf_dev_mutex);
 
-static ssize_t nvmf_dev_write(struct file *file, const char __user *ubuf,
-		size_t count, loff_t *pos)
+static ssize_t nvmf_dev_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *seq_file = file->private_data;
+	struct seq_file *seq_file = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct nvme_ctrl *ctrl;
 	const char *buf;
 	int ret = 0;
@@ -1337,7 +1337,7 @@ static ssize_t nvmf_dev_write(struct file *file, const char __user *ubuf,
 	if (count > PAGE_SIZE)
 		return -ENOMEM;
 
-	buf = memdup_user_nul(ubuf, count);
+	buf = iterdup_nul(from, count);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -1422,8 +1422,8 @@ static int nvmf_dev_release(struct inode *inode, struct file *file)
 
 static const struct file_operations nvmf_dev_fops = {
 	.owner		= THIS_MODULE,
-	.write		= nvmf_dev_write,
-	.read		= seq_read,
+	.write_iter	= nvmf_dev_write,
+	.read_iter	= seq_read_iter,
 	.open		= nvmf_dev_open,
 	.release	= nvmf_dev_release,
 };
Signature · 1 line
2.43.0
author maintainer
#237 lore raw

PATCH 231/437 drivers/firewire: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/firewire/core-cdev.c | 15 +++++++--------
 drivers/firewire/nosy.c      | 18 ++++++++----------
 2 files changed, 15 insertions(+), 18 deletions(-)
drivers/firewire/core-cdev.c +7 -8
index 6274b86eb943..ded5873c444b 100644
@@ -301,9 +301,9 @@ static void queue_event(struct client *client, struct event *event,
 	wake_up_interruptible(&client->wait);
 }
 
-static int dequeue_event(struct client *client,
-			 char __user *buffer, size_t count)
+static int dequeue_event(struct client *client, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct event *event;
 	size_t size, total;
 	int i, ret;
@@ -326,7 +326,7 @@ static int dequeue_event(struct client *client,
 	total = 0;
 	for (i = 0; i < ARRAY_SIZE(event->v) && total < count; i++) {
 		size = min(event->v[i].size, count - total);
-		if (copy_to_user(buffer + total, event->v[i].data, size)) {
+		if (!copy_to_iter_full(event->v[i].data, size, to)) {
 			ret = -EFAULT;
 			goto out;
 		}
@@ -340,12 +340,11 @@ static int dequeue_event(struct client *client,
 	return ret;
 }
 
-static ssize_t fw_device_op_read(struct file *file, char __user *buffer,
-				 size_t count, loff_t *offset)
+static ssize_t fw_device_op_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct client *client = file->private_data;
+	struct client *client = iocb->ki_filp->private_data;
 
-	return dequeue_event(client, buffer, count);
+	return dequeue_event(client, to);
 }
 
 static void fill_bus_reset_event(struct fw_cdev_event_bus_reset *event,
@@ -1922,7 +1921,7 @@ const struct file_operations fw_device_ops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
 	.open		= fw_device_op_open,
-	.read		= fw_device_op_read,
+	.read_iter	= fw_device_op_read,
 	.unlocked_ioctl	= fw_device_op_ioctl,
 	.mmap		= fw_device_op_mmap,
 	.release	= fw_device_op_release,
drivers/firewire/nosy.c +8 -10
index b0d671db178a..d4e7f465afc4 100644
@@ -133,8 +133,7 @@ packet_buffer_destroy(struct packet_buffer *buffer)
 	kfree(buffer->data);
 }
 
-static int
-packet_buffer_get(struct client *client, char __user *data, size_t user_length)
+static int packet_buffer_get(struct client *client, struct iov_iter *to)
 {
 	struct packet_buffer *buffer = &client->buffer;
 	size_t length;
@@ -154,15 +153,15 @@ packet_buffer_get(struct client *client, char __user *data, size_t user_length)
 	length = buffer->head->length;
 
 	if (&buffer->head->data[length] < end) {
-		if (copy_to_user(data, buffer->head->data, length))
+		if (!copy_to_iter_full(buffer->head->data, length, to))
 			return -EFAULT;
 		buffer->head = (struct packet *) &buffer->head->data[length];
 	} else {
 		size_t split = end - buffer->head->data;
 
-		if (copy_to_user(data, buffer->head->data, split))
+		if (!copy_to_iter_full(buffer->head->data, split, to))
 			return -EFAULT;
-		if (copy_to_user(data + split, buffer->data, length - split))
+		if (!copy_to_iter_full(buffer->data, length - split, to))
 			return -EFAULT;
 		buffer->head = (struct packet *) &buffer->data[length - split];
 	}
@@ -332,12 +331,11 @@ nosy_poll(struct file *file, poll_table *pt)
 	return ret;
 }
 
-static ssize_t
-nosy_read(struct file *file, char __user *buffer, size_t count, loff_t *offset)
+static ssize_t nosy_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct client *client = file->private_data;
+	struct client *client = iocb->ki_filp->private_data;
 
-	return packet_buffer_get(client, buffer, count);
+	return packet_buffer_get(client, to);
 }
 
 static long
@@ -393,7 +391,7 @@ nosy_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 static const struct file_operations nosy_ops = {
 	.owner =		THIS_MODULE,
-	.read =			nosy_read,
+	.read_iter =		nosy_read,
 	.unlocked_ioctl =	nosy_ioctl,
 	.poll =			nosy_poll,
 	.open =			nosy_open,
Signature · 1 line
2.43.0
author maintainer
#238 lore raw

PATCH 232/437 drivers/mfd: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/mfd/tps65010.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/tps65010.c +1 -1
index 2b9105295f30..74272a534020 100644
@@ -290,7 +290,7 @@ static int dbg_tps_open(struct inode *inode, struct file *file)
 
 static const struct file_operations debug_fops = {
 	.open		= dbg_tps_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
Signature · 1 line
2.43.0
author maintainer
#239 lore raw

PATCH 233/437 watchdog: acquirewdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/acquirewdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/acquirewdt.c +4 -4
index 53b04abd55b0..cdc27fc68f4a 100644
@@ -114,9 +114,9 @@ static void acq_stop(void)
  *	/dev/watchdog handling
  */
 
-static ssize_t acq_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t acq_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -128,7 +128,7 @@ static ssize_t acq_write(struct file *file, const char __user *buf,
 			   magic character */
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -219,7 +219,7 @@ static int acq_close(struct inode *inode, struct file *file)
 static const struct file_operations acq_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= acq_write,
+	.write_iter	= acq_write,
 	.unlocked_ioctl	= acq_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= acq_open,
Signature · 1 line
2.43.0
author maintainer
#240 lore raw

PATCH 234/437 watchdog: advantechwdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/advantechwdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/advantechwdt.c +4 -4
index 7a0acbc3e4dd..95c1b90abedc 100644
@@ -106,9 +106,9 @@ static int advwdt_set_heartbeat(int t)
  *	/dev/watchdog handling
  */
 
-static ssize_t advwdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t advwdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -117,7 +117,7 @@ static ssize_t advwdt_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					adv_expect_close = 42;
@@ -218,7 +218,7 @@ static int advwdt_close(struct inode *inode, struct file *file)
 static const struct file_operations advwdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= advwdt_write,
+	.write_iter	= advwdt_write,
 	.unlocked_ioctl	= advwdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= advwdt_open,
Signature · 1 line
2.43.0
author maintainer
#241 lore raw

PATCH 235/437 watchdog: alim1535_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/alim1535_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/alim1535_wdt.c +4 -4
index bfb9a91ca1df..9a12706d9cdf 100644
@@ -134,9 +134,9 @@ static int ali_settimer(int t)
  *	the next close to turn off the watchdog.
  */
 
-static ssize_t ali_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t ali_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
 		if (!nowayout) {
@@ -150,7 +150,7 @@ static ssize_t ali_write(struct file *file, const char __user *data,
 			   the magic character */
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					ali_expect_release = 42;
@@ -360,7 +360,7 @@ static int __init ali_find_watchdog(void)
 static const struct file_operations ali_fops = {
 	.owner		=	THIS_MODULE,
 	.llseek		=	no_llseek,
-	.write		=	ali_write,
+	.write_iter	=	ali_write,
 	.unlocked_ioctl =	ali_ioctl,
 	.compat_ioctl	= 	compat_ptr_ioctl,
 	.open		=	ali_open,
Signature · 1 line
2.43.0
author maintainer
#242 lore raw

PATCH 236/437 watchdog: alim7101_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/alim7101_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/alim7101_wdt.c +4 -4
index 4ff7f5afb7aa..5a85f53542d9 100644
@@ -181,9 +181,9 @@ static void wdt_keepalive(void)
  * /dev/watchdog handling
  */
 
-static ssize_t fop_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t fop_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -196,7 +196,7 @@ static ssize_t fop_write(struct file *file, const char __user *buf,
 			/* now scan */
 			for (ofs = 0; ofs != count; ofs++) {
 				char c;
-				if (get_user(c, buf + ofs))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					wdt_expect_close = 42;
@@ -290,7 +290,7 @@ static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations wdt_fops = {
 	.owner		=	THIS_MODULE,
 	.llseek		=	no_llseek,
-	.write		=	fop_write,
+	.write_iter	=	fop_write,
 	.open		=	fop_open,
 	.release	=	fop_close,
 	.unlocked_ioctl	=	fop_ioctl,
Signature · 1 line
2.43.0
author maintainer
#243 lore raw

PATCH 237/437 watchdog: at91rm9200_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/at91rm9200_wdt.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/watchdog/at91rm9200_wdt.c +3 -4
index 558015f08c7a..1860fbeb6e57 100644
@@ -199,11 +199,10 @@ static long at91_wdt_ioctl(struct file *file,
 /*
  * Pat the watchdog whenever device is written to.
  */
-static ssize_t at91_wdt_write(struct file *file, const char *data,
-						size_t len, loff_t *ppos)
+static ssize_t at91_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	at91_wdt_reload();		/* pat the watchdog */
-	return len;
+	return iov_iter_count(from);
 }
 
 /* ......................................................................... */
@@ -215,7 +214,7 @@ static const struct file_operations at91wdt_fops = {
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= at91_wdt_open,
 	.release	= at91_wdt_close,
-	.write		= at91_wdt_write,
+	.write_iter	= at91_wdt_write,
 };
 
 static struct miscdevice at91wdt_miscdev = {
Signature · 1 line
2.43.0
author maintainer
#244 lore raw

PATCH 238/437 watchdog: cpu5wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/cpu5wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/cpu5wdt.c +3 -3
index 688b112e712b..cef1d6ba6ecf 100644
@@ -174,9 +174,9 @@ static long cpu5wdt_ioctl(struct file *file, unsigned int cmd,
 	return 0;
 }
 
-static ssize_t cpu5wdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t cpu5wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (!count)
 		return -EIO;
 	cpu5wdt_reset();
@@ -189,7 +189,7 @@ static const struct file_operations cpu5wdt_fops = {
 	.unlocked_ioctl	= cpu5wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= cpu5wdt_open,
-	.write		= cpu5wdt_write,
+	.write_iter	= cpu5wdt_write,
 	.release	= cpu5wdt_release,
 };
 
Signature · 1 line
2.43.0
author maintainer
#245 lore raw

PATCH 239/437 watchdog: eurotechwdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/eurotechwdt.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/watchdog/eurotechwdt.c +6 -8
index e26609ad4c17..e11b4acfa8ed 100644
@@ -186,18 +186,16 @@ static void eurwdt_ping(void)
 
 /**
  * eurwdt_write:
- * @file: file handle to the watchdog
- * @buf: buffer to write (unused as data does not matter here
- * @count: count of bytes
- * @ppos: pointer to the position to write. No seeks allowed
+ * @iocb: metadata for IO
+ * @from: buffer to write (unused as data does not matter here
  *
  * A write to a watchdog device is defined as a keepalive signal. Any
  * write of data will do, as we don't define content meaning.
  */
 
-static ssize_t eurwdt_write(struct file *file, const char __user *buf,
-size_t count, loff_t *ppos)
+static ssize_t eurwdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -206,7 +204,7 @@ size_t count, loff_t *ppos)
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					eur_expect_close = 42;
@@ -369,7 +367,7 @@ static int eurwdt_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations eurwdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= eurwdt_write,
+	.write_iter	= eurwdt_write,
 	.unlocked_ioctl	= eurwdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= eurwdt_open,
Signature · 1 line
2.43.0
author maintainer
#246 lore raw

PATCH 240/437 watchdog: geodewdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/geodewdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/geodewdt.c +4 -4
index 5186c37ad451..2a0c904536d9 100644
@@ -108,9 +108,9 @@ static int geodewdt_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t geodewdt_write(struct file *file, const char __user *data,
-				size_t len, loff_t *ppos)
+static ssize_t geodewdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -119,7 +119,7 @@ static ssize_t geodewdt_write(struct file *file, const char __user *data,
 			for (i = 0; i != len; i++) {
 				char c;
 
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 
 				if (c == 'V')
@@ -197,7 +197,7 @@ static long geodewdt_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations geodewdt_fops = {
 	.owner          = THIS_MODULE,
 	.llseek         = no_llseek,
-	.write          = geodewdt_write,
+	.write_iter     = geodewdt_write,
 	.unlocked_ioctl = geodewdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open           = geodewdt_open,
Signature · 1 line
2.43.0
author maintainer
#247 lore raw

PATCH 241/437 watchdog: ib700wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/ib700wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/ib700wdt.c +4 -4
index 39ea97009abd..e5daeed9cd5c 100644
@@ -141,9 +141,9 @@ static int ibwdt_set_heartbeat(int t)
  *	/dev/watchdog handling
  */
 
-static ssize_t ibwdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t ibwdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -153,7 +153,7 @@ static ssize_t ibwdt_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -257,7 +257,7 @@ static int ibwdt_close(struct inode *inode, struct file *file)
 static const struct file_operations ibwdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= ibwdt_write,
+	.write_iter	= ibwdt_write,
 	.unlocked_ioctl	= ibwdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= ibwdt_open,
Signature · 1 line
2.43.0
author maintainer
#248 lore raw

PATCH 242/437 watchdog: ibmasr: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/ibmasr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/ibmasr.c +4 -4
index 6955c693b5fd..6f0931f33a6d 100644
@@ -243,9 +243,9 @@ static int __init asr_get_base_address(void)
 }
 
 
-static ssize_t asr_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t asr_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -255,7 +255,7 @@ static ssize_t asr_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					asr_expect_close = 42;
@@ -341,7 +341,7 @@ static int asr_release(struct inode *inode, struct file *file)
 static const struct file_operations asr_fops = {
 	.owner =		THIS_MODULE,
 	.llseek =		no_llseek,
-	.write =		asr_write,
+	.write_iter =		asr_write,
 	.unlocked_ioctl =	asr_ioctl,
 	.compat_ioctl =		compat_ptr_ioctl,
 	.open =			asr_open,
Signature · 1 line
2.43.0
author maintainer
#249 lore raw

PATCH 243/437 watchdog: it8712f_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/it8712f_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/it8712f_wdt.c +4 -4
index 3ce6a58bd81e..897f312eb5c9 100644
@@ -228,9 +228,9 @@ static struct notifier_block it8712f_wdt_notifier = {
 	.notifier_call = it8712f_wdt_notify,
 };
 
-static ssize_t it8712f_wdt_write(struct file *file, const char __user *data,
-					size_t len, loff_t *ppos)
+static ssize_t it8712f_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* check for a magic close character */
 	if (len) {
 		size_t i;
@@ -240,7 +240,7 @@ static ssize_t it8712f_wdt_write(struct file *file, const char __user *data,
 		expect_close = 0;
 		for (i = 0; i < len; ++i) {
 			char c;
-			if (get_user(c, data + i))
+			if (get_iter(c, from))
 				return -EFAULT;
 			if (c == 'V')
 				expect_close = 42;
@@ -342,7 +342,7 @@ static int it8712f_wdt_release(struct inode *inode, struct file *file)
 static const struct file_operations it8712f_wdt_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.write = it8712f_wdt_write,
+	.write_iter = it8712f_wdt_write,
 	.unlocked_ioctl = it8712f_wdt_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 	.open = it8712f_wdt_open,
Signature · 1 line
2.43.0
author maintainer
#250 lore raw

PATCH 244/437 watchdog: machzwd: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/machzwd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/machzwd.c +4 -4
index 73f2221f6222..c36a0a441c2c 100644
@@ -262,9 +262,9 @@ static void zf_ping(struct timer_list *unused)
 		pr_crit("I will reset your machine\n");
 }
 
-static ssize_t zf_write(struct file *file, const char __user *buf, size_t count,
-								loff_t *ppos)
+static ssize_t zf_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character */
 	if (count) {
 		/*
@@ -282,7 +282,7 @@ static ssize_t zf_write(struct file *file, const char __user *buf, size_t count,
 			/* now scan */
 			for (ofs = 0; ofs != count; ofs++) {
 				char c;
-				if (get_user(c, buf + ofs))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V') {
 					zf_expect_close = 42;
@@ -360,7 +360,7 @@ static int zf_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations zf_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= zf_write,
+	.write_iter	= zf_write,
 	.unlocked_ioctl = zf_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= zf_open,
Signature · 1 line
2.43.0
author maintainer
#251 lore raw

PATCH 245/437 watchdog: mei_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/mei_wdt.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/watchdog/mei_wdt.c +8 -10
index c7a7235e6224..c930fb5b8fe1 100644
@@ -491,10 +491,9 @@ static void mei_wdt_notif(struct mei_cl_device *cldev)
 
 #if IS_ENABLED(CONFIG_DEBUG_FS)
 
-static ssize_t mei_dbgfs_read_activation(struct file *file, char __user *ubuf,
-					size_t cnt, loff_t *ppos)
+static ssize_t mei_dbgfs_read_activation(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mei_wdt *wdt = file->private_data;
+	struct mei_wdt *wdt = iocb->ki_filp->private_data;
 	const size_t bufsz = 32;
 	char buf[32];
 	ssize_t pos;
@@ -504,31 +503,30 @@ static ssize_t mei_dbgfs_read_activation(struct file *file, char __user *ubuf,
 		__mei_wdt_is_registered(wdt) ? "activated" : "deactivated");
 	mutex_unlock(&wdt->reg_lock);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static const struct file_operations dbgfs_fops_activation = {
 	.open    = simple_open,
-	.read    = mei_dbgfs_read_activation,
+	.read_iter = mei_dbgfs_read_activation,
 	.llseek  = generic_file_llseek,
 };
 
-static ssize_t mei_dbgfs_read_state(struct file *file, char __user *ubuf,
-				    size_t cnt, loff_t *ppos)
+static ssize_t mei_dbgfs_read_state(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mei_wdt *wdt = file->private_data;
+	struct mei_wdt *wdt = iocb->ki_filp->private_data;
 	char buf[32];
 	ssize_t pos;
 
 	pos = scnprintf(buf, sizeof(buf), "state: %s\n",
 			mei_wdt_state_str(wdt->state));
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static const struct file_operations dbgfs_fops_state = {
 	.open = simple_open,
-	.read = mei_dbgfs_read_state,
+	.read_iter = mei_dbgfs_read_state,
 	.llseek = generic_file_llseek,
 };
 
Signature · 1 line
2.43.0
author maintainer
#252 lore raw

PATCH 246/437 watchdog: nv_tco: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/nv_tco.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/nv_tco.c +4 -4
index ac4a9c16341d..e9535ba7eba7 100644
@@ -174,9 +174,9 @@ static int nv_tco_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t nv_tco_write(struct file *file, const char __user *data,
-			    size_t len, loff_t *ppos)
+static ssize_t nv_tco_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
 		if (!nowayout) {
@@ -194,7 +194,7 @@ static ssize_t nv_tco_write(struct file *file, const char __user *data,
 			 */
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					tco_expect_close = 42;
@@ -265,7 +265,7 @@ static long nv_tco_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations nv_tco_fops = {
 	.owner =		THIS_MODULE,
 	.llseek =		no_llseek,
-	.write =		nv_tco_write,
+	.write_iter =		nv_tco_write,
 	.unlocked_ioctl =	nv_tco_ioctl,
 	.compat_ioctl =		compat_ptr_ioctl,
 	.open =			nv_tco_open,
Signature · 1 line
2.43.0
author maintainer
#253 lore raw

PATCH 247/437 watchdog: pc87413_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/pc87413_wdt.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/watchdog/pc87413_wdt.c +6 -8
index c7f745caf203..7ccc5aa4bd25 100644
@@ -327,18 +327,16 @@ static int pc87413_status(void)
 
 /**
  *	pc87413_write:
- *	@file: file handle to the watchdog
- *	@data: data buffer to write
- *	@len: length in bytes
- *	@ppos: pointer to the position to write. No seeks allowed
+ *	@iocb: metadata for IO
+ *	@from: data buffer to write
  *
  *	A write to a watchdog device is defined as a keepalive signal. Any
  *	write of data will do, as we we don't define content meaning.
  */
 
-static ssize_t pc87413_write(struct file *file, const char __user *data,
-			     size_t len, loff_t *ppos)
+static ssize_t pc87413_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
 		if (!nowayout) {
@@ -351,7 +349,7 @@ static ssize_t pc87413_write(struct file *file, const char __user *data,
 			   magic character */
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -471,7 +469,7 @@ static int pc87413_notify_sys(struct notifier_block *this,
 static const struct file_operations pc87413_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= pc87413_write,
+	.write_iter	= pc87413_write,
 	.unlocked_ioctl	= pc87413_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= pc87413_open,
Signature · 1 line
2.43.0
author maintainer
#254 lore raw

PATCH 248/437 watchdog: pcwd_pci: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/pcwd_pci.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/watchdog/pcwd_pci.c +7 -8
index 54d86fcb1837..6b7b3bd2ed83 100644
@@ -431,9 +431,9 @@ static int pcipcwd_get_timeleft(int *time_left)
  *	/dev/watchdog handling
  */
 
-static ssize_t pcipcwd_write(struct file *file, const char __user *data,
-			     size_t len, loff_t *ppos)
+static ssize_t pcipcwd_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
 		if (!nowayout) {
@@ -447,7 +447,7 @@ static ssize_t pcipcwd_write(struct file *file, const char __user *data,
 			 * magic character */
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_release = 42;
@@ -597,15 +597,14 @@ static int pcipcwd_release(struct inode *inode, struct file *file)
  *	/dev/temperature handling
  */
 
-static ssize_t pcipcwd_temp_read(struct file *file, char __user *data,
-				size_t len, loff_t *ppos)
+static ssize_t pcipcwd_temp_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int temperature;
 
 	if (pcipcwd_get_temperature(&temperature))
 		return -EFAULT;
 
-	if (copy_to_user(data, &temperature, 1))
+	if (!copy_to_iter_full(&temperature, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -644,7 +643,7 @@ static int pcipcwd_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations pcipcwd_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
-	.write =	pcipcwd_write,
+	.write_iter =	pcipcwd_write,
 	.unlocked_ioctl = pcipcwd_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 	.open =		pcipcwd_open,
@@ -660,7 +659,7 @@ static struct miscdevice pcipcwd_miscdev = {
 static const struct file_operations pcipcwd_temp_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
-	.read =		pcipcwd_temp_read,
+	.read_iter =	pcipcwd_temp_read,
 	.open =		pcipcwd_temp_open,
 	.release =	pcipcwd_temp_release,
 };
Signature · 1 line
2.43.0
author maintainer
#255 lore raw

PATCH 249/437 watchdog: pcwd_usb: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/pcwd_usb.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/watchdog/pcwd_usb.c +8 -8
index 8202f0a6b093..5fd830c0fdf3 100644
@@ -358,9 +358,9 @@ static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd,
  *	/dev/watchdog handling
  */
 
-static ssize_t usb_pcwd_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t usb_pcwd_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
 		if (!nowayout) {
@@ -374,7 +374,7 @@ static ssize_t usb_pcwd_write(struct file *file, const char __user *data,
 			 * magic character */
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_release = 42;
@@ -506,15 +506,15 @@ static int usb_pcwd_release(struct inode *inode, struct file *file)
  *	/dev/temperature handling
  */
 
-static ssize_t usb_pcwd_temperature_read(struct file *file, char __user *data,
-				size_t len, loff_t *ppos)
+static ssize_t usb_pcwd_temperature_read(struct kiocb *iocb,
+					 struct iov_iter *to)
 {
 	int temperature;
 
 	if (usb_pcwd_get_temperature(usb_pcwd_device, &temperature))
 		return -EFAULT;
 
-	if (copy_to_user(data, &temperature, 1))
+	if (!copy_to_iter_full(&temperature, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -550,7 +550,7 @@ static int usb_pcwd_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations usb_pcwd_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
-	.write =	usb_pcwd_write,
+	.write_iter =	usb_pcwd_write,
 	.unlocked_ioctl = usb_pcwd_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 	.open =		usb_pcwd_open,
@@ -566,7 +566,7 @@ static struct miscdevice usb_pcwd_miscdev = {
 static const struct file_operations usb_pcwd_temperature_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
-	.read =		usb_pcwd_temperature_read,
+	.read_iter =	usb_pcwd_temperature_read,
 	.open =		usb_pcwd_temperature_open,
 	.release =	usb_pcwd_temperature_release,
 };
Signature · 1 line
2.43.0
author maintainer
#256 lore raw

PATCH 250/437 watchdog: rdc321x_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/rdc321x_wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/rdc321x_wdt.c +3 -3
index 6176f4343fc5..de3210a342ff 100644
@@ -184,9 +184,9 @@ static long rdc321x_wdt_ioctl(struct file *file, unsigned int cmd,
 	return 0;
 }
 
-static ssize_t rdc321x_wdt_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t rdc321x_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (!count)
 		return -EIO;
 
@@ -201,7 +201,7 @@ static const struct file_operations rdc321x_wdt_fops = {
 	.unlocked_ioctl	= rdc321x_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= rdc321x_wdt_open,
-	.write		= rdc321x_wdt_write,
+	.write_iter	= rdc321x_wdt_write,
 	.release	= rdc321x_wdt_release,
 };
 
Signature · 1 line
2.43.0
author maintainer
#257 lore raw

PATCH 251/437 watchdog: sa1100_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/sa1100_wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/sa1100_wdt.c +3 -3
index 5d2df008b92a..f994b52565ec 100644
@@ -98,9 +98,9 @@ static int sa1100dog_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t sa1100dog_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t sa1100dog_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	if (len)
 		/* Refresh OSMR3 timer. */
 		sa1100_wr(sa1100_rd(REG_OSCR) + pre_margin, REG_OSMR3);
@@ -165,7 +165,7 @@ static long sa1100dog_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations sa1100dog_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= sa1100dog_write,
+	.write_iter	= sa1100dog_write,
 	.unlocked_ioctl	= sa1100dog_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= sa1100dog_open,
Signature · 1 line
2.43.0
author maintainer
#258 lore raw

PATCH 252/437 watchdog: sbc60xxwdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/sbc60xxwdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/sbc60xxwdt.c +4 -4
index 7b974802dfc7..ce727f42b88e 100644
@@ -161,9 +161,9 @@ static void wdt_keepalive(void)
  * /dev/watchdog handling
  */
 
-static ssize_t fop_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t fop_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -177,7 +177,7 @@ static ssize_t fop_write(struct file *file, const char __user *buf,
 			   magic character */
 			for (ofs = 0; ofs != count; ofs++) {
 				char c;
-				if (get_user(c, buf + ofs))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					wdt_expect_close = 42;
@@ -276,7 +276,7 @@ static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= fop_write,
+	.write_iter	= fop_write,
 	.open		= fop_open,
 	.release	= fop_close,
 	.unlocked_ioctl	= fop_ioctl,
Signature · 1 line
2.43.0
author maintainer
#259 lore raw

PATCH 253/437 watchdog: sbc_epx_c3: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/sbc_epx_c3.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/sbc_epx_c3.c +3 -3
index 5e3a9ddb952e..6bbb9db5e57e 100644
@@ -89,9 +89,9 @@ static int epx_c3_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t epx_c3_write(struct file *file, const char __user *data,
-			size_t len, loff_t *ppos)
+static ssize_t epx_c3_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* Refresh the timer. */
 	if (len)
 		epx_c3_pet();
@@ -154,7 +154,7 @@ static int epx_c3_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations epx_c3_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= epx_c3_write,
+	.write_iter	= epx_c3_write,
 	.unlocked_ioctl	= epx_c3_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= epx_c3_open,
Signature · 1 line
2.43.0
author maintainer
#260 lore raw

PATCH 254/437 watchdog: sbc_fitpc2_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/sbc_fitpc2_wdt.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/watchdog/sbc_fitpc2_wdt.c +4 -5
index b8eb8d5ca1af..1619f92814cf 100644
@@ -76,9 +76,9 @@ static int fitpc2_wdt_open(struct inode *inode, struct file *file)
 	return stream_open(inode, file);
 }
 
-static ssize_t fitpc2_wdt_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t fitpc2_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	size_t i;
 
 	if (!len)
@@ -94,7 +94,7 @@ static ssize_t fitpc2_wdt_write(struct file *file, const char __user *data,
 	for (i = 0; i != len; i++) {
 		char c;
 
-		if (get_user(c, data + i))
+		if (get_iter(c, from))
 			return -EFAULT;
 
 		if (c == 'V')
@@ -107,7 +107,6 @@ static ssize_t fitpc2_wdt_write(struct file *file, const char __user *data,
 	return len;
 }
 
-
 static const struct watchdog_info ident = {
 	.options	= WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT |
 				WDIOF_KEEPALIVEPING,
@@ -182,7 +181,7 @@ static int fitpc2_wdt_release(struct inode *inode, struct file *file)
 static const struct file_operations fitpc2_wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= fitpc2_wdt_write,
+	.write_iter	= fitpc2_wdt_write,
 	.unlocked_ioctl	= fitpc2_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= fitpc2_wdt_open,
Signature · 1 line
2.43.0
author maintainer
#261 lore raw

PATCH 255/437 watchdog: sc1200wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/sc1200wdt.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/watchdog/sc1200wdt.c +4 -5
index f22ebe89fe13..d8d8bee1d6d4 100644
@@ -261,9 +261,9 @@ static int sc1200wdt_release(struct inode *inode, struct file *file)
 }
 
 
-static ssize_t sc1200wdt_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t sc1200wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -273,7 +273,7 @@ static ssize_t sc1200wdt_write(struct file *file, const char __user *data,
 			for (i = 0; i != len; i++) {
 				char c;
 
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -287,7 +287,6 @@ static ssize_t sc1200wdt_write(struct file *file, const char __user *data,
 	return 0;
 }
 
-
 static int sc1200wdt_notify_sys(struct notifier_block *this,
 					unsigned long code, void *unused)
 {
@@ -305,7 +304,7 @@ static struct notifier_block sc1200wdt_notifier = {
 static const struct file_operations sc1200wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= sc1200wdt_write,
+	.write_iter	= sc1200wdt_write,
 	.unlocked_ioctl = sc1200wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= sc1200wdt_open,
Signature · 1 line
2.43.0
author maintainer
#262 lore raw

PATCH 256/437 watchdog: sc520_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/sc520_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/sc520_wdt.c +4 -4
index ca65468f4b9c..a428f1e28fbd 100644
@@ -215,9 +215,9 @@ static int wdt_set_heartbeat(int t)
  *	/dev/watchdog handling
  */
 
-static ssize_t fop_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t fop_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -230,7 +230,7 @@ static ssize_t fop_write(struct file *file, const char __user *buf,
 			/* now scan */
 			for (ofs = 0; ofs != count; ofs++) {
 				char c;
-				if (get_user(c, buf + ofs))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					wdt_expect_close = 42;
@@ -332,7 +332,7 @@ static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= fop_write,
+	.write_iter	= fop_write,
 	.open		= fop_open,
 	.release	= fop_close,
 	.unlocked_ioctl	= fop_ioctl,
Signature · 1 line
2.43.0
author maintainer
#263 lore raw

PATCH 257/437 watchdog: sch311x_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/sch311x_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/sch311x_wdt.c +4 -4
index 409d49880170..2d93a0353e79 100644
@@ -218,9 +218,9 @@ static void sch311x_wdt_get_status(int *status)
  *	/dev/watchdog handling
  */
 
-static ssize_t sch311x_wdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t sch311x_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -229,7 +229,7 @@ static ssize_t sch311x_wdt_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					sch311x_wdt_expect_close = 42;
@@ -335,7 +335,7 @@ static int sch311x_wdt_close(struct inode *inode, struct file *file)
 static const struct file_operations sch311x_wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= sch311x_wdt_write,
+	.write_iter	= sch311x_wdt_write,
 	.unlocked_ioctl	= sch311x_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= sch311x_wdt_open,
Signature · 1 line
2.43.0
author maintainer
#264 lore raw

PATCH 258/437 watchdog: smsc37b787_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/smsc37b787_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/smsc37b787_wdt.c +4 -4
index 7463df479d11..e1a0c1b4ca90 100644
@@ -386,9 +386,9 @@ static int wb_smsc_wdt_release(struct inode *inode, struct file *file)
 
 /* write => update the timer to keep the machine alive */
 
-static ssize_t wb_smsc_wdt_write(struct file *file, const char __user *data,
-				 size_t len, loff_t *ppos)
+static ssize_t wb_smsc_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
 		if (!nowayout) {
@@ -401,7 +401,7 @@ static ssize_t wb_smsc_wdt_write(struct file *file, const char __user *data,
 			   magic character */
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -503,7 +503,7 @@ static int wb_smsc_wdt_notify_sys(struct notifier_block *this,
 static const struct file_operations wb_smsc_wdt_fops = {
 	.owner	  = THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wb_smsc_wdt_write,
+	.write_iter	= wb_smsc_wdt_write,
 	.unlocked_ioctl	= wb_smsc_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wb_smsc_wdt_open,
Signature · 1 line
2.43.0
author maintainer
#265 lore raw

PATCH 259/437 watchdog: w83877f_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/w83877f_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/w83877f_wdt.c +4 -4
index f2650863fd02..5c55951f9d5b 100644
@@ -183,9 +183,9 @@ static void wdt_keepalive(void)
  * /dev/watchdog handling
  */
 
-static ssize_t fop_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t fop_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -199,7 +199,7 @@ static ssize_t fop_write(struct file *file, const char __user *buf,
 			   magic character */
 			for (ofs = 0; ofs != count; ofs++) {
 				char c;
-				if (get_user(c, buf + ofs))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					wdt_expect_close = 42;
@@ -300,7 +300,7 @@ static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= fop_write,
+	.write_iter	= fop_write,
 	.open		= fop_open,
 	.release	= fop_close,
 	.unlocked_ioctl	= fop_ioctl,
Signature · 1 line
2.43.0
author maintainer
#266 lore raw

PATCH 260/437 watchdog: w83977f_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/w83977f_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/w83977f_wdt.c +4 -4
index 31bf21ceaf48..2b9a8920ac2c 100644
@@ -324,9 +324,9 @@ static int wdt_release(struct inode *inode, struct file *file)
  *      write of data will do, as we don't define content meaning.
  */
 
-static ssize_t wdt_write(struct file *file, const char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -340,7 +340,7 @@ static ssize_t wdt_write(struct file *file, const char __user *buf,
 			   magic character */
 			for (ofs = 0; ofs != count; ofs++) {
 				char c;
-				if (get_user(c, buf + ofs))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -444,7 +444,7 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wdt_write,
+	.write_iter	= wdt_write,
 	.unlocked_ioctl	= wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wdt_open,
Signature · 1 line
2.43.0
author maintainer
#267 lore raw

PATCH 261/437 watchdog: wafer5823wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/wafer5823wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/wafer5823wdt.c +4 -4
index a8a1ed215e1e..64d6317f058f 100644
@@ -91,9 +91,9 @@ static void wafwdt_stop(void)
 	inb_p(wdt_stop);
 }
 
-static ssize_t wafwdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t wafwdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -106,7 +106,7 @@ static ssize_t wafwdt_write(struct file *file, const char __user *buf,
 			   character */
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -228,7 +228,7 @@ static int wafwdt_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations wafwdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wafwdt_write,
+	.write_iter	= wafwdt_write,
 	.unlocked_ioctl	= wafwdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wafwdt_open,
Signature · 1 line
2.43.0
author maintainer
#268 lore raw

PATCH 262/437 watchdog: watchdog_dev: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/watchdog_dev.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/watchdog/watchdog_dev.c +5 -5
index e2bd266b1b5b..828141d16264 100644
@@ -694,10 +694,10 @@ static int watchdog_ioctl_op(struct watchdog_device *wdd, unsigned int cmd,
  *
  * Return: @len if successful, error otherwise.
  */
-static ssize_t watchdog_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t watchdog_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct watchdog_core_data *wd_data = file->private_data;
+	struct watchdog_core_data *wd_data = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct watchdog_device *wdd;
 	int err;
 	size_t i;
@@ -714,7 +714,7 @@ static ssize_t watchdog_write(struct file *file, const char __user *data,
 
 	/* scan to see whether or not we got the magic character */
 	for (i = 0; i != len; i++) {
-		if (get_user(c, data + i))
+		if (get_iter(c, from))
 			return -EFAULT;
 		if (c == 'V')
 			set_bit(_WDOG_ALLOW_RELEASE, &wd_data->status);
@@ -991,7 +991,7 @@ static int watchdog_release(struct inode *inode, struct file *file)
 
 static const struct file_operations watchdog_fops = {
 	.owner		= THIS_MODULE,
-	.write		= watchdog_write,
+	.write_iter	= watchdog_write,
 	.unlocked_ioctl	= watchdog_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= watchdog_open,
Signature · 1 line
2.43.0
author maintainer
#269 lore raw

PATCH 263/437 watchdog: wdt_pci: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/wdt_pci.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/watchdog/wdt_pci.c +9 -12
index d5e56b601351..21efe34c9fd6 100644
@@ -350,9 +350,9 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id)
  *	write of data will do, as we we don't define content meaning.
  */
 
-static ssize_t wdtpci_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t wdtpci_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -362,7 +362,7 @@ static ssize_t wdtpci_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -487,24 +487,21 @@ static int wdtpci_release(struct inode *inode, struct file *file)
 
 /**
  *	wdtpci_temp_read:
- *	@file: file handle to the watchdog board
- *	@buf: buffer to write 1 byte into
- *	@count: length of buffer
- *	@ptr: offset (no seek allowed)
+ *	@iocb: metadata for IO
+ *	@to: buffer to write 1 byte into
  *
  *	Read reports the temperature in degrees Fahrenheit. The API is in
  *	fahrenheit. It was designed by an imperial measurement luddite.
  */
 
-static ssize_t wdtpci_temp_read(struct file *file, char __user *buf,
-						size_t count, loff_t *ptr)
+static ssize_t wdtpci_temp_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int temperature;
 
 	if (wdtpci_get_temperature(&temperature))
 		return -EFAULT;
 
-	if (copy_to_user(buf, &temperature, 1))
+	if (!copy_to_iter_full(&temperature, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -564,7 +561,7 @@ static int wdtpci_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations wdtpci_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wdtpci_write,
+	.write_iter	= wdtpci_write,
 	.unlocked_ioctl	= wdtpci_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wdtpci_open,
@@ -580,7 +577,7 @@ static struct miscdevice wdtpci_miscdev = {
 static const struct file_operations wdtpci_temp_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= wdtpci_temp_read,
+	.read_iter	= wdtpci_temp_read,
 	.open		= wdtpci_temp_open,
 	.release	= wdtpci_temp_release,
 };
Signature · 1 line
2.43.0
author maintainer
#270 lore raw

PATCH 264/437 watchdog: ath79_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/ath79_wdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/watchdog/ath79_wdt.c +5 -4
index e5cc30622b12..33320f83c190 100644
@@ -146,9 +146,10 @@ static int ath79_wdt_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath79_wdt_write(struct file *file, const char *data,
-				size_t len, loff_t *ppos)
+static ssize_t ath79_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -158,7 +159,7 @@ static ssize_t ath79_wdt_write(struct file *file, const char *data,
 			for (i = 0; i != len; i++) {
 				char c;
 
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 
 				if (c == 'V')
@@ -232,7 +233,7 @@ static long ath79_wdt_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations ath79_wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= ath79_wdt_write,
+	.write_iter	= ath79_wdt_write,
 	.unlocked_ioctl	= ath79_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= ath79_wdt_open,
Signature · 1 line
2.43.0
author maintainer
#271 lore raw

PATCH 265/437 watchdog: cpwd: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/cpwd.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/watchdog/cpwd.c +6 -7
index 901b94d456db..ca6d08107043 100644
@@ -478,10 +478,10 @@ static long cpwd_compat_ioctl(struct file *file, unsigned int cmd, unsigned long
 	return cpwd_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
 }
 
-static ssize_t cpwd_write(struct file *file, const char __user *buf,
-			  size_t count, loff_t *ppos)
+static ssize_t cpwd_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct cpwd *p = cpwd_device;
 	int index = iminor(inode);
 
@@ -493,8 +493,7 @@ static ssize_t cpwd_write(struct file *file, const char __user *buf,
 	return 0;
 }
 
-static ssize_t cpwd_read(struct file *file, char __user *buffer,
-			 size_t count, loff_t *ppos)
+static ssize_t cpwd_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return -EINVAL;
 }
@@ -504,8 +503,8 @@ static const struct file_operations cpwd_fops = {
 	.unlocked_ioctl =	cpwd_ioctl,
 	.compat_ioctl =		cpwd_compat_ioctl,
 	.open =			cpwd_open,
-	.write =		cpwd_write,
-	.read =			cpwd_read,
+	.write_iter =		cpwd_write,
+	.read_iter =		cpwd_read,
 	.release =		cpwd_release,
 	.llseek =		no_llseek,
 };
Signature · 1 line
2.43.0
author maintainer
#272 lore raw

PATCH 266/437 watchdog: gef_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/gef_wdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/watchdog/gef_wdt.c +5 -4
index 6a1db1c783fa..c946fd169966 100644
@@ -132,9 +132,10 @@ static void gef_wdt_set_timeout(unsigned int timeout)
 }
 
 
-static ssize_t gef_wdt_write(struct file *file, const char __user *data,
-				 size_t len, loff_t *ppos)
+static ssize_t gef_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -143,7 +144,7 @@ static ssize_t gef_wdt_write(struct file *file, const char __user *data,
 
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -246,7 +247,7 @@ static int gef_wdt_release(struct inode *inode, struct file *file)
 static const struct file_operations gef_wdt_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.write = gef_wdt_write,
+	.write_iter = gef_wdt_write,
 	.unlocked_ioctl = gef_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open = gef_wdt_open,
Signature · 1 line
2.43.0
author maintainer
#273 lore raw

PATCH 267/437 watchdog: indydog: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/indydog.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/indydog.c +3 -3
index 9857bb74a723..967a95a886a4 100644
@@ -86,9 +86,9 @@ static int indydog_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t indydog_write(struct file *file, const char *data,
-						size_t len, loff_t *ppos)
+static ssize_t indydog_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* Refresh the timer. */
 	if (len)
 		indydog_ping();
@@ -150,7 +150,7 @@ static int indydog_notify_sys(struct notifier_block *this,
 static const struct file_operations indydog_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= indydog_write,
+	.write_iter	= indydog_write,
 	.unlocked_ioctl	= indydog_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= indydog_open,
Signature · 1 line
2.43.0
author maintainer
#274 lore raw

PATCH 268/437 watchdog: m54xx_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/m54xx_wdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/watchdog/m54xx_wdt.c +5 -4
index 062ea3e6497e..1421e305ca12 100644
@@ -87,9 +87,10 @@ static int m54xx_wdt_open(struct inode *inode, struct file *file)
 	return stream_open(inode, file);
 }
 
-static ssize_t m54xx_wdt_write(struct file *file, const char *data,
-						size_t len, loff_t *ppos)
+static ssize_t m54xx_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -99,7 +100,7 @@ static ssize_t m54xx_wdt_write(struct file *file, const char *data,
 			for (i = 0; i != len; i++) {
 				char c;
 
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					set_bit(WDT_OK_TO_CLOSE, &wdt_status);
@@ -180,7 +181,7 @@ static int m54xx_wdt_release(struct inode *inode, struct file *file)
 static const struct file_operations m54xx_wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= m54xx_wdt_write,
+	.write_iter	= m54xx_wdt_write,
 	.unlocked_ioctl	= m54xx_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= m54xx_wdt_open,
Signature · 1 line
2.43.0
author maintainer
#275 lore raw

PATCH 269/437 watchdog: mixcomwd: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/mixcomwd.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/watchdog/mixcomwd.c +5 -4
index d387bad377c4..c980e542c31b 100644
@@ -166,9 +166,10 @@ static int mixcomwd_release(struct inode *inode, struct file *file)
 }
 
 
-static ssize_t mixcomwd_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t mixcomwd_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -178,7 +179,7 @@ static ssize_t mixcomwd_write(struct file *file, const char __user *data,
 
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -225,7 +226,7 @@ static long mixcomwd_ioctl(struct file *file,
 static const struct file_operations mixcomwd_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= mixcomwd_write,
+	.write_iter	= mixcomwd_write,
 	.unlocked_ioctl	= mixcomwd_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= mixcomwd_open,
Signature · 1 line
2.43.0
author maintainer
#276 lore raw

PATCH 270/437 watchdog: mtx-1_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/mtx-1_wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/mtx-1_wdt.c +3 -3
index 152e41ecbb14..1d7f5154c144 100644
@@ -166,9 +166,9 @@ static long mtx1_wdt_ioctl(struct file *file, unsigned int cmd,
 }
 
 
-static ssize_t mtx1_wdt_write(struct file *file, const char *buf,
-						size_t count, loff_t *ppos)
+static ssize_t mtx1_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (!count)
 		return -EIO;
 	mtx1_wdt_reset();
@@ -181,7 +181,7 @@ static const struct file_operations mtx1_wdt_fops = {
 	.unlocked_ioctl	= mtx1_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= mtx1_wdt_open,
-	.write		= mtx1_wdt_write,
+	.write_iter	= mtx1_wdt_write,
 	.release	= mtx1_wdt_release,
 };
 
Signature · 1 line
2.43.0
author maintainer
#277 lore raw

PATCH 271/437 watchdog: pcwd: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/pcwd.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/watchdog/pcwd.c +7 -8
index a793b03a785d..9515f87c0b9e 100644
@@ -663,9 +663,9 @@ static long pcwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	return 0;
 }
 
-static ssize_t pcwd_write(struct file *file, const char __user *buf, size_t len,
-			  loff_t *ppos)
+static ssize_t pcwd_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -676,7 +676,7 @@ static ssize_t pcwd_write(struct file *file, const char __user *buf, size_t len,
 			for (i = 0; i != len; i++) {
 				char c;
 
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -716,15 +716,14 @@ static int pcwd_close(struct inode *inode, struct file *file)
  *	/dev/temperature handling
  */
 
-static ssize_t pcwd_temp_read(struct file *file, char __user *buf, size_t count,
-			 loff_t *ppos)
+static ssize_t pcwd_temp_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int temperature;
 
 	if (pcwd_get_temperature(&temperature))
 		return -EFAULT;
 
-	if (copy_to_user(buf, &temperature, 1))
+	if (!copy_to_iter_full(&temperature, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -750,7 +749,7 @@ static int pcwd_temp_close(struct inode *inode, struct file *file)
 static const struct file_operations pcwd_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= pcwd_write,
+	.write_iter	= pcwd_write,
 	.unlocked_ioctl	= pcwd_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= pcwd_open,
@@ -766,7 +765,7 @@ static struct miscdevice pcwd_miscdev = {
 static const struct file_operations pcwd_temp_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= pcwd_temp_read,
+	.read_iter	= pcwd_temp_read,
 	.open		= pcwd_temp_open,
 	.release	= pcwd_temp_close,
 };
Signature · 1 line
2.43.0
author maintainer
#278 lore raw

PATCH 272/437 watchdog: pika_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/pika_wdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/watchdog/pika_wdt.c +5 -4
index 782b8c23d99c..bf1ac356df69 100644
@@ -139,9 +139,10 @@ static int pikawdt_release(struct inode *inode, struct file *file)
 /*
  * Pat the watchdog whenever device is written to.
  */
-static ssize_t pikawdt_write(struct file *file, const char __user *data,
-			     size_t len, loff_t *ppos)
+static ssize_t pikawdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	if (!len)
 		return 0;
 
@@ -153,7 +154,7 @@ static ssize_t pikawdt_write(struct file *file, const char __user *data,
 
 		for (i = 0; i < len; i++) {
 			char c;
-			if (get_user(c, data + i))
+			if (get_iter(c, from))
 				return -EFAULT;
 			if (c == 'V') {
 				pikawdt_private.expect_close = 42;
@@ -212,7 +213,7 @@ static const struct file_operations pikawdt_fops = {
 	.llseek		= no_llseek,
 	.open		= pikawdt_open,
 	.release	= pikawdt_release,
-	.write		= pikawdt_write,
+	.write_iter	= pikawdt_write,
 	.unlocked_ioctl	= pikawdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 };
Signature · 1 line
2.43.0
author maintainer
#279 lore raw

PATCH 273/437 watchdog: rc32434_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/rc32434_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/rc32434_wdt.c +4 -4
index 417f9b75679c..76c046c9beb9 100644
@@ -161,9 +161,9 @@ static int rc32434_wdt_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t rc32434_wdt_write(struct file *file, const char *data,
-				size_t len, loff_t *ppos)
+static ssize_t rc32434_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -173,7 +173,7 @@ static ssize_t rc32434_wdt_write(struct file *file, const char *data,
 
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -243,7 +243,7 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations rc32434_wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= rc32434_wdt_write,
+	.write_iter	= rc32434_wdt_write,
 	.unlocked_ioctl	= rc32434_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= rc32434_wdt_open,
Signature · 1 line
2.43.0
author maintainer
#280 lore raw

PATCH 274/437 watchdog: riowd: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/riowd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/riowd.c +3 -3
index b293792a292a..d9a85b4c1de2 100644
@@ -145,10 +145,10 @@ static long riowd_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	return 0;
 }
 
-static ssize_t riowd_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t riowd_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct riowd *p = riowd_device;
+	size_t count = iov_iter_count(from);
 
 	if (count) {
 		riowd_writereg(p, riowd_timeout, WDTO_INDEX);
@@ -164,7 +164,7 @@ static const struct file_operations riowd_fops = {
 	.unlocked_ioctl =	riowd_ioctl,
 	.compat_ioctl	=	compat_ptr_ioctl,
 	.open =			riowd_open,
-	.write =		riowd_write,
+	.write_iter =		riowd_write,
 	.release =		riowd_release,
 };
 
Signature · 1 line
2.43.0
author maintainer
#281 lore raw

PATCH 275/437 watchdog: sb_wdog: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/sb_wdog.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/sb_wdog.c +4 -4
index 504be461f992..cb1123b7bdbf 100644
@@ -141,9 +141,9 @@ static int sbwdog_release(struct inode *inode, struct file *file)
 /*
  * 42 - the answer
  */
-static ssize_t sbwdog_write(struct file *file, const char __user *data,
-			size_t len, loff_t *ppos)
+static ssize_t sbwdog_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	int i;
 
 	if (len) {
@@ -155,7 +155,7 @@ static ssize_t sbwdog_write(struct file *file, const char __user *data,
 		for (i = 0; i != len; i++) {
 			char c;
 
-			if (get_user(c, data + i))
+			if (get_iter(c, from))
 				return -EFAULT;
 			if (c == 'V')
 				expect_close = 42;
@@ -235,7 +235,7 @@ static int sbwdog_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations sbwdog_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= sbwdog_write,
+	.write_iter	= sbwdog_write,
 	.unlocked_ioctl	= sbwdog_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= sbwdog_open,
Signature · 1 line
2.43.0
author maintainer
#282 lore raw

PATCH 276/437 watchdog: sbc7240_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/sbc7240_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/sbc7240_wdt.c +4 -4
index d640b26e18a6..3e31a047bb91 100644
@@ -91,9 +91,9 @@ static inline void wdt_keepalive(void)
 /*
  * /dev/watchdog handling
  */
-static ssize_t fop_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t fop_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	size_t i;
 	char c;
 
@@ -104,7 +104,7 @@ static ssize_t fop_write(struct file *file, const char __user *buf,
 
 			/* is there a magic char ? */
 			for (i = 0; i != count; i++) {
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == SBC7240_MAGIC_CHAR) {
 					set_bit(SBC7240_EXPECT_CLOSE_STATUS_BIT,
@@ -206,7 +206,7 @@ static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations wdt_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.write = fop_write,
+	.write_iter = fop_write,
 	.open = fop_open,
 	.release = fop_close,
 	.unlocked_ioctl = fop_ioctl,
Signature · 1 line
2.43.0
author maintainer
#283 lore raw

PATCH 277/437 watchdog: sbc8360: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/sbc8360.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/watchdog/sbc8360.c +5 -4
index 4f8b9912fc51..5d7042c85988 100644
@@ -234,9 +234,10 @@ static void sbc8360_stop(void)
 }
 
 /* Userspace pings kernel driver, or requests clean close */
-static ssize_t sbc8360_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *ppos)
+static ssize_t sbc8360_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
+
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -246,7 +247,7 @@ static ssize_t sbc8360_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -302,7 +303,7 @@ static int sbc8360_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations sbc8360_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.write = sbc8360_write,
+	.write_iter = sbc8360_write,
 	.open = sbc8360_open,
 	.release = sbc8360_close,
 };
Signature · 1 line
2.43.0
author maintainer
#284 lore raw

PATCH 278/437 watchdog: scx200_wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/scx200_wdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/watchdog/scx200_wdt.c +5 -4
index 7b5e18323f3f..a9b6a4734805 100644
@@ -128,9 +128,10 @@ static struct notifier_block scx200_wdt_notifier = {
 	.notifier_call = scx200_wdt_notify_sys,
 };
 
-static ssize_t scx200_wdt_write(struct file *file, const char __user *data,
-				     size_t len, loff_t *ppos)
+static ssize_t scx200_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	/* check for a magic close character */
 	if (len) {
 		size_t i;
@@ -140,7 +141,7 @@ static ssize_t scx200_wdt_write(struct file *file, const char __user *data,
 		expect_close = 0;
 		for (i = 0; i < len; ++i) {
 			char c;
-			if (get_user(c, data + i))
+			if (get_iter(c, from))
 				return -EFAULT;
 			if (c == 'V')
 				expect_close = 42;
@@ -199,7 +200,7 @@ static long scx200_wdt_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations scx200_wdt_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.write = scx200_wdt_write,
+	.write_iter = scx200_wdt_write,
 	.unlocked_ioctl = scx200_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open = scx200_wdt_open,
Signature · 1 line
2.43.0
author maintainer
#285 lore raw

PATCH 279/437 watchdog: wdrtas: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/wdrtas.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/watchdog/wdrtas.c +9 -12
index c00627825de8..591e5dcc8383 100644
@@ -231,9 +231,9 @@ static int wdrtas_get_boot_status(void)
  * character 'V'. This character allows the watchdog device to be closed
  * properly.
  */
-static ssize_t wdrtas_write(struct file *file, const char __user *buf,
-	     size_t len, loff_t *ppos)
+static ssize_t wdrtas_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	int i;
 	char c;
 
@@ -244,7 +244,7 @@ static ssize_t wdrtas_write(struct file *file, const char __user *buf,
 		wdrtas_expect_close = 0;
 		/* look for 'V' */
 		for (i = 0; i < len; i++) {
-			if (get_user(c, buf + i))
+			if (get_iter(c, from))
 				return -EFAULT;
 			/* allow to close device */
 			if (c == 'V')
@@ -392,10 +392,8 @@ static int wdrtas_close(struct inode *inode, struct file *file)
 
 /**
  * wdrtas_temp_read - gives back the temperature in fahrenheit
- * @file: file structure
- * @buf: user buffer
- * @count: number of bytes to be read
- * @ppos: position in file
+ * @iocb: metadata for IO
+ * @to: user buffer
  *
  * returns always 1 or -EFAULT in case of user space copy failures, <0 on
  * other failures
@@ -403,8 +401,7 @@ static int wdrtas_close(struct inode *inode, struct file *file)
  * wdrtas_temp_read gives the temperature to the users by copying this
  * value as one byte into the user space buffer. The unit is Fahrenheit...
  */
-static ssize_t wdrtas_temp_read(struct file *file, char __user *buf,
-		 size_t count, loff_t *ppos)
+static ssize_t wdrtas_temp_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int temperature = 0;
 
@@ -412,7 +409,7 @@ static ssize_t wdrtas_temp_read(struct file *file, char __user *buf,
 	if (temperature < 0)
 		return temperature;
 
-	if (copy_to_user(buf, &temperature, 1))
+	if (!copy_to_iter_full(&temperature, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -470,7 +467,7 @@ static int wdrtas_reboot(struct notifier_block *this,
 static const struct file_operations wdrtas_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wdrtas_write,
+	.write_iter	= wdrtas_write,
 	.unlocked_ioctl	= wdrtas_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wdrtas_open,
@@ -486,7 +483,7 @@ static struct miscdevice wdrtas_miscdev = {
 static const struct file_operations wdrtas_temp_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= wdrtas_temp_read,
+	.read_iter	= wdrtas_temp_read,
 	.open		= wdrtas_temp_open,
 	.release	= wdrtas_temp_close,
 };
Signature · 1 line
2.43.0
author maintainer
#286 lore raw

PATCH 280/437 watchdog: wdt: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/wdt.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/watchdog/wdt.c +12 -16
index 183876156243..4f942a82271b 100644
@@ -305,18 +305,17 @@ static irqreturn_t wdt_interrupt(int irq, void *dev_id)
 
 /**
  *	wdt_write:
- *	@file: file handle to the watchdog
- *	@buf: buffer to write (unused as data does not matter here
- *	@count: count of bytes
- *	@ppos: pointer to the position to write. No seeks allowed
+ *	@iocb: metadata for the request
+ *	@from: iov_iter to read from
  *
  *	A write to a watchdog device is defined as a keepalive signal. Any
  *	write of data will do, as we we don't define content meaning.
  */
 
-static ssize_t wdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
+
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -326,7 +325,7 @@ static ssize_t wdt_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -447,21 +446,18 @@ static int wdt_release(struct inode *inode, struct file *file)
 
 /**
  *	wdt_temp_read:
- *	@file: file handle to the watchdog board
- *	@buf: buffer to write 1 byte into
- *	@count: length of buffer
- *	@ptr: offset (no seek allowed)
+ *	@iocb: metadata for the request
+ *	@to: iov_iter to write to
  *
  *	Temp_read reports the temperature in degrees Fahrenheit. The API is in
  *	farenheit. It was designed by an imperial measurement luddite.
  */
 
-static ssize_t wdt_temp_read(struct file *file, char __user *buf,
-						size_t count, loff_t *ptr)
+static ssize_t wdt_temp_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int temperature = wdt_get_temperature();
 
-	if (copy_to_user(buf, &temperature, 1))
+	if (!copy_to_iter_full(&temperature, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -521,7 +517,7 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wdt_write,
+	.write_iter	= wdt_write,
 	.unlocked_ioctl	= wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wdt_open,
@@ -537,7 +533,7 @@ static struct miscdevice wdt_miscdev = {
 static const struct file_operations wdt_temp_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= wdt_temp_read,
+	.read_iter	= wdt_temp_read,
 	.open		= wdt_temp_open,
 	.release	= wdt_temp_release,
 };
Signature · 1 line
2.43.0
author maintainer
#287 lore raw

PATCH 281/437 watchdog: wdt285: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/wdt285.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/watchdog/wdt285.c +4 -3
index 5b7be7a62d54..eee5aada2ddd 100644
@@ -114,9 +114,10 @@ static int watchdog_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t watchdog_write(struct file *file, const char __user *data,
-			      size_t len, loff_t *ppos)
+static ssize_t watchdog_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	/*
 	 *	Refresh the timer.
 	 */
@@ -179,7 +180,7 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations watchdog_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= watchdog_write,
+	.write_iter	= watchdog_write,
 	.unlocked_ioctl	= watchdog_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= watchdog_open,
Signature · 1 line
2.43.0
author maintainer
#288 lore raw

PATCH 282/437 watchdog: wdt977: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/watchdog/wdt977.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/watchdog/wdt977.c +5 -4
index c9b8e863f70f..e50a7374ceb1 100644
@@ -301,9 +301,10 @@ static int wdt977_release(struct inode *inode, struct file *file)
  *      write of data will do, as we we don't define content meaning.
  */
 
-static ssize_t wdt977_write(struct file *file, const char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t wdt977_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
+
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -313,7 +314,7 @@ static ssize_t wdt977_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -420,7 +421,7 @@ static int wdt977_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations wdt977_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wdt977_write,
+	.write_iter	= wdt977_write,
 	.unlocked_ioctl	= wdt977_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wdt977_open,
Signature · 1 line
2.43.0
author maintainer
#289 lore raw

PATCH 283/437 fs/binfmt_misc: convert to read/write iterators

In reply to Jens Axboe
---
 fs/binfmt_misc.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
fs/binfmt_misc.c +14 -13
index 68fa225f89e5..f44b626c4df7 100644
@@ -734,10 +734,9 @@ static void remove_binfmt_handler(struct binfmt_misc *misc, Node *e)
 
 /* /<entry> */
 
-static ssize_t
-bm_entry_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
+static ssize_t bm_entry_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	Node *e = file_inode(file)->i_private;
+	Node *e = file_inode(iocb->ki_filp)->i_private;
 	ssize_t res;
 	char *page;
 
@@ -747,7 +746,7 @@ bm_entry_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 
 	entry_status(e, page);
 
-	res = simple_read_from_buffer(buf, nbytes, ppos, page, strlen(page));
+	res = simple_copy_to_iter(page, &iocb->ki_pos, strlen(page), to);
 
 	free_page((unsigned long) page);
 	return res;
@@ -794,10 +793,11 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(bm_entry_write);
 
 static const struct file_operations bm_entry_operations = {
-	.read		= bm_entry_read,
-	.write		= bm_entry_write,
+	.read_iter	= bm_entry_read,
+	.write_iter	= bm_entry_write_iter,
 	.llseek		= default_llseek,
 };
 
@@ -882,23 +882,23 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
 	}
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(bm_register_write);
 
 static const struct file_operations bm_register_operations = {
-	.write		= bm_register_write,
+	.write_iter	= bm_register_write_iter,
 	.llseek		= noop_llseek,
 };
 
 /* /status */
 
-static ssize_t
-bm_status_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
+static ssize_t bm_status_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct binfmt_misc *misc;
 	char *s;
 
-	misc = i_binfmt_misc(file_inode(file));
+	misc = i_binfmt_misc(file_inode(iocb->ki_filp));
 	s = misc->enabled ? "enabled\n" : "disabled\n";
-	return simple_read_from_buffer(buf, nbytes, ppos, s, strlen(s));
+	return simple_copy_to_iter(s, &iocb->ki_pos, strlen(s), to);
 }
 
 static ssize_t bm_status_write(struct file *file, const char __user *buffer,
@@ -944,10 +944,11 @@ static ssize_t bm_status_write(struct file *file, const char __user *buffer,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(bm_status_write);
 
 static const struct file_operations bm_status_operations = {
-	.read		= bm_status_read,
-	.write		= bm_status_write,
+	.read_iter	= bm_status_read,
+	.write_iter	= bm_status_write_iter,
 	.llseek		= default_llseek,
 };
 
Signature · 1 line
2.43.0
author maintainer
#290 lore raw

PATCH 284/437 fs/coda: convert to read/write iterators

In reply to Jens Axboe
---
 fs/coda/psdev.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
fs/coda/psdev.c +9 -8
index 3c3148588491..1c7f1c5c4941 100644
@@ -196,16 +196,17 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
 out:
         return(count ? count : retval);  
 }
+FOPS_WRITE_ITER_HELPER(coda_psdev_write);
 
 /*
  *	Read a message from the kernel to Venus
  */
 
-static ssize_t coda_psdev_read(struct file * file, char __user * buf, 
-			       size_t nbytes, loff_t *off)
+static ssize_t coda_psdev_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	DECLARE_WAITQUEUE(wait, current);
-        struct venus_comm *vcp = (struct venus_comm *) file->private_data;
+	struct venus_comm *vcp = iocb->ki_filp->private_data;
+	size_t nbytes = iov_iter_count(to);
         struct upc_req *req;
 	ssize_t retval = 0, count = 0;
 
@@ -218,7 +219,7 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf,
 	set_current_state(TASK_INTERRUPTIBLE);
 
 	while (list_empty(&vcp->vc_pending)) {
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
 			break;
 		}
@@ -248,9 +249,9 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf,
 		count = nbytes;
         }
 
-	if (copy_to_user(buf, req->uc_data, count))
+	if (!copy_to_iter_full(req->uc_data, count, to))
 	        retval = -EFAULT;
-        
+
 	/* If request was not a signal, enqueue and don't free */
 	if (!(req->uc_flags & CODA_REQ_ASYNC)) {
 		req->uc_flags |= CODA_REQ_READ;
@@ -344,8 +345,8 @@ static int coda_psdev_release(struct inode * inode, struct file * file)
 
 static const struct file_operations coda_psdev_fops = {
 	.owner		= THIS_MODULE,
-	.read		= coda_psdev_read,
-	.write		= coda_psdev_write,
+	.read_iter	= coda_psdev_read,
+	.write_iter	= coda_psdev_write_iter,
 	.poll		= coda_psdev_poll,
 	.unlocked_ioctl	= coda_psdev_ioctl,
 	.open		= coda_psdev_open,
Signature · 1 line
2.43.0
author maintainer
#291 lore raw

PATCH 285/437 fs/nfsd: convert to read/write iterators

In reply to Jens Axboe
---
 fs/nfsd/nfs4state.c |  5 +++--
 fs/nfsd/nfsctl.c    | 10 ++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)
fs/nfsd/nfs4state.c +3 -2
index 84d4093ca713..cbe82431633a 100644
@@ -2958,7 +2958,7 @@ static int client_opens_release(struct inode *inode, struct file *file)
 
 static const struct file_operations client_states_fops = {
 	.open		= client_states_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= client_opens_release,
 };
@@ -3011,9 +3011,10 @@ static ssize_t client_ctl_write(struct file *file, const char __user *buf,
 	drop_client(clp);
 	return 7;
 }
+FOPS_WRITE_ITER_HELPER(client_ctl_write);
 
 static const struct file_operations client_ctl_fops = {
-	.write		= client_ctl_write,
+	.write_iter	= client_ctl_write_iter,
 	.release	= simple_transaction_release,
 };
 
fs/nfsd/nfsctl.c +6 -4
index ecd18bffeebc..788194ac663d 100644
@@ -118,6 +118,7 @@ static ssize_t nfsctl_transaction_write(struct file *file, const char __user *bu
 	simple_transaction_set(file, rv);
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(nfsctl_transaction_write);
 
 static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos)
 {
@@ -132,10 +133,11 @@ static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size
 	}
 	return simple_transaction_read(file, buf, size, pos);
 }
+FOPS_READ_ITER_HELPER(nfsctl_transaction_read);
 
 static const struct file_operations transaction_ops = {
-	.write		= nfsctl_transaction_write,
-	.read		= nfsctl_transaction_read,
+	.write_iter	= nfsctl_transaction_write_iter,
+	.read_iter	= nfsctl_transaction_read_iter,
 	.release	= simple_transaction_release,
 	.llseek		= default_llseek,
 };
@@ -162,7 +164,7 @@ static int exports_nfsd_open(struct inode *inode, struct file *file)
 
 static const struct file_operations exports_nfsd_operations = {
 	.open		= exports_nfsd_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
@@ -177,7 +179,7 @@ DEFINE_SHOW_ATTRIBUTE(export_features);
 
 static const struct file_operations pool_stats_operations = {
 	.open		= nfsd_pool_stats_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
Signature · 1 line
2.43.0
author maintainer
#292 lore raw

PATCH 286/437 ubifs: convert to read/write iterators

In reply to Jens Axboe
---
 fs/ubifs/debug.c | 59 ++++++++++++++++++++++--------------------------
 1 file changed, 27 insertions(+), 32 deletions(-)
fs/ubifs/debug.c +27 -32
index 2d63f57aca6f..52f93ea1ac7f 100644
@@ -2677,17 +2677,15 @@ static int dfs_file_open(struct inode *inode, struct file *file)
 /**
  * provide_user_output - provide output to the user reading a debugfs file.
  * @val: boolean value for the answer
- * @u: the buffer to store the answer at
- * @count: size of the buffer
- * @ppos: position in the @u output buffer
+ * @iocb: metadata for IO
+ * @to: the buffer to store the answer at
  *
  * This is a simple helper function which stores @val boolean value in the user
  * buffer when the user reads one of UBIFS debugfs files. Returns amount of
  * bytes written to @u in case of success and a negative error code in case of
  * failure.
  */
-static int provide_user_output(int val, char __user *u, size_t count,
-			       loff_t *ppos)
+static int provide_user_output(int val, struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[3];
 
@@ -2698,14 +2696,13 @@ static int provide_user_output(int val, char __user *u, size_t count,
 	buf[1] = '\n';
 	buf[2] = 0x00;
 
-	return simple_read_from_buffer(u, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,
-			     loff_t *ppos)
+static ssize_t dfs_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dentry *dent = file->f_path.dentry;
-	struct ubifs_info *c = file->private_data;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
+	struct ubifs_info *c = iocb->ki_filp->private_data;
 	struct ubifs_debug_info *d = c->dbg;
 	int val;
 
@@ -2726,26 +2723,25 @@ static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,
 	else
 		return -EINVAL;
 
-	return provide_user_output(val, u, count, ppos);
+	return provide_user_output(val, iocb, to);
 }
-FOPS_READ_ITER_HELPER(dfs_file_read);
 
 /**
  * interpret_user_input - interpret user debugfs file input.
- * @u: user-provided buffer with the input
- * @count: buffer size
+ * @from: user-provided buffer with the input
  *
  * This is a helper function which interpret user input to a boolean UBIFS
  * debugfs file. Returns %0 or %1 in case of success and a negative error code
  * in case of failure.
  */
-static int interpret_user_input(const char __user *u, size_t count)
+static int interpret_user_input(struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	size_t buf_size;
 	char buf[8];
 
 	buf_size = min_t(size_t, count, (sizeof(buf) - 1));
-	if (copy_from_user(buf, u, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	if (buf[0] == '1')
@@ -2756,12 +2752,13 @@ static int interpret_user_input(const char __user *u, size_t count)
 	return -EINVAL;
 }
 
-static ssize_t dfs_file_write(struct file *file, const char __user *u,
-			      size_t count, loff_t *ppos)
+static ssize_t dfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	struct file *file = iocb->ki_filp;
 	struct ubifs_info *c = file->private_data;
 	struct ubifs_debug_info *d = c->dbg;
 	struct dentry *dent = file->f_path.dentry;
+	size_t count = iov_iter_count(from);
 	int val;
 
 	if (file->f_path.dentry == d->dfs_dump_lprops) {
@@ -2779,7 +2776,7 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
 		return count;
 	}
 
-	val = interpret_user_input(u, count);
+	val = interpret_user_input(from);
 	if (val < 0)
 		return val;
 
@@ -2802,12 +2799,11 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
 
 	return count;
 }
-FOPS_WRITE_ITER_HELPER(dfs_file_write);
 
 static const struct file_operations dfs_fops = {
 	.open = dfs_file_open,
-	.read_iter = dfs_file_read_iter,
-	.write_iter = dfs_file_write_iter,
+	.read_iter = dfs_file_read,
+	.write_iter = dfs_file_write,
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
 };
@@ -2898,10 +2894,9 @@ static struct dentry *dfs_chk_lprops;
 static struct dentry *dfs_chk_fs;
 static struct dentry *dfs_tst_rcvry;
 
-static ssize_t dfs_global_file_read(struct file *file, char __user *u,
-				    size_t count, loff_t *ppos)
+static ssize_t dfs_global_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dentry *dent = file->f_path.dentry;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
 	int val;
 
 	if (dent == dfs_chk_gen)
@@ -2919,16 +2914,16 @@ static ssize_t dfs_global_file_read(struct file *file, char __user *u,
 	else
 		return -EINVAL;
 
-	return provide_user_output(val, u, count, ppos);
+	return provide_user_output(val, iocb, to);
 }
 
-static ssize_t dfs_global_file_write(struct file *file, const char __user *u,
-				     size_t count, loff_t *ppos)
+static ssize_t dfs_global_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct dentry *dent = file->f_path.dentry;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
+	size_t count = iov_iter_count(from);
 	int val;
 
-	val = interpret_user_input(u, count);
+	val = interpret_user_input(from);
 	if (val < 0)
 		return val;
 
@@ -2951,8 +2946,8 @@ static ssize_t dfs_global_file_write(struct file *file, const char __user *u,
 }
 
 static const struct file_operations dfs_global_fops = {
-	.read = dfs_global_file_read,
-	.write = dfs_global_file_write,
+	.read_iter = dfs_global_file_read,
+	.write_iter = dfs_global_file_write,
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
 };
Signature · 1 line
2.43.0
author maintainer
#293 lore raw

PATCH 287/437 cachefiles: convert to read/write iterators

In reply to Jens Axboe
---
 fs/cachefiles/daemon.c   | 35 ++++++++++++++++-------------------
 fs/cachefiles/internal.h |  4 ++--
 fs/cachefiles/ondemand.c |  5 +++--
 3 files changed, 21 insertions(+), 23 deletions(-)
fs/cachefiles/daemon.c +16 -19
index 6465e2574230..4a6a31a76d35 100644
@@ -23,10 +23,8 @@
 
 static int cachefiles_daemon_open(struct inode *, struct file *);
 static int cachefiles_daemon_release(struct inode *, struct file *);
-static ssize_t cachefiles_daemon_read(struct file *, char __user *, size_t,
-				      loff_t *);
-static ssize_t cachefiles_daemon_write(struct file *, const char __user *,
-				       size_t, loff_t *);
+static ssize_t cachefiles_daemon_read(struct kiocb *, struct iov_iter *);
+static ssize_t cachefiles_daemon_write(struct kiocb *, struct iov_iter *);
 static __poll_t cachefiles_daemon_poll(struct file *,
 					   struct poll_table_struct *);
 static int cachefiles_daemon_frun(struct cachefiles_cache *, char *);
@@ -50,8 +48,8 @@ const struct file_operations cachefiles_daemon_fops = {
 	.owner		= THIS_MODULE,
 	.open		= cachefiles_daemon_open,
 	.release	= cachefiles_daemon_release,
-	.read		= cachefiles_daemon_read,
-	.write		= cachefiles_daemon_write,
+	.read_iter	= cachefiles_daemon_read,
+	.write_iter	= cachefiles_daemon_write,
 	.poll		= cachefiles_daemon_poll,
 	.llseek		= noop_llseek,
 };
@@ -207,8 +205,9 @@ static int cachefiles_daemon_release(struct inode *inode, struct file *file)
 }
 
 static ssize_t cachefiles_do_daemon_read(struct cachefiles_cache *cache,
-					 char __user *_buffer, size_t buflen)
+					 struct iov_iter *to)
 {
+	size_t buflen = iov_iter_count(to);
 	unsigned long long b_released;
 	unsigned f_released;
 	char buffer[256];
@@ -245,7 +244,7 @@ static ssize_t cachefiles_do_daemon_read(struct cachefiles_cache *cache,
 	if (n > buflen)
 		return -EMSGSIZE;
 
-	if (copy_to_user(_buffer, buffer, n) != 0)
+	if (!copy_to_iter_full(buffer, n, to) != 0)
 		return -EFAULT;
 
 	return n;
@@ -254,10 +253,9 @@ static ssize_t cachefiles_do_daemon_read(struct cachefiles_cache *cache,
 /*
  * Read the cache state.
  */
-static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
-				      size_t buflen, loff_t *pos)
+static ssize_t cachefiles_daemon_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct cachefiles_cache *cache = file->private_data;
+	struct cachefiles_cache *cache = iocb->ki_filp->private_data;
 
 	//_enter(",,%zu,", buflen);
 
@@ -265,21 +263,20 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
 		return 0;
 
 	if (cachefiles_in_ondemand_mode(cache))
-		return cachefiles_ondemand_daemon_read(cache, _buffer, buflen);
+		return cachefiles_ondemand_daemon_read(cache, to);
 	else
-		return cachefiles_do_daemon_read(cache, _buffer, buflen);
+		return cachefiles_do_daemon_read(cache, to);
 }
 
 /*
  * Take a command from cachefilesd, parse it and act on it.
  */
-static ssize_t cachefiles_daemon_write(struct file *file,
-				       const char __user *_data,
-				       size_t datalen,
-				       loff_t *pos)
+static ssize_t cachefiles_daemon_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
 	const struct cachefiles_daemon_cmd *cmd;
-	struct cachefiles_cache *cache = file->private_data;
+	struct cachefiles_cache *cache = iocb->ki_filp->private_data;
+	size_t datalen = iov_iter_count(from);
 	ssize_t ret;
 	char *data, *args, *cp;
 
@@ -294,7 +291,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
 		return -EOPNOTSUPP;
 
 	/* drag the command string into the kernel so we can parse it */
-	data = memdup_user_nul(_data, datalen);
+	data = iterdup_nul(from, datalen);
 	if (IS_ERR(data))
 		return PTR_ERR(data);
 
fs/cachefiles/internal.h +2 -2
index d33169f0018b..2b5565d38cb3 100644
@@ -298,7 +298,7 @@ extern bool cachefiles_commit_tmpfile(struct cachefiles_cache *cache,
  */
 #ifdef CONFIG_CACHEFILES_ONDEMAND
 extern ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
-					char __user *_buffer, size_t buflen);
+					struct iov_iter *to);
 
 extern int cachefiles_ondemand_copen(struct cachefiles_cache *cache,
 				     char *args);
@@ -341,7 +341,7 @@ static inline bool cachefiles_ondemand_is_reopening_read(struct cachefiles_req *
 
 #else
 static inline ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
-					char __user *_buffer, size_t buflen)
+					struct iov_iter *to)
 {
 	return -EOPNOTSUPP;
 }
fs/cachefiles/ondemand.c +3 -2
index 4ba42f1fa3b4..e27144ff2050 100644
@@ -295,8 +295,9 @@ static struct cachefiles_req *cachefiles_ondemand_select_req(struct xa_state *xa
 }
 
 ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
-					char __user *_buffer, size_t buflen)
+					struct iov_iter *to)
 {
+	size_t buflen = iov_iter_count(to);
 	struct cachefiles_req *req;
 	struct cachefiles_msg *msg;
 	unsigned long id = 0;
@@ -345,7 +346,7 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
 	msg->msg_id = id;
 	msg->object_id = req->object->ondemand->ondemand_id;
 
-	if (copy_to_user(_buffer, msg, n) != 0) {
+	if (!copy_to_iter_full(msg, n, to) != 0) {
 		ret = -EFAULT;
 		goto err_put_fd;
 	}
Signature · 1 line
2.43.0
author maintainer
#294 lore raw

PATCH 288/437 fs/xfs: convert to read/write iterators

In reply to Jens Axboe
---
 fs/xfs/scrub/stats.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
fs/xfs/scrub/stats.c +12 -15
index 42cafbed94ac..bd546b61334d 100644
@@ -235,12 +235,10 @@ xchk_stats_merge(
 
 static ssize_t
 xchk_scrub_stats_read(
-	struct file		*file,
-	char __user		*ubuf,
-	size_t			count,
-	loff_t			*ppos)
+	struct kiocb		*iocb,
+	struct iov_iter		*to)
 {
-	struct xchk_stats	*cs = file->private_data;
+	struct xchk_stats	*cs = iocb->ki_filp->private_data;
 	char			*buf;
 	size_t			bufsize;
 	ssize_t			avail, ret;
@@ -250,7 +248,7 @@ xchk_scrub_stats_read(
 	 * do not want userspace to receive garbled text from multiple calls.
 	 * If the file position is greater than 0, return a short read.
 	 */
-	if (*ppos > 0)
+	if (iocb->ki_pos > 0)
 		return 0;
 
 	bufsize = xchk_stats_estimate_bufsize(cs);
@@ -265,7 +263,7 @@ xchk_scrub_stats_read(
 		goto out;
 	}
 
-	ret = simple_read_from_buffer(ubuf, count, ppos, buf, avail);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, avail, to);
 out:
 	kvfree(buf);
 	return ret;
@@ -273,21 +271,20 @@ xchk_scrub_stats_read(
 
 static const struct file_operations scrub_stats_fops = {
 	.open			= simple_open,
-	.read			= xchk_scrub_stats_read,
+	.read_iter		= xchk_scrub_stats_read,
 };
 
 static ssize_t
 xchk_clear_scrub_stats_write(
-	struct file		*file,
-	const char __user	*ubuf,
-	size_t			count,
-	loff_t			*ppos)
+	struct kiocb 		*iocb,
+	struct iov_iter		*from)
 {
-	struct xchk_stats	*cs = file->private_data;
+	struct xchk_stats	*cs = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(from);
 	unsigned int		val;
 	int			ret;
 
-	ret = kstrtouint_from_user(ubuf, count, 0, &val);
+	ret = kstrtouint_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -300,7 +297,7 @@ xchk_clear_scrub_stats_write(
 
 static const struct file_operations clear_scrub_stats_fops = {
 	.open			= simple_open,
-	.write			= xchk_clear_scrub_stats_write,
+	.write_iter		= xchk_clear_scrub_stats_write,
 };
 
 /* Initialize the stats object. */
Signature · 1 line
2.43.0
author maintainer
#295 lore raw

PATCH 289/437 fs/bcachefs: convert to read/write iterators

In reply to Jens Axboe
---
 fs/bcachefs/chardev.c          | 10 +++++-----
 fs/bcachefs/debug.c            | 24 ++++++++++++++++--------
 fs/bcachefs/thread_with_file.c | 14 ++++++++------
 3 files changed, 29 insertions(+), 19 deletions(-)
fs/bcachefs/chardev.c +5 -5
index cbfa6459bdbc..9f27c3f4b960 100644
@@ -438,10 +438,9 @@ static int bch2_data_job_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t bch2_data_job_read(struct file *file, char __user *buf,
-				  size_t len, loff_t *ppos)
+static ssize_t bch2_data_job_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct bch_data_ctx *ctx = container_of(file->private_data, struct bch_data_ctx, thr);
+	struct bch_data_ctx *ctx = container_of(iocb->ki_filp->private_data, struct bch_data_ctx, thr);
 	struct bch_fs *c = ctx->c;
 	struct bch_ioctl_data_event e = {
 		.type			= BCH_DATA_EVENT_PROGRESS,
@@ -451,16 +450,17 @@ static ssize_t bch2_data_job_read(struct file *file, char __user *buf,
 		.p.sectors_done		= atomic64_read(&ctx->stats.sectors_seen),
 		.p.sectors_total	= bch2_fs_usage_read_short(c).used,
 	};
+	size_t len = iov_iter_count(to);
 
 	if (len < sizeof(e))
 		return -EINVAL;
 
-	return copy_to_user_errcode(buf, &e, sizeof(e)) ?: sizeof(e);
+	return copy_to_iter(&e, sizeof(e), to);
 }
 
 static const struct file_operations bcachefs_data_ops = {
 	.release	= bch2_data_job_release,
-	.read		= bch2_data_job_read,
+	.read_iter	= bch2_data_job_read,
 	.llseek		= no_llseek,
 };
 
fs/bcachefs/debug.c +16 -8
index 208ce6f0fc43..9b5c7aa57fda 100644
@@ -384,12 +384,13 @@ static ssize_t bch2_read_btree(struct file *file, char __user *buf,
 			}))) ?:
 		i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_read_btree);
 
 static const struct file_operations btree_debug_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_read_btree,
+	.read_iter	= bch2_read_btree_iter,
 };
 
 static ssize_t bch2_read_btree_formats(struct file *file, char __user *buf,
@@ -438,12 +439,13 @@ static ssize_t bch2_read_btree_formats(struct file *file, char __user *buf,
 
 	return ret ?: i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_read_btree_formats);
 
 static const struct file_operations btree_format_debug_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_read_btree_formats,
+	.read_iter	= bch2_read_btree_formats_iter,
 };
 
 static ssize_t bch2_read_bfloat_failed(struct file *file, char __user *buf,
@@ -477,12 +479,13 @@ static ssize_t bch2_read_bfloat_failed(struct file *file, char __user *buf,
 			}))) ?:
 		i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_read_bfloat_failed);
 
 static const struct file_operations bfloat_failed_debug_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_read_bfloat_failed,
+	.read_iter	= bch2_read_bfloat_failed_iter,
 };
 
 static void bch2_cached_btree_node_to_text(struct printbuf *out, struct bch_fs *c,
@@ -584,12 +587,13 @@ static ssize_t bch2_cached_btree_nodes_read(struct file *file, char __user *buf,
 
 	return ret ?: i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_cached_btree_nodes_read);
 
 static const struct file_operations cached_btree_nodes_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_cached_btree_nodes_read,
+	.read_iter	= bch2_cached_btree_nodes_read_iter,
 };
 
 static ssize_t bch2_btree_transactions_read(struct file *file, char __user *buf,
@@ -648,12 +652,13 @@ static ssize_t bch2_btree_transactions_read(struct file *file, char __user *buf,
 
 	return ret ?: i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_btree_transactions_read);
 
 static const struct file_operations btree_transactions_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_btree_transactions_read,
+	.read_iter	= bch2_btree_transactions_read_iter,
 };
 
 static ssize_t bch2_journal_pins_read(struct file *file, char __user *buf,
@@ -685,12 +690,13 @@ static ssize_t bch2_journal_pins_read(struct file *file, char __user *buf,
 
 	return i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_journal_pins_read);
 
 static const struct file_operations journal_pins_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_journal_pins_read,
+	.read_iter	= bch2_journal_pins_read_iter,
 };
 
 static int btree_transaction_stats_open(struct inode *inode, struct file *file)
@@ -792,12 +798,13 @@ static ssize_t btree_transaction_stats_read(struct file *file, char __user *buf,
 
 	return i->ret;
 }
+FOPS_READ_ITER_HELPER(btree_transaction_stats_read);
 
 static const struct file_operations btree_transaction_stats_op = {
 	.owner		= THIS_MODULE,
 	.open		= btree_transaction_stats_open,
 	.release	= btree_transaction_stats_release,
-	.read		= btree_transaction_stats_read,
+	.read_iter	= btree_transaction_stats_read_iter,
 };
 
 static ssize_t bch2_btree_deadlock_read(struct file *file, char __user *buf,
@@ -852,12 +859,13 @@ static ssize_t bch2_btree_deadlock_read(struct file *file, char __user *buf,
 
 	return ret ?: i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_btree_deadlock_read);
 
 static const struct file_operations btree_deadlock_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_btree_deadlock_read,
+	.read_iter	= bch2_btree_deadlock_read_iter,
 };
 
 void bch2_fs_debug_exit(struct bch_fs *c)
fs/bcachefs/thread_with_file.c +8 -6
index 940db15d6a93..fa6f333605da 100644
@@ -27,11 +27,11 @@ int bch2_run_thread_with_file(struct thread_with_file *thr,
 	int ret, fd = -1;
 	unsigned fd_flags = O_CLOEXEC;
 
-	if (fops->read && fops->write)
+	if (fops->read_iter && fops->write_iter)
 		fd_flags |= O_RDWR;
-	else if (fops->read)
+	else if (fops->read_iter)
 		fd_flags |= O_RDONLY;
-	else if (fops->write)
+	else if (fops->write_iter)
 		fd_flags |= O_WRONLY;
 
 	char name[TASK_COMM_LEN];
@@ -145,6 +145,7 @@ static ssize_t thread_with_stdio_read(struct file *file, char __user *ubuf,
 
 	return copied ?: ret;
 }
+FOPS_READ_ITER_HELPER(thread_with_stdio_read);
 
 static int thread_with_stdio_release(struct inode *inode, struct file *file)
 {
@@ -211,6 +212,7 @@ static ssize_t thread_with_stdio_write(struct file *file, const char __user *ubu
 
 	return copied ?: ret;
 }
+FOPS_WRITE_ITER_HELPER(thread_with_stdio_write);
 
 static __poll_t thread_with_stdio_poll(struct file *file, struct poll_table_struct *wait)
 {
@@ -267,8 +269,8 @@ static long thread_with_stdio_ioctl(struct file *file, unsigned int cmd, unsigne
 
 static const struct file_operations thread_with_stdio_fops = {
 	.llseek		= no_llseek,
-	.read		= thread_with_stdio_read,
-	.write		= thread_with_stdio_write,
+	.read_iter	= thread_with_stdio_read_iter,
+	.write_iter	= thread_with_stdio_write_iter,
 	.poll		= thread_with_stdio_poll,
 	.flush		= thread_with_stdio_flush,
 	.release	= thread_with_stdio_release,
@@ -277,7 +279,7 @@ static const struct file_operations thread_with_stdio_fops = {
 
 static const struct file_operations thread_with_stdout_fops = {
 	.llseek		= no_llseek,
-	.read		= thread_with_stdio_read,
+	.read_iter	= thread_with_stdio_read_iter,
 	.poll		= thread_with_stdout_poll,
 	.flush		= thread_with_stdio_flush,
 	.release	= thread_with_stdio_release,
Signature · 1 line
2.43.0
author maintainer
#296 lore raw

PATCH 290/437 fs/ocfs2: convert to read/write iterators

In reply to Jens Axboe
---
 fs/ocfs2/cluster/netdebug.c | 11 ++++++-----
 fs/ocfs2/dlmfs/dlmfs.c      | 38 +++++++++++++++++--------------------
 2 files changed, 23 insertions(+), 26 deletions(-)
fs/ocfs2/cluster/netdebug.c +6 -5
index fde10358c8ee..877955f35aef 100644
@@ -468,17 +468,18 @@ static int o2net_debug_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t o2net_debug_read(struct file *file, char __user *buf,
-				size_t nbytes, loff_t *ppos)
+static ssize_t o2net_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(buf, nbytes, ppos, file->private_data,
-				       i_size_read(file->f_mapping->host));
+	struct file *file = iocb->ki_filp;
+
+	return simple_copy_to_iter(file->private_data, &iocb->ki_pos,
+				       i_size_read(file->f_mapping->host), to);
 }
 
 static const struct file_operations nodes_fops = {
 	.open		= nodes_fop_open,
 	.release	= o2net_debug_release,
-	.read		= o2net_debug_read,
+	.read_iter	= o2net_debug_read,
 	.llseek		= generic_file_llseek,
 };
 
fs/ocfs2/dlmfs/dlmfs.c +17 -21
index 7fc0e920eda7..a13b80cb11f1 100644
@@ -28,6 +28,7 @@
 #include <linux/string.h>
 #include <linux/backing-dev.h>
 #include <linux/poll.h>
+#include <linux/uio.h>
 
 #include <linux/uaccess.h>
 
@@ -219,47 +220,42 @@ static __poll_t dlmfs_file_poll(struct file *file, poll_table *wait)
 	return event;
 }
 
-static ssize_t dlmfs_file_read(struct file *file,
-			       char __user *buf,
-			       size_t count,
-			       loff_t *ppos)
+static ssize_t dlmfs_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char lvb[DLM_LVB_LEN];
 
-	if (!user_dlm_read_lvb(file_inode(file), lvb))
+	if (!user_dlm_read_lvb(file_inode(iocb->ki_filp), lvb))
 		return 0;
 
-	return simple_read_from_buffer(buf, count, ppos, lvb, sizeof(lvb));
+	return simple_copy_to_iter(lvb, &iocb->ki_pos, sizeof(lvb), to);
 }
 
-static ssize_t dlmfs_file_write(struct file *filp,
-				const char __user *buf,
-				size_t count,
-				loff_t *ppos)
+static ssize_t dlmfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char lvb_buf[DLM_LVB_LEN];
-	int bytes_left;
-	struct inode *inode = file_inode(filp);
+	int copied;
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 
 	mlog(0, "inode %lu, count = %zu, *ppos = %llu\n",
-		inode->i_ino, count, *ppos);
+		inode->i_ino, count, iocb->ki_pos);
 
-	if (*ppos >= DLM_LVB_LEN)
+	if (iocb->ki_pos >= DLM_LVB_LEN)
 		return -ENOSPC;
 
 	/* don't write past the lvb */
-	if (count > DLM_LVB_LEN - *ppos)
-		count = DLM_LVB_LEN - *ppos;
+	if (count > DLM_LVB_LEN - iocb->ki_pos)
+		count = DLM_LVB_LEN - iocb->ki_pos;
 
 	if (!count)
 		return 0;
 
-	bytes_left = copy_from_user(lvb_buf, buf, count);
-	count -= bytes_left;
+	copied = copy_from_iter(lvb_buf, count, from);
+	count -= copied;
 	if (count)
 		user_dlm_write_lvb(inode, lvb_buf, count);
 
-	*ppos = *ppos + count;
+	iocb->ki_pos += count;
 	mlog(0, "wrote %zu bytes\n", count);
 	return count;
 }
@@ -525,8 +521,8 @@ static const struct file_operations dlmfs_file_operations = {
 	.open		= dlmfs_file_open,
 	.release	= dlmfs_file_release,
 	.poll		= dlmfs_file_poll,
-	.read		= dlmfs_file_read,
-	.write		= dlmfs_file_write,
+	.read_iter	= dlmfs_file_read,
+	.write_iter	= dlmfs_file_write,
 	.llseek		= default_llseek,
 };
 
Signature · 1 line
2.43.0
author maintainer
#297 lore raw

PATCH 291/437 drivers/net/wireless/marvell: convert to read/write iterators

In reply to Jens Axboe
---
 .../net/wireless/marvell/libertas/debugfs.c   | 242 +++++++-----------
 .../net/wireless/marvell/mwifiex/debugfs.c    | 183 ++++++-------
 2 files changed, 172 insertions(+), 253 deletions(-)
drivers/net/wireless/marvell/libertas/debugfs.c +97 -145
index c604613ab506..0a5a2084b0d6 100644
@@ -22,18 +22,16 @@ static char *szStates[] = {
 static void lbs_debug_init(struct lbs_private *priv);
 #endif
 
-static ssize_t write_file_dummy(struct file *file, const char __user *buf,
-                                size_t count, loff_t *ppos)
+static ssize_t write_file_dummy(struct kiocb *iocb, struct iov_iter *from)
 {
         return -EINVAL;
 }
 
 static const size_t len = PAGE_SIZE;
 
-static ssize_t lbs_dev_info(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_dev_info(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	size_t pos = 0;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
 	char *buf = (char *)addr;
@@ -46,23 +44,22 @@ static ssize_t lbs_dev_info(struct file *file, char __user *userbuf,
 	pos += snprintf(buf+pos, len-pos, "region_code = %02x\n",
 				(u32) priv->regioncode);
 
-	res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+	res = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
 	free_page(addr);
 	return res;
 }
 
-static ssize_t lbs_sleepparams_write(struct file *file,
-				const char __user *user_buf, size_t count,
-				loff_t *ppos)
+static ssize_t lbs_sleepparams_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 	struct sleep_params sp;
 	int p1, p2, p3, p4, p5, p6;
 	char *buf;
 
-	buf = memdup_user_nul(user_buf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -89,10 +86,9 @@ static ssize_t lbs_sleepparams_write(struct file *file,
 	return ret;
 }
 
-static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_sleepparams_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	ssize_t ret;
 	size_t pos = 0;
 	struct sleep_params sp;
@@ -110,23 +106,22 @@ static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf,
 			sp.sp_calcontrol, sp.sp_extsleepclk,
 			sp.sp_reserved);
 
-	ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
 out_unlock:
 	free_page(addr);
 	return ret;
 }
 
-static ssize_t lbs_host_sleep_write(struct file *file,
-				const char __user *user_buf, size_t count,
-				loff_t *ppos)
+static ssize_t lbs_host_sleep_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 	int host_sleep;
 	char *buf;
 
-	buf = memdup_user_nul(user_buf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -159,10 +154,9 @@ static ssize_t lbs_host_sleep_write(struct file *file,
 	return ret;
 }
 
-static ssize_t lbs_host_sleep_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_host_sleep_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	ssize_t ret;
 	size_t pos = 0;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
@@ -172,7 +166,7 @@ static ssize_t lbs_host_sleep_read(struct file *file, char __user *userbuf,
 
 	pos += snprintf(buf, len, "%d\n", priv->is_host_sleep_activated);
 
-	ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
 	free_page(addr);
 	return ret;
@@ -215,12 +209,11 @@ static void *lbs_tlv_find(uint16_t tlv_type, const uint8_t *tlv, uint16_t size)
 
 
 static ssize_t lbs_threshold_read(uint16_t tlv_type, uint16_t event_mask,
-				  struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+				  struct kiocb *iocb, struct iov_iter *to)
 {
 	struct cmd_ds_802_11_subscribe_event *subscribed;
 	struct mrvl_ie_thresholds *got;
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	ssize_t ret = 0;
 	size_t pos = 0;
 	char *buf;
@@ -255,7 +248,7 @@ static ssize_t lbs_threshold_read(uint16_t tlv_type, uint16_t event_mask,
 				!!(events & event_mask));
 	}
 
-	ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
  out_cmd:
 	kfree(subscribed);
@@ -267,19 +260,18 @@ static ssize_t lbs_threshold_read(uint16_t tlv_type, uint16_t event_mask,
 
 
 static ssize_t lbs_threshold_write(uint16_t tlv_type, uint16_t event_mask,
-				   struct file *file,
-				   const char __user *userbuf, size_t count,
-				   loff_t *ppos)
+				   struct kiocb *iocb, struct iov_iter *from)
 {
 	struct cmd_ds_802_11_subscribe_event *events;
 	struct mrvl_ie_thresholds *tlv;
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int value, freq, new_mask;
 	uint16_t curr_mask;
 	char *buf;
 	int ret;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -335,105 +327,81 @@ static ssize_t lbs_threshold_write(uint16_t tlv_type, uint16_t event_mask,
 }
 
 
-static ssize_t lbs_lowrssi_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t lbs_lowrssi_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return lbs_threshold_read(TLV_TYPE_RSSI_LOW, CMD_SUBSCRIBE_RSSI_LOW,
-				  file, userbuf, count, ppos);
+				  iocb, to);
 }
 
-
-static ssize_t lbs_lowrssi_write(struct file *file, const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t lbs_lowrssi_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return lbs_threshold_write(TLV_TYPE_RSSI_LOW, CMD_SUBSCRIBE_RSSI_LOW,
-				   file, userbuf, count, ppos);
+				   iocb, from);
 }
 
-
-static ssize_t lbs_lowsnr_read(struct file *file, char __user *userbuf,
-			       size_t count, loff_t *ppos)
+static ssize_t lbs_lowsnr_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return lbs_threshold_read(TLV_TYPE_SNR_LOW, CMD_SUBSCRIBE_SNR_LOW,
-				  file, userbuf, count, ppos);
+				  iocb, to);
 }
 
-
-static ssize_t lbs_lowsnr_write(struct file *file, const char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t lbs_lowsnr_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return lbs_threshold_write(TLV_TYPE_SNR_LOW, CMD_SUBSCRIBE_SNR_LOW,
-				   file, userbuf, count, ppos);
+				   iocb, from);
 }
 
-
-static ssize_t lbs_failcount_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_failcount_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return lbs_threshold_read(TLV_TYPE_FAILCOUNT, CMD_SUBSCRIBE_FAILCOUNT,
-				  file, userbuf, count, ppos);
+				  iocb, to);
 }
 
-
-static ssize_t lbs_failcount_write(struct file *file, const char __user *userbuf,
-				   size_t count, loff_t *ppos)
+static ssize_t lbs_failcount_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return lbs_threshold_write(TLV_TYPE_FAILCOUNT, CMD_SUBSCRIBE_FAILCOUNT,
-				   file, userbuf, count, ppos);
+				   iocb, from);
 }
 
-
-static ssize_t lbs_highrssi_read(struct file *file, char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t lbs_highrssi_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return lbs_threshold_read(TLV_TYPE_RSSI_HIGH, CMD_SUBSCRIBE_RSSI_HIGH,
-				  file, userbuf, count, ppos);
+				  iocb, to);
 }
 
-
-static ssize_t lbs_highrssi_write(struct file *file, const char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_highrssi_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return lbs_threshold_write(TLV_TYPE_RSSI_HIGH, CMD_SUBSCRIBE_RSSI_HIGH,
-				   file, userbuf, count, ppos);
+				   iocb, from);
 }
 
-
-static ssize_t lbs_highsnr_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t lbs_highsnr_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return lbs_threshold_read(TLV_TYPE_SNR_HIGH, CMD_SUBSCRIBE_SNR_HIGH,
-				  file, userbuf, count, ppos);
+				  iocb, to);
 }
 
-
-static ssize_t lbs_highsnr_write(struct file *file, const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t lbs_highsnr_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return lbs_threshold_write(TLV_TYPE_SNR_HIGH, CMD_SUBSCRIBE_SNR_HIGH,
-				   file, userbuf, count, ppos);
+				   iocb, from);
 }
 
-static ssize_t lbs_bcnmiss_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t lbs_bcnmiss_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return lbs_threshold_read(TLV_TYPE_BCNMISS, CMD_SUBSCRIBE_BCNMISS,
-				  file, userbuf, count, ppos);
+				  iocb, to);
 }
 
-
-static ssize_t lbs_bcnmiss_write(struct file *file, const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t lbs_bcnmiss_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return lbs_threshold_write(TLV_TYPE_BCNMISS, CMD_SUBSCRIBE_BCNMISS,
-				   file, userbuf, count, ppos);
+				   iocb, from);
 }
 
-
-static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_rdmac_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	ssize_t pos = 0;
 	int ret;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
@@ -448,20 +416,19 @@ static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
 	if (!ret) {
 		pos = snprintf(buf, len, "MAC[0x%x] = 0x%08x\n",
 				priv->mac_offset, val);
-		ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+		ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	}
 	free_page(addr);
 	return ret;
 }
 
-static ssize_t lbs_rdmac_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t lbs_rdmac_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buf;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -470,17 +437,15 @@ static ssize_t lbs_rdmac_write(struct file *file,
 	return count;
 }
 
-static ssize_t lbs_wrmac_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t lbs_wrmac_write(struct kiocb *iocb, struct iov_iter *from)
 {
-
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t res;
 	u32 offset, value;
 	char *buf;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -500,10 +465,9 @@ static ssize_t lbs_wrmac_write(struct file *file,
 	return res;
 }
 
-static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_rdbbp_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	ssize_t pos = 0;
 	int ret;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
@@ -518,21 +482,20 @@ static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
 	if (!ret) {
 		pos = snprintf(buf, len, "BBP[0x%x] = 0x%08x\n",
 				priv->bbp_offset, val);
-		ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+		ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	}
 	free_page(addr);
 
 	return ret;
 }
 
-static ssize_t lbs_rdbbp_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t lbs_rdbbp_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buf;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -542,17 +505,15 @@ static ssize_t lbs_rdbbp_write(struct file *file,
 	return count;
 }
 
-static ssize_t lbs_wrbbp_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t lbs_wrbbp_write(struct kiocb *iocb, struct iov_iter *from)
 {
-
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t res;
 	u32 offset, value;
 	char *buf;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -572,10 +533,9 @@ static ssize_t lbs_wrbbp_write(struct file *file,
 	return res;
 }
 
-static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_rdrf_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	ssize_t pos = 0;
 	int ret;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
@@ -590,21 +550,20 @@ static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
 	if (!ret) {
 		pos = snprintf(buf, len, "RF[0x%x] = 0x%08x\n",
 				priv->rf_offset, val);
-		ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+		ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	}
 	free_page(addr);
 
 	return ret;
 }
 
-static ssize_t lbs_rdrf_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t lbs_rdrf_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buf;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -613,17 +572,15 @@ static ssize_t lbs_rdrf_write(struct file *file,
 	return count;
 }
 
-static ssize_t lbs_wrrf_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t lbs_wrrf_write(struct kiocb *iocb, struct iov_iter *from)
 {
-
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t res;
 	u32 offset, value;
 	char *buf;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -646,8 +603,8 @@ static ssize_t lbs_wrrf_write(struct file *file,
 #define FOPS(fread, fwrite) { \
 	.owner = THIS_MODULE, \
 	.open = simple_open, \
-	.read = (fread), \
-	.write = (fwrite), \
+	.read_iter = (fread), \
+	.write_iter = (fwrite), \
 	.llseek = generic_file_llseek, \
 }
 
@@ -796,15 +753,12 @@ static int num_of_items = ARRAY_SIZE(items);
 /**
  * lbs_debugfs_read - proc read function
  *
- * @file:	file to read
- * @userbuf:	pointer to buffer
- * @count:	number of bytes to read
- * @ppos:	read data starting position
+ * @iocb:	metadata for IO
+ * @to:		iov_iter to copy to
  *
  * returns:	amount of data read or negative error code
  */
-static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
-			size_t count, loff_t *ppos)
+static ssize_t lbs_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int val = 0;
 	size_t pos = 0;
@@ -819,7 +773,7 @@ static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
 
 	p = buf;
 
-	d = file->private_data;
+	d = iocb->ki_filp->private_data;
 
 	for (i = 0; i < num_of_items; i++) {
 		if (d[i].size == 1)
@@ -834,7 +788,7 @@ static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
 		pos += sprintf(p + pos, "%s=%d\n", d[i].name, val);
 	}
 
-	res = simple_read_from_buffer(userbuf, count, ppos, p, pos);
+	res = simple_copy_to_iter(p, &iocb->ki_pos, pos, to);
 
 	free_page(addr);
 	return res;
@@ -843,28 +797,26 @@ static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
 /**
  * lbs_debugfs_write - proc write function
  *
- * @f:		file pointer
- * @buf:	pointer to data buffer
- * @cnt:	data number to write
- * @ppos:	file position
+ * @iocb:	metadata for IO
+ * @from:	iov_iter to cooy from
  *
  * returns:	amount of data written
  */
-static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
-			    size_t cnt, loff_t *ppos)
+static ssize_t lbs_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t cnt = iov_iter_count(from);
 	int r, i;
 	char *pdata;
 	char *p;
 	char *p0;
 	char *p1;
 	char *p2;
-	struct debug_data *d = f->private_data;
+	struct debug_data *d = iocb->ki_filp->private_data;
 
 	if (cnt == 0)
 		return 0;
 
-	pdata = memdup_user_nul(buf, cnt);
+	pdata = iterdup_nul(from, cnt);
 	if (IS_ERR(pdata))
 		return PTR_ERR(pdata);
 
@@ -902,8 +854,8 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
 static const struct file_operations lbs_debug_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = lbs_debugfs_write,
-	.read = lbs_debugfs_read,
+	.write_iter = lbs_debugfs_write,
+	.read_iter = lbs_debugfs_read,
 	.llseek = default_llseek,
 };
 
drivers/net/wireless/marvell/mwifiex/debugfs.c +75 -108

444 lines not on this page · raw message

Signature · 1 line
2.43.0
author maintainer
#298 lore raw

PATCH 292/437 fs/proc: convert to read/write iterators

In reply to Jens Axboe
---
 fs/proc/base.c                 | 316 ++++++++++++++++-----------------
 fs/proc/fd.c                   |   2 +-
 fs/proc/inode.c                |  18 +-
 fs/proc/task_mmu.c             |  37 ++--
 fs/proc/task_nommu.c           |   2 +-
 include/linux/user_namespace.h |  10 +-
 kernel/user_namespace.c        |  39 ++--
 7 files changed, 214 insertions(+), 210 deletions(-)
fs/proc/base.c +149 -167
index 4c6a7aafe66a..d810ede0e399 100644
@@ -373,9 +373,10 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
 		*pos += ret;
 	return ret;
 }
+FOPS_READ_ITER_HELPER(proc_pid_cmdline_read);
 
 static const struct file_operations proc_pid_cmdline_ops = {
-	.read	= proc_pid_cmdline_read,
+	.read_iter = proc_pid_cmdline_read_iter,
 	.llseek	= generic_file_llseek,
 };
 
@@ -525,23 +526,22 @@ static int lstats_open(struct inode *inode, struct file *file)
 	return single_open(file, lstats_show_proc, inode);
 }
 
-static ssize_t lstats_write(struct file *file, const char __user *buf,
-			    size_t count, loff_t *offs)
+static ssize_t lstats_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct task_struct *task = get_proc_task(file_inode(file));
+	struct task_struct *task = get_proc_task(file_inode(iocb->ki_filp));
 
 	if (!task)
 		return -ESRCH;
 	clear_tsk_latency_tracing(task);
 	put_task_struct(task);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations proc_lstats_operations = {
 	.open		= lstats_open,
-	.read		= seq_read,
-	.write		= lstats_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= lstats_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -788,7 +788,7 @@ static int proc_single_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations proc_single_file_operations = {
 	.open		= proc_single_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -835,11 +835,11 @@ static int mem_open(struct inode *inode, struct file *file)
 	return ret;
 }
 
-static ssize_t mem_rw(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos, int write)
+static ssize_t mem_rw(struct kiocb *iocb, struct iov_iter *iov, int write)
 {
-	struct mm_struct *mm = file->private_data;
-	unsigned long addr = *ppos;
+	struct mm_struct *mm = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(iov);
+	unsigned long addr = iocb->ki_pos;
 	ssize_t copied;
 	char *page;
 	unsigned int flags;
@@ -860,7 +860,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
 	while (count > 0) {
 		size_t this_len = min_t(size_t, count, PAGE_SIZE);
 
-		if (write && copy_from_user(page, buf, this_len)) {
+		if (write && !copy_from_iter_full(page, this_len, iov)) {
 			copied = -EFAULT;
 			break;
 		}
@@ -872,17 +872,16 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
 			break;
 		}
 
-		if (!write && copy_to_user(buf, page, this_len)) {
+		if (!write && !copy_to_iter_full(page, this_len, iov)) {
 			copied = -EFAULT;
 			break;
 		}
 
-		buf += this_len;
 		addr += this_len;
 		copied += this_len;
 		count -= this_len;
 	}
-	*ppos = addr;
+	iocb->ki_pos = addr;
 
 	mmput(mm);
 free:
@@ -890,16 +889,14 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
 	return copied;
 }
 
-static ssize_t mem_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t mem_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return mem_rw(file, buf, count, ppos, 0);
+	return mem_rw(iocb, to, 0);
 }
 
-static ssize_t mem_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t mem_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	return mem_rw(file, (char __user*)buf, count, ppos, 1);
+	return mem_rw(iocb, from, 1);
 }
 
 loff_t mem_lseek(struct file *file, loff_t offset, int orig)
@@ -928,8 +925,8 @@ static int mem_release(struct inode *inode, struct file *file)
 
 static const struct file_operations proc_mem_operations = {
 	.llseek		= mem_lseek,
-	.read		= mem_read,
-	.write		= mem_write,
+	.read_iter	= mem_read,
+	.write_iter	= mem_write,
 	.open		= mem_open,
 	.release	= mem_release,
 };
@@ -939,13 +936,13 @@ static int environ_open(struct inode *inode, struct file *file)
 	return __mem_open(inode, file, PTRACE_MODE_READ);
 }
 
-static ssize_t environ_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t environ_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	char *page;
-	unsigned long src = *ppos;
+	unsigned long src = iocb->ki_pos;
 	int ret = 0;
-	struct mm_struct *mm = file->private_data;
+	struct mm_struct *mm = iocb->ki_filp->private_data;
 	unsigned long env_start, env_end;
 
 	/* Ensure the process spawned far enough to have an environment. */
@@ -984,17 +981,16 @@ static ssize_t environ_read(struct file *file, char __user *buf,
 			break;
 		}
 
-		if (copy_to_user(buf, page, retval)) {
+		if (!copy_to_iter_full(page, retval, to)) {
 			ret = -EFAULT;
 			break;
 		}
 
 		ret += retval;
 		src += retval;
-		buf += retval;
 		count -= retval;
 	}
-	*ppos = src;
+	iocb->ki_pos = src;
 	mmput(mm);
 
 free:
@@ -1004,7 +1000,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
 
 static const struct file_operations proc_environ_operations = {
 	.open		= environ_open,
-	.read		= environ_read,
+	.read_iter	= environ_read,
 	.llseek		= generic_file_llseek,
 	.release	= mem_release,
 };
@@ -1014,10 +1010,9 @@ static int auxv_open(struct inode *inode, struct file *file)
 	return __mem_open(inode, file, PTRACE_MODE_READ_FSCREDS);
 }
 
-static ssize_t auxv_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t auxv_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mm_struct *mm = file->private_data;
+	struct mm_struct *mm = iocb->ki_filp->private_data;
 	unsigned int nwords = 0;
 
 	if (!mm)
@@ -1025,21 +1020,20 @@ static ssize_t auxv_read(struct file *file, char __user *buf,
 	do {
 		nwords += 2;
 	} while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
-	return simple_read_from_buffer(buf, count, ppos, mm->saved_auxv,
-				       nwords * sizeof(mm->saved_auxv[0]));
+	return simple_copy_to_iter(mm->saved_auxv, &iocb->ki_pos,
+				   nwords * sizeof(mm->saved_auxv[0]), to);
 }
 
 static const struct file_operations proc_auxv_operations = {
 	.open		= auxv_open,
-	.read		= auxv_read,
+	.read_iter	= auxv_read,
 	.llseek		= generic_file_llseek,
 	.release	= mem_release,
 };
 
-static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
-			    loff_t *ppos)
+static ssize_t oom_adj_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct task_struct *task = get_proc_task(file_inode(file));
+	struct task_struct *task = get_proc_task(file_inode(iocb->ki_filp));
 	char buffer[PROC_NUMBUF];
 	int oom_adj = OOM_ADJUST_MIN;
 	size_t len;
@@ -1055,7 +1049,7 @@ static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
 	if (oom_adj > OOM_ADJUST_MAX)
 		oom_adj = OOM_ADJUST_MAX;
 	len = snprintf(buffer, sizeof(buffer), "%d\n", oom_adj);
-	return simple_read_from_buffer(buf, count, ppos, buffer, len);
+	return simple_copy_to_iter(buffer, &iocb->ki_pos, len, to);
 }
 
 static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
@@ -1151,16 +1145,16 @@ static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
  *
  * oom_adj cannot be removed since existing userspace binaries use it.
  */
-static ssize_t oom_adj_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *ppos)
+static ssize_t oom_adj_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char buffer[PROC_NUMBUF] = {};
 	int oom_adj;
 	int err;
 
 	if (count > sizeof(buffer) - 1)
 		count = sizeof(buffer) - 1;
-	if (copy_from_user(buffer, buf, count)) {
+	if (!copy_from_iter_full(buffer, count, from)) {
 		err = -EFAULT;
 		goto out;
 	}
@@ -1183,21 +1177,20 @@ static ssize_t oom_adj_write(struct file *file, const char __user *buf,
 	else
 		oom_adj = (oom_adj * OOM_SCORE_ADJ_MAX) / -OOM_DISABLE;
 
-	err = __set_oom_adj(file, oom_adj, true);
+	err = __set_oom_adj(iocb->ki_filp, oom_adj, true);
 out:
 	return err < 0 ? err : count;
 }
 
 static const struct file_operations proc_oom_adj_operations = {
-	.read		= oom_adj_read,
-	.write		= oom_adj_write,
+	.read_iter	= oom_adj_read,
+	.write_iter	= oom_adj_write,
 	.llseek		= generic_file_llseek,
 };
 
-static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t oom_score_adj_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct task_struct *task = get_proc_task(file_inode(file));
+	struct task_struct *task = get_proc_task(file_inode(iocb->ki_filp));
 	char buffer[PROC_NUMBUF];
 	short oom_score_adj = OOM_SCORE_ADJ_MIN;
 	size_t len;
@@ -1207,19 +1200,19 @@ static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
 	oom_score_adj = task->signal->oom_score_adj;
 	put_task_struct(task);
 	len = snprintf(buffer, sizeof(buffer), "%hd\n", oom_score_adj);
-	return simple_read_from_buffer(buf, count, ppos, buffer, len);
+	return simple_copy_to_iter(buffer, &iocb->ki_pos, len, to);
 }
 
-static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t oom_score_adj_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char buffer[PROC_NUMBUF] = {};
 	int oom_score_adj;
 	int err;
 
 	if (count > sizeof(buffer) - 1)
 		count = sizeof(buffer) - 1;
-	if (copy_from_user(buffer, buf, count)) {
+	if (!copy_from_iter_full(buffer, count, from)) {
 		err = -EFAULT;
 		goto out;
 	}
@@ -1233,23 +1226,22 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
 		goto out;
 	}
 
-	err = __set_oom_adj(file, oom_score_adj, false);
+	err = __set_oom_adj(iocb->ki_filp, oom_score_adj, false);
 out:
 	return err < 0 ? err : count;
 }
 
 static const struct file_operations proc_oom_score_adj_operations = {
-	.read		= oom_score_adj_read,
-	.write		= oom_score_adj_write,
+	.read_iter	= oom_score_adj_read,
+	.write_iter	= oom_score_adj_write,
 	.llseek		= default_llseek,
 };
 
 #ifdef CONFIG_AUDIT
 #define TMPBUFLEN 11
-static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
-				  size_t count, loff_t *ppos)
+static ssize_t proc_loginuid_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode * inode = file_inode(file);
+	struct inode * inode = file_inode(iocb->ki_filp);
 	struct task_struct *task = get_proc_task(inode);
 	ssize_t length;
 	char tmpbuf[TMPBUFLEN];
@@ -1257,16 +1249,16 @@ static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
 	if (!task)
 		return -ESRCH;
 	length = scnprintf(tmpbuf, TMPBUFLEN, "%u",
-			   from_kuid(file->f_cred->user_ns,
+			   from_kuid(iocb->ki_filp->f_cred->user_ns,
 				     audit_get_loginuid(task)));
 	put_task_struct(task);
-	return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+	return simple_copy_to_iter(tmpbuf, &iocb->ki_pos, length, to);
 }
 
-static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
-				   size_t count, loff_t *ppos)
+static ssize_t proc_loginuid_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode * inode = file_inode(file);
+	struct inode * inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	uid_t loginuid;
 	kuid_t kloginuid;
 	int rv;
@@ -1282,12 +1274,12 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
 	}
 	rcu_read_unlock();
 
-	if (*ppos != 0) {
+	if (iocb->ki_pos != 0) {
 		/* No partial writes. */
 		return -EINVAL;
 	}
 
-	rv = kstrtou32_from_user(buf, count, 10, &loginuid);
+	rv = kstrtou32_from_iter(from, count, 10, &loginuid);
 	if (rv < 0)
 		return rv;
 
@@ -1295,7 +1287,7 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
 	if (loginuid == AUDIT_UID_UNSET) {
 		kloginuid = INVALID_UID;
 	} else {
-		kloginuid = make_kuid(file->f_cred->user_ns, loginuid);
+		kloginuid = make_kuid(iocb->ki_filp->f_cred->user_ns, loginuid);
 		if (!uid_valid(kloginuid))
 			return -EINVAL;
 	}
@@ -1307,15 +1299,14 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
 }
 
 static const struct file_operations proc_loginuid_operations = {
-	.read		= proc_loginuid_read,
-	.write		= proc_loginuid_write,
+	.read_iter	= proc_loginuid_read,
+	.write_iter	= proc_loginuid_write,
 	.llseek		= generic_file_llseek,
 };
 
-static ssize_t proc_sessionid_read(struct file * file, char __user * buf,
-				  size_t count, loff_t *ppos)
+static ssize_t proc_sessionid_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode * inode = file_inode(file);
+	struct inode * inode = file_inode(iocb->ki_filp);
 	struct task_struct *task = get_proc_task(inode);
 	ssize_t length;
 	char tmpbuf[TMPBUFLEN];
@@ -1325,20 +1316,19 @@ static ssize_t proc_sessionid_read(struct file * file, char __user * buf,
 	length = scnprintf(tmpbuf, TMPBUFLEN, "%u",
 				audit_get_sessionid(task));
 	put_task_struct(task);
-	return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+	return simple_copy_to_iter(tmpbuf, &iocb->ki_pos, length, to);
 }
 
 static const struct file_operations proc_sessionid_operations = {
-	.read		= proc_sessionid_read,
+	.read_iter	= proc_sessionid_read,
 	.llseek		= generic_file_llseek,
 };
 #endif
 
 #ifdef CONFIG_FAULT_INJECTION
-static ssize_t proc_fault_inject_read(struct file * file, char __user * buf,
-				      size_t count, loff_t *ppos)
+static ssize_t proc_fault_inject_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct task_struct *task = get_proc_task(file_inode(file));
+	struct task_struct *task = get_proc_task(file_inode(iocb->ki_filp));
 	char buffer[PROC_NUMBUF];
 	size_t len;
 	int make_it_fail;
@@ -1349,13 +1339,12 @@ static ssize_t proc_fault_inject_read(struct file * file, char __user * buf,
 	put_task_struct(task);
 
 	len = snprintf(buffer, sizeof(buffer), "%i\n", make_it_fail);
-
-	return simple_read_from_buffer(buf, count, ppos, buffer, len);
+	return simple_copy_to_iter(buffer, &iocb->ki_pos, len, to);
 }
 
-static ssize_t proc_fault_inject_write(struct file * file,
-			const char __user * buf, size_t count, loff_t *ppos)
+static ssize_t proc_fault_inject_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct task_struct *task;
 	char buffer[PROC_NUMBUF] = {};
 	int make_it_fail;
@@ -1366,7 +1355,7 @@ static ssize_t proc_fault_inject_write(struct file * file,
 
 	if (count > sizeof(buffer) - 1)
 		count = sizeof(buffer) - 1;
-	if (copy_from_user(buffer, buf, count))
+	if (!copy_from_iter_full(buffer, count, from))
 		return -EFAULT;
 	rv = kstrtoint(strstrip(buffer), 0, &make_it_fail);
 	if (rv < 0)
@@ -1374,7 +1363,7 @@ static ssize_t proc_fault_inject_write(struct file * file,
 	if (make_it_fail < 0 || make_it_fail > 1)
 		return -EINVAL;
 
-	task = get_proc_task(file_inode(file));
+	task = get_proc_task(file_inode(iocb->ki_filp));
 	if (!task)
 		return -ESRCH;
 	task->make_it_fail = make_it_fail;
@@ -1384,23 +1373,23 @@ static ssize_t proc_fault_inject_write(struct file * file,
 }
 
 static const struct file_operations proc_fault_inject_operations = {
-	.read		= proc_fault_inject_read,
-	.write		= proc_fault_inject_write,
+	.read_iter	= proc_fault_inject_read,
+	.write_iter	= proc_fault_inject_write,
 	.llseek		= generic_file_llseek,
 };
 
-static ssize_t proc_fail_nth_write(struct file *file, const char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t proc_fail_nth_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct task_struct *task;
 	int err;
 	unsigned int n;
 
-	err = kstrtouint_from_user(buf, count, 0, &n);
+	err = kstrtouint_from_iter(from, count, 0, &n);
 	if (err)
 		return err;
 
-	task = get_proc_task(file_inode(file));
+	task = get_proc_task(file_inode(iocb->ki_filp));
 	if (!task)
 		return -ESRCH;
 	task->fail_nth = n;
@@ -1409,24 +1398,23 @@ static ssize_t proc_fail_nth_write(struct file *file, const char __user *buf,
 	return count;
 }
 
-static ssize_t proc_fail_nth_read(struct file *file, char __user *buf,
-				  size_t count, loff_t *ppos)
+static ssize_t proc_fail_nth_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct task_struct *task;
 	char numbuf[PROC_NUMBUF];
 	ssize_t len;
 
-	task = get_proc_task(file_inode(file));
+	task = get_proc_task(file_inode(iocb->ki_filp));
 	if (!task)
 		return -ESRCH;
 	len = snprintf(numbuf, sizeof(numbuf), "%u\n", task->fail_nth);
 	put_task_struct(task);
-	return simple_read_from_buffer(buf, count, ppos, numbuf, len);
+	return simple_copy_to_iter(numbuf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations proc_fail_nth_operations = {
-	.read		= proc_fail_nth_read,
-	.write		= proc_fail_nth_write,
+	.read_iter	= proc_fail_nth_read,
+	.write_iter	= proc_fail_nth_write,
 };
 #endif
 
@@ -1451,11 +1439,9 @@ static int sched_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t
-sched_write(struct file *file, const char __user *buf,
-	    size_t count, loff_t *offset)
+static ssize_t sched_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
 	struct task_struct *p;
 
 	p = get_proc_task(inode);
@@ -1465,7 +1451,7 @@ sched_write(struct file *file, const char __user *buf,
 
 	put_task_struct(p);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static int sched_open(struct inode *inode, struct file *filp)
@@ -1475,8 +1461,8 @@ static int sched_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations proc_pid_sched_operations = {
 	.open		= sched_open,
-	.read		= seq_read,
-	.write		= sched_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= sched_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -1502,11 +1488,10 @@ static int sched_autogroup_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t
-sched_autogroup_write(struct file *file, const char __user *buf,
-	    size_t count, loff_t *offset)
+static ssize_t sched_autogroup_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct task_struct *p;
 	char buffer[PROC_NUMBUF] = {};
 	int nice;
@@ -1514,7 +1499,7 @@ sched_autogroup_write(struct file *file, const char __user *buf,
 
 	if (count > sizeof(buffer) - 1)
 		count = sizeof(buffer) - 1;
-	if (copy_from_user(buffer, buf, count))
+	if (!copy_from_iter_full(buffer, count, from))
 		return -EFAULT;
 
 	err = kstrtoint(strstrip(buffer), 0, &nice);
@@ -1549,8 +1534,8 @@ static int sched_autogroup_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations proc_pid_sched_autogroup_operations = {
 	.open		= sched_autogroup_open,
-	.read		= seq_read,
-	.write		= sched_autogroup_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= sched_autogroup_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -1572,21 +1557,21 @@ static int timens_offsets_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t timens_offsets_write(struct file *file, const char __user *buf,
-				    size_t count, loff_t *ppos)
+static ssize_t timens_offsets_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct proc_timens_offset offsets[2];
 	char *kbuf = NULL, *pos, *next_line;
 	struct task_struct *p;
 	int ret, noffsets;
 
 	/* Only allow < page size writes at the beginning of the file */
-	if ((*ppos != 0) || (count >= PAGE_SIZE))
+	if ((iocb->ki_pos != 0) || (count >= PAGE_SIZE))
 		return -EINVAL;
 
 	/* Slurp in the user data */
-	kbuf = memdup_user_nul(buf, count);
+	kbuf = iterdup_nul(from, count);
 	if (IS_ERR(kbuf))
 		return PTR_ERR(kbuf);
 
@@ -1634,7 +1619,7 @@ static ssize_t timens_offsets_write(struct file *file, const char __user *buf,
 	p = get_proc_task(inode);
 	if (!p)
 		goto out;
-	ret = proc_timens_set_offset(file, p, offsets, noffsets);
+	ret = proc_timens_set_offset(iocb->ki_filp, p, offsets, noffsets);
 	put_task_struct(p);
 	if (ret)
 		goto out;
@@ -1652,22 +1637,22 @@ static int timens_offsets_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations proc_timens_offsets_operations = {
 	.open		= timens_offsets_open,
-	.read		= seq_read,
-	.write		= timens_offsets_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= timens_offsets_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
 #endif /* CONFIG_TIME_NS */
 
-static ssize_t comm_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *offset)
+static ssize_t comm_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct task_struct *p;
 	char buffer[TASK_COMM_LEN] = {};
 	const size_t maxlen = sizeof(buffer) - 1;
 
-	if (copy_from_user(buffer, buf, count > maxlen ? maxlen : count))
+	if (!copy_from_iter_full(buffer, count > maxlen ? maxlen : count, from))
 		return -EFAULT;
 
 	p = get_proc_task(inode);
@@ -1710,8 +1695,8 @@ static int comm_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations proc_pid_set_comm_operations = {
 	.open		= comm_open,
-	.read		= seq_read,
-	.write		= comm_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= comm_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -2530,21 +2515,21 @@ static int proc_timers_open(struct inode *inode, struct file *file)
 
 static const struct file_operations proc_timers_operations = {
 	.open		= proc_timers_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release_private,
 };
 #endif
 
-static ssize_t timerslack_ns_write(struct file *file, const char __user *buf,
-					size_t count, loff_t *offset)
+static ssize_t timerslack_ns_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct task_struct *p;
 	u64 slack_ns;
 	int err;
 
-	err = kstrtoull_from_user(buf, count, 10, &slack_ns);
+	err = kstrtoull_from_iter(from, count, 10, &slack_ns);
 	if (err < 0)
 		return err;
 
@@ -2622,8 +2607,8 @@ static int timerslack_ns_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations proc_pid_set_timerslack_ns_operations = {
 	.open		= timerslack_ns_open,
-	.read		= seq_read,
-	.write		= timerslack_ns_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= timerslack_ns_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -2714,10 +2699,9 @@ static int proc_pid_attr_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t proc_pid_attr_read(struct file * file, char __user * buf,
-				  size_t count, loff_t *ppos)
+static ssize_t proc_pid_attr_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode * inode = file_inode(file);
+	struct inode * inode = file_inode(iocb->ki_filp);
 	char *p = NULL;
 	ssize_t length;
 	struct task_struct *task = get_proc_task(inode);
@@ -2726,25 +2710,25 @@ static ssize_t proc_pid_attr_read(struct file * file, char __user * buf,
 		return -ESRCH;
 
 	length = security_getprocattr(task, PROC_I(inode)->op.lsmid,
-				      file->f_path.dentry->d_name.name,
+				      iocb->ki_filp->f_path.dentry->d_name.name,
 				      &p);
 	put_task_struct(task);
 	if (length > 0)
-		length = simple_read_from_buffer(buf, count, ppos, p, length);
+		length = simple_copy_to_iter(p, &iocb->ki_pos, length, to);
 	kfree(p);
 	return length;
 }
 
-static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
-				   size_t count, loff_t *ppos)
+static ssize_t proc_pid_attr_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode * inode = file_inode(file);
+	struct inode * inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct task_struct *task;
 	void *page;
 	int rv;
 
 	/* A task may only write when it was the opener. */
-	if (file->private_data != current->mm)
+	if (iocb->ki_filp->private_data != current->mm)
 		return -EPERM;
 
 	rcu_read_lock();
@@ -2769,10 +2753,10 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
 		count = PAGE_SIZE;
 
 	/* No partial writes. */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return -EINVAL;
 
-	page = memdup_user(buf, count);
+	page = iterdup(from, count);
 	if (IS_ERR(page)) {
 		rv = PTR_ERR(page);
 		goto out;
@@ -2784,8 +2768,8 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
 		goto out_free;
 
 	rv = security_setprocattr(PROC_I(inode)->op.lsmid,
-				  file->f_path.dentry->d_name.name, page,
-				  count);
+				  iocb->ki_filp->f_path.dentry->d_name.name,
+				  page, count);
 	mutex_unlock(&current->signal->cred_guard_mutex);
 out_free:
 	kfree(page);
@@ -2795,8 +2779,8 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
 
 static const struct file_operations proc_pid_attr_operations = {
 	.open		= proc_pid_attr_open,
-	.read		= proc_pid_attr_read,
-	.write		= proc_pid_attr_write,
+	.read_iter	= proc_pid_attr_read,
+	.write_iter	= proc_pid_attr_write,
 	.llseek		= generic_file_llseek,
 	.release	= mem_release,
 };
@@ -2892,10 +2876,9 @@ static const struct inode_operations proc_attr_dir_inode_operations = {
 #endif
 
 #ifdef CONFIG_ELF_CORE
-static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf,
-					 size_t count, loff_t *ppos)
+static ssize_t proc_coredump_filter_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct task_struct *task = get_proc_task(file_inode(file));
+	struct task_struct *task = get_proc_task(file_inode(iocb->ki_filp));
 	struct mm_struct *mm;
 	char buffer[PROC_NUMBUF];
 	size_t len;
@@ -2911,7 +2894,7 @@ static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf,
 			       ((mm->flags & MMF_DUMP_FILTER_MASK) >>
 				MMF_DUMP_FILTER_SHIFT));
 		mmput(mm);
-		ret = simple_read_from_buffer(buf, count, ppos, buffer, len);
+		ret = simple_copy_to_iter(buffer, &iocb->ki_pos, len, to);
 	}
 
 	put_task_struct(task);
@@ -2919,11 +2902,10 @@ static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf,
 	return ret;
 }
 
-static ssize_t proc_coredump_filter_write(struct file *file,
-					  const char __user *buf,
-					  size_t count,
-					  loff_t *ppos)
+static ssize_t proc_coredump_filter_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct task_struct *task;
 	struct mm_struct *mm;
 	unsigned int val;
@@ -2931,12 +2913,12 @@ static ssize_t proc_coredump_filter_write(struct file *file,
 	int i;
 	unsigned long mask;
 
-	ret = kstrtouint_from_user(buf, count, 0, &val);
+	ret = kstrtouint_from_iter(from, count, 0, &val);
 	if (ret < 0)
 		return ret;
 
 	ret = -ESRCH;
-	task = get_proc_task(file_inode(file));
+	task = get_proc_task(file_inode(iocb->ki_filp));
 	if (!task)
 		goto out_no_task;
 
@@ -2962,8 +2944,8 @@ static ssize_t proc_coredump_filter_write(struct file *file,
 }
 
 static const struct file_operations proc_coredump_filter_operations = {
-	.read		= proc_coredump_filter_read,
-	.write		= proc_coredump_filter_write,
+	.read_iter	= proc_coredump_filter_read,
+	.write_iter	= proc_coredump_filter_write,
 	.llseek		= generic_file_llseek,
 };
 #endif
@@ -3098,24 +3080,24 @@ static int proc_projid_map_open(struct inode *inode, struct file *file)
 
 static const struct file_operations proc_uid_map_operations = {
 	.open		= proc_uid_map_open,
-	.write		= proc_uid_map_write,
-	.read		= seq_read,
+	.write_iter	= proc_uid_map_write_iter,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_id_map_release,
 };
 
 static const struct file_operations proc_gid_map_operations = {
 	.open		= proc_gid_map_open,
-	.write		= proc_gid_map_write,
-	.read		= seq_read,
+	.write_iter	= proc_gid_map_write_iter,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_id_map_release,
 };
 
 static const struct file_operations proc_projid_map_operations = {
 	.open		= proc_projid_map_open,
-	.write		= proc_projid_map_write,
-	.read		= seq_read,
+	.write_iter	= proc_projid_map_write_iter,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_id_map_release,
 };
@@ -3165,8 +3147,8 @@ static int proc_setgroups_release(struct inode *inode, struct file *file)
 
 static const struct file_operations proc_setgroups_operations = {
 	.open		= proc_setgroups_open,
-	.write		= proc_setgroups_write,
-	.read		= seq_read,
+	.write_iter	= proc_setgroups_write,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_setgroups_release,
 };
fs/proc/fd.c +1 -1
index 63a3aebdf223..ee3f608559e5 100644
@@ -103,7 +103,7 @@ static int seq_fdinfo_open(struct inode *inode, struct file *file)
 
 static const struct file_operations proc_fdinfo_file_operations = {
 	.open		= seq_fdinfo_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
fs/proc/inode.c +12 -6
index dcd513dccf55..092164889e74 100644
@@ -325,6 +325,11 @@ static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count,
 	return rv;
 }
 
+static ssize_t __proc_reg_read_iter(struct kiocb *iocb, struct iov_iter *to)
+{
+	return vfs_read_iter(iocb, to, proc_reg_read);
+}
+
 static ssize_t pde_write(struct proc_dir_entry *pde, struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
 	typeof_member(struct proc_ops, proc_write) write;
@@ -348,6 +353,7 @@ static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t
 	}
 	return rv;
 }
+FOPS_WRITE_ITER_HELPER(proc_reg_write);
 
 static __poll_t pde_poll(struct proc_dir_entry *pde, struct file *file, struct poll_table_struct *pts)
 {
@@ -571,8 +577,8 @@ static int proc_reg_release(struct inode *inode, struct file *file)
 
 static const struct file_operations proc_reg_file_ops = {
 	.llseek		= proc_reg_llseek,
-	.read		= proc_reg_read,
-	.write		= proc_reg_write,
+	.read_iter	= __proc_reg_read_iter,
+	.write_iter	= proc_reg_write_iter,
 	.poll		= proc_reg_poll,
 	.unlocked_ioctl	= proc_reg_unlocked_ioctl,
 	.mmap		= proc_reg_mmap,
@@ -584,7 +590,7 @@ static const struct file_operations proc_reg_file_ops = {
 static const struct file_operations proc_iter_file_ops = {
 	.llseek		= proc_reg_llseek,
 	.read_iter	= proc_reg_read_iter,
-	.write		= proc_reg_write,
+	.write_iter	= proc_reg_write_iter,
 	.splice_read	= copy_splice_read,
 	.poll		= proc_reg_poll,
 	.unlocked_ioctl	= proc_reg_unlocked_ioctl,
@@ -597,8 +603,8 @@ static const struct file_operations proc_iter_file_ops = {
 #ifdef CONFIG_COMPAT
 static const struct file_operations proc_reg_file_ops_compat = {
 	.llseek		= proc_reg_llseek,
-	.read		= proc_reg_read,
-	.write		= proc_reg_write,
+	.read_iter	= proc_reg_read_iter,
+	.write_iter	= proc_reg_write_iter,
 	.poll		= proc_reg_poll,
 	.unlocked_ioctl	= proc_reg_unlocked_ioctl,
 	.compat_ioctl	= proc_reg_compat_ioctl,
@@ -612,7 +618,7 @@ static const struct file_operations proc_iter_file_ops_compat = {
 	.llseek		= proc_reg_llseek,
 	.read_iter	= proc_reg_read_iter,
 	.splice_read	= copy_splice_read,
-	.write		= proc_reg_write,
+	.write_iter	= proc_reg_write_iter,
 	.poll		= proc_reg_poll,
 	.unlocked_ioctl	= proc_reg_unlocked_ioctl,
 	.compat_ioctl	= proc_reg_compat_ioctl,
fs/proc/task_mmu.c +18 -19
index 23fbab954c20..ff86fe94fcba 100644
@@ -360,7 +360,7 @@ static int pid_maps_open(struct inode *inode, struct file *file)
 
 const struct file_operations proc_pid_maps_operations = {
 	.open		= pid_maps_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_map_release,
 };
@@ -1049,14 +1049,14 @@ static int smaps_rollup_release(struct inode *inode, struct file *file)
 
 const struct file_operations proc_pid_smaps_operations = {
 	.open		= pid_smaps_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_map_release,
 };
 
 const struct file_operations proc_pid_smaps_rollup_operations = {
 	.open		= smaps_rollup_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= smaps_rollup_release,
 };
@@ -1242,9 +1242,9 @@ static const struct mm_walk_ops clear_refs_walk_ops = {
 	.walk_lock		= PGWALK_WRLOCK,
 };
 
-static ssize_t clear_refs_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t clear_refs_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct task_struct *task;
 	char buffer[PROC_NUMBUF] = {};
 	struct mm_struct *mm;
@@ -1255,7 +1255,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
 
 	if (count > sizeof(buffer) - 1)
 		count = sizeof(buffer) - 1;
-	if (copy_from_user(buffer, buf, count))
+	if (!copy_from_iter_full(buffer, count, from))
 		return -EFAULT;
 	rv = kstrtoint(strstrip(buffer), 10, &itype);
 	if (rv < 0)
@@ -1264,7 +1264,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
 	if (type < CLEAR_REFS_ALL || type >= CLEAR_REFS_LAST)
 		return -EINVAL;
 
-	task = get_proc_task(file_inode(file));
+	task = get_proc_task(file_inode(iocb->ki_filp));
 	if (!task)
 		return -ESRCH;
 	mm = get_task_mm(task);
@@ -1318,7 +1318,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
 }
 
 const struct file_operations proc_clear_refs_operations = {
-	.write		= clear_refs_write,
+	.write_iter	= clear_refs_write,
 	.llseek		= noop_llseek,
 };
 
@@ -1645,10 +1645,10 @@ static const struct mm_walk_ops pagemap_ops = {
  * determine which areas of memory are actually mapped and llseek to
  * skip over unmapped regions.
  */
-static ssize_t pagemap_read(struct file *file, char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t pagemap_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mm_struct *mm = file->private_data;
+	struct mm_struct *mm = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct pagemapread pm;
 	unsigned long src;
 	unsigned long svpfn;
@@ -1661,7 +1661,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 
 	ret = -EINVAL;
 	/* file position must be aligned */
-	if ((*ppos % PM_ENTRY_BYTES) || (count % PM_ENTRY_BYTES))
+	if ((iocb->ki_pos % PM_ENTRY_BYTES) || (count % PM_ENTRY_BYTES))
 		goto out_mm;
 
 	ret = 0;
@@ -1669,7 +1669,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 		goto out_mm;
 
 	/* do not disclose physical addresses: attack vector */
-	pm.show_pfn = file_ns_capable(file, &init_user_ns, CAP_SYS_ADMIN);
+	pm.show_pfn = file_ns_capable(iocb->ki_filp, &init_user_ns, CAP_SYS_ADMIN);
 
 	pm.len = (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
 	pm.buffer = kmalloc_array(pm.len, PM_ENTRY_BYTES, GFP_KERNEL);
@@ -1677,7 +1677,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 	if (!pm.buffer)
 		goto out_mm;
 
-	src = *ppos;
+	src = iocb->ki_pos;
 	svpfn = src / PM_ENTRY_BYTES;
 	end_vaddr = mm->task_size;
 
@@ -1719,15 +1719,14 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 		start_vaddr = end;
 
 		len = min(count, PM_ENTRY_BYTES * pm.pos);
-		if (copy_to_user(buf, pm.buffer, len)) {
+		if (!copy_to_iter_full(pm.buffer, len, to)) {
 			ret = -EFAULT;
 			goto out_free;
 		}
 		copied += len;
-		buf += len;
 		count -= len;
 	}
-	*ppos += copied;
+	iocb->ki_pos += copied;
 	if (!ret || ret == PM_END_OF_BUFFER)
 		ret = copied;
 
@@ -2518,7 +2517,7 @@ static long do_pagemap_cmd(struct file *file, unsigned int cmd,
 
 const struct file_operations proc_pagemap_operations = {
 	.llseek		= mem_lseek, /* borrow this */
-	.read		= pagemap_read,
+	.read_iter	= pagemap_read,
 	.open		= pagemap_open,
 	.release	= pagemap_release,
 	.unlocked_ioctl = do_pagemap_cmd,
@@ -2787,7 +2786,7 @@ static int pid_numa_maps_open(struct inode *inode, struct file *file)
 
 const struct file_operations proc_pid_numa_maps_operations = {
 	.open		= pid_numa_maps_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_map_release,
 };
fs/proc/task_nommu.c +1 -1
index bce674533000..b1385bf8dd05 100644
@@ -289,7 +289,7 @@ static int pid_maps_open(struct inode *inode, struct file *file)
 
 const struct file_operations proc_pid_maps_operations = {
 	.open		= pid_maps_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= map_release,
 };
include/linux/user_namespace.h +6 -4
index 6030a8235617..181ba788a56b 100644
@@ -174,13 +174,15 @@ static inline void put_user_ns(struct user_namespace *ns)
 }
 
 struct seq_operations;
+struct kiocb;
+struct iov_iter;
 extern const struct seq_operations proc_uid_seq_operations;
 extern const struct seq_operations proc_gid_seq_operations;
 extern const struct seq_operations proc_projid_seq_operations;
-extern ssize_t proc_uid_map_write(struct file *, const char __user *, size_t, loff_t *);
-extern ssize_t proc_gid_map_write(struct file *, const char __user *, size_t, loff_t *);
-extern ssize_t proc_projid_map_write(struct file *, const char __user *, size_t, loff_t *);
-extern ssize_t proc_setgroups_write(struct file *, const char __user *, size_t, loff_t *);
+ssize_t proc_uid_map_write_iter(struct kiocb *iocb, struct iov_iter *from);
+ssize_t proc_gid_map_write_iter(struct kiocb *iocb, struct iov_iter *from);
+ssize_t proc_projid_map_write_iter(struct kiocb *iocb, struct iov_iter *from);
+ssize_t proc_setgroups_write(struct kiocb *iocb, struct iov_iter *from);
 extern int proc_setgroups_show(struct seq_file *m, void *v);
 extern bool userns_may_setgroups(const struct user_namespace *ns);
 extern bool in_userns(const struct user_namespace *ancestor,
kernel/user_namespace.c +27 -12
index 0b0b95418b16..05ec5be1c2d7 100644
@@ -1108,8 +1108,8 @@ static ssize_t map_write(struct file *file, const char __user *buf,
 	return ret;
 }
 
-ssize_t proc_uid_map_write(struct file *file, const char __user *buf,
-			   size_t size, loff_t *ppos)
+static ssize_t proc_uid_map_write(struct file *file, const char __user *buf,
+				  size_t size, loff_t *ppos)
 {
 	struct seq_file *seq = file->private_data;
 	struct user_namespace *ns = seq->private;
@@ -1125,8 +1125,13 @@ ssize_t proc_uid_map_write(struct file *file, const char __user *buf,
 			 &ns->uid_map, &ns->parent->uid_map);
 }
 
-ssize_t proc_gid_map_write(struct file *file, const char __user *buf,
-			   size_t size, loff_t *ppos)
+ssize_t proc_uid_map_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, proc_uid_map_write);
+}
+
+static ssize_t proc_gid_map_write(struct file *file, const char __user *buf,
+				  size_t size, loff_t *ppos)
 {
 	struct seq_file *seq = file->private_data;
 	struct user_namespace *ns = seq->private;
@@ -1142,8 +1147,13 @@ ssize_t proc_gid_map_write(struct file *file, const char __user *buf,
 			 &ns->gid_map, &ns->parent->gid_map);
 }
 
-ssize_t proc_projid_map_write(struct file *file, const char __user *buf,
-			      size_t size, loff_t *ppos)
+ssize_t proc_gid_map_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, proc_gid_map_write);
+}
+
+static ssize_t proc_projid_map_write(struct file *file, const char __user *buf,
+				     size_t size, loff_t *ppos)
 {
 	struct seq_file *seq = file->private_data;
 	struct user_namespace *ns = seq->private;
@@ -1160,6 +1170,11 @@ ssize_t proc_projid_map_write(struct file *file, const char __user *buf,
 			 &ns->projid_map, &ns->parent->projid_map);
 }
 
+ssize_t proc_projid_map_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, proc_projid_map_write);
+}
+
 static bool new_idmap_permitted(const struct file *file,
 				struct user_namespace *ns, int cap_setid,
 				struct uid_gid_map *new_map)
@@ -1213,23 +1228,23 @@ int proc_setgroups_show(struct seq_file *seq, void *v)
 	return 0;
 }
 
-ssize_t proc_setgroups_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *ppos)
+ssize_t proc_setgroups_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *seq = file->private_data;
+	struct seq_file *seq = iocb->ki_filp->private_data;
 	struct user_namespace *ns = seq->private;
+	size_t count = iov_iter_count(from);
 	char kbuf[8], *pos;
 	bool setgroups_allowed;
 	ssize_t ret;
 
 	/* Only allow a very narrow range of strings to be written */
 	ret = -EINVAL;
-	if ((*ppos != 0) || (count >= sizeof(kbuf)))
+	if ((iocb->ki_pos != 0) || (count >= sizeof(kbuf)))
 		goto out;
 
 	/* What was written? */
 	ret = -EFAULT;
-	if (copy_from_user(kbuf, buf, count))
+	if (!copy_from_iter_full(kbuf, count, from))
 		goto out;
 	kbuf[count] = '\0';
 	pos = kbuf;
@@ -1271,7 +1286,7 @@ ssize_t proc_setgroups_write(struct file *file, const char __user *buf,
 	mutex_unlock(&userns_state_mutex);
 
 	/* Report a successful write */
-	*ppos = count;
+	iocb->ki_pos = count;
 	ret = count;
 out:
 	return ret;
Signature · 1 line
2.43.0
author maintainer
#299 lore raw

PATCH 293/437 fs: convert fs_open to read/write iterators

In reply to Jens Axboe
---
 fs/fsopen.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
fs/fsopen.c +6 -5
index 6593ae518115..a68b7d4071b1 100644
@@ -14,6 +14,7 @@
 #include <linux/anon_inodes.h>
 #include <linux/namei.h>
 #include <linux/file.h>
+#include <linux/uio.h>
 #include <uapi/linux/mount.h>
 #include "internal.h"
 #include "mount.h"
@@ -21,12 +22,12 @@
 /*
  * Allow the user to read back any error, warning or informational messages.
  */
-static ssize_t fscontext_read(struct file *file,
-			      char __user *_buf, size_t len, loff_t *pos)
+static ssize_t fscontext_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct fs_context *fc = file->private_data;
+	struct fs_context *fc = iocb->ki_filp->private_data;
 	struct fc_log *log = fc->log.log;
 	unsigned int logsize = ARRAY_SIZE(log->buffer);
+	size_t len = iov_iter_count(to);
 	ssize_t ret;
 	char *p;
 	bool need_free;
@@ -54,7 +55,7 @@ static ssize_t fscontext_read(struct file *file,
 	if (n > len)
 		goto err_free;
 	ret = -EFAULT;
-	if (copy_to_user(_buf, p, n) != 0)
+	if (!copy_to_iter_full(p, n, to) != 0)
 		goto err_free;
 	ret = n;
 
@@ -76,7 +77,7 @@ static int fscontext_release(struct inode *inode, struct file *file)
 }
 
 const struct file_operations fscontext_fops = {
-	.read		= fscontext_read,
+	.read_iter	= fscontext_read,
 	.release	= fscontext_release,
 	.llseek		= no_llseek,
 };
Signature · 1 line
2.43.0
author maintainer
#300 lore raw

PATCH 294/437 openpromfs: convert to read/write iterators

In reply to Jens Axboe
---
 fs/openpromfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/openpromfs/inode.c +1 -1
index e25eceac86f4..66667b55562b 100644
@@ -159,7 +159,7 @@ static int property_open(struct inode *inode, struct file *file)
 
 static const struct file_operations openpromfs_prop_ops = {
 	.open		= property_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
Signature · 1 line
2.43.0