[PATCH 174/437] soc: qcom: convert to read/write iterators

Jens Axboe
2024-04-11T15:36:34Z

drivers/soc/qcom/cmd-db.c | 2 +-
drivers/soc/qcom/qcom_aoss.c | 14 ++++++-------
drivers/soc/qcom/rmtfs_mem.c | 38 ++++++++++++++++++------------------
drivers/soc/qcom/socinfo.c | 4 ++--
4 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
index a5fd68411bed..0589e63fdb0d 100644
--- a/drivers/soc/qcom/cmd-db.c
+++ b/drivers/soc/qcom/cmd-db.c
@@ -308,7 +308,7 @@ static const struct file_operations cmd_db_debugfs_ops = {
#ifdef CONFIG_DEBUG_FS
.open = open_cmd_db_debugfs,
#endif
- .read = seq_read,
+ .read_iter = seq_read_iter,
.llseek = seq_lseek,
.release = single_release,
};
diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c
index ca2f6b7629ce..6ce5fdf96432 100644
--- a/drivers/soc/qcom/qcom_aoss.c
+++ b/drivers/soc/qcom/qcom_aoss.c
@@ -504,11 +504,11 @@ static const struct qmp_debugfs_entry qmp_debugfs_entries[QMP_DEBUGFS_FILES] = {
{ "prevent_ddr_collapse", "{class: ddr_mol, res: ddr, val: %s}", true, "mol", "off" },
};

-static ssize_t qmp_debugfs_write(struct file *file, const char __user *user_buf,
- size_t count, loff_t *pos)
+static ssize_t qmp_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
{
const struct qmp_debugfs_entry *entry = NULL;
- struct qmp *qmp = file->private_data;
+ struct qmp *qmp = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(from);
char buf[QMP_MSG_LEN];
unsigned int uint_val;
const char *str_val;
@@ -517,7 +517,7 @@ static ssize_t qmp_debugfs_write(struct file *file, const char __user *user_buf,
int i;

for (i = 0; i < ARRAY_SIZE(qmp->debugfs_files); i++) {
- if (qmp->debugfs_files[i] == file->f_path.dentry) {
+ if (qmp->debugfs_files[i] == iocb->ki_filp->f_path.dentry) {
entry = &qmp_debugfs_entries[i];
break;
}
@@ -526,7 +526,7 @@ static ssize_t qmp_debugfs_write(struct file *file, const char __user *user_buf,
return -EFAULT;

if (entry->is_bool) {
- ret = kstrtobool_from_user(user_buf, count, &bool_val);
+ ret = kstrtobool_from_iter(from, count, &bool_val);
if (ret)
return ret;

@@ -536,7 +536,7 @@ static ssize_t qmp_debugfs_write(struct file *file, const char __user *user_buf,
if (ret >= sizeof(buf))
return -EINVAL;
} else {
- ret = kstrtou32_from_user(user_buf, count, 0, &uint_val);
+ ret = kstrtou32_from_iter(from, count, 0, &uint_val);
if (ret)
return ret;

@@ -554,7 +554,7 @@ static ssize_t qmp_debugfs_write(struct file *file, const char __user *user_buf,

static const struct file_operations qmp_debugfs_fops = {
.open = simple_open,
- .write = qmp_debugfs_write,
+ .write_iter = qmp_debugfs_write,
};

static void qmp_debugfs_create(struct qmp *qmp)
diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
index df850d073102..065faa808f49 100644
--- a/drivers/soc/qcom/rmtfs_mem.c
+++ b/drivers/soc/qcom/rmtfs_mem.c
@@ -15,6 +15,7 @@
#include <linux/uaccess.h>
#include <linux/io.h>
#include <linux/firmware/qcom/qcom_scm.h>
+#include <linux/uio.h>

#define QCOM_RMTFS_MEM_DEV_MAX (MINORMASK + 1)
#define NUM_MAX_VMIDS 2
@@ -79,40 +80,39 @@ static int qcom_rmtfs_mem_open(struct inode *inode, struct file *filp)

return 0;
}
-static ssize_t qcom_rmtfs_mem_read(struct file *filp,
- char __user *buf, size_t count, loff_t *f_pos)
+static ssize_t qcom_rmtfs_mem_read(struct kiocb *iocb, struct iov_iter *to)
{
- struct qcom_rmtfs_mem *rmtfs_mem = filp->private_data;
+ struct qcom_rmtfs_mem *rmtfs_mem = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(to);

- if (*f_pos >= rmtfs_mem->size)
+ if (iocb->ki_pos >= rmtfs_mem->size)
return 0;

- if (*f_pos + count >= rmtfs_mem->size)
- count = rmtfs_mem->size - *f_pos;
+ if (iocb->ki_pos + count >= rmtfs_mem->size)
+ count = rmtfs_mem->size - iocb->ki_pos;

- if (copy_to_user(buf, rmtfs_mem->base + *f_pos, count))
+ if (!copy_to_iter_full(rmtfs_mem->base + iocb->ki_pos, count, to))
return -EFAULT;

- *f_pos += count;
+ iocb->ki_pos += count;
return count;
}

-static ssize_t qcom_rmtfs_mem_write(struct file *filp,
- const char __user *buf, size_t count,
- loff_t *f_pos)
+static ssize_t qcom_rmtfs_mem_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct qcom_rmtfs_mem *rmtfs_mem = filp->private_data;
+ struct qcom_rmtfs_mem *rmtfs_mem = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(from);

- if (*f_pos >= rmtfs_mem->size)
+ if (iocb->ki_pos >= rmtfs_mem->size)
return 0;

- if (*f_pos + count >= rmtfs_mem->size)
- count = rmtfs_mem->size - *f_pos;
+ if (iocb->ki_pos + count >= rmtfs_mem->size)
+ count = rmtfs_mem->size - iocb->ki_pos;

- if (copy_from_user(rmtfs_mem->base + *f_pos, buf, count))
+ if (!copy_from_iter_full(rmtfs_mem->base + iocb->ki_pos, count, from))
return -EFAULT;

- *f_pos += count;
+ iocb->ki_pos += count;
return count;
}

@@ -152,8 +152,8 @@ static int qcom_rmtfs_mem_mmap(struct file *filep, struct vm_area_struct *vma)
static const struct file_operations qcom_rmtfs_mem_fops = {
.owner = THIS_MODULE,
.open = qcom_rmtfs_mem_open,
- .read = qcom_rmtfs_mem_read,
- .write = qcom_rmtfs_mem_write,
+ .read_iter = qcom_rmtfs_mem_read,
+ .write_iter = qcom_rmtfs_mem_write,
.release = qcom_rmtfs_mem_release,
.llseek = default_llseek,
.mmap = qcom_rmtfs_mem_mmap,
diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index e8ff9819ac47..fbee271d4646 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -467,7 +467,7 @@ static int qcom_open_##name(struct inode *inode, struct file *file) \
\
static const struct file_operations qcom_ ##name## _ops = { \
.open = qcom_open_##name, \
- .read = seq_read, \
+ .read_iter = seq_read_iter, \
.llseek = seq_lseek, \
.release = single_release, \
}
@@ -570,7 +570,7 @@ static int open_image_##type(struct inode *inode, struct file *file) \
\
static const struct file_operations qcom_image_##type##_ops = { \
.open = open_image_##type, \
- .read = seq_read, \
+ .read_iter = seq_read_iter, \
.llseek = seq_lseek, \
.release = single_release, \
}
--
2.43.0