| From | Jens Axboe <> | Subject | [PATCH 427/437] hwtracing: coresight: convert to read/write iterators | Date | Thu, 11 Apr 2024 09:19:27 -0600 |
| |
Signed-off-by: Jens Axboe <axboe@kernel.dk> --- .../hwtracing/coresight/coresight-cpu-debug.c | 15 +++++++-------- drivers/hwtracing/coresight/coresight-etb10.c | 18 +++++++++--------- .../hwtracing/coresight/coresight-tmc-core.c | 14 +++++++------- drivers/hwtracing/coresight/ultrasoc-smb.c | 12 ++++++------ 4 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c index 1874df7c6a73..5ee3dc600066 100644 --- a/drivers/hwtracing/coresight/coresight-cpu-debug.c +++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c @@ -471,13 +471,13 @@ static int debug_disable_func(void) return err; } -static ssize_t debug_func_knob_write(struct file *f, - const char __user *buf, size_t count, loff_t *ppos) +static ssize_t debug_func_knob_write(struct kiocb *iocb, struct iov_iter *from) { + size_t count = iov_iter_count(from); u8 val; int ret; - ret = kstrtou8_from_user(buf, count, 2, &val); + ret = kstrtou8_from_iter(from, count, 2, &val); if (ret) return ret; @@ -505,8 +505,7 @@ static ssize_t debug_func_knob_write(struct file *f, return ret; } -static ssize_t debug_func_knob_read(struct file *f, - char __user *ubuf, size_t count, loff_t *ppos) +static ssize_t debug_func_knob_read(struct kiocb *iocb, struct iov_iter *to) { ssize_t ret; char buf[3]; @@ -515,14 +514,14 @@ static ssize_t debug_func_knob_read(struct file *f, snprintf(buf, sizeof(buf), "%d\n", debug_enable); mutex_unlock(&debug_lock); - ret = simple_read_from_buffer(ubuf, count, ppos, buf, sizeof(buf)); + ret = simple_copy_to_iter(buf, &iocb->ki_pos, sizeof(buf), to); return ret; } static const struct file_operations debug_func_knob_fops = { .open = simple_open, - .read = debug_func_knob_read, - .write = debug_func_knob_write, + .read_iter = debug_func_knob_read, + .write_iter = debug_func_knob_write, }; static int debug_func_init(void) diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 3aab182b562f..14735de16316 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -610,30 +610,30 @@ static int etb_open(struct inode *inode, struct file *file) return 0; } -static ssize_t etb_read(struct file *file, char __user *data, - size_t len, loff_t *ppos) +static ssize_t etb_read(struct kiocb *iocb, struct iov_iter *to) { + size_t len = iov_iter_count(to); u32 depth; - struct etb_drvdata *drvdata = container_of(file->private_data, + struct etb_drvdata *drvdata = container_of(iocb->ki_filp->private_data, struct etb_drvdata, miscdev); struct device *dev = &drvdata->csdev->dev; etb_dump(drvdata); depth = drvdata->buffer_depth; - if (*ppos + len > depth * 4) - len = depth * 4 - *ppos; + if (iocb->ki_pos + len > depth * 4) + len = depth * 4 - iocb->ki_pos; - if (copy_to_user(data, drvdata->buf + *ppos, len)) { + if (!copy_to_iter_full(drvdata->buf + iocb->ki_pos, len, to)) { dev_dbg(dev, "%s: copy_to_user failed\n", __func__); return -EFAULT; } - *ppos += len; + iocb->ki_pos += len; dev_dbg(dev, "%s: %zu bytes copied, %d bytes left\n", - __func__, len, (int)(depth * 4 - *ppos)); + __func__, len, (int)(depth * 4 - iocb->ki_pos)); return len; } @@ -650,7 +650,7 @@ static int etb_release(struct inode *inode, struct file *file) static const struct file_operations etb_fops = { .owner = THIS_MODULE, .open = etb_open, - .read = etb_read, + .read_iter = etb_read, .release = etb_release, .llseek = no_llseek, }; diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c index 72005b0c633e..337599655242 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-core.c +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c @@ -176,24 +176,24 @@ static inline ssize_t tmc_get_sysfs_trace(struct tmc_drvdata *drvdata, return -EINVAL; } -static ssize_t tmc_read(struct file *file, char __user *data, size_t len, - loff_t *ppos) +static ssize_t tmc_read(struct kiocb *iocb, struct iov_iter *to) { + size_t len = iov_iter_count(to); char *bufp; ssize_t actual; - struct tmc_drvdata *drvdata = container_of(file->private_data, + struct tmc_drvdata *drvdata = container_of(iocb->ki_filp->private_data, struct tmc_drvdata, miscdev); - actual = tmc_get_sysfs_trace(drvdata, *ppos, len, &bufp); + actual = tmc_get_sysfs_trace(drvdata, iocb->ki_pos, len, &bufp); if (actual <= 0) return 0; - if (copy_to_user(data, bufp, actual)) { + if (!copy_to_iter_full(bufp, actual, to)) { dev_dbg(&drvdata->csdev->dev, "%s: copy_to_user failed\n", __func__); return -EFAULT; } - *ppos += actual; + iocb->ki_pos += actual; dev_dbg(&drvdata->csdev->dev, "%zu bytes copied\n", actual); return actual; @@ -216,7 +216,7 @@ static int tmc_release(struct inode *inode, struct file *file) static const struct file_operations tmc_fops = { .owner = THIS_MODULE, .open = tmc_open, - .read = tmc_read, + .read_iter = tmc_read, .release = tmc_release, .llseek = no_llseek, }; diff --git a/drivers/hwtracing/coresight/ultrasoc-smb.c b/drivers/hwtracing/coresight/ultrasoc-smb.c index f9ebf20c91e6..27e883e69ce6 100644 --- a/drivers/hwtracing/coresight/ultrasoc-smb.c +++ b/drivers/hwtracing/coresight/ultrasoc-smb.c @@ -112,13 +112,13 @@ static int smb_open(struct inode *inode, struct file *file) return 0; } -static ssize_t smb_read(struct file *file, char __user *data, size_t len, - loff_t *ppos) +static ssize_t smb_read(struct kiocb *iocb, struct iov_iter *to) { - struct smb_drv_data *drvdata = container_of(file->private_data, + struct smb_drv_data *drvdata = container_of(iocb->ki_filp->private_data, struct smb_drv_data, miscdev); struct smb_data_buffer *sdb = &drvdata->sdb; struct device *dev = &drvdata->csdev->dev; + size_t len = iov_iter_count(to); ssize_t to_copy = 0; if (!len) @@ -133,12 +133,12 @@ static ssize_t smb_read(struct file *file, char __user *data, size_t len, if (sdb->buf_rdptr + to_copy > sdb->buf_size) to_copy = sdb->buf_size - sdb->buf_rdptr; - if (copy_to_user(data, sdb->buf_base + sdb->buf_rdptr, to_copy)) { + if (!copy_to_iter_full(sdb->buf_base + sdb->buf_rdptr, to_copy, to)) { dev_dbg(dev, "Failed to copy data to user\n"); return -EFAULT; } - *ppos += to_copy; + iocb->ki_pos += to_copy; smb_update_read_ptr(drvdata, to_copy); if (!sdb->data_size) smb_reset_buffer(drvdata); @@ -161,7 +161,7 @@ static int smb_release(struct inode *inode, struct file *file) static const struct file_operations smb_fops = { .owner = THIS_MODULE, .open = smb_open, - .read = smb_read, + .read_iter = smb_read, .release = smb_release, .llseek = no_llseek, }; -- 2.43.0
|