[PATCH 369/437] drivers/mmc: convert to read/write iterators

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

drivers/mmc/core/block.c | 10 ++++------
drivers/mmc/core/debugfs.c | 11 +++++------
drivers/mmc/core/mmc_test.c | 12 ++++++------
3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 90c51b12148e..490cf789de72 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2933,13 +2933,11 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
return err;
}

-static ssize_t mmc_ext_csd_read(struct file *filp, char __user *ubuf,
- size_t cnt, loff_t *ppos)
+static ssize_t mmc_ext_csd_read(struct kiocb *iocb, struct iov_iter *to)
{
- char *buf = filp->private_data;
+ char *buf = iocb->ki_filp->private_data;

- return simple_read_from_buffer(ubuf, cnt, ppos,
- buf, EXT_CSD_STR_LEN);
+ return simple_copy_to_iter(buf, &iocb->ki_pos, EXT_CSD_STR_LEN, to);
}

static int mmc_ext_csd_release(struct inode *inode, struct file *file)
@@ -2950,7 +2948,7 @@ static int mmc_ext_csd_release(struct inode *inode, struct file *file)

static const struct file_operations mmc_dbg_ext_csd_fops = {
.open = mmc_ext_csd_open,
- .read = mmc_ext_csd_read,
+ .read_iter = mmc_ext_csd_read,
.release = mmc_ext_csd_release,
.llseek = default_llseek,
};
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index 1642ea72d22c..37aa1529f4f8 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -283,21 +283,20 @@ static int mmc_err_stats_open(struct inode *inode, struct file *file)
return single_open(file, mmc_err_stats_show, inode->i_private);
}

-static ssize_t mmc_err_stats_write(struct file *filp, const char __user *ubuf,
- size_t cnt, loff_t *ppos)
+static ssize_t mmc_err_stats_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct mmc_host *host = filp->f_mapping->host->i_private;
+ struct mmc_host *host = iocb->ki_filp->f_mapping->host->i_private;

pr_debug("%s: Resetting MMC error statistics\n", __func__);
memset(host->err_stats, 0, sizeof(host->err_stats));

- return cnt;
+ return iov_iter_count(from);
}

static const struct file_operations mmc_err_stats_fops = {
.open = mmc_err_stats_open,
- .read = seq_read,
- .write = mmc_err_stats_write,
+ .read_iter = seq_read_iter,
+ .write_iter = mmc_err_stats_write,
.release = single_release,
};

diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
index 8f7f587a0025..6bbec9154f8a 100644
--- a/drivers/mmc/core/mmc_test.c
+++ b/drivers/mmc/core/mmc_test.c
@@ -3097,16 +3097,16 @@ static int mtf_test_open(struct inode *inode, struct file *file)
return single_open(file, mtf_test_show, inode->i_private);
}

-static ssize_t mtf_test_write(struct file *file, const char __user *buf,
- size_t count, loff_t *pos)
+static ssize_t mtf_test_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct seq_file *sf = file->private_data;
+ struct seq_file *sf = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(from);
struct mmc_card *card = sf->private;
struct mmc_test_card *test;
long testcase;
int ret;

- ret = kstrtol_from_user(buf, count, 10, &testcase);
+ ret = kstrtol_from_iter(from, count, 10, &testcase);
if (ret)
return ret;

@@ -3148,8 +3148,8 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,

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