Messages in this thread Patch in this message | | | From | Jens Axboe <> | Subject | [PATCH 218/437] misc: tps6594-pfsm: convert to read/write iterators | Date | Thu, 11 Apr 2024 09:15:58 -0600 |
| |
Signed-off-by: Jens Axboe <axboe@kernel.dk> --- drivers/misc/tps6594-pfsm.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/drivers/misc/tps6594-pfsm.c b/drivers/misc/tps6594-pfsm.c index 88dcac814892..3e3da7b4bb7e 100644 --- a/drivers/misc/tps6594-pfsm.c +++ b/drivers/misc/tps6594-pfsm.c @@ -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, }; -- 2.43.0
| |