Kill off old fops ->read() and ->write()
Subsystems (424)
Jens Axboe
maintainerPATCH 353/437 arch/s390: convert to read/write iterators
In reply to Jens Axboe--- arch/s390/crypto/prng.c | 18 ++++++++---------- arch/s390/hypfs/hypfs_dbfs.c | 11 +++++------ arch/s390/kernel/debug.c | 29 +++++++++++++---------------- arch/s390/kernel/sysinfo.c | 6 +++--- arch/s390/pci/pci_debug.c | 12 ++++++------ 5 files changed, 35 insertions(+), 41 deletions(-)
arch/s390/crypto/prng.c +8 -10
@@ -509,9 +509,9 @@ static int prng_open(struct inode *inode, struct file *file) } -static ssize_t prng_tdes_read (struct file *file,char __user *ubuf, -size_t nbytes,loff_t *ppos) +static ssize_t prng_tdes_read (struct kiocb *iocb,struct iov_iter *to) { +size_t nbytes =iov_iter_count (to);int chunk, n, ret =0 ;/* lock prng_data struct */
@@ -570,14 +570,13 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf, prng_data->prngws.byte_counter += n; prng_data->prngws.reseed_counter += n; -if (copy_to_user (ubuf, prng_data->buf, chunk)) { +if (!copy_to_iter_full (prng_data->buf, chunk, to)) { ret = -EFAULT ;break ; } nbytes -= chunk; ret += chunk; - ubuf += chunk; }/* unlock prng_data struct */
@@ -587,9 +586,9 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf, } -static ssize_t prng_sha512_read (struct file *file,char __user *ubuf, -size_t nbytes,loff_t *ppos) +static ssize_t prng_sha512_read (struct kiocb *iocb,struct iov_iter *to) { +size_t nbytes =iov_iter_count (to);int n, ret =0 ;u8 *p;
@@ -640,12 +639,11 @@ static ssize_t prng_sha512_read(struct file *file, char __user *ubuf, prng_data->rest =0 ; } } -if (copy_to_user (ubuf, p, n)) { +if (!copy_to_iter_full (p, n, to)) { ret = -EFAULT ;break ; }memzero_explicit (p, n); - ubuf += n; nbytes -= n; ret += n; }
@@ -663,14 +661,14 @@ static const struct file_operations prng_sha512_fops = { .owner = THIS_MODULE, .open = &prng_open, .release = NULL, - .read = &prng_sha512_read, + .read_iter = &prng_sha512_read, .llseek = noop_llseek, };static const struct file_operations prng_tdes_fops = { .owner =THIS_MODULE , .open = &prng_open, .release =NULL , - .read = &prng_tdes_read, + .read_iter = &prng_tdes_read, .llseek = noop_llseek, };
arch/s390/hypfs/hypfs_dbfs.c +5 -6
@@ -28,17 +28,16 @@ static void hypfs_dbfs_data_free(struct hypfs_dbfs_data *data)kfree (data); } -static ssize_t dbfs_read (struct file *file,char __user *buf, -size_t size,loff_t *ppos) +static ssize_t dbfs_read (struct kiocb *iocb,struct iov_iter *to) {struct hypfs_dbfs_data *data;struct hypfs_dbfs_file *df;ssize_t rc; -if (*ppos !=0 ) +if (iocb->ki_pos !=0 )return 0 ; - df =file_inode (file)->i_private; + df =file_inode (iocb->ki_filp)->i_private;mutex_lock (&df->lock); data =hypfs_dbfs_data_alloc (df);if (!data) {
@@ -53,7 +52,7 @@ static ssize_t dbfs_read(struct file *file, char __user *buf, }mutex_unlock (&df->lock); - rc =simple_read_from_buffer (buf, size, ppos, data->buf, data->size); + rc =simple_copy_to_iter (data->buf, &iocb->ki_pos, data->size, to);hypfs_dbfs_data_free (data);return rc; }
@@ -73,7 +72,7 @@ static long dbfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) }static const struct file_operations dbfs_ops = { - .read = dbfs_read, + .read_iter = dbfs_read, .llseek = no_llseek, .unlocked_ioctl = dbfs_ioctl, };
arch/s390/kernel/debug.c +13 -16
@@ -66,10 +66,8 @@ typedef struct {/* internal function prototyes */ static int debug_init (void ); -static ssize_t debug_output (struct file *file,char __user *user_buf, -size_t user_len,loff_t *offset); -static ssize_t debug_input (struct file *file,const char __user *user_buf, -size_t user_len,loff_t *offset); +static ssize_t debug_output (struct kiocb *iocb,struct iov_iter *to); +static ssize_t debug_input_iter (struct kiocb *iocb,struct iov_iter *from);static int debug_open (struct inode *inode,struct file *file);static int debug_close (struct inode *inode,struct file *file); static debug_info_t *debug_info_create(const char *name, int pages_per_area,
@@ -159,8 +157,8 @@ static int debug_critical;static const struct file_operations debug_file_ops = { .owner =THIS_MODULE , - .read = debug_output, - .write = debug_input, + .read_iter = debug_output, + .write_iter = debug_input_iter, .open = debug_open, .release = debug_close, .llseek = no_llseek,
@@ -452,17 +450,15 @@ static inline int debug_next_entry(file_private_info_t *p_info)* - called for user read() * - copies formated debug entries to the user buffer */ -static ssize_t debug_output (struct file *file,/* file descriptor */ -char __user *user_buf,/* user buffer */ -size_t len,/* length of buffer */ -loff_t *offset)/* offset in the file */ +static ssize_t debug_output (struct kiocb *iocb,struct iov_iter *to) {size_t count =0 ;size_t entry_offset;file_private_info_t *p_info; +size_t len =iov_iter_count (to); - p_info = (file_private_info_t *) file->private_data; -if (*offset != p_info->offset) + p_info = (file_private_info_t *) iocb->ki_filp->private_data; +if (iocb->ki_pos != p_info->offset)return -EPIPE ;if (p_info->act_area >= p_info->debug_info_snap->nr_areas)return 0 ;
@@ -478,8 +474,8 @@ static ssize_t debug_output(struct file *file, /* file descriptor */ user_buf_residue = len-count; copy_size =min (user_buf_residue, formatted_line_residue);if (copy_size) { -if (copy_to_user (user_buf + count, p_info->temp_buf - + entry_offset, copy_size)) +if (!copy_to_iter_full (p_info->temp_buf + + entry_offset, copy_size, to))return -EFAULT ; count += copy_size; entry_offset += copy_size;
@@ -491,9 +487,9 @@ static ssize_t debug_output(struct file *file, /* file descriptor */ } } out: - p_info->offset = *offset + count; + p_info->offset = iocb->ki_pos + count; p_info->act_entry_offset = entry_offset; - *offset = p_info->offset; + iocb->ki_pos = p_info->offset;return count; }
@@ -520,6 +516,7 @@ static ssize_t debug_input(struct file *file, const char __user *user_buf,mutex_unlock (&debug_mutex);return rc;/* number of input characters */ } +FOPS_WRITE_ITER_HELPER (debug_input);/* * debug_open:
arch/s390/kernel/sysinfo.c +3 -3
@@ -497,7 +497,7 @@ static int stsi_open_##fc##_##s1##_##s2(struct inode *inode, struct file *file)\ static const struct file_operations stsi_##fc##_##s1##_##s2##_fs_ops = { \ .open = stsi_open_##fc##_##s1##_##s2, \ .release = stsi_release, \ - .read = stsi_read, \ + .read_iter = stsi_read, \ .llseek = no_llseek, \ };
@@ -507,9 +507,9 @@ static int stsi_release(struct inode *inode, struct file *file)return 0 ; } -static ssize_t stsi_read (struct file *file,char __user *buf,size_t size,loff_t *ppos) +static ssize_t stsi_read (struct kiocb *iocb,struct iov_iter *to) { -return simple_read_from_buffer (buf, size, ppos, file->private_data,PAGE_SIZE ); +return simple_copy_to_iter (iocb->ki_filp->private_data, &iocb->ki_pos,PAGE_SIZE , to); }STSI_FILE (1 ,1 ,1 );
arch/s390/pci/pci_debug.c +6 -6
@@ -134,17 +134,17 @@ static int pci_perf_show(struct seq_file *m, void *v)return 0 ; } -static ssize_t pci_perf_seq_write (struct file *file,const char __user *ubuf, -size_t count,loff_t *off) +static ssize_t pci_perf_seq_write (struct kiocb *iocb,struct iov_iter *from) { -struct zpci_dev *zdev = ((struct seq_file *) file->private_data)->private; +struct zpci_dev *zdev = ((struct seq_file *) iocb->ki_filp->private_data)->private; +size_t count =iov_iter_count (from);unsigned long val;int rc;if (!zdev)return 0 ; - rc =kstrtoul_from_user (ubuf, count,10 , &val); + rc =kstrtoul_from_iter (from, count,10 , &val);if (rc)return rc;
@@ -169,8 +169,8 @@ static int pci_perf_seq_open(struct inode *inode, struct file *filp)static const struct file_operations debugfs_pci_perf_fops = { .open = pci_perf_seq_open, - .read = seq_read, - .write = pci_perf_seq_write, + .read_iter = seq_read_iter, + .write_iter = pci_perf_seq_write, .llseek = seq_lseek, .release = single_release, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 354/437 arch/sh: convert to read/write iterators
In reply to Jens Axboe--- arch/sh/mm/tlb-debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/mm/tlb-debugfs.c +1 -1
@@ -142,7 +142,7 @@ static int tlb_debugfs_open(struct inode *inode, struct file *file)static const struct file_operations tlb_debugfs_fops = { .owner =THIS_MODULE , .open = tlb_debugfs_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 355/437 arch/um: convert to read/write iterators
In reply to Jens Axboe--- arch/um/drivers/harddog_kern.c | 6 +++--- arch/um/drivers/hostaudio_kern.c | 22 +++++++++++----------- arch/um/drivers/mmapper_kern.c | 16 +++++++--------- 3 files changed, 21 insertions(+), 23 deletions(-)
arch/um/drivers/harddog_kern.c +3 -3
@@ -109,9 +109,9 @@ static int harddog_release(struct inode *inode, struct file *file)return 0 ; } -static ssize_t harddog_write (struct file *file,const char __user *data,size_t len, -loff_t *ppos) +static ssize_t harddog_write (struct kiocb *iocb,struct iov_iter *from) { +size_t len =iov_iter_count (from);/* * Refresh the timer. */
@@ -158,7 +158,7 @@ static long harddog_ioctl(struct file *file,static const struct file_operations harddog_fops = { .owner =THIS_MODULE , - .write = harddog_write, + .write_iter = harddog_write, .unlocked_ioctl = harddog_ioctl, .compat_ioctl = compat_ptr_ioctl, .open = harddog_open,
arch/um/drivers/hostaudio_kern.c +11 -11
@@ -67,10 +67,10 @@ static DEFINE_MUTEX(hostaudio_mutex);/* /dev/dsp file operations */ -static ssize_t hostaudio_read (struct file *file,char __user *buffer, -size_t count,loff_t *ppos) +static ssize_t hostaudio_read (struct kiocb *iocb,struct iov_iter *to) { -struct hostaudio_state *state = file->private_data; +struct hostaudio_state *state = iocb->ki_filp->private_data; +size_t count =iov_iter_count (to);void *kbuf;int err;
@@ -86,7 +86,7 @@ static ssize_t hostaudio_read(struct file *file, char __user *buffer,if (err <0 ) goto out; -if (copy_to_user (buffer, kbuf, err)) +if (!copy_to_iter_full (kbuf, err, to)) err = -EFAULT ; out:
@@ -94,10 +94,10 @@ static ssize_t hostaudio_read(struct file *file, char __user *buffer,return err; } -static ssize_t hostaudio_write (struct file *file,const char __user *buffer, -size_t count,loff_t *ppos) +static ssize_t hostaudio_write (struct kiocb *iocb,struct iov_iter *from) { -struct hostaudio_state *state = file->private_data; +struct hostaudio_state *state = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);void *kbuf;int err;
@@ -105,14 +105,14 @@ static ssize_t hostaudio_write(struct file *file, const char __user *buffer,printk (KERN_DEBUG "hostaudio: write called, count = %d\n" , count);#endif - kbuf =memdup_user (buffer, count); + kbuf =iterdup (from, count);if (IS_ERR (kbuf))return PTR_ERR (kbuf); err =os_write_file (state->fd, kbuf, count);if (err <0 ) goto out; - *ppos += err; + iocb->ki_pos += err; out:kfree (kbuf);
@@ -292,8 +292,8 @@ static int hostmixer_release(struct inode *inode, struct file *file)static const struct file_operations hostaudio_fops = { .owner =THIS_MODULE , .llseek = no_llseek, - .read = hostaudio_read, - .write = hostaudio_write, + .read_iter = hostaudio_read, + .write_iter = hostaudio_write, .poll = hostaudio_poll, .unlocked_ioctl = hostaudio_ioctl, .compat_ioctl = compat_ptr_ioctl,
arch/um/drivers/mmapper_kern.c +7 -9
@@ -26,19 +26,17 @@ static unsigned long mmapper_size;static unsigned long p_buf;static char *v_buf; -static ssize_t mmapper_read (struct file *file,char __user *buf,size_t count, -loff_t *ppos) +static ssize_t mmapper_read (struct kiocb *iocb,struct iov_iter *to) { -return simple_read_from_buffer (buf, count, ppos, v_buf, mmapper_size); +return simple_copy_to_iter (v_buf, &iocb->ki_pos, mmapper_size, to); } -static ssize_t mmapper_write (struct file *file,const char __user *buf, -size_t count,loff_t *ppos) +static ssize_t mmapper_write (struct kiocb *iocb,struct iov_iter *from) { -if (*ppos > mmapper_size) +if (iocb->ki_pos > mmapper_size)return -EINVAL ; -return simple_write_to_buffer (v_buf, mmapper_size, ppos, buf, count); +return simple_copy_from_iter (v_buf, &iocb->ki_pos, mmapper_size, from); }static long mmapper_ioctl (struct file *file,unsigned int cmd,unsigned long arg)
@@ -82,8 +80,8 @@ static int mmapper_release(struct inode *inode, struct file *file)static const struct file_operations mmapper_fops = { .owner =THIS_MODULE , - .read = mmapper_read, - .write = mmapper_write, + .read_iter = mmapper_read, + .write_iter = mmapper_write, .unlocked_ioctl = mmapper_ioctl, .mmap = mmapper_mmap, .open = mmapper_open,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 356/437 arch/sparc: convert to read/write iterators
In reply to Jens Axboe--- arch/sparc/kernel/mdesc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
arch/sparc/kernel/mdesc.c +9 -9
@@ -1261,24 +1261,24 @@ static int mdesc_open(struct inode *inode, struct file *file)return 0 ; } -static ssize_t mdesc_read (struct file *file,char __user *buf, -size_t len,loff_t *offp) +static ssize_t mdesc_read (struct kiocb *iocb,struct iov_iter *to) { -struct mdesc_handle *hp = file->private_data; +struct mdesc_handle *hp = iocb->ki_filp->private_data; +size_t len =iov_iter_count (to);unsigned char *mdesc;int bytes_left, count = len; -if (*offp >= hp->handle_size) +if (iocb->ki_pos >= hp->handle_size)return 0 ; - bytes_left = hp->handle_size - *offp; + bytes_left = hp->handle_size - iocb->ki_pos;if (count > bytes_left) count = bytes_left; mdesc = (unsigned char *)&hp->mdesc; - mdesc += *offp; -if (!copy_to_user (buf, mdesc, count)) { - *offp += count; + mdesc += iocb->ki_pos; +if (!copy_to_iter_full (mdesc, count, to)) { + iocb->ki_pos += count;return count; }else {return -EFAULT ;
@@ -1303,7 +1303,7 @@ static int mdesc_close(struct inode *inode, struct file *file)static const struct file_operations mdesc_fops = { .open = mdesc_open, - .read = mdesc_read, + .read_iter = mdesc_read, .llseek = mdesc_llseek, .release = mdesc_close, .owner =THIS_MODULE ,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 357/437 samples/vfio-mdev: convert to read/write iterators
In reply to Jens Axboe--- samples/vfio-mdev/mtty.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
samples/vfio-mdev/mtty.c +16 -14
@@ -881,16 +881,17 @@ static long mtty_precopy_ioctl(struct file *filp, unsigned int cmd,return ret; } -static ssize_t mtty_save_read (struct file *filp,char __user *buf, -size_t len,loff_t *pos) +static ssize_t mtty_save_read (struct kiocb *iocb,struct iov_iter *to) { -struct mtty_migration_file *migf = filp->private_data; +struct mtty_migration_file *migf = iocb->ki_filp->private_data; +size_t len =iov_iter_count (to);ssize_t ret =0 ; +loff_t *pos; -if (pos) +if (iocb->ki_pos)return -ESPIPE ; - pos = &filp->f_pos; + pos = &iocb->ki_filp->f_pos;mutex_lock (&migf->lock);
@@ -908,7 +909,7 @@ static ssize_t mtty_save_read(struct file *filp, char __user *buf, len =min_t (size_t, migf->filled_size - *pos, len);if (len) { -if (copy_to_user (buf, (void *)&migf->data + *pos, len)) { +if (!copy_to_iter_full ((void *)&migf->data + *pos, len, to)) { ret = -EFAULT ; goto out_unlock; }
@@ -923,7 +924,7 @@ static ssize_t mtty_save_read(struct file *filp, char __user *buf,static const struct file_operations mtty_save_fops = { .owner =THIS_MODULE , - .read = mtty_save_read, + .read_iter = mtty_save_read, .unlocked_ioctl = mtty_precopy_ioctl, .compat_ioctl = compat_ptr_ioctl, .release = mtty_release_migf,
@@ -1018,18 +1019,19 @@ mtty_save_device_data(struct mdev_state *mdev_state,return ret; } -static ssize_t mtty_resume_write (struct file *filp,const char __user *buf, -size_t len,loff_t *pos) +static ssize_t mtty_resume_write (struct kiocb *iocb,struct iov_iter *from) { -struct mtty_migration_file *migf = filp->private_data; +struct mtty_migration_file *migf = iocb->ki_filp->private_data;struct mdev_state *mdev_state = migf->mdev_state; +size_t len =iov_iter_count (from);loff_t requested_length;ssize_t ret =0 ; +loff_t *pos; -if (pos) +if (iocb->ki_pos)return -ESPIPE ; - pos = &filp->f_pos; + pos = &iocb->ki_filp->f_pos;if (*pos <0 ||check_add_overflow ((loff_t )len, *pos, &requested_length))
@@ -1045,7 +1047,7 @@ static ssize_t mtty_resume_write(struct file *filp, const char __user *buf, goto out_unlock; } -if (copy_from_user ((void *)&migf->data + *pos, buf, len)) { +if (!copy_from_iter_full ((void *)&migf->data + *pos, len, from)) { ret = -EFAULT ; goto out_unlock; }
@@ -1080,7 +1082,7 @@ static ssize_t mtty_resume_write(struct file *filp, const char __user *buf,static const struct file_operations mtty_resume_fops = { .owner =THIS_MODULE , - .write = mtty_resume_write, + .write_iter = mtty_resume_write, .release = mtty_release_migf, .llseek = no_llseek, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 358/437 hwmon: fschmd: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwmon/fschmd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hwmon/fschmd.c +5 -5
@@ -848,11 +848,11 @@ static int watchdog_release(struct inode *inode, struct file *filp)return 0 ; } -static ssize_t watchdog_write (struct file *filp,const char __user *buf, -size_t count,loff_t *offset) +static ssize_t watchdog_write (struct kiocb *iocb,struct iov_iter *from) {int ret; -struct fschmd_data *data = filp->private_data; +struct fschmd_data *data = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);if (count) {if (!nowayout) {
@@ -863,7 +863,7 @@ static ssize_t watchdog_write(struct file *filp, 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' ) data->watchdog_expect_close =1 ;
@@ -951,7 +951,7 @@ static const struct file_operations watchdog_fops = { .llseek = no_llseek, .open = watchdog_open, .release = watchdog_release, - .write = watchdog_write, + .write_iter = watchdog_write, .unlocked_ioctl = watchdog_ioctl, .compat_ioctl = compat_ptr_ioctl, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 359/437 hwmon: w83793: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwmon/w83793.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hwmon/w83793.c +5 -5
@@ -1352,11 +1352,11 @@ static int watchdog_close(struct inode *inode, struct file *filp)return 0 ; } -static ssize_t watchdog_write (struct file *filp,const char __user *buf, -size_t count,loff_t *offset) +static ssize_t watchdog_write (struct kiocb *iocb,struct iov_iter *from) {ssize_t ret; -struct w83793_data *data = filp->private_data; +struct w83793_data *data = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);if (count) {if (!nowayout) {
@@ -1367,7 +1367,7 @@ static ssize_t watchdog_write(struct file *filp, 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' ) data->watchdog_expect_close =1 ;
@@ -1454,7 +1454,7 @@ static const struct file_operations watchdog_fops = { .llseek = no_llseek, .open = watchdog_open, .release = watchdog_close, - .write = watchdog_write, + .write_iter = watchdog_write, .unlocked_ioctl = watchdog_ioctl, .compat_ioctl = compat_ptr_ioctl, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 360/437 hwmon: asus_atk0110: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwmon/asus_atk0110.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/hwmon/asus_atk0110.c +4 -5
@@ -764,13 +764,12 @@ static int atk_debugfs_ggrp_open(struct inode *inode, struct file *file)return nonseekable_open (inode, file); } -static ssize_t atk_debugfs_ggrp_read (struct file *file,char __user *buf, -size_t count,loff_t *pos) +static ssize_t atk_debugfs_ggrp_read (struct kiocb *iocb,struct iov_iter *to) { -char *str = file->private_data; +char *str = iocb->ki_filp->private_data;size_t len =strlen (str); -return simple_read_from_buffer (buf, count, pos, str, len); +return simple_copy_to_iter (str, &iocb->ki_pos, len, to); }static int atk_debugfs_ggrp_release (struct inode *inode,struct file *file)
@@ -780,7 +779,7 @@ static int atk_debugfs_ggrp_release(struct inode *inode, struct file *file) }static const struct file_operations atk_debugfs_ggrp_fops = { - .read = atk_debugfs_ggrp_read, + .read_iter = atk_debugfs_ggrp_read, .open = atk_debugfs_ggrp_open, .release = atk_debugfs_ggrp_release, .llseek = no_llseek,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 361/437 hwmon: mr75203: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwmon/mr75203.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/hwmon/mr75203.c +9 -11
@@ -182,26 +182,24 @@ struct pvt_device {u32 ip_freq; }; -static ssize_t pvt_ts_coeff_j_read (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) +static ssize_t pvt_ts_coeff_j_read (struct kiocb *iocb,struct iov_iter *to) { -struct pvt_device *pvt = file->private_data; +struct pvt_device *pvt = iocb->ki_filp->private_data;unsigned int len;char buf[13 ]; len =scnprintf (buf,sizeof (buf),"%d\n" , pvt->ts_coeff.j); -return simple_read_from_buffer (user_buf, count, ppos, buf, len); +return simple_copy_to_iter (buf, &iocb->ki_pos, len, to); } -static ssize_t pvt_ts_coeff_j_write (struct file *file, -const char __user *user_buf, -size_t count,loff_t *ppos) +static ssize_t pvt_ts_coeff_j_write (struct kiocb *iocb,struct iov_iter *from) { -struct pvt_device *pvt = file->private_data; +struct pvt_device *pvt = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);int ret; - ret =kstrtos32_from_user (user_buf, count,0 , &pvt->ts_coeff.j); + ret =kstrtos32_from_iter (from, count,0 , &pvt->ts_coeff.j);if (ret)return ret;
@@ -209,8 +207,8 @@ static ssize_t pvt_ts_coeff_j_write(struct file *file, }static const struct file_operations pvt_ts_coeff_j_fops = { - .read = pvt_ts_coeff_j_read, - .write = pvt_ts_coeff_j_write, + .read_iter = pvt_ts_coeff_j_read, + .write_iter = pvt_ts_coeff_j_write, .open = simple_open, .owner =THIS_MODULE , .llseek = default_llseek,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 362/437 hwmon: acbel-fsg032: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwmon/pmbus/acbel-fsg032.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/hwmon/pmbus/acbel-fsg032.c +4 -6
@@ -15,10 +15,9 @@#define ACBEL_MFR_FW_REVISION 0xd9 -static ssize_t acbel_fsg032_debugfs_read (struct file *file,char __user *buf,size_t count, -loff_t *ppos) +static ssize_t acbel_fsg032_debugfs_read (struct kiocb *iocb,struct iov_iter *to) { -struct i2c_client *client = file->private_data; +struct i2c_client *client = iocb->ki_filp->private_data;u8 data[I2C_SMBUS_BLOCK_MAX +2 ] = {0 };char out[8 ];int rc;
@@ -28,13 +27,12 @@ static ssize_t acbel_fsg032_debugfs_read(struct file *file, char __user *buf, sireturn rc; rc =snprintf (out,sizeof (out),"%*phN\n" ,min (rc,3 ), data); -return simple_read_from_buffer (buf, count, ppos, out, rc); +return simple_copy_to_iter (out, &iocb->ki_pos, rc, to); }static const struct file_operations acbel_debugfs_ops = { .llseek = noop_llseek, - .read = acbel_fsg032_debugfs_read, - .write =NULL , + .read_iter = acbel_fsg032_debugfs_read, .open = simple_open, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 363/437 hwmon: ibm-cffps: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwmon/pmbus/ibm-cffps.c | 35 +++++++++++++++------------------ 1 file changed, 16 insertions(+), 19 deletions(-)
drivers/hwmon/pmbus/ibm-cffps.c +16 -19
@@ -75,12 +75,12 @@ struct ibm_cffps {#define to_psu (x, y) container_of((x), struct ibm_cffps, debugfs_entries[(y)]) -static ssize_t ibm_cffps_debugfs_read_input_history (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t ibm_cffps_debugfs_read_input_history (struct kiocb *iocb, +struct iov_iter *to) {int rc;u8 cmd =CFFPS_INPUT_HISTORY_CMD ; -struct ibm_cffps *psu = file->private_data; +struct ibm_cffps *psu = iocb->ki_filp->private_data;struct i2c_msg msg[2 ] = { { .addr = psu->client->addr,
@@ -95,7 +95,7 @@ static ssize_t ibm_cffps_debugfs_read_input_history(struct file *file, char __us }, }; -if (!*ppos) { +if (!iocb->ki_pos) { rc =pmbus_lock_interruptible (psu->client);if (rc)return rc;
@@ -116,22 +116,20 @@ static ssize_t ibm_cffps_debugfs_read_input_history(struct file *file, char __usreturn rc; } -return simple_read_from_buffer (buf, count, ppos, - psu->input_history +1 , - psu->input_history[0 ]); +return simple_copy_to_iter (psu->input_history +1 , &iocb->ki_pos, + psu->input_history[0 ], to); }static const struct file_operations ibm_cffps_input_history_fops = { .llseek = noop_llseek, - .read = ibm_cffps_debugfs_read_input_history, + .read_iter = ibm_cffps_debugfs_read_input_history, .open = simple_open, }; -static ssize_t ibm_cffps_debugfs_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t ibm_cffps_debugfs_read (struct kiocb *iocb,struct iov_iter *to) {int i, rc; -int *idxp = file->private_data; +int *idxp = iocb->ki_filp->private_data;int idx = *idxp;struct ibm_cffps *psu =to_psu (idxp, idx);char data[I2C_SMBUS_BLOCK_MAX +2 ] = {0 };
@@ -205,22 +203,21 @@ static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf, data[rc] ='\n' ; rc +=2 ; -return simple_read_from_buffer (buf, count, ppos, data, rc); +return simple_copy_to_iter (data, &iocb->ki_pos, rc, to); } -static ssize_t ibm_cffps_debugfs_write (struct file *file, -const char __user *buf,size_t count, -loff_t *ppos) +static ssize_t ibm_cffps_debugfs_write (struct kiocb *iocb, +struct iov_iter *from) {u8 data;ssize_t rc; -int *idxp = file->private_data; +int *idxp = iocb->ki_filp->private_data;int idx = *idxp;struct ibm_cffps *psu =to_psu (idxp, idx);switch (idx) {case CFFPS_DEBUGFS_ON_OFF_CONFIG : - rc =simple_write_to_buffer (&data,1 , ppos, buf, count); + rc =simple_copy_from_iter (&data, &iocb->ki_pos,1 , from);if (rc <=0 )return rc;
@@ -250,8 +247,8 @@ static ssize_t ibm_cffps_debugfs_write(struct file *file,static const struct file_operations ibm_cffps_fops = { .llseek = noop_llseek, - .read = ibm_cffps_debugfs_read, - .write = ibm_cffps_debugfs_write, + .read_iter = ibm_cffps_debugfs_read, + .write_iter = ibm_cffps_debugfs_write, .open = simple_open, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 364/437 hwmon: max20730: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwmon/pmbus/max20730.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/hwmon/pmbus/max20730.c +4 -6
@@ -104,11 +104,10 @@ struct max20730_debugfs_data { struct max20730_debugfs_data, debugfs_entries[(y)]) #ifdef CONFIG_DEBUG_FS -static ssize_t max20730_debugfs_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t max20730_debugfs_read (struct kiocb *iocb,struct iov_iter *to) {int ret, len; -int *idxp = file->private_data; +int *idxp = iocb->ki_filp->private_data;int idx = *idxp;struct max20730_debugfs_data *psu =to_psu (idxp, idx);const struct pmbus_driver_info *info;
@@ -292,13 +291,12 @@ static ssize_t max20730_debugfs_read(struct file *file, char __user *buf, } len =strlen (result); -return simple_read_from_buffer (buf, count, ppos, result, len); +return simple_copy_to_iter (result, &iocb->ki_pos, len, to); }static const struct file_operations max20730_fops = { .llseek = noop_llseek, - .read = max20730_debugfs_read, - .write =NULL , + .read_iter = max20730_debugfs_read, .open = simple_open, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 365/437 hwmon: pmbus: core: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwmon/pmbus/pmbus_core.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +4 -6
@@ -3303,11 +3303,10 @@ static int pmbus_debugfs_get_status(void *data, u64 *val)DEFINE_DEBUGFS_ATTRIBUTE (pmbus_debugfs_ops_status, pmbus_debugfs_get_status,NULL ,"0x%04llx\n" ); -static ssize_t pmbus_debugfs_mfr_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t pmbus_debugfs_mfr_read (struct kiocb *iocb,struct iov_iter *to) {int rc; -struct pmbus_debugfs_entry *entry = file->private_data; +struct pmbus_debugfs_entry *entry = iocb->ki_filp->private_data;struct pmbus_data *pdata =i2c_get_clientdata (entry->client);char data[I2C_SMBUS_BLOCK_MAX +2 ] = {0 };
@@ -3326,13 +3325,12 @@ static ssize_t pmbus_debugfs_mfr_read(struct file *file, char __user *buf,/* Include newline into the length */ rc +=1 ; -return simple_read_from_buffer (buf, count, ppos, data, rc); +return simple_copy_to_iter (data, &iocb->ki_pos, rc, to); }static const struct file_operations pmbus_debugfs_ops_mfr = { .llseek = noop_llseek, - .read = pmbus_debugfs_mfr_read, - .write =NULL , + .read_iter = pmbus_debugfs_mfr_read, .open = simple_open, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 366/437 hwmon: q54sj108a2: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwmon/pmbus/q54sj108a2.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/hwmon/pmbus/q54sj108a2.c +12 -13
@@ -70,11 +70,10 @@ static struct pmbus_driver_info q54sj108a2_info[] = { }, }; -static ssize_t q54sj108a2_debugfs_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t q54sj108a2_debugfs_read (struct kiocb *iocb,struct iov_iter *to) {int rc; -int *idxp = file->private_data; +int *idxp = iocb->ki_filp->private_data;int idx = *idxp;struct q54sj108a2_data *psu =to_psu (idxp, idx);char data[I2C_SMBUS_BLOCK_MAX +2 ] = {0 };
@@ -169,18 +168,18 @@ static ssize_t q54sj108a2_debugfs_read(struct file *file, char __user *buf, data[rc] ='\n' ; rc +=2 ; -return simple_read_from_buffer (buf, count, ppos, data, rc); +return simple_copy_to_iter (data, &iocb->ki_pos, rc, to); } -static ssize_t q54sj108a2_debugfs_write (struct file *file,const char __user *buf, -size_t count,loff_t *ppos) +static ssize_t q54sj108a2_debugfs_write (struct kiocb *iocb,struct iov_iter *from) {u8 flash_key[4 ];u8 dst_data;ssize_t rc; -int *idxp = file->private_data; +int *idxp = iocb->ki_filp->private_data;int idx = *idxp;struct q54sj108a2_data *psu =to_psu (idxp, idx); +size_t count =iov_iter_count (from); rc =i2c_smbus_write_byte_data (psu->client,PMBUS_WRITE_PROTECT ,0 );if (rc)
@@ -188,7 +187,7 @@ static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *buswitch (idx) {case Q54SJ108A2_DEBUGFS_OPERATION : - rc =kstrtou8_from_user (buf, count,0 , &dst_data); + rc =kstrtou8_from_iter (from, count,0 , &dst_data);if (rc <0 )return rc;
@@ -218,7 +217,7 @@ static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *bubreak ;case Q54SJ108A2_DEBUGFS_VOOV_RESPONSE : - rc =kstrtou8_from_user (buf, count,0 , &dst_data); + rc =kstrtou8_from_iter (from, count,0 , &dst_data);if (rc <0 )return rc;
@@ -228,7 +227,7 @@ static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *bubreak ;case Q54SJ108A2_DEBUGFS_IOOC_RESPONSE : - rc =kstrtou8_from_user (buf, count,0 , &dst_data); + rc =kstrtou8_from_iter (from, count,0 , &dst_data);if (rc <0 )return rc;
@@ -244,7 +243,7 @@ static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *bubreak ;case Q54SJ108A2_DEBUGFS_BLACKBOX_SET_OFFSET : - rc =kstrtou8_from_user (buf, count,0 , &dst_data); + rc =kstrtou8_from_iter (from, count,0 , &dst_data);if (rc <0 )return rc;
@@ -262,8 +261,8 @@ static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *bustatic const struct file_operations q54sj108a2_fops = { .llseek = noop_llseek, - .read = q54sj108a2_debugfs_read, - .write = q54sj108a2_debugfs_write, + .read_iter = q54sj108a2_debugfs_read, + .write_iter = q54sj108a2_debugfs_write, .open = simple_open, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 367/437 hwmon: ucd9000: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwmon/pmbus/ucd9000.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/hwmon/pmbus/ucd9000.c +5 -6
@@ -471,11 +471,10 @@ static int ucd9000_debugfs_show_mfr_status_bit(void *data, u64 *val)DEFINE_DEBUGFS_ATTRIBUTE (ucd9000_debugfs_mfr_status_bit, ucd9000_debugfs_show_mfr_status_bit,NULL ,"%1lld\n" ); -static ssize_t ucd9000_debugfs_read_mfr_status (struct file *file, -char __user *buf,size_t count, -loff_t *ppos) +static ssize_t ucd9000_debugfs_read_mfr_status (struct kiocb *iocb, +struct iov_iter *to) { -struct i2c_client *client = file->private_data; +struct i2c_client *client = iocb->ki_filp->private_data;u8 buffer[I2C_SMBUS_BLOCK_MAX ];char str[(I2C_SMBUS_BLOCK_MAX *2 ) +2 ];char *res;
@@ -489,12 +488,12 @@ static ssize_t ucd9000_debugfs_read_mfr_status(struct file *file, *res++ ='\n' ; *res =0 ; -return simple_read_from_buffer (buf, count, ppos, str, res - str); +return simple_copy_to_iter (str, &iocb->ki_pos, res - str, to); }static const struct file_operations ucd9000_debugfs_show_mfr_status_fops = { .llseek = noop_llseek, - .read = ucd9000_debugfs_read_mfr_status, + .read_iter = ucd9000_debugfs_read_mfr_status, .open = simple_open, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 368/437 hwmon: pt5161l: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwmon/pt5161l.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
drivers/hwmon/pt5161l.c +15 -16
@@ -493,10 +493,10 @@ static const struct hwmon_chip_info pt5161l_chip_info = { .info = pt5161l_info, }; -static ssize_t pt5161l_debugfs_read_fw_ver (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t pt5161l_debugfs_read_fw_ver (struct kiocb *iocb, +struct iov_iter *to) { -struct pt5161l_data *data = file->private_data; +struct pt5161l_data *data = iocb->ki_filp->private_data;int ret;char ver[32 ];
@@ -509,19 +509,18 @@ static ssize_t pt5161l_debugfs_read_fw_ver(struct file *file, char __user *buf, ret =snprintf (ver,sizeof (ver),"%u.%u.%u\n" , data->fw_ver.major, data->fw_ver.minor, data->fw_ver.build); -return simple_read_from_buffer (buf, count, ppos, ver, ret); +return simple_copy_to_iter (ver, &iocb->ki_pos, ret, to); }static const struct file_operations pt5161l_debugfs_ops_fw_ver = { - .read = pt5161l_debugfs_read_fw_ver, + .read_iter = pt5161l_debugfs_read_fw_ver, .open = simple_open, }; -static ssize_t pt5161l_debugfs_read_fw_load_sts (struct file *file, -char __user *buf,size_t count, -loff_t *ppos) +static ssize_t pt5161l_debugfs_read_fw_load_sts (struct kiocb *iocb, +struct iov_iter *to) { -struct pt5161l_data *data = file->private_data; +struct pt5161l_data *data = iocb->ki_filp->private_data;int ret;bool status = false;char health[16 ];
@@ -535,18 +534,18 @@ static ssize_t pt5161l_debugfs_read_fw_load_sts(struct file *file, ret =snprintf (health,sizeof (health),"%s\n" , status ?"normal" :"abnormal" ); -return simple_read_from_buffer (buf, count, ppos, health, ret); +return simple_copy_to_iter (health, &iocb->ki_pos, ret, to); }static const struct file_operations pt5161l_debugfs_ops_fw_load_sts = { - .read = pt5161l_debugfs_read_fw_load_sts, + .read_iter = pt5161l_debugfs_read_fw_load_sts, .open = simple_open, }; -static ssize_t pt5161l_debugfs_read_hb_sts (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t pt5161l_debugfs_read_hb_sts (struct kiocb *iocb, +struct iov_iter *to) { -struct pt5161l_data *data = file->private_data; +struct pt5161l_data *data = iocb->ki_filp->private_data;int ret;bool status = false;char health[16 ];
@@ -560,11 +559,11 @@ static ssize_t pt5161l_debugfs_read_hb_sts(struct file *file, char __user *buf, ret =snprintf (health,sizeof (health),"%s\n" , status ?"normal" :"abnormal" ); -return simple_read_from_buffer (buf, count, ppos, health, ret); +return simple_copy_to_iter (health, &iocb->ki_pos, ret, to); }static const struct file_operations pt5161l_debugfs_ops_hb_sts = { - .read = pt5161l_debugfs_read_hb_sts, + .read_iter = pt5161l_debugfs_read_hb_sts, .open = simple_open, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 369/437 drivers/mmc: convert to read/write iterators
In reply to Jens Axboe--- 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(-)
drivers/mmc/core/block.c +4 -6
@@ -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, };
drivers/mmc/core/debugfs.c +5 -6
@@ -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, };
drivers/mmc/core/mmc_test.c +6 -6
@@ -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, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 370/437 drivers/most: convert to read/write iterators
In reply to Jens Axboe--- drivers/most/most_cdev.c | 50 ++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 30 deletions(-)
drivers/most/most_cdev.c +20 -30
@@ -174,24 +174,22 @@ static int comp_close(struct inode *inode, struct file *filp)/** * comp_write - implements the syscall to write to the device -* @filp: file pointer -* @buf: pointer to user buffer -* @count: number of bytes to write -* @offset: offset from where to start writing +* @iocb: metadata for IO +* @from: pointer to user buffer */ -static ssize_t comp_write (struct file *filp,const char __user *buf, -size_t count,loff_t *offset) +static ssize_t comp_write (struct kiocb *iocb,struct iov_iter *from) {int ret; -size_t to_copy, left; +size_t to_copy;struct mbo *mbo =NULL ; -struct comp_channel *c = filp->private_data; +struct comp_channel *c = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);mutex_lock (&c->io_mutex);while (c->dev && !ch_get_mbo (c, &mbo)) {mutex_unlock (&c->io_mutex); -if ((filp->f_flags &O_NONBLOCK )) +if (iocb->ki_filp->f_flags &O_NONBLOCK )return -EAGAIN ;if (wait_event_interruptible (c->wq,ch_has_mbo (c) || !c->dev))return -ERESTARTSYS ;
@@ -204,13 +202,13 @@ static ssize_t comp_write(struct file *filp, const char __user *buf, } to_copy =min (count, c->cfg->buffer_size - c->mbo_offs); - left =copy_from_user (mbo->virt_address + c->mbo_offs, buf, to_copy); -if (left == to_copy) { + ret =copy_from_iter (mbo->virt_address + c->mbo_offs, to_copy, from); +if (ret != to_copy) { ret = -EFAULT ; goto unlock; } - c->mbo_offs += to_copy - left; + c->mbo_offs += ret;if (c->mbo_offs >= c->cfg->buffer_size || c->cfg->data_type ==MOST_CH_CONTROL || c->cfg->data_type ==MOST_CH_ASYNC ) {
@@ -219,8 +217,6 @@ static ssize_t comp_write(struct file *filp, const char __user *buf, c->mbo_offs =0 ;most_submit_mbo (mbo); } - - ret = to_copy - left; unlock:mutex_unlock (&c->io_mutex);return ret;
@@ -228,22 +224,20 @@ static ssize_t comp_write(struct file *filp, const char __user *buf,/** * comp_read - implements the syscall to read from the device -* @filp: file pointer -* @buf: pointer to user buffer -* @count: number of bytes to read -* @offset: offset from where to start reading +* @iocb: metadata for IO +* @to: pointer to user buffer */ -static ssize_t -comp_read (struct file *filp,char __user *buf,size_t count,loff_t *offset) +static ssize_t comp_read (struct kiocb *iocb,struct iov_iter *to) { -size_t to_copy, not_copied, copied; +size_t to_copy, copied;struct mbo *mbo =NULL ; -struct comp_channel *c = filp->private_data; +struct comp_channel *c = iocb->ki_filp->private_data; +size_t count =iov_iter_count (to);mutex_lock (&c->io_mutex);while (c->dev && !kfifo_peek (&c->fifo, &mbo)) {mutex_unlock (&c->io_mutex); -if (filp->f_flags &O_NONBLOCK ) +if (iocb->ki_filp->f_flags &O_NONBLOCK )return -EAGAIN ; if (wait_event_interruptible(c->wq, (!kfifo_is_empty(&c->fifo) ||
@@ -262,11 +256,7 @@ comp_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) count, mbo->processed_length - c->mbo_offs); - not_copied =copy_to_user (buf, - mbo->virt_address + c->mbo_offs, - to_copy); - - copied = to_copy - not_copied; + copied =copy_to_iter (mbo->virt_address + c->mbo_offs, to_copy, to); c->mbo_offs += copied;if (c->mbo_offs >= mbo->processed_length) {
@@ -302,8 +292,8 @@ static __poll_t comp_poll(struct file *filp, poll_table *wait)*/ static const struct file_operations channel_fops = { .owner =THIS_MODULE , - .read = comp_read, - .write = comp_write, + .read_iter = comp_read, + .write_iter = comp_write, .open = comp_open, .release = comp_close, .poll = comp_poll,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 371/437 drivers/ntb: convert to read/write iterators
In reply to Jens Axboe--- drivers/ntb/hw/amd/ntb_hw_amd.c | 10 +- drivers/ntb/hw/idt/ntb_hw_idt.c | 29 ++- drivers/ntb/hw/intel/ntb_hw_gen1.c | 21 +- drivers/ntb/hw/intel/ntb_hw_gen3.c | 8 +- drivers/ntb/hw/intel/ntb_hw_gen3.h | 3 +- drivers/ntb/hw/intel/ntb_hw_gen4.c | 8 +- drivers/ntb/hw/intel/ntb_hw_gen4.h | 5 +- drivers/ntb/ntb_transport.c | 9 +- drivers/ntb/test/ntb_perf.c | 49 +++-- drivers/ntb/test/ntb_tool.c | 307 +++++++++++++---------------- 10 files changed, 203 insertions(+), 246 deletions(-)
drivers/ntb/hw/amd/ntb_hw_amd.c +5 -5
@@ -835,8 +835,7 @@ static void ndev_deinit_isr(struct amd_ntb_dev *ndev) } } -static ssize_t ndev_debugfs_read (struct file *filp,char __user *ubuf, -size_t count,loff_t *offp) +static ssize_t ndev_debugfs_read (struct kiocb *iocb,struct iov_iter *to) {struct amd_ntb_dev *ndev;void __iomem *mmio;
@@ -844,8 +843,9 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,size_t buf_size;ssize_t ret, off;union {u64 v64;u32 v32;u16 v16; } u; +size_t count =iov_iter_count (to); - ndev = filp->private_data; + ndev = iocb->ki_filp->private_data; mmio = ndev->self_mmio; buf_size =min (count,0x800ul );
@@ -927,7 +927,7 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf, off +=scnprintf (buf + off, buf_size - off,"LMT45 -\t\t\t%#018llx\n" , u.v64); - ret =simple_read_from_buffer (ubuf, count, offp, buf, off); + ret =simple_copy_to_iter (buf, &iocb->ki_pos, off, to);kfree (buf);return ret; }
@@ -1299,7 +1299,7 @@ static void amd_ntb_pci_shutdown(struct pci_dev *pdev)static const struct file_operations amd_ntb_debugfs_info = { .owner =THIS_MODULE , .open = simple_open, - .read = ndev_debugfs_read, + .read_iter = ndev_debugfs_read, };static const struct ntb_dev_data dev_data[] = {
drivers/ntb/hw/idt/ntb_hw_idt.c +13 -16
@@ -2312,18 +2312,6 @@ static void idt_unregister_device(struct idt_ntb_dev *ndev)*============================================================================= */ -static ssize_t idt_dbgfs_info_read (struct file *filp,char __user *ubuf, -size_t count,loff_t *offp); - -/* -* Driver DebugFS info file operations -*/ -static const struct file_operations idt_dbgfs_info_ops = { - .owner =THIS_MODULE , - .open = simple_open, - .read = idt_dbgfs_info_read -}; -/* * idt_dbgfs_info_read() - DebugFS read info node callback * @file: File node descriptor.
@@ -2331,10 +2319,10 @@ static const struct file_operations idt_dbgfs_info_ops = {* @count: Size of the buffer * @offp: Offset within the buffer */ -static ssize_t idt_dbgfs_info_read (struct file *filp,char __user *ubuf, -size_t count,loff_t *offp) +static ssize_t idt_dbgfs_info_read (struct kiocb *iocb,struct iov_iter *to) { -struct idt_ntb_dev *ndev = filp->private_data; +struct idt_ntb_dev *ndev = iocb->ki_filp->private_data; +size_t count =iov_iter_count (to);unsigned char idx, pidx, cnt;unsigned long irqflags, mdeg;ssize_t ret =0 , off =0 ;
@@ -2492,12 +2480,21 @@ static ssize_t idt_dbgfs_info_read(struct file *filp, char __user *ubuf, idt_get_deg(mdeg), idt_get_deg_frac(mdeg));/* Copy the buffer to the User Space */ - ret =simple_read_from_buffer (ubuf, count, offp, strbuf, off); + ret =simple_copy_to_iter (strbuf, &iocb->ki_pos, off, to);kfree (strbuf);return ret; } +/* +* Driver DebugFS info file operations +*/ +static const struct file_operations idt_dbgfs_info_ops = { + .owner =THIS_MODULE , + .open = simple_open, + .read_iter = idt_dbgfs_info_read +}; +/* * idt_init_dbgfs() - initialize DebugFS node * @ndev: IDT NTB hardware driver descriptor
drivers/ntb/hw/intel/ntb_hw_gen1.c +10 -11
@@ -488,8 +488,7 @@ static void ndev_deinit_isr(struct intel_ntb_dev *ndev) } } -static ssize_t ndev_ntb_debugfs_read (struct file *filp,char __user *ubuf, -size_t count,loff_t *offp) +static ssize_t ndev_ntb_debugfs_read (struct kiocb *iocb,struct iov_iter *to) {struct intel_ntb_dev *ndev;struct pci_dev *pdev;
@@ -498,8 +497,9 @@ static ssize_t ndev_ntb_debugfs_read(struct file *filp, char __user *ubuf,size_t buf_size;ssize_t ret, off;union {u64 v64;u32 v32;u16 v16;u8 v8; } u; +size_t count =iov_iter_count (to); - ndev = filp->private_data; + ndev = iocb->ki_filp->private_data; pdev = ndev->ntb.pdev; mmio = ndev->self_mmio;
@@ -749,22 +749,21 @@ static ssize_t ndev_ntb_debugfs_read(struct file *filp, char __user *ubuf, "CORERRSTS -\t\t%#06x\n", u.v32); } - ret =simple_read_from_buffer (ubuf, count, offp, buf, off); + ret =simple_copy_to_iter (buf, &iocb->ki_pos, off, to);kfree (buf);return ret; } -static ssize_t ndev_debugfs_read (struct file *filp,char __user *ubuf, -size_t count,loff_t *offp) +static ssize_t ndev_debugfs_read (struct kiocb *iocb,struct iov_iter *to) { -struct intel_ntb_dev *ndev = filp->private_data; +struct intel_ntb_dev *ndev = iocb->ki_filp->private_data;if (pdev_is_gen1 (ndev->ntb.pdev)) -return ndev_ntb_debugfs_read (filp, ubuf, count, offp); +return ndev_ntb_debugfs_read (iocb, to);else if (pdev_is_gen3 (ndev->ntb.pdev)) -return ndev_ntb3_debugfs_read (filp, ubuf, count, offp); +return ndev_ntb3_debugfs_read (iocb, to);else if (pdev_is_gen4 (ndev->ntb.pdev) ||pdev_is_gen5 (ndev->ntb.pdev)) -return ndev_ntb4_debugfs_read (filp, ubuf, count, offp); +return ndev_ntb4_debugfs_read (iocb, to);return -ENXIO ; }
@@ -2021,7 +2020,7 @@ static const struct ntb_dev_ops intel_ntb_ops = {static const struct file_operations intel_ntb_debugfs_info = { .owner =THIS_MODULE , .open = simple_open, - .read = ndev_debugfs_read, + .read_iter = ndev_debugfs_read, };static const struct pci_device_id intel_ntb_pci_tbl[] = {
drivers/ntb/hw/intel/ntb_hw_gen3.c +4 -4
@@ -252,8 +252,7 @@ int gen3_init_dev(struct intel_ntb_dev *ndev)return gen3_init_isr (ndev); } -ssize_t ndev_ntb3_debugfs_read (struct file *filp,char __user *ubuf, -size_t count,loff_t *offp) +ssize_t ndev_ntb3_debugfs_read (struct kiocb *iocb,struct iov_iter *to) {struct intel_ntb_dev *ndev;void __iomem *mmio;
@@ -261,8 +260,9 @@ ssize_t ndev_ntb3_debugfs_read(struct file *filp, char __user *ubuf,size_t buf_size;ssize_t ret, off;union {u64 v64;u32 v32;u16 v16; } u; +size_t count =iov_iter_count (to); - ndev = filp->private_data; + ndev = iocb->ki_filp->private_data; mmio = ndev->self_mmio; buf_size =min (count,0x800ul );
@@ -410,7 +410,7 @@ ssize_t ndev_ntb3_debugfs_read(struct file *filp, char __user *ubuf, off +=scnprintf (buf + off, buf_size - off,"CORERRSTS -\t\t%#06x\n" , u.v32); - ret =simple_read_from_buffer (ubuf, count, offp, buf, off); + ret =simple_copy_to_iter (buf, &iocb->ki_pos, off, to);kfree (buf);return ret; }
drivers/ntb/hw/intel/ntb_hw_gen3.h +1 -2
@@ -101,8 +101,7 @@ static inline void gen3_db_iowrite(u64 bits, void __iomem *mmio)iowrite64 (bits, mmio); } -ssize_t ndev_ntb3_debugfs_read (struct file *filp,char __user *ubuf, -size_t count,loff_t *offp); +ssize_t ndev_ntb3_debugfs_read (struct kiocb *iocb,struct iov_iter *to);int gen3_init_dev (struct intel_ntb_dev *ndev);int intel_ntb3_link_enable (struct ntb_dev *ntb,enum ntb_speed max_speed,enum ntb_width max_width);
drivers/ntb/hw/intel/ntb_hw_gen4.c +4 -4
@@ -216,8 +216,7 @@ int gen4_init_dev(struct intel_ntb_dev *ndev)return gen4_init_isr (ndev); } -ssize_t ndev_ntb4_debugfs_read (struct file *filp,char __user *ubuf, -size_t count,loff_t *offp) +ssize_t ndev_ntb4_debugfs_read (struct kiocb *iocb,struct iov_iter *to) {struct intel_ntb_dev *ndev;void __iomem *mmio;
@@ -225,8 +224,9 @@ ssize_t ndev_ntb4_debugfs_read(struct file *filp, char __user *ubuf,size_t buf_size;ssize_t ret, off;union {u64 v64;u32 v32;u16 v16; } u; +size_t count =iov_iter_count (to); - ndev = filp->private_data; + ndev = iocb->ki_filp->private_data; mmio = ndev->self_mmio; buf_size =min (count,0x800ul );
@@ -329,7 +329,7 @@ ssize_t ndev_ntb4_debugfs_read(struct file *filp, char __user *ubuf, off +=scnprintf (buf + off, buf_size - off,"CORERRSTS -\t\t%#06x\n" , u.v32); - ret =simple_read_from_buffer (ubuf, count, offp, buf, off); + ret =simple_copy_to_iter (buf, &iocb->ki_pos, off, to);kfree (buf);return ret; }
drivers/ntb/hw/intel/ntb_hw_gen4.h +1 -4
@@ -103,11 +103,8 @@#define NTB_LTR_IDLE_LATSCALE 0x0800/* 1us scale */ #define NTB_LTR_IDLE_REQMNT 0x8000/* snoop req enable */ -ssize_t ndev_ntb4_debugfs_read (struct file *filp,char __user *ubuf, -size_t count,loff_t *offp); +ssize_t ndev_ntb4_debugfs_read (struct kiocb *iocb,struct iov_iter *to);int gen4_init_dev (struct intel_ntb_dev *ndev); -ssize_t ndev_ntb4_debugfs_read (struct file *filp,char __user *ubuf, -size_t count,loff_t *offp);extern const struct ntb_dev_ops intel_ntb4_ops;
drivers/ntb/ntb_transport.c +4 -5
@@ -460,14 +460,13 @@ void ntb_transport_unregister_client(struct ntb_transport_client *drv) }EXPORT_SYMBOL_GPL (ntb_transport_unregister_client); -static ssize_t debugfs_read (struct file *filp,char __user *ubuf,size_t count, -loff_t *offp) +static ssize_t debugfs_read (struct kiocb *iocb,struct iov_iter *to) {struct ntb_transport_qp *qp;char *buf;ssize_t ret, out_offset, out_count; - qp = filp->private_data; + qp = iocb->ki_filp->private_data;if (!qp || !qp->link_is_up)return 0 ;
@@ -548,7 +547,7 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count,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; }
@@ -556,7 +555,7 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count,static const struct file_operations ntb_qp_debugfs_stats = { .owner =THIS_MODULE , .open = simple_open, - .read = debugfs_read, + .read_iter = debugfs_read, }; static void ntb_list_add(spinlock_t *lock, struct list_head *entry,
drivers/ntb/test/ntb_perf.c +23 -26
113 lines not on this page · raw message
drivers/ntb/test/ntb_tool.c +138 -169
684 lines not on this page · raw message
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 372/437 drivers/md: convert bcache to read/write iterators
In reply to Jens Axboe--- drivers/md/bcache/debug.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/md/bcache/debug.c +5 -6
@@ -169,10 +169,10 @@ static bool dump_pred(struct keybuf *buf, struct bkey *k)return true; } -static ssize_t bch_dump_read (struct file *file,char __user *buf, -size_t size,loff_t *ppos) +static ssize_t bch_dump_read (struct kiocb *iocb,struct iov_iter *to) { -struct dump_iterator *i = file->private_data; +struct dump_iterator *i = iocb->ki_filp->private_data; +size_t size =iov_iter_count (to);ssize_t ret =0 ;char kbuf[80 ];
@@ -180,11 +180,10 @@ static ssize_t bch_dump_read(struct file *file, char __user *buf,struct keybuf_key *w;unsigned int bytes =min (i->bytes, size); -if (copy_to_user (buf, i->buf, bytes)) +if (!copy_to_iter_full (i->buf, bytes, to))return -EFAULT ; ret += bytes; - buf += bytes; size -= bytes; i->bytes -= bytes;memmove (i->buf, i->buf + bytes, i->bytes);
@@ -230,7 +229,7 @@ static int bch_dump_release(struct inode *inode, struct file *file)static const struct file_operations cache_set_debug_ops = { .owner =THIS_MODULE , .open = bch_dump_open, - .read = bch_dump_read, + .read_iter = bch_dump_read, .release = bch_dump_release };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 373/437 drivers/remoteproc: convert to read/write iterators
In reply to Jens Axboe--- drivers/remoteproc/remoteproc_cdev.c | 9 ++-- drivers/remoteproc/remoteproc_debugfs.c | 68 +++++++++++-------------- 2 files changed, 36 insertions(+), 41 deletions(-)
drivers/remoteproc/remoteproc_cdev.c +5 -4
@@ -18,16 +18,17 @@#define NUM_RPROC_DEVICES 64static dev_t rproc_major; -static ssize_t rproc_cdev_write (struct file *filp,const char __user *buf,size_t len,loff_t *pos) +static ssize_t rproc_cdev_write (struct kiocb *iocb,struct iov_iter *from) { - struct rproc *rproc = container_of(filp->f_inode->i_cdev, struct rproc, cdev); + struct rproc *rproc = container_of(iocb->ki_filp->f_inode->i_cdev, struct rproc, cdev); +size_t len =iov_iter_count (from);int ret =0 ;char cmd[10 ];if (!len || len >sizeof (cmd))return -EINVAL ; - ret =copy_from_user (cmd, buf, len); + ret = !copy_from_iter_full (cmd, len, from);if (ret)return -EFAULT ;
@@ -89,7 +90,7 @@ static int rproc_cdev_release(struct inode *inode, struct file *filp) }static const struct file_operations rproc_fops = { - .write = rproc_cdev_write, + .write_iter = rproc_cdev_write, .unlocked_ioctl = rproc_device_ioctl, .compat_ioctl = compat_ptr_ioctl, .release = rproc_cdev_release,
drivers/remoteproc/remoteproc_debugfs.c +31 -37
173 lines not on this page · raw message
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 374/437 drivers/thunderbolt: convert to read/write iterators
In reply to Jens Axboe--- drivers/thunderbolt/debugfs.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/thunderbolt/debugfs.c +14 -5
@@ -43,8 +43,8 @@ static const struct file_operations __space ## _fops = { \ .owner = THIS_MODULE, \ .open = __space ## _open, \ .release = single_release, \ - .read = seq_read, \ - .write = __write, \ + .read_iter = seq_read_iter, \ + .write_iter = __write, \ .llseek = seq_lseek, \ }
@@ -52,7 +52,7 @@ static const struct file_operations __space ## _fops = { \ DEBUGFS_ATTR(__space, NULL)#define DEBUGFS_ATTR_RW (__space) \ - DEBUGFS_ATTR(__space, __space ## _write) + DEBUGFS_ATTR(__space, __space ## _write ## _iter)static struct dentry *tb_debugfs_root;
@@ -175,6 +175,7 @@ static ssize_t port_regs_write(struct file *file, const char __user *user_buf,return regs_write (port->sw, port, user_buf, count, ppos); } +FOPS_WRITE_ITER_HELPER (port_regs_write);static ssize_t switch_regs_write (struct file *file,const char __user *user_buf,size_t count,loff_t *ppos)
@@ -184,10 +185,11 @@ static ssize_t switch_regs_write(struct file *file, const char __user *user_buf, return regs_write(sw, NULL, user_buf, count, ppos); } +FOPS_WRITE_ITER_HELPER (switch_regs_write);#define DEBUGFS_MODE 0600#else -#define port_regs_write NULL -#define switch_regs_write NULL +#define port_regs_write_iter NULL +#define switch_regs_write_iter NULL#define DEBUGFS_MODE 0400#endif
@@ -305,6 +307,7 @@ margining_ber_level_write(struct file *file, const char __user *user_buf,return ret <0 ? ret : count; } +FOPS_WRITE_ITER_HELPER (margining_ber_level_write);static void ber_level_show (struct seq_file *s,unsigned int val) {
@@ -445,6 +448,7 @@ margining_lanes_write(struct file *file, const char __user *user_buf,free_page ((unsigned long )buf);return ret <0 ? ret : count; } +FOPS_WRITE_ITER_HELPER (margining_lanes_write);static int margining_lanes_show (struct seq_file *s,void *not_used) {
@@ -518,6 +522,7 @@ static ssize_t margining_mode_write(struct file *file,free_page ((unsigned long )buf);return ret ? ret : count; } +FOPS_WRITE_ITER_HELPER (margining_mode_write);static int margining_mode_show (struct seq_file *s,void *not_used) {
@@ -646,6 +651,7 @@ static ssize_t margining_results_write(struct file *file,mutex_unlock (&tb->lock);return count; } +FOPS_WRITE_ITER_HELPER (margining_results_write);static void voltage_margin_show (struct seq_file *s,const struct tb_margining *margining,u8 val)
@@ -775,6 +781,7 @@ static ssize_t margining_test_write(struct file *file,free_page ((unsigned long )buf);return ret ? ret : count; } +FOPS_WRITE_ITER_HELPER (margining_test_write);static int margining_test_show (struct seq_file *s,void *not_used) {
@@ -843,6 +850,7 @@ static ssize_t margining_margin_write(struct file *file,free_page ((unsigned long )buf);return ret ? ret : count; } +FOPS_WRITE_ITER_HELPER (margining_margin_write);static int margining_margin_show (struct seq_file *s,void *not_used) {
@@ -1089,6 +1097,7 @@ static ssize_t counters_write(struct file *file, const char __user *user_buf,return ret <0 ? ret : count; } +FOPS_WRITE_ITER_HELPER (counters_write); static void cap_show_by_dw(struct seq_file *s, struct tb_switch *sw, struct tb_port *port, unsigned int cap,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 375/437 drivers/vfio: convert to read/write iterators
In reply to Jens Axboe--- .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 31 ++++++++++-------- drivers/vfio/pci/mlx5/main.c | 6 ++-- drivers/vfio/pci/pds/lm.c | 32 +++++++++---------- drivers/vfio/vfio_main.c | 6 ++-- 4 files changed, 41 insertions(+), 34 deletions(-)
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +17 -14
@@ -676,18 +676,20 @@ static int hisi_acc_vf_release_file(struct inode *inode, struct file *filp)return 0 ; } -static ssize_t hisi_acc_vf_resume_write (struct file *filp,const char __user *buf, -size_t len,loff_t *pos) +static ssize_t hisi_acc_vf_resume_write (struct kiocb *iocb, +struct iov_iter *from) { -struct hisi_acc_vf_migration_file *migf = filp->private_data; +struct hisi_acc_vf_migration_file *migf = iocb->ki_filp->private_data;u8 *vf_data = (u8 *)&migf->vf_data; +size_t len =iov_iter_count (from);loff_t requested_length;ssize_t done =0 ; +loff_t *pos;int ret; -if (pos) +if (iocb->ki_pos)return -ESPIPE ; - pos = &filp->f_pos; + pos = &iocb->ki_filp->f_pos;if (*pos <0 ||check_add_overflow ((loff_t )len, *pos, &requested_length))
@@ -702,7 +704,7 @@ static ssize_t hisi_acc_vf_resume_write(struct file *filp, const char __user *bu goto out_unlock; } - ret =copy_from_user (vf_data + *pos, buf, len); + ret = !copy_from_iter_full (vf_data + *pos, len, from);if (ret) { done = -EFAULT ; goto out_unlock;
@@ -721,7 +723,7 @@ static ssize_t hisi_acc_vf_resume_write(struct file *filp, const char __user *bustatic const struct file_operations hisi_acc_vf_resume_fops = { .owner =THIS_MODULE , - .write = hisi_acc_vf_resume_write, + .write_iter = hisi_acc_vf_resume_write, .release = hisi_acc_vf_release_file, .llseek = no_llseek, };
@@ -800,16 +802,17 @@ static long hisi_acc_vf_precopy_ioctl(struct file *filp,return ret; } -static ssize_t hisi_acc_vf_save_read (struct file *filp,char __user *buf,size_t len, -loff_t *pos) +static ssize_t hisi_acc_vf_save_read (struct kiocb *iocb,struct iov_iter *to) { -struct hisi_acc_vf_migration_file *migf = filp->private_data; +struct hisi_acc_vf_migration_file *migf = iocb->ki_filp->private_data; +size_t len =iov_iter_count (to);ssize_t done =0 ; +loff_t *pos;int ret; -if (pos) +if (iocb->ki_pos)return -ESPIPE ; - pos = &filp->f_pos; + pos = &iocb->ki_filp->f_pos;mutex_lock (&migf->lock);if (*pos > migf->total_length) {
@@ -826,7 +829,7 @@ static ssize_t hisi_acc_vf_save_read(struct file *filp, char __user *buf, size_tif (len) {u8 *vf_data = (u8 *)&migf->vf_data; - ret =copy_to_user (buf, vf_data + *pos, len); + ret = !copy_to_iter_full (vf_data + *pos, len, to);if (ret) { done = -EFAULT ; goto out_unlock;
@@ -841,7 +844,7 @@ static ssize_t hisi_acc_vf_save_read(struct file *filp, char __user *buf, size_tstatic const struct file_operations hisi_acc_vf_save_fops = { .owner =THIS_MODULE , - .read = hisi_acc_vf_save_read, + .read_iter = hisi_acc_vf_save_read, .unlocked_ioctl = hisi_acc_vf_precopy_ioctl, .compat_ioctl = compat_ptr_ioctl, .release = hisi_acc_vf_release_file,
drivers/vfio/pci/mlx5/main.c +4 -2
@@ -263,6 +263,7 @@ static ssize_t mlx5vf_save_read(struct file *filp, char __user *buf, size_t len,mutex_unlock (&migf->lock);return done; } +FOPS_READ_ITER_HELPER (mlx5vf_save_read);static __poll_t mlx5vf_save_poll (struct file *filp,struct poll_table_struct *wait)
@@ -582,7 +583,7 @@ static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd,static const struct file_operations mlx5vf_save_fops = { .owner =THIS_MODULE , - .read = mlx5vf_save_read, + .read_iter = mlx5vf_save_read_iter, .poll = mlx5vf_save_poll, .unlocked_ioctl = mlx5vf_precopy_ioctl, .compat_ioctl = compat_ptr_ioctl,
@@ -995,10 +996,11 @@ static ssize_t mlx5vf_resume_write(struct file *filp, const char __user *buf,mlx5vf_state_mutex_unlock (migf->mvdev);return ret ? ret : done; } +FOPS_WRITE_ITER_HELPER (mlx5vf_resume_write);static const struct file_operations mlx5vf_resume_fops = { .owner =THIS_MODULE , - .write = mlx5vf_resume_write, + .write_iter = mlx5vf_resume_write_iter, .release = mlx5vf_release_file, .llseek = no_llseek, };
drivers/vfio/pci/pds/lm.c +16 -16
@@ -174,15 +174,16 @@ static int pds_vfio_release_file(struct inode *inode, struct file *filp)return 0 ; } -static ssize_t pds_vfio_save_read (struct file *filp,char __user *buf, -size_t len,loff_t *pos) +static ssize_t pds_vfio_save_read (struct kiocb *iocb,struct iov_iter *to) { -struct pds_vfio_lm_file *lm_file = filp->private_data; +struct pds_vfio_lm_file *lm_file = iocb->ki_filp->private_data; +size_t len =iov_iter_count (to);ssize_t done =0 ; +loff_t *pos; -if (pos) +if (iocb->ki_pos)return -ESPIPE ; - pos = &filp->f_pos; + pos = &iocb->ki_filp->f_pos;mutex_lock (&lm_file->lock);
@@ -214,7 +215,7 @@ static ssize_t pds_vfio_save_read(struct file *filp, char __user *buf, page_len =min_t (size_t, len,PAGE_SIZE - page_offset); from_buff =kmap_local_page (page); - err =copy_to_user (buf, from_buff + page_offset, page_len); + err = !copy_to_iter_full (from_buff + page_offset, page_len, to);kunmap_local (from_buff);if (err) { done = -EFAULT ;
@@ -223,7 +224,6 @@ static ssize_t pds_vfio_save_read(struct file *filp, char __user *buf, *pos += page_len; len -= page_len; done += page_len; - buf += page_len; } out_unlock:
@@ -233,7 +233,7 @@ static ssize_t pds_vfio_save_read(struct file *filp, char __user *buf,static const struct file_operations pds_vfio_save_fops = { .owner =THIS_MODULE , - .read = pds_vfio_save_read, + .read_iter = pds_vfio_save_read, .release = pds_vfio_release_file, .llseek = no_llseek, };
@@ -273,17 +273,18 @@ static int pds_vfio_get_save_file(struct pds_vfio_pci_device *pds_vfio)return 0 ; } -static ssize_t pds_vfio_restore_write (struct file *filp,const char __user *buf, -size_t len,loff_t *pos) +static ssize_t pds_vfio_restore_write (struct kiocb *iocb,struct iov_iter *from) { -struct pds_vfio_lm_file *lm_file = filp->private_data; +struct pds_vfio_lm_file *lm_file = iocb->ki_filp->private_data; +size_t len =iov_iter_count (from);loff_t requested_length;ssize_t done =0 ; +loff_t *pos; -if (pos) +if (iocb->ki_pos)return -ESPIPE ; - pos = &filp->f_pos; + pos = &iocb->ki_filp->f_pos;if (*pos <0 ||check_add_overflow ((loff_t )len, *pos, &requested_length))
@@ -313,7 +314,7 @@ static ssize_t pds_vfio_restore_write(struct file *filp, const char __user *buf, page_len =min_t (size_t, len,PAGE_SIZE - page_offset); to_buff =kmap_local_page (page); - err =copy_from_user (to_buff + page_offset, buf, page_len); + err = !copy_from_iter_full (to_buff + page_offset, page_len, from);kunmap_local (to_buff);if (err) { done = -EFAULT ;
@@ -322,7 +323,6 @@ static ssize_t pds_vfio_restore_write(struct file *filp, const char __user *buf, *pos += page_len; len -= page_len; done += page_len; - buf += page_len; lm_file->size += page_len; } out_unlock:
@@ -332,7 +332,7 @@ static ssize_t pds_vfio_restore_write(struct file *filp, const char __user *buf,static const struct file_operations pds_vfio_restore_fops = { .owner =THIS_MODULE , - .write = pds_vfio_restore_write, + .write_iter = pds_vfio_restore_write, .release = pds_vfio_release_file, .llseek = no_llseek, };
drivers/vfio/vfio_main.c +4 -2
@@ -1277,6 +1277,7 @@ static ssize_t vfio_device_fops_read(struct file *filep, char __user *buf,return device->ops->read (device, buf, count, ppos); } +FOPS_READ_ITER_HELPER (vfio_device_fops_read); static ssize_t vfio_device_fops_write(struct file *filep, const char __user *buf,
@@ -1294,6 +1295,7 @@ static ssize_t vfio_device_fops_write(struct file *filep,return device->ops->write (device, buf, count, ppos); } +FOPS_WRITE_ITER_HELPER (vfio_device_fops_write);static int vfio_device_fops_mmap (struct file *filep,struct vm_area_struct *vma) {
@@ -1314,8 +1316,8 @@ const struct file_operations vfio_device_fops = { .owner = THIS_MODULE, .open = vfio_device_fops_cdev_open, .release = vfio_device_fops_release, - .read = vfio_device_fops_read, - .write = vfio_device_fops_write, + .read_iter = vfio_device_fops_read_iter, + .write_iter = vfio_device_fops_write_iter, .unlocked_ioctl = vfio_device_fops_unl_ioctl, .compat_ioctl = compat_ptr_ioctl, .mmap = vfio_device_fops_mmap,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 376/437 drivers/fsi: convert to read/write iterators
In reply to Jens Axboe--- drivers/fsi/fsi-core.c | 28 ++++++++++++++-------------- drivers/fsi/fsi-occ.c | 20 ++++++++++---------- drivers/fsi/fsi-sbefifo.c | 6 ++++-- drivers/fsi/fsi-scom.c | 24 ++++++++++++------------ drivers/fsi/i2cr-scom.c | 23 ++++++++++++----------- 5 files changed, 52 insertions(+), 49 deletions(-)
drivers/fsi/fsi-core.c +14 -14
@@ -657,12 +657,12 @@ static struct device_node *fsi_slave_find_of_node(struct fsi_master *master,return NULL ; } -static ssize_t cfam_read (struct file *filep,char __user *buf,size_t count, -loff_t *offset) +static ssize_t cfam_read (struct kiocb *iocb,struct iov_iter *to) { -struct fsi_slave *slave = filep->private_data; +struct fsi_slave *slave = iocb->ki_filp->private_data; +size_t count =iov_iter_count (to);size_t total_len, read_len; -loff_t off = *offset; +loff_t off = iocb->ki_pos;ssize_t rc;if (off <0 )
@@ -680,7 +680,7 @@ static ssize_t cfam_read(struct file *filep, char __user *buf, size_t count, rc =fsi_slave_read (slave, off, &data, read_len);if (rc) goto fail; - rc =copy_to_user (buf + total_len, &data, read_len); + rc = !copy_to_iter_full (&data, read_len, to);if (rc) { rc = -EFAULT ; goto fail;
@@ -689,16 +689,16 @@ static ssize_t cfam_read(struct file *filep, char __user *buf, size_t count, } rc = count; fail: - *offset = off; + iocb->ki_pos = off;return rc; } -static ssize_t cfam_write (struct file *filep,const char __user *buf, -size_t count,loff_t *offset) +static ssize_t cfam_write (struct kiocb *iocb,struct iov_iter *from) { -struct fsi_slave *slave = filep->private_data; +struct fsi_slave *slave = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);size_t total_len, write_len; -loff_t off = *offset; +loff_t off = iocb->ki_pos;ssize_t rc;
@@ -714,7 +714,7 @@ static ssize_t cfam_write(struct file *filep, const char __user *buf, write_len =min_t (size_t, count,4 ); write_len -= off &0x3 ; - rc =copy_from_user (&data, buf + total_len, write_len); + rc = !copy_from_iter_full (&data, write_len, from);if (rc) { rc = -EFAULT ; goto fail;
@@ -726,7 +726,7 @@ static ssize_t cfam_write(struct file *filep, const char __user *buf, } rc = count; fail: - *offset = off; + iocb->ki_pos = off;return rc; }
@@ -758,8 +758,8 @@ static const struct file_operations cfam_fops = { .owner = THIS_MODULE, .open = cfam_open, .llseek = cfam_llseek, - .read = cfam_read, - .write = cfam_write, + .read_iter = cfam_read, + .write_iter = cfam_write, }; static ssize_t send_term_store(struct device *dev,
drivers/fsi/fsi-occ.c +10 -10
@@ -104,10 +104,10 @@ static int occ_open(struct inode *inode, struct file *file)return 0 ; } -static ssize_t occ_read (struct file *file,char __user *buf,size_t len, -loff_t *offset) +static ssize_t occ_read (struct kiocb *iocb,struct iov_iter *to) { -struct occ_client *client = file->private_data; +struct occ_client *client = iocb->ki_filp->private_data; +size_t len =iov_iter_count (to);ssize_t rc =0 ;if (!client)
@@ -126,7 +126,7 @@ static ssize_t occ_read(struct file *file, char __user *buf, size_t len,/* Grab how much data we have to read */ rc =min (len, client->data_size - client->read_offset); -if (copy_to_user (buf, client->buffer + client->read_offset, rc)) +if (!copy_to_iter_full (client->buffer + client->read_offset, rc, to)) rc = -EFAULT ;else client->read_offset += rc;
@@ -137,10 +137,10 @@ static ssize_t occ_read(struct file *file, char __user *buf, size_t len,return rc; } -static ssize_t occ_write (struct file *file,const char __user *buf, -size_t len,loff_t *offset) +static ssize_t occ_write (struct kiocb *iocb,struct iov_iter *from) { -struct occ_client *client = file->private_data; +struct occ_client *client = iocb->ki_filp->private_data; +size_t len =iov_iter_count (from);size_t rlen, data_length;ssize_t rc;u8 *cmd;
@@ -163,7 +163,7 @@ static ssize_t occ_write(struct file *file, const char __user *buf,* bytes 1-2: data length (msb first) * bytes 3-n: data */ -if (copy_from_user (&cmd[1 ], buf, len)) { +if (!copy_from_iter_full (&cmd[1 ], len, from)) { rc = -EFAULT ; goto done; }
@@ -209,8 +209,8 @@ static int occ_release(struct inode *inode, struct file *file)static const struct file_operations occ_fops = { .owner =THIS_MODULE , .open = occ_open, - .read = occ_read, - .write = occ_write, + .read_iter = occ_read, + .write_iter = occ_write, .release = occ_release, };
drivers/fsi/fsi-sbefifo.c +4 -2
@@ -864,6 +864,7 @@ static ssize_t sbefifo_user_read(struct file *file, char __user *buf,mutex_unlock (&user->file_lock);return rc; } +FOPS_READ_ITER_HELPER (sbefifo_user_read);static ssize_t sbefifo_user_write (struct file *file,const char __user *buf,size_t len,loff_t *offset)
@@ -927,6 +928,7 @@ static ssize_t sbefifo_user_write(struct file *file, const char __user *buf,/* And that's it, we'll issue the command on a read */ return rc; } +FOPS_WRITE_ITER_HELPER (sbefifo_user_write);static int sbefifo_user_release (struct inode *inode,struct file *file) {
@@ -1004,8 +1006,8 @@ static long sbefifo_user_ioctl(struct file *file, unsigned int cmd, unsigned lonstatic const struct file_operations sbefifo_fops = { .owner =THIS_MODULE , .open = sbefifo_user_open, - .read = sbefifo_user_read, - .write = sbefifo_user_write, + .read_iter = sbefifo_user_read_iter, + .write_iter = sbefifo_user_write_iter, .release = sbefifo_user_release, .unlocked_ioctl = sbefifo_user_ioctl, };
drivers/fsi/fsi-scom.c +12 -12
@@ -310,11 +310,11 @@ static int get_scom(struct scom_device *scom, uint64_t *value, >> SCOM_STATUS_PIB_RESP_SHIFT); } -static ssize_t scom_read (struct file *filep,char __user *buf,size_t len, -loff_t *offset) +static ssize_t scom_read (struct kiocb *iocb,struct iov_iter *to) { -struct scom_device *scom = filep->private_data; +struct scom_device *scom = iocb->ki_filp->private_data;struct device *dev = &scom->fsi_dev->dev; +size_t len =iov_iter_count (to);uint64_t val;int rc;
@@ -325,32 +325,32 @@ static ssize_t scom_read(struct file *filep, char __user *buf, size_t len,if (scom->dead) rc = -ENODEV ;else - rc =get_scom (scom, &val, *offset); + rc =get_scom (scom, &val, iocb->ki_pos);mutex_unlock (&scom->lock);if (rc) {dev_dbg (dev,"get_scom fail:%d\n" , rc);return rc; } - rc =copy_to_user (buf, &val, len); + rc = !copy_to_iter_full (&val, len, to);if (rc)dev_dbg (dev,"copy to user failed:%d\n" , rc);return rc ? rc : len; } -static ssize_t scom_write (struct file *filep,const char __user *buf, -size_t len,loff_t *offset) +static ssize_t scom_write (struct kiocb *iocb,struct iov_iter *from) {int rc; -struct scom_device *scom = filep->private_data; +struct scom_device *scom = iocb->ki_filp->private_data;struct device *dev = &scom->fsi_dev->dev; +size_t len =iov_iter_count (from);uint64_t val;if (len !=sizeof (uint64_t ))return -EINVAL ; - rc =copy_from_user (&val, buf, len); + rc = !copy_from_iter_full (&val, len, from);if (rc) {dev_dbg (dev,"copy from user failed:%d\n" , rc);return -EINVAL ;
@@ -360,7 +360,7 @@ static ssize_t scom_write(struct file *filep, const char __user *buf,if (scom->dead) rc = -ENODEV ;else - rc =put_scom (scom, val, *offset); + rc =put_scom (scom, val, iocb->ki_pos);mutex_unlock (&scom->lock);if (rc) {dev_dbg (dev,"put_scom failed with:%d\n" , rc);
@@ -514,8 +514,8 @@ static const struct file_operations scom_fops = { .owner = THIS_MODULE, .open = scom_open, .llseek = scom_llseek, - .read = scom_read, - .write = scom_write, + .read_iter = scom_read, + .write_iter = scom_write, .unlocked_ioctl = scom_ioctl, };
drivers/fsi/i2cr-scom.c +12 -11
@@ -32,41 +32,42 @@ static loff_t i2cr_scom_llseek(struct file *file, loff_t offset, int whence)return offset; } -static ssize_t i2cr_scom_read (struct file *filep,char __user *buf,size_t len,loff_t *offset) +static ssize_t i2cr_scom_read (struct kiocb *iocb,struct iov_iter *to) { -struct i2cr_scom *scom = filep->private_data; +struct i2cr_scom *scom = iocb->ki_filp->private_data; +size_t len =iov_iter_count (to);u64 data;int ret;if (len !=sizeof (data))return -EINVAL ; - ret =fsi_master_i2cr_read (scom->i2cr, (u32)*offset, &data); + ret =fsi_master_i2cr_read (scom->i2cr, (u32 )iocb->ki_pos, &data);if (ret)return ret; - ret =copy_to_user (buf, &data, len); + ret = !copy_to_iter_full (&data, len, to);if (ret)return ret;return len; } -static ssize_t i2cr_scom_write (struct file *filep,const char __user *buf,size_t len, -loff_t *offset) +static ssize_t i2cr_scom_write (struct kiocb *iocb,struct iov_iter *from) { -struct i2cr_scom *scom = filep->private_data; +struct i2cr_scom *scom = iocb->ki_filp->private_data; +size_t len =iov_iter_count (from);u64 data;int ret;if (len !=sizeof (data))return -EINVAL ; - ret =copy_from_user (&data, buf, len); + ret = !copy_from_iter (&data, len, from);if (ret)return ret; - ret =fsi_master_i2cr_write (scom->i2cr, (u32)*offset, data); + ret =fsi_master_i2cr_write (scom->i2cr, (u32 )iocb->ki_pos, data);if (ret)return ret;
@@ -77,8 +78,8 @@ static const struct file_operations i2cr_scom_fops = { .owner = THIS_MODULE, .open = simple_open, .llseek = i2cr_scom_llseek, - .read = i2cr_scom_read, - .write = i2cr_scom_write, + .read_iter = i2cr_scom_read, + .write_iter = i2cr_scom_write, };static int i2cr_scom_probe (struct device *dev)
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 377/437 iio: convert to read/write iterators
In reply to Jens Axboe--- drivers/iio/iio_core.h | 7 +++---- drivers/iio/industrialio-buffer.c | 20 +++++++++--------- drivers/iio/industrialio-core.c | 34 +++++++++++++++---------------- drivers/iio/industrialio-event.c | 3 ++- 4 files changed, 31 insertions(+), 33 deletions(-)
drivers/iio/iio_core.h +3 -4
@@ -11,6 +11,7 @@#define _IIO_CORE_H_#include <linux/kernel.h> #include <linux/device.h> +#include <linux/fs.h> struct iio_buffer ;struct iio_chan_spec ;
@@ -63,10 +64,8 @@ struct poll_table_struct;__poll_t iio_buffer_poll_wrapper (struct file *filp,struct poll_table_struct *wait); -ssize_t iio_buffer_read_wrapper (struct file *filp,char __user *buf, -size_t n,loff_t *f_ps); -ssize_t iio_buffer_write_wrapper (struct file *filp,const char __user *buf, -size_t n,loff_t *f_ps); +ssize_t iio_buffer_read_wrapper (struct kiocb *iocb,struct iov_iter *to); +ssize_t iio_buffer_write_wrapper (struct kiocb *iocb,struct iov_iter *from);int iio_buffers_alloc_sysfs_and_mask (struct iio_dev *indio_dev);void iio_buffers_free_sysfs_and_mask (struct iio_dev *indio_dev);
drivers/iio/industrialio-buffer.c +10 -10
@@ -163,6 +163,7 @@ static ssize_t iio_buffer_read(struct file *filp, char __user *buf,return ret; } +FOPS_READ_ITER_HELPER (iio_buffer_read);static size_t iio_buffer_space_available (struct iio_buffer *buf) {
@@ -225,6 +226,7 @@ static ssize_t iio_buffer_write(struct file *filp, const char __user *buf,return ret <0 ? ret : written; } +FOPS_WRITE_ITER_HELPER (iio_buffer_write);/** * iio_buffer_poll() - poll the buffer to find out if it has data
@@ -261,30 +263,28 @@ static __poll_t iio_buffer_poll(struct file *filp,return 0 ; } -ssize_t iio_buffer_read_wrapper (struct file *filp,char __user *buf, -size_t n,loff_t *f_ps) +ssize_t iio_buffer_read_wrapper (struct kiocb *iocb,struct iov_iter *to) { -struct iio_dev_buffer_pair *ib = filp->private_data; +struct iio_dev_buffer_pair *ib = iocb->ki_filp->private_data;struct iio_buffer *rb = ib->buffer;/* check if buffer was opened through new API */ if (test_bit (IIO_BUSY_BIT_POS , &rb->flags))return -EBUSY ; -return iio_buffer_read (filp, buf, n, f_ps); +return vfs_read_iter (iocb, to, iio_buffer_read); } -ssize_t iio_buffer_write_wrapper (struct file *filp,const char __user *buf, -size_t n,loff_t *f_ps) +ssize_t iio_buffer_write_wrapper (struct kiocb *iocb,struct iov_iter *from) { -struct iio_dev_buffer_pair *ib = filp->private_data; +struct iio_dev_buffer_pair *ib = iocb->ki_filp->private_data;struct iio_buffer *rb = ib->buffer;/* check if buffer was opened through new API */ if (test_bit (IIO_BUSY_BIT_POS , &rb->flags))return -EBUSY ; -return iio_buffer_write (filp, buf, n, f_ps); +return vfs_write_iter (iocb, from, iio_buffer_write); } __poll_t iio_buffer_poll_wrapper(struct file *filp,
@@ -1537,8 +1537,8 @@ static int iio_buffer_chrdev_release(struct inode *inode, struct file *filep)static const struct file_operations iio_buffer_chrdev_fileops = { .owner =THIS_MODULE , .llseek = noop_llseek, - .read = iio_buffer_read, - .write = iio_buffer_write, + .read_iter = iio_buffer_read_iter, + .write_iter = iio_buffer_write_iter, .poll = iio_buffer_poll, .release = iio_buffer_chrdev_release, };
drivers/iio/industrialio-core.c +16 -18
@@ -369,18 +369,17 @@ static void __exit iio_exit(void) }#if defined(CONFIG_DEBUG_FS ) -static ssize_t iio_debugfs_read_reg (struct file *file,char __user *userbuf, -size_t count,loff_t *ppos) +static ssize_t iio_debugfs_read_reg (struct kiocb *iocb,struct iov_iter *to) { -struct iio_dev *indio_dev = file->private_data; +struct iio_dev *indio_dev = iocb->ki_filp->private_data;struct iio_dev_opaque *iio_dev_opaque =to_iio_dev_opaque (indio_dev);unsigned int val =0 ;int ret; -if (*ppos >0 ) -return simple_read_from_buffer (userbuf, count, ppos, - iio_dev_opaque->read_buf, - iio_dev_opaque->read_buf_len); +if (iocb->ki_pos >0 ) +return simple_copy_to_iter (iio_dev_opaque->read_buf, + &iocb->ki_pos, + iio_dev_opaque->read_buf_len, to); ret = indio_dev->info->debugfs_reg_access(indio_dev, iio_dev_opaque->cached_reg_addr,
@@ -394,22 +393,21 @@ static ssize_t iio_debugfs_read_reg(struct file *file, char __user *userbuf,sizeof (iio_dev_opaque->read_buf), "0x%X\n", val); -return simple_read_from_buffer (userbuf, count, ppos, - iio_dev_opaque->read_buf, - iio_dev_opaque->read_buf_len); +return simple_copy_to_iter (iio_dev_opaque->read_buf, &iocb->ki_pos, + iio_dev_opaque->read_buf_len, to); } -static ssize_t iio_debugfs_write_reg (struct file *file, -const char __user *userbuf,size_t count,loff_t *ppos) +static ssize_t iio_debugfs_write_reg (struct kiocb *iocb,struct iov_iter *from) { -struct iio_dev *indio_dev = file->private_data; +struct iio_dev *indio_dev = iocb->ki_filp->private_data;struct iio_dev_opaque *iio_dev_opaque =to_iio_dev_opaque (indio_dev); +size_t count =iov_iter_count (from);unsigned int reg, val;char buf[80 ];int ret; count =min (count,sizeof (buf) -1 ); -if (copy_from_user (buf, userbuf, count)) +if (!copy_from_iter_full (buf, count, from))return -EFAULT ; buf[count] =0 ;
@@ -439,8 +437,8 @@ static ssize_t iio_debugfs_write_reg(struct file *file,static const struct file_operations iio_debugfs_reg_fops = { .open = simple_open, - .read = iio_debugfs_read_reg, - .write = iio_debugfs_write_reg, + .read_iter = iio_debugfs_read_reg, + .write_iter = iio_debugfs_write_reg, };static void iio_device_unregister_debugfs (struct iio_dev *indio_dev)
@@ -1839,8 +1837,8 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)static const struct file_operations iio_buffer_fileops = { .owner =THIS_MODULE , .llseek = noop_llseek, - .read = iio_buffer_read_outer_addr, - .write = iio_buffer_write_outer_addr, + .read_iter = iio_buffer_read_outer_addr, + .write_iter = iio_buffer_write_outer_addr, .poll = iio_buffer_poll_addr, .unlocked_ioctl = iio_ioctl, .compat_ioctl = compat_ptr_ioctl,
drivers/iio/industrialio-event.c +2 -1
@@ -167,6 +167,7 @@ static ssize_t iio_event_chrdev_read(struct file *filep,return copied; } +FOPS_READ_ITER_HELPER (iio_event_chrdev_read);static int iio_event_chrdev_release (struct inode *inode,struct file *filep) {
@@ -182,7 +183,7 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep) }static const struct file_operations iio_event_chrdev_fileops = { - .read = iio_event_chrdev_read, + .read_iter = iio_event_chrdev_read_iter, .poll = iio_event_poll, .release = iio_event_chrdev_release, .owner =THIS_MODULE ,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 378/437 iio: adis16400: convert to read/write iterators
In reply to Jens Axboe--- drivers/iio/imu/adis16400.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/iio/imu/adis16400.c +5 -5
@@ -204,10 +204,10 @@ enum {#ifdef CONFIG_DEBUG_FS -static ssize_t adis16400_show_serial_number (struct file *file, -char __user *userbuf,size_t count,loff_t *ppos) +static ssize_t adis16400_show_serial_number (struct kiocb *iocb, +struct iov_iter *to) { -struct adis16400_state *st = file->private_data; +struct adis16400_state *st = iocb->ki_filp->private_data;u16 lot1, lot2, serial_number;char buf[16 ];size_t len;
@@ -229,12 +229,12 @@ static ssize_t adis16400_show_serial_number(struct file *file, len =snprintf (buf,sizeof (buf),"%.4x-%.4x-%.4x\n" , lot1, lot2, serial_number); -return simple_read_from_buffer (userbuf, count, ppos, buf, len); +return simple_copy_to_iter (buf, &iocb->ki_pos, len, to); }static const struct file_operations adis16400_serial_number_fops = { .open = simple_open, - .read = adis16400_show_serial_number, + .read_iter = adis16400_show_serial_number, .llseek = default_llseek, .owner =THIS_MODULE , };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 379/437 iio: adis16475: convert to read/write iterators
In reply to Jens Axboe--- drivers/iio/imu/adis16475.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/iio/imu/adis16475.c +10 -12
@@ -142,11 +142,10 @@ MODULE_PARM_DESC(low_rate_allow, "Allow IMU rates below the minimum advisable when external clk is used in SCALED mode (default: N)");#ifdef CONFIG_DEBUG_FS -static ssize_t adis16475_show_firmware_revision (struct file *file, -char __user *userbuf, -size_t count,loff_t *ppos) +static ssize_t adis16475_show_firmware_revision (struct kiocb *iocb, +struct iov_iter *to) { -struct adis16475 *st = file->private_data; +struct adis16475 *st = iocb->ki_filp->private_data;char buf[7 ];size_t len;u16 rev;
@@ -158,21 +157,20 @@ static ssize_t adis16475_show_firmware_revision(struct file *file, len =scnprintf (buf,sizeof (buf),"%x.%x\n" , rev >>8 , rev &0xff ); -return simple_read_from_buffer (userbuf, count, ppos, buf, len); +return simple_copy_to_iter (buf, &iocb->ki_pos, len, to); }static const struct file_operations adis16475_firmware_revision_fops = { .open = simple_open, - .read = adis16475_show_firmware_revision, + .read_iter = adis16475_show_firmware_revision, .llseek = default_llseek, .owner =THIS_MODULE , }; -static ssize_t adis16475_show_firmware_date (struct file *file, -char __user *userbuf, -size_t count,loff_t *ppos) +static ssize_t adis16475_show_firmware_date (struct kiocb *iocb, +struct iov_iter *to) { -struct adis16475 *st = file->private_data; +struct adis16475 *st = iocb->ki_filp->private_data;u16 md, year;char buf[12 ];size_t len;
@@ -189,12 +187,12 @@ static ssize_t adis16475_show_firmware_date(struct file *file, len =snprintf (buf,sizeof (buf),"%.2x-%.2x-%.4x\n" , md >>8 , md &0xff , year); -return simple_read_from_buffer (userbuf, count, ppos, buf, len); +return simple_copy_to_iter (buf, &iocb->ki_pos, len, to); }static const struct file_operations adis16475_firmware_date_fops = { .open = simple_open, - .read = adis16475_show_firmware_date, + .read_iter = adis16475_show_firmware_date, .llseek = default_llseek, .owner =THIS_MODULE , };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 380/437 iio: adis16480: convert to read/write iterators
In reply to Jens Axboe--- drivers/iio/imu/adis16480.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/iio/imu/adis16480.c +10 -10
@@ -188,10 +188,10 @@ MODULE_PARM_DESC(low_rate_allow,#ifdef CONFIG_DEBUG_FS -static ssize_t adis16480_show_firmware_revision (struct file *file, -char __user *userbuf,size_t count,loff_t *ppos) +static ssize_t adis16480_show_firmware_revision (struct kiocb *iocb, +struct iov_iter *to) { -struct adis16480 *adis16480 = file->private_data; +struct adis16480 *adis16480 = iocb->ki_filp->private_data;char buf[7 ];size_t len;u16 rev;
@@ -203,20 +203,20 @@ static ssize_t adis16480_show_firmware_revision(struct file *file, len =scnprintf (buf,sizeof (buf),"%x.%x\n" , rev >>8 , rev &0xff ); -return simple_read_from_buffer (userbuf, count, ppos, buf, len); +return simple_copy_to_iter (buf, &iocb->ki_pos, len, to); }static const struct file_operations adis16480_firmware_revision_fops = { .open = simple_open, - .read = adis16480_show_firmware_revision, + .read_iter = adis16480_show_firmware_revision, .llseek = default_llseek, .owner =THIS_MODULE , }; -static ssize_t adis16480_show_firmware_date (struct file *file, -char __user *userbuf,size_t count,loff_t *ppos) +static ssize_t adis16480_show_firmware_date (struct kiocb *iocb, +struct iov_iter *to) { -struct adis16480 *adis16480 = file->private_data; +struct adis16480 *adis16480 = iocb->ki_filp->private_data;u16 md, year;char buf[12 ];size_t len;
@@ -233,12 +233,12 @@ static ssize_t adis16480_show_firmware_date(struct file *file, len =snprintf (buf,sizeof (buf),"%.2x-%.2x-%.4x\n" , md >>8 , md &0xff , year); -return simple_read_from_buffer (userbuf, count, ppos, buf, len); +return simple_copy_to_iter (buf, &iocb->ki_pos, len, to); }static const struct file_operations adis16480_firmware_date_fops = { .open = simple_open, - .read = adis16480_show_firmware_date, + .read_iter = adis16480_show_firmware_date, .llseek = default_llseek, .owner =THIS_MODULE , };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 381/437 iio: bno055: convert to read/write iterators
In reply to Jens Axboe--- drivers/iio/imu/bno055/bno055.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/iio/imu/bno055/bno055.c +4 -5
@@ -1269,10 +1269,9 @@ static int bno055_debugfs_reg_access(struct iio_dev *iio_dev, unsigned int reg,return regmap_write (priv->regmap, reg, writeval); } -static ssize_t bno055_show_fw_version (struct file *file,char __user *userbuf, -size_t count,loff_t *ppos) +static ssize_t bno055_show_fw_version (struct kiocb *iocb,struct iov_iter *to) { -struct bno055_priv *priv = file->private_data; +struct bno055_priv *priv = iocb->ki_filp->private_data;int rev, ver;char *buf;int ret;
@@ -1289,7 +1288,7 @@ static ssize_t bno055_show_fw_version(struct file *file, char __user *userbuf,if (!buf)return -ENOMEM ; - ret =simple_read_from_buffer (userbuf, count, ppos, buf,strlen (buf)); + ret =simple_copy_to_iter (buf, &iocb->ki_pos,strlen (buf), to);kfree (buf);return ret;
@@ -1297,7 +1296,7 @@ static ssize_t bno055_show_fw_version(struct file *file, char __user *userbuf,static const struct file_operations bno055_fw_version_ops = { .open = simple_open, - .read = bno055_show_fw_version, + .read_iter = bno055_show_fw_version, .llseek = default_llseek, .owner =THIS_MODULE , };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 382/437 iio: gyro/adis16136: convert to read/write iterators
In reply to Jens Axboe--- drivers/iio/gyro/adis16136.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/iio/gyro/adis16136.c +4 -5
@@ -65,10 +65,9 @@ struct adis16136 {#ifdef CONFIG_DEBUG_FS -static ssize_t adis16136_show_serial (struct file *file, -char __user *userbuf,size_t count,loff_t *ppos) +static ssize_t adis16136_show_serial (struct kiocb *iocb,struct iov_iter *to) { -struct adis16136 *adis16136 = file->private_data; +struct adis16136 *adis16136 = iocb->ki_filp->private_data;uint16_t lot1, lot2, lot3, serial;char buf[20 ];size_t len;
@@ -94,12 +93,12 @@ static ssize_t adis16136_show_serial(struct file *file, len =snprintf (buf,sizeof (buf),"%.4x%.4x%.4x-%.4x\n" , lot1, lot2, lot3, serial); -return simple_read_from_buffer (userbuf, count, ppos, buf, len); +return simple_copy_to_iter (buf, &iocb->ki_pos, len, to); }static const struct file_operations adis16136_serial_fops = { .open = simple_open, - .read = adis16136_show_serial, + .read_iter = adis16136_show_serial, .llseek = default_llseek, .owner =THIS_MODULE , };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 383/437 intel_th: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwtracing/intel_th/msu.c | 46 +++++++++++++++----------------- 1 file changed, 22 insertions(+), 24 deletions(-)
drivers/hwtracing/intel_th/msu.c +22 -24
@@ -1429,8 +1429,8 @@ static struct page *msc_buffer_get_page(struct msc *msc, unsigned long pgoff)* @offset: running offset */ struct msc_win_to_user_struct { -char __user *buf; -unsigned long offset; +struct iov_iter *to; +struct kiocb *iocb; };/**
@@ -1442,11 +1442,11 @@ struct msc_win_to_user_struct {static unsigned long msc_win_to_user (void *data,void *src,size_t len) {struct msc_win_to_user_struct *u = data; -unsigned long ret; - - ret =copy_to_user (u->buf + u->offset, src, len); - u->offset += len - ret; +size_t ret; + ret =copy_to_iter (src, len, u->to); +if (ret >0 ) + u->iocb->ki_pos += ret;return ret; }
@@ -1483,20 +1483,20 @@ static int intel_th_msc_release(struct inode *inode, struct file *file)return 0 ; } -static ssize_t -msc_single_to_user (struct msc *msc,char __user *buf,loff_t off,size_t len) +static ssize_t msc_single_to_user (struct msc *msc,struct kiocb *iocb, +struct iov_iter *to) { +size_t len =iov_iter_count (to);unsigned long size = msc->nr_pages <<PAGE_SHIFT , rem = len; -unsigned long start = off, tocopy =0 ; +unsigned long start = iocb->ki_pos, tocopy =0 ;if (msc->single_wrap) { start += msc->single_sz;if (start < size) { tocopy =min (rem, size - start); -if (copy_to_user (buf, msc->base + start, tocopy)) +if (!copy_to_iter_full (msc->base + start, tocopy, to))return -EFAULT ; - buf += tocopy; rem -= tocopy; start += tocopy; }
@@ -1504,7 +1504,7 @@ msc_single_to_user(struct msc *msc, char __user *buf, loff_t off, size_t len) start &= size -1 ;if (rem) { tocopy =min (rem, msc->single_sz - start); -if (copy_to_user (buf, msc->base + start, tocopy)) +if (!copy_to_iter_full (msc->base + start, tocopy, to))return -EFAULT ; rem -= tocopy;
@@ -1513,19 +1513,19 @@ msc_single_to_user(struct msc *msc, char __user *buf, loff_t off, size_t len)return len - rem; } -if (copy_to_user (buf, msc->base + start, rem)) +if (!copy_to_iter_full (msc->base + start, rem, to))return -EFAULT ;return len; } -static ssize_t intel_th_msc_read (struct file *file,char __user *buf, -size_t len,loff_t *ppos) +static ssize_t intel_th_msc_read (struct kiocb *iocb,struct iov_iter *to) { -struct msc_iter *iter = file->private_data; +struct msc_iter *iter = iocb->ki_filp->private_data;struct msc *msc = iter->msc; +size_t len =iov_iter_count (to);size_t size; -loff_t off = *ppos; +loff_t off = iocb->ki_pos;ssize_t ret =0 ;if (!atomic_inc_unless_negative (&msc->user_count))
@@ -1546,18 +1546,16 @@ static ssize_t intel_th_msc_read(struct file *file, char __user *buf, len = size - off;if (msc->mode ==MSC_MODE_SINGLE ) { - ret =msc_single_to_user (msc, buf, off, len); + ret =msc_single_to_user (msc, iocb, to);if (ret >=0 ) - *ppos += ret; + iocb->ki_pos += ret; }else if (msc->mode ==MSC_MODE_MULTI ) {struct msc_win_to_user_struct u = { - .buf = buf, - .offset =0 , + .to = to, + .iocb = iocb, }; ret =msc_buffer_iterate (iter, len, &u, msc_win_to_user); -if (ret >=0 ) - *ppos = iter->offset; }else { ret = -EINVAL ; }
@@ -1667,7 +1665,7 @@ static int intel_th_msc_mmap(struct file *file, struct vm_area_struct *vma)static const struct file_operations intel_th_msc_fops = { .open = intel_th_msc_open, .release = intel_th_msc_release, - .read = intel_th_msc_read, + .read_iter = intel_th_msc_read, .mmap = intel_th_msc_mmap, .llseek = no_llseek, .owner =THIS_MODULE ,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 384/437 stm class: convert to read/write iterators
In reply to Jens Axboe--- drivers/hwtracing/stm/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hwtracing/stm/core.c +5 -5
@@ -615,11 +615,11 @@ stm_write(struct stm_device *stm, struct stm_output *output,return err; } -static ssize_t stm_char_write (struct file *file,const char __user *buf, -size_t count,loff_t *ppos) +static ssize_t stm_char_write (struct kiocb *iocb,struct iov_iter *from) { -struct stm_file *stmf = file->private_data; +struct stm_file *stmf = iocb->ki_filp->private_data;struct stm_device *stm = stmf->stm; +size_t count =iov_iter_count (from);char *kbuf;int err;
@@ -649,7 +649,7 @@ static ssize_t stm_char_write(struct file *file, const char __user *buf,if (!kbuf)return -ENOMEM ; - err =copy_from_user (kbuf, buf, count); + err = !copy_from_iter_full (kbuf, count, from);if (err) {kfree (kbuf);return -EFAULT ;
@@ -835,7 +835,7 @@ stm_char_ioctl(struct file *file, unsigned int cmd, unsigned long arg)static const struct file_operations stm_fops = { .open = stm_char_open, .release = stm_char_release, - .write = stm_char_write, + .write_iter = stm_char_write, .mmap = stm_char_mmap, .unlocked_ioctl = stm_char_ioctl, .compat_ioctl = compat_ptr_ioctl,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 385/437 speakup: convert to read/write iterators
In reply to Jens Axboe--- drivers/accessibility/speakup/devsynth.c | 27 +++++------- drivers/accessibility/speakup/speakup_soft.c | 46 +++++++++----------- 2 files changed, 31 insertions(+), 42 deletions(-)
drivers/accessibility/speakup/devsynth.c +11 -16
@@ -11,11 +11,10 @@ static int synth_registered, synthu_registered;static int dev_opened;/* Latin1 version */ -static ssize_t speakup_file_write (struct file *fp,const char __user *buffer, -size_t nbytes,loff_t *ppos) +static ssize_t speakup_file_write (struct kiocb *iocb,struct iov_iter *from) { +size_t nbytes =iov_iter_count (from);size_t count = nbytes; -const char __user *ptr = buffer;size_t bytes;unsigned long flags;u_char buf[256 ];
@@ -24,10 +23,9 @@ static ssize_t speakup_file_write(struct file *fp, const char __user *buffer,return -ENODEV ;while (count >0 ) { bytes =min (count,sizeof (buf)); -if (copy_from_user (buf, ptr, bytes)) +if (!copy_from_iter_full (buf, bytes, from))return -EFAULT ; count -= bytes; - ptr += bytes;spin_lock_irqsave (&speakup_info.spinlock, flags);synth_write (buf, bytes);spin_unlock_irqrestore (&speakup_info.spinlock, flags);
@@ -36,11 +34,10 @@ static ssize_t speakup_file_write(struct file *fp, const char __user *buffer, }/* UTF-8 version */ -static ssize_t speakup_file_writeu (struct file *fp,const char __user *buffer, -size_t nbytes,loff_t *ppos) +static ssize_t speakup_file_writeu (struct kiocb *iocb,struct iov_iter *from) { +size_t nbytes =iov_iter_count (from);size_t count = nbytes, want; -const char __user *ptr = buffer;size_t bytes;unsigned long flags;unsigned char buf[256 ];
@@ -54,7 +51,7 @@ static ssize_t speakup_file_writeu(struct file *fp, const char __user *buffer,while (count >= want) {/* Copy some UTF-8 piece from userland */ bytes =min (count,sizeof (buf)); -if (copy_from_user (buf, ptr, bytes)) +if (!copy_from_iter_full (buf, bytes, from))return -EFAULT ;/* Convert to u16 */
@@ -112,7 +109,6 @@ static ssize_t speakup_file_writeu(struct file *fp, const char __user *buffer, } count -= bytes; - ptr += bytes;/* And speak this up */ if (out) {
@@ -127,8 +123,7 @@ static ssize_t speakup_file_writeu(struct file *fp, const char __user *buffer,return (ssize_t )(nbytes - count); } -static ssize_t speakup_file_read (struct file *fp,char __user *buf, -size_t nbytes,loff_t *ppos) +static ssize_t speakup_file_read (struct kiocb *iocb,struct iov_iter *to) {return 0 ; }
@@ -149,15 +144,15 @@ static int speakup_file_release(struct inode *ip, struct file *fp) }static const struct file_operations synth_fops = { - .read = speakup_file_read, - .write = speakup_file_write, + .read_iter = speakup_file_read, + .write_iter = speakup_file_write, .open = speakup_file_open, .release = speakup_file_release, };static const struct file_operations synthu_fops = { - .read = speakup_file_read, - .write = speakup_file_writeu, + .read_iter = speakup_file_read, + .write_iter = speakup_file_writeu, .open = speakup_file_open, .release = speakup_file_release, };
drivers/accessibility/speakup/speakup_soft.c +20 -26
135 lines not on this page · raw message
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 386/437 EDAC/versal: convert to read/write iterators
In reply to Jens Axboe--- drivers/edac/versal_edac.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/edac/versal_edac.c +10 -10
@@ -781,16 +781,16 @@ static void xddr_inject_data_ce_store(struct mem_ctl_info *mci, u8 ce_bitpos)* * Upon doing a read to the address the errors are injected. */ -static ssize_t inject_data_ce_store (struct file *file,const char __user *data, -size_t count,loff_t *ppos) +static ssize_t inject_data_ce_store (struct kiocb *iocb,struct iov_iter *from) { -struct device *dev = file->private_data; +struct device *dev = iocb->ki_filp->private_data;struct mem_ctl_info *mci =to_mci (dev);struct edac_priv *priv = mci->pvt_info; +size_t count =iov_iter_count (from);u8 ce_bitpos;int ret; - ret =kstrtou8_from_user (data, count,0 , &ce_bitpos); + ret =kstrtou8_from_iter (from, count,0 , &ce_bitpos);if (ret)return ret;
@@ -812,7 +812,7 @@ static ssize_t inject_data_ce_store(struct file *file, const char __user *data,static const struct file_operations xddr_inject_ce_fops = { .open = simple_open, - .write = inject_data_ce_store, + .write_iter = inject_data_ce_store, .llseek = generic_file_llseek, };
@@ -845,19 +845,19 @@ static void xddr_inject_data_ue_store(struct mem_ctl_info *mci, u32 val0, u32 va* * Upon doing a read to the address the errors are injected. */ -static ssize_t inject_data_ue_store (struct file *file,const char __user *data, -size_t count,loff_t *ppos) +static ssize_t inject_data_ue_store (struct kiocb *iocb,struct iov_iter *from) { -struct device *dev = file->private_data; +struct device *dev = iocb->ki_filp->private_data;struct mem_ctl_info *mci =to_mci (dev);struct edac_priv *priv = mci->pvt_info; +size_t count =iov_iter_count (from);char buf[6 ], *pbuf, *token[2 ];u32 val0 =0 , val1 =0 ;u8 len, ue0, ue1;int i, ret; len =min_t (size_t, count,sizeof (buf)); -if (copy_from_user (buf, data, len)) +if (!copy_from_iter_full (from, len, from))return -EFAULT ; buf[len] ='\0' ;
@@ -903,7 +903,7 @@ static ssize_t inject_data_ue_store(struct file *file, const char __user *data,static const struct file_operations xddr_inject_ue_fops = { .open = simple_open, - .write = inject_data_ue_store, + .write_iter = inject_data_ue_store, .llseek = generic_file_llseek, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 387/437 EDAC/xgene: convert to read/write iterators
In reply to Jens Axboe--- drivers/edac/xgene_edac.c | 43 ++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 23 deletions(-)
drivers/edac/xgene_edac.c +20 -23
@@ -137,11 +137,10 @@ struct xgene_edac_mc_ctx {u32 mcu_id; }; -static ssize_t xgene_edac_mc_err_inject_write (struct file *file, -const char __user *data, -size_t count,loff_t *ppos) +static ssize_t xgene_edac_mc_err_inject_write (struct kiocb *iocb, +struct iov_iter *from) { -struct mem_ctl_info *mci = file->private_data; +struct mem_ctl_info *mci = iocb->ki_filp->private_data;struct xgene_edac_mc_ctx *ctx = mci->pvt_info;int i;
@@ -150,12 +149,12 @@ static ssize_t xgene_edac_mc_err_inject_write(struct file *file,MCU_ESRR_DEMANDUCERR_MASK |MCU_ESRR_CERR_MASK , ctx->mcu_csr + MCUESRRA0 + i * MCU_RANK_STRIDE); } -return count; +return iov_iter_count (from); }static const struct file_operations xgene_edac_mc_debug_inject_fops = { .open = simple_open, - .write = xgene_edac_mc_err_inject_write, + .write_iter = xgene_edac_mc_err_inject_write, .llseek = generic_file_llseek, };
@@ -803,11 +802,10 @@ static void xgene_edac_pmd_hw_ctl(struct edac_device_ctl_info *edac_dev, } } -static ssize_t xgene_edac_pmd_l1_inject_ctrl_write (struct file *file, -const char __user *data, -size_t count,loff_t *ppos) +static ssize_t xgene_edac_pmd_l1_inject_ctrl_write (struct kiocb *iocb, +struct iov_iter *from) { -struct edac_device_ctl_info *edac_dev = file->private_data; +struct edac_device_ctl_info *edac_dev = iocb->ki_filp->private_data;struct xgene_edac_pmd_ctx *ctx = edac_dev->pvt_info;void __iomem *cpux_pg_f;int i;
@@ -826,16 +824,16 @@ static ssize_t xgene_edac_pmd_l1_inject_ctrl_write(struct file *file,MEMERR_CPU_MMUESR_CERR_MASK , cpux_pg_f + MEMERR_CPU_MMUESRA_PAGE_OFFSET); } -return count; +return iov_iter_count (from); } -static ssize_t xgene_edac_pmd_l2_inject_ctrl_write (struct file *file, -const char __user *data, -size_t count,loff_t *ppos) +static ssize_t xgene_edac_pmd_l2_inject_ctrl_write (struct kiocb *iocb, +struct iov_iter *from) { -struct edac_device_ctl_info *edac_dev = file->private_data; +struct edac_device_ctl_info *edac_dev = iocb->ki_filp->private_data;struct xgene_edac_pmd_ctx *ctx = edac_dev->pvt_info;void __iomem *pg_e = ctx->pmd_csr +CPU_MEMERR_L2C_PAGE ; +size_t count =iov_iter_count (from); writel(MEMERR_L2C_L2ESR_MULTUCERR_MASK | MEMERR_L2C_L2ESR_MULTICERR_MASK |
@@ -848,11 +846,11 @@ static ssize_t xgene_edac_pmd_l2_inject_ctrl_write(struct file *file,static const struct file_operations xgene_edac_pmd_debug_inject_fops[] = { { .open = simple_open, - .write = xgene_edac_pmd_l1_inject_ctrl_write, + .write_iter = xgene_edac_pmd_l1_inject_ctrl_write, .llseek = generic_file_llseek, }, { .open = simple_open, - .write = xgene_edac_pmd_l2_inject_ctrl_write, + .write_iter = xgene_edac_pmd_l2_inject_ctrl_write, .llseek = generic_file_llseek, }, { } };
@@ -1143,21 +1141,20 @@ static void xgene_edac_l3_hw_init(struct edac_device_ctl_info *edac_dev, } } -static ssize_t xgene_edac_l3_inject_ctrl_write (struct file *file, -const char __user *data, -size_t count,loff_t *ppos) +static ssize_t xgene_edac_l3_inject_ctrl_write (struct kiocb *iocb, +struct iov_iter *from) { -struct edac_device_ctl_info *edac_dev = file->private_data; +struct edac_device_ctl_info *edac_dev = iocb->ki_filp->private_data;struct xgene_edac_dev_ctx *ctx = edac_dev->pvt_info;/* Generate all errors */ writel (0xFFFFFFFF , ctx->dev_csr +L3C_ESR ); -return count; +return iov_iter_count (from); }static const struct file_operations xgene_edac_l3_debug_inject_fops = { .open = simple_open, - .write = xgene_edac_l3_inject_ctrl_write, + .write_iter = xgene_edac_l3_inject_ctrl_write, .llseek = generic_file_llseek };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 388/437 EDAC/zynqmp: convert to read/write iterators
In reply to Jens Axboe--- drivers/edac/zynqmp_edac.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
drivers/edac/zynqmp_edac.c +10 -16
@@ -247,17 +247,14 @@ static void write_fault_count(struct edac_priv *priv)* - Write the Correctable Error bit position value: * echo <bit_pos val> > /sys/kernel/debug/edac/ocm/inject_ce_bitpos */ -static ssize_t inject_ce_write (struct file *file,const char __user *data, -size_t count,loff_t *ppos) +static ssize_t inject_ce_write (struct kiocb *iocb,struct iov_iter *from) { -struct edac_device_ctl_info *edac_dev = file->private_data; +struct edac_device_ctl_info *edac_dev = iocb->ki_filp->private_data;struct edac_priv *priv = edac_dev->pvt_info; +size_t count =iov_iter_count (from);int ret; -if (!data) -return -EFAULT ; - - ret =kstrtou8_from_user (data, count,0 , &priv->ce_bitpos); + ret =kstrtou8_from_iter (from, count,0 , &priv->ce_bitpos);if (ret)return ret;
@@ -280,7 +277,7 @@ static ssize_t inject_ce_write(struct file *file, const char __user *data,static const struct file_operations inject_ce_fops = { .open = simple_open, - .write = inject_ce_write, + .write_iter = inject_ce_write, .llseek = generic_file_llseek, };
@@ -291,21 +288,18 @@ static const struct file_operations inject_ce_fops = {* - Write the Uncorrectable Error bit position values: * echo <bit_pos0 val>,<bit_pos1 val> > /sys/kernel/debug/edac/ocm/inject_ue_bitpos */ -static ssize_t inject_ue_write (struct file *file,const char __user *data, -size_t count,loff_t *ppos) +static ssize_t inject_ue_write (struct kiocb *iocb,struct iov_iter *from) { -struct edac_device_ctl_info *edac_dev = file->private_data; +struct edac_device_ctl_info *edac_dev = iocb->ki_filp->private_data;struct edac_priv *priv = edac_dev->pvt_info;char buf[6 ], *pbuf, *token[2 ]; +size_t count =iov_iter_count (from);u64 ue_bitpos;int i, ret;u8 len; -if (!data) -return -EFAULT ; - len =min_t (size_t, count,sizeof (buf)); -if (copy_from_user (buf, data, len)) +if (!copy_from_iter_full (from, len, from))return -EFAULT ; buf[len] ='\0' ;
@@ -342,7 +336,7 @@ static ssize_t inject_ue_write(struct file *file, const char __user *data,static const struct file_operations inject_ue_fops = { .open = simple_open, - .write = inject_ue_write, + .write_iter = inject_ue_write, .llseek = generic_file_llseek, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 389/437 EDAC/thunderx: convert to read/write iterators
In reply to Jens Axboe--- drivers/edac/thunderx_edac.c | 71 +++++++++++++++++------------------- 1 file changed, 33 insertions(+), 38 deletions(-)
drivers/edac/thunderx_edac.c +33 -38
@@ -219,33 +219,32 @@ static struct debugfs_entry debugfs_##_name = { \ .mode = VERIFY_OCTAL_PERMISSIONS(_mode), \ .fops = { \ .open = simple_open, \ - .write = _write, \ - .read = _read, \ + .write_iter = _write, \ + .read_iter = _read, \ .llseek = generic_file_llseek, \ }, \ }#define DEBUGFS_FIELD_ATTR (_type, _field) \ -static ssize_t thunderx_##_type##_##_field##_read(struct file *file, \ - char __user *data, \ - size_t count, loff_t *ppos) \ +static ssize_t thunderx_##_type##_##_field##_read(struct kiocb *iocb, \ + struct iov_iter *to) \ { \ - struct thunderx_##_type *pdata = file->private_data; \ + struct thunderx_##_type *pdata = iocb->ki_filp->private_data; \ + size_t count = iov_iter_count(to); \ char buf[20]; \ \ snprintf(buf, count, "0x%016llx", pdata->_field); \ - return simple_read_from_buffer(data, count, ppos, \ - buf, sizeof(buf)); \ + return simple_copy_to_iter(buf, &iocb->ki_pos, sizeof(buf), to); \ } \ \ -static ssize_t thunderx_##_type##_##_field##_write(struct file *file, \ - const char __user *data, \ - size_t count, loff_t *ppos) \ +static ssize_t thunderx_##_type##_##_field##_write(struct kiocb *iocb, \ + struct iov_iter *from) \ { \ - struct thunderx_##_type *pdata = file->private_data; \ + struct thunderx_##_type *pdata = iocb->ki_filp->private_data; \ + size_t count = iov_iter_count(from); \ int res; \ \ - res = kstrtoull_from_user(data, count, 0, &pdata->_field); \ + res = kstrtoull_from_iter(from, count, 0, &pdata->_field); \ \ return res ? res : count; \ } \
@@ -255,27 +254,25 @@ DEBUGFS_STRUCT(_field, 0600, \ thunderx_##_type##_##_field##_read) \ #define DEBUGFS_REG_ATTR(_type, _name, _reg) \ -static ssize_t thunderx_##_type##_##_name##_read(struct file *file, \ - char __user *data, \ - size_t count, loff_t *ppos) \ +static ssize_t thunderx_##_type##_##_name##_read(struct kiocb *iocb, \ + struct iov_iter *to) \ { \ - struct thunderx_##_type *pdata = file->private_data; \ + struct thunderx_##_type *pdata = iocb->ki_filp->private_data; \ char buf[20]; \ \ sprintf(buf, "0x%016llx", readq(pdata->regs + _reg)); \ -return simple_read_from_buffer(data, count, ppos, \ -buf, sizeof(buf)); \ +return simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf), to); \ } \ \ -static ssize_t thunderx_##_type##_##_name##_write(struct file *file, \ -const char __user *data, \ -size_t count, loff_t *ppos) \ +static ssize_t thunderx_##_type##_##_name##_write(struct kiocb *iocb, \ +struct iov_iter *from) \ { \ -struct thunderx_##_type *pdata = file->private_data; \ +struct thunderx_##_type *pdata = iocb->ki_filp->private_data; \ +size_t count = iov_iter_count(from); \ u64 val; \ int res; \ \ -res = kstrtoull_from_user(data, count, 0, &val); \ +res = kstrtoull_from_iter(from, count, 0, &val); \ \ if (!res) { \ writeq(val, pdata->regs + _reg); \
@@ -300,15 +297,15 @@ DEBUGFS_STRUCT(_name, 0600, \* - Do the actual injection: * echo 1 > /sys/kernel/debug/<device number>/inject_ecc */ -static ssize_t thunderx_lmc_inject_int_write (struct file *file, -const char __user *data, -size_t count,loff_t *ppos) +static ssize_t thunderx_lmc_inject_int_write (struct kiocb *iocb, +struct iov_iter *from) { -struct thunderx_lmc *lmc = file->private_data; +struct thunderx_lmc *lmc = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);u64 val;int res; - res =kstrtoull_from_user (data, count,0 , &val); + res =kstrtoull_from_iter (from, count,0 , &val);if (!res) {/* Trigger the interrupt */
@@ -319,16 +316,14 @@ static ssize_t thunderx_lmc_inject_int_write(struct file *file,return res; } -static ssize_t thunderx_lmc_int_read (struct file *file, -char __user *data, -size_t count,loff_t *ppos) +static ssize_t thunderx_lmc_int_read (struct kiocb *iocb,struct iov_iter *to) { -struct thunderx_lmc *lmc = file->private_data; +struct thunderx_lmc *lmc = iocb->ki_filp->private_data;char buf[20 ];u64 lmc_int =readq (lmc->regs +LMC_INT );snprintf (buf,sizeof (buf),"0x%016llx" , lmc_int); -return simple_read_from_buffer (data, count, ppos, buf,sizeof (buf)); +return simple_copy_to_iter (buf, &iocb->ki_pos,sizeof (buf), to); }#define TEST_PATTERN 0xa5
@@ -403,12 +398,12 @@ static int inject_ecc_fn(void *arg)return 0 ; } -static ssize_t thunderx_lmc_inject_ecc_write (struct file *file, -const char __user *data, -size_t count,loff_t *ppos) +static ssize_t thunderx_lmc_inject_ecc_write (struct kiocb *iocb, +struct iov_iter *from) { -struct thunderx_lmc *lmc = file->private_data; +struct thunderx_lmc *lmc = iocb->ki_filp->private_data;unsigned int cline_size =cache_line_size (); +size_t count =iov_iter_count (from);u8 *tmp;void __iomem *addr;unsigned int offs, timeout =100000 ;
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 390/437 EDAC/npcm: convert to read/write iterators
In reply to Jens Axboe--- drivers/edac/npcm_edac.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/edac/npcm_edac.c +4 -4
@@ -195,13 +195,13 @@ static irqreturn_t edac_ecc_isr(int irq, void *dev_id)return IRQ_NONE ; } -static ssize_t force_ecc_error (struct file *file,const char __user *data, -size_t count,loff_t *ppos) +static ssize_t force_ecc_error (struct kiocb *iocb,struct iov_iter *from) { -struct device *dev = file->private_data; +struct device *dev = iocb->ki_filp->private_data;struct mem_ctl_info *mci =to_mci (dev);struct priv_data *priv = mci->pvt_info;const struct npcm_platform_data *pdata; +size_t count =iov_iter_count (from);u32 val, syndrome;int ret;
@@ -261,7 +261,7 @@ static ssize_t force_ecc_error(struct file *file, const char __user *data,static const struct file_operations force_ecc_error_fops = { .open = simple_open, - .write = force_ecc_error, + .write_iter = force_ecc_error, .llseek = generic_file_llseek, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 391/437 EDAC/i5100: convert to read/write iterators
In reply to Jens Axboe--- drivers/edac/i5100_edac.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/edac/i5100_edac.c +4 -5
@@ -924,20 +924,19 @@ static void i5100_do_inject(struct mem_ctl_info *mci) }#define to_mci (k) container_of(k, struct mem_ctl_info, dev) -static ssize_t inject_enable_write (struct file *file,const char __user *data, -size_t count,loff_t *ppos) +static ssize_t inject_enable_write (struct kiocb *iocb,struct iov_iter *from) { -struct device *dev = file->private_data; +struct device *dev = iocb->ki_filp->private_data;struct mem_ctl_info *mci =to_mci (dev);i5100_do_inject (mci); -return count; +return iov_iter_count (from); }static const struct file_operations i5100_inject_enable_fops = { .open = simple_open, - .write = inject_enable_write, + .write_iter = inject_enable_write, .llseek = generic_file_llseek, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 392/437 EDAC/altera: convert to read/write iterators
In reply to Jens Axboe--- drivers/edac/altera_edac.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/edac/altera_edac.c +13 -12
@@ -115,13 +115,13 @@ static irqreturn_t altr_sdram_mc_err_handler(int irq, void *dev_id)return IRQ_NONE ; } -static ssize_t altr_sdr_mc_err_inject_write (struct file *file, -const char __user *data, -size_t count,loff_t *ppos) +static ssize_t altr_sdr_mc_err_inject_write (struct kiocb *iocb, +struct iov_iter *from) { -struct mem_ctl_info *mci = file->private_data; +struct mem_ctl_info *mci = iocb->ki_filp->private_data;struct altr_sdram_mc_data *drvdata = mci->pvt_info;const struct altr_sdram_prv_data *priv = drvdata->data; +size_t count =iov_iter_count (from);u32 *ptemp;dma_addr_t dma_handle;u32 reg, read_reg;
@@ -187,7 +187,7 @@ static ssize_t altr_sdr_mc_err_inject_write(struct file *file,static const struct file_operations altr_sdr_mc_debug_inject_fops = { .open = simple_open, - .write = altr_sdr_mc_err_inject_write, + .write_iter = altr_sdr_mc_err_inject_write, .llseek = generic_file_llseek, };
@@ -640,30 +640,29 @@ altr_edac_device_trig(struct file *file, const char __user *user_buf,return count; } +FOPS_WRITE_ITER_HELPER (altr_edac_device_trig);static const struct file_operations altr_edac_device_inject_fops__maybe_unused = { .open = simple_open, - .write = altr_edac_device_trig, + .write_iter = altr_edac_device_trig_iter, .llseek = generic_file_llseek, };static ssize_t __maybe_unused -altr_edac_a10_device_trig (struct file *file,const char __user *user_buf, -size_t count,loff_t *ppos); +altr_edac_a10_device_trig_iter (struct kiocb *iocb,struct iov_iter *from);static const struct file_operations altr_edac_a10_device_inject_fops__maybe_unused = { .open = simple_open, - .write = altr_edac_a10_device_trig, + .write_iter = altr_edac_a10_device_trig_iter, .llseek = generic_file_llseek, };static ssize_t __maybe_unused -altr_edac_a10_device_trig2 (struct file *file,const char __user *user_buf, -size_t count,loff_t *ppos); +altr_edac_a10_device_trig2_iter (struct kiocb *iocb,struct iov_iter *from);static const struct file_operations altr_edac_a10_device_inject2_fops__maybe_unused = { .open = simple_open, - .write = altr_edac_a10_device_trig2, + .write_iter = altr_edac_a10_device_trig2_iter, .llseek = generic_file_llseek, };
@@ -1760,6 +1759,7 @@ altr_edac_a10_device_trig(struct file *file, const char __user *user_buf,return count; } +FOPS_WRITE_ITER_HELPER (altr_edac_a10_device_trig);/* * The Stratix10 EDAC Error Injection Functions differ from Arria10
@@ -1823,6 +1823,7 @@ altr_edac_a10_device_trig2(struct file *file, const char __user *user_buf,return count; } +FOPS_WRITE_ITER_HELPER (altr_edac_a10_device_trig2);static void altr_edac_a10_irq_handler (struct irq_desc *desc) {
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 393/437 EDAC/debugfs: convert to read/write iterators
In reply to Jens Axboe--- drivers/edac/altera_edac.c | 37 +++++++++++++++++-------------------- drivers/edac/debugfs.c | 9 ++++----- 2 files changed, 21 insertions(+), 25 deletions(-)
drivers/edac/altera_edac.c +17 -20
@@ -571,20 +571,20 @@ static irqreturn_t altr_edac_device_handler(int irq, void *dev_id) }static ssize_t __maybe_unused -altr_edac_device_trig (struct file *file,const char __user *user_buf, -size_t count,loff_t *ppos) +altr_edac_device_trig (struct kiocb *iocb,struct iov_iter *from) {u32 *ptemp, i, error_mask;int result =0 ;u8 trig_type;unsigned long flags; -struct edac_device_ctl_info *edac_dci = file->private_data; +struct edac_device_ctl_info *edac_dci = iocb->ki_filp->private_data;struct altr_edac_device_dev *drvdata = edac_dci->pvt_info;const struct edac_device_prv_data *priv = drvdata->data; +size_t count =iov_iter_count (from);void *generic_ptr = edac_dci->dev; -if (!user_buf ||get_user (trig_type, user_buf)) +if (get_iter (trig_type, from))return -EFAULT ;if (!priv->alloc_mem)
@@ -640,29 +640,28 @@ altr_edac_device_trig(struct file *file, const char __user *user_buf,return count; } -FOPS_WRITE_ITER_HELPER (altr_edac_device_trig);static const struct file_operations altr_edac_device_inject_fops__maybe_unused = { .open = simple_open, - .write_iter = altr_edac_device_trig_iter, + .write_iter = altr_edac_device_trig, .llseek = generic_file_llseek, };static ssize_t __maybe_unused -altr_edac_a10_device_trig_iter (struct kiocb *iocb,struct iov_iter *from); +altr_edac_a10_device_trig (struct kiocb *iocb,struct iov_iter *from);static const struct file_operations altr_edac_a10_device_inject_fops__maybe_unused = { .open = simple_open, - .write_iter = altr_edac_a10_device_trig_iter, + .write_iter = altr_edac_a10_device_trig, .llseek = generic_file_llseek, };static ssize_t __maybe_unused -altr_edac_a10_device_trig2_iter (struct kiocb *iocb,struct iov_iter *from); +altr_edac_a10_device_trig2 (struct kiocb *iocb,struct iov_iter *from);static const struct file_operations altr_edac_a10_device_inject2_fops__maybe_unused = { .open = simple_open, - .write_iter = altr_edac_a10_device_trig2_iter, + .write_iter = altr_edac_a10_device_trig2, .llseek = generic_file_llseek, };
@@ -1734,17 +1733,17 @@ MODULE_DEVICE_TABLE(of, altr_edac_a10_device_of_match);*/ static ssize_t __maybe_unused -altr_edac_a10_device_trig (struct file *file,const char __user *user_buf, -size_t count,loff_t *ppos) +altr_edac_a10_device_trig (struct kiocb *iocb,struct iov_iter *from) { -struct edac_device_ctl_info *edac_dci = file->private_data; +struct edac_device_ctl_info *edac_dci = iocb->ki_filp->private_data;struct altr_edac_device_dev *drvdata = edac_dci->pvt_info;const struct edac_device_prv_data *priv = drvdata->data;void __iomem *set_addr = (drvdata->base + priv->set_err_ofst); +size_t count =iov_iter_count (from);unsigned long flags;u8 trig_type; -if (!user_buf ||get_user (trig_type, user_buf)) +if (get_iter (trig_type, from))return -EFAULT ;local_irq_save (flags);
@@ -1759,7 +1758,6 @@ altr_edac_a10_device_trig(struct file *file, const char __user *user_buf,return count; } -FOPS_WRITE_ITER_HELPER (altr_edac_a10_device_trig);/* * The Stratix10 EDAC Error Injection Functions differ from Arria10
@@ -1767,17 +1765,17 @@ FOPS_WRITE_ITER_HELPER(altr_edac_a10_device_trig);* Inject the error into the memory and then readback to trigger the IRQ. */ static ssize_t __maybe_unused -altr_edac_a10_device_trig2 (struct file *file,const char __user *user_buf, -size_t count,loff_t *ppos) +altr_edac_a10_device_trig2 (struct kiocb *iocb,struct iov_iter *from) { -struct edac_device_ctl_info *edac_dci = file->private_data; +struct edac_device_ctl_info *edac_dci = iocb->ki_filp->private_data;struct altr_edac_device_dev *drvdata = edac_dci->pvt_info;const struct edac_device_prv_data *priv = drvdata->data;void __iomem *set_addr = (drvdata->base + priv->set_err_ofst); +size_t count =iov_iter_count (from);unsigned long flags;u8 trig_type; -if (!user_buf ||get_user (trig_type, user_buf)) +if (get_iter (trig_type, from))return -EFAULT ;local_irq_save (flags);
@@ -1823,7 +1821,6 @@ altr_edac_a10_device_trig2(struct file *file, const char __user *user_buf,return count; } -FOPS_WRITE_ITER_HELPER (altr_edac_a10_device_trig2);static void altr_edac_a10_irq_handler (struct irq_desc *desc) {
drivers/edac/debugfs.c +4 -5
@@ -3,14 +3,13 @@static struct dentry *edac_debugfs; -static ssize_t edac_fake_inject_write (struct file *file, -const char __user *data, -size_t count,loff_t *ppos) +static ssize_t edac_fake_inject_write (struct kiocb *iocb,struct iov_iter *from) { -struct device *dev = file->private_data; +struct device *dev = iocb->ki_filp->private_data;struct mem_ctl_info *mci =to_mci (dev);static enum hw_event_mc_err_type type;u16 errcount = mci->fake_inject_count; +size_t count =iov_iter_count (from);if (!errcount) errcount =1 ;
@@ -38,7 +37,7 @@ static ssize_t edac_fake_inject_write(struct file *file,static const struct file_operations debug_fake_inject_fops = { .open = simple_open, - .write = edac_fake_inject_write, + .write_iter = edac_fake_inject_write, .llseek = generic_file_llseek, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 394/437 drivers/hsi: convert to read/write iterators
In reply to Jens Axboe--- drivers/hsi/clients/hsi_char.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/hsi/clients/hsi_char.c +11 -11
@@ -409,10 +409,10 @@ static inline void hsc_tx_get(struct hsi_client *cl, struct hsc_tx_config *txc) txc->arb_mode = cl->tx_cfg.arb_mode; } -static ssize_t hsc_read (struct file *file,char __user *buf,size_t len, -loff_t *ppos__maybe_unused ) +static ssize_t hsc_read (struct kiocb *iocb,struct iov_iter *to) { -struct hsc_channel *channel = file->private_data; +struct hsc_channel *channel = iocb->ki_filp->private_data; +size_t len =iov_iter_count (to);struct hsi_msg *msg;ssize_t ret;
@@ -451,8 +451,8 @@ static ssize_t hsc_read(struct file *file, char __user *buf, size_t len, msg =hsc_get_first_msg (channel, &channel->rx_msgs_queue);if (msg) {if (msg->status !=HSI_STATUS_ERROR ) { - ret =copy_to_user ((void __user *)buf, -sg_virt (msg->sgt.sgl),hsc_msg_len_get (msg)); + ret = !copy_to_iter_full (sg_virt (msg->sgt.sgl), +hsc_msg_len_get (msg), to);if (ret) ret = -EFAULT ;else
@@ -468,10 +468,10 @@ static ssize_t hsc_read(struct file *file, char __user *buf, size_t len,return ret; } -static ssize_t hsc_write (struct file *file,const char __user *buf,size_t len, -loff_t *ppos__maybe_unused ) +static ssize_t hsc_write (struct kiocb *iocb,struct iov_iter *from) { -struct hsc_channel *channel = file->private_data; +struct hsc_channel *channel = iocb->ki_filp->private_data; +size_t len =iov_iter_count (from);struct hsi_msg *msg;ssize_t ret;
@@ -488,7 +488,7 @@ static ssize_t hsc_write(struct file *file, const char __user *buf, size_t len,clear_bit (HSC_CH_WRITE , &channel->flags);return -ENOSPC ; } -if (copy_from_user (sg_virt (msg->sgt.sgl), (void __user *)buf, len)) { +if (!copy_from_iter_full (sg_virt (msg->sgt.sgl), len, from)) { ret = -EFAULT ; goto out; }
@@ -655,8 +655,8 @@ static int hsc_release(struct inode *inode __maybe_unused, struct file *file)static const struct file_operations hsc_fops = { .owner =THIS_MODULE , - .read = hsc_read, - .write = hsc_write, + .read_iter = hsc_read, + .write_iter = hsc_write, .unlocked_ioctl = hsc_ioctl, .open = hsc_open, .release = hsc_release,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 395/437 hsi: clients: cmt_speech: convert to read/write iterators
In reply to Jens Axboe--- drivers/hsi/clients/cmt_speech.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/hsi/clients/cmt_speech.c +11 -11
@@ -1126,10 +1126,10 @@ static __poll_t cs_char_poll(struct file *file, poll_table *wait)return ret; } -static ssize_t cs_char_read (struct file *file,char __user *buf,size_t count, -loff_t *unused) +static ssize_t cs_char_read (struct kiocb *iocb,struct iov_iter *to) { -struct cs_char *csdata = file->private_data; +struct cs_char *csdata = iocb->ki_filp->private_data; +size_t count =iov_iter_count (to);u32 data;ssize_t retval;
@@ -1152,7 +1152,7 @@ static ssize_t cs_char_read(struct file *file, char __user *buf, size_t count,if (data)break ; -if (file->f_flags &O_NONBLOCK ) { +if (iocb->ki_filp->f_flags &O_NONBLOCK ) { retval = -EAGAIN ; goto out; }else if (signal_pending (current)) {
@@ -1165,7 +1165,7 @@ static ssize_t cs_char_read(struct file *file, char __user *buf, size_t count,finish_wait (&csdata->wait, &wait); } - retval =put_user (data, (u32 __user *)buf); + retval =put_iter (data, to);if (!retval) retval =sizeof (data);
@@ -1173,10 +1173,10 @@ static ssize_t cs_char_read(struct file *file, char __user *buf, size_t count,return retval; } -static ssize_t cs_char_write (struct file *file,const char __user *buf, -size_t count,loff_t *unused) +static ssize_t cs_char_write (struct kiocb *iocb,struct iov_iter *from) { -struct cs_char *csdata = file->private_data; +struct cs_char *csdata = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);u32 data;int err;ssize_t retval;
@@ -1184,7 +1184,7 @@ static ssize_t cs_char_write(struct file *file, const char __user *buf,if (count <sizeof (data))return -EINVAL ; -if (get_user (data, (u32 __user *)buf)) +if (get_iter (data, from)) retval = -EFAULT ;else retval = count;
@@ -1349,8 +1349,8 @@ static int cs_char_release(struct inode *unused, struct file *file)static const struct file_operations cs_char_fops = { .owner =THIS_MODULE , - .read = cs_char_read, - .write = cs_char_write, + .read_iter = cs_char_read, + .write_iter = cs_char_write, .poll = cs_char_poll, .unlocked_ioctl = cs_char_ioctl, .mmap = cs_char_mmap,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 396/437 macintosh: adb: convert to read/write iterators
In reply to Jens Axboe--- drivers/macintosh/adb.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/macintosh/adb.c +11 -11
@@ -713,11 +713,11 @@ static int adb_release(struct inode *inode, struct file *file)return 0 ; } -static ssize_t adb_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t adb_read (struct kiocb *iocb,struct iov_iter *to) {int ret =0 ; -struct adbdev_state *state = file->private_data; +struct adbdev_state *state = iocb->ki_filp->private_data; +size_t count =iov_iter_count (to);struct adb_request *req;DECLARE_WAITQUEUE (wait, current);unsigned long flags;
@@ -741,7 +741,7 @@ static ssize_t adb_read(struct file *file, char __user *buf,if (req !=NULL || ret !=0 )break ; -if (file->f_flags &O_NONBLOCK ) { +if (iocb->ki_filp->f_flags &O_NONBLOCK ) { ret = -EAGAIN ;break ; }
@@ -764,18 +764,18 @@ static ssize_t adb_read(struct file *file, char __user *buf, ret = req->reply_len;if (ret > count) ret = count; -if (ret >0 &©_to_user (buf, req->reply, ret)) +if (ret >0 && !copy_to_iter_full (req->reply, ret, to)) ret = -EFAULT ;kfree (req);return ret; } -static ssize_t adb_write (struct file *file,const char __user *buf, -size_t count,loff_t *ppos) +static ssize_t adb_write (struct kiocb *iocb,struct iov_iter *from) {int ret/*, i*/ ; -struct adbdev_state *state = file->private_data; +struct adbdev_state *state = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);struct adb_request *req;if (count <2 || count >sizeof (req->data))
@@ -794,7 +794,7 @@ static ssize_t adb_write(struct file *file, const char __user *buf, req->complete =0 ; ret = -EFAULT ; -if (copy_from_user (req->data, buf, count)) +if (!copy_from_iter_full (req->data, count, from)) goto out;atomic_inc (&state->n_pending);
@@ -843,8 +843,8 @@ static ssize_t adb_write(struct file *file, const char __user *buf,static const struct file_operations adb_fops = { .owner =THIS_MODULE , .llseek = no_llseek, - .read = adb_read, - .write = adb_write, + .read_iter = adb_read, + .write_iter = adb_write, .open = adb_open, .release = adb_release, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 397/437 macintosh: ans-lcd: convert to read/write iterators
In reply to Jens Axboe--- drivers/macintosh/ans-lcd.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/macintosh/ans-lcd.c +15 -14
@@ -53,30 +53,31 @@ anslcd_write_byte_data ( unsigned char c )udelay (anslcd_short_delay); } -static ssize_t -anslcd_write (struct file * file,const char __user * buf, -size_t count,loff_t *ppos ) +static ssize_t anslcd_write (struct kiocb *iocb,struct iov_iter *from) { -const char __user *p = buf; -int i; +size_t count =iov_iter_count (from); +int i, err =0 ;#ifdef DEBUG printk (KERN_DEBUG "LCD: write\n" );#endif -if (!access_ok (buf, count)) -return -EFAULT ; -mutex_lock (&anslcd_mutex); -for ( i = *ppos; count >0 ; ++i, ++p, --count ) +for ( i = iocb->ki_pos; count >0 ; ++i, --count ) {char c; -__get_user (c, p); -anslcd_write_byte_data ( c ); +if (get_iter (c, from)) { + err = -EFAULT ; +break ; + } +anslcd_write_byte_data (c); }mutex_unlock (&anslcd_mutex); - *ppos = i; -return p - buf; +if (i - iocb->ki_pos) { + err = i - iocb->ki_pos; + iocb->ki_pos = i; + } +return err; } static long
@@ -135,7 +136,7 @@ anslcd_open( struct inode * inode, struct file * file ) }const struct file_operations anslcd_fops = { - .write = anslcd_write, + .write_iter = anslcd_write, .unlocked_ioctl = anslcd_ioctl, .open = anslcd_open, .llseek = default_llseek,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 398/437 macintosh: smu: convert to read/write iterators
In reply to Jens Axboe--- drivers/macintosh/smu.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)
drivers/macintosh/smu.c +18 -22
@@ -1111,17 +1111,17 @@ static void smu_user_cmd_done(struct smu_cmd *cmd, void *misc) } -static ssize_t smu_write (struct file *file,const char __user *buf, -size_t count,loff_t *ppos) +static ssize_t smu_write (struct kiocb *iocb,struct iov_iter *from) { -struct smu_private *pp = file->private_data; +struct smu_private *pp = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);unsigned long flags;struct smu_user_cmd_hdr hdr;int rc =0 ;if (pp->busy)return -EBUSY ; -else if (copy_from_user (&hdr, buf,sizeof (hdr))) +else if (!copy_from_iter_full (&hdr,sizeof (hdr), from))return -EFAULT ;else if (hdr.cmdtype ==SMU_CMDTYPE_WANTS_EVENTS ) { pp->mode = smu_file_events;
@@ -1150,7 +1150,7 @@ static ssize_t smu_write(struct file *file, const char __user *buf, pp->cmd.status =1 ;spin_unlock_irqrestore (&pp->lock, flags); -if (copy_from_user (pp->buffer, buf +sizeof (hdr), hdr.data_len)) { +if (!copy_from_iter_full (pp->buffer, hdr.data_len, from)) { pp->busy =0 ;return -EFAULT ; }
@@ -1168,10 +1168,10 @@ static ssize_t smu_write(struct file *file, const char __user *buf,return count; } - -static ssize_t smu_read_command (struct file *file,struct smu_private *pp, -char __user *buf,size_t count) +static ssize_t smu_read_command (struct smu_private *pp,struct kiocb *iocb, +struct iov_iter *to) { +size_t count =iov_iter_count (to);DECLARE_WAITQUEUE (wait, current);struct smu_user_reply_hdr hdr;unsigned long flags;
@@ -1183,7 +1183,7 @@ static ssize_t smu_read_command(struct file *file, struct smu_private *pp,return -EOVERFLOW ;spin_lock_irqsave (&pp->lock, flags);if (pp->cmd.status ==1 ) { -if (file->f_flags &O_NONBLOCK ) { +if (iocb->ki_filp->f_flags &O_NONBLOCK ) {spin_unlock_irqrestore (&pp->lock, flags);return -EAGAIN ; }
@@ -1214,35 +1214,31 @@ static ssize_t smu_read_command(struct file *file, struct smu_private *pp, rc = size; hdr.status = pp->cmd.status; hdr.reply_len = pp->cmd.reply_len; -if (copy_to_user (buf, &hdr,sizeof (hdr))) +if (!copy_to_iter_full (&hdr,sizeof (hdr), to))return -EFAULT ; size -=sizeof (hdr); -if (size &©_to_user (buf +sizeof (hdr), pp->buffer, size)) +if (size && !copy_to_iter_full (pp->buffer, size, to))return -EFAULT ; pp->busy =0 ;return rc; } - -static ssize_t smu_read_events (struct file *file,struct smu_private *pp, -char __user *buf,size_t count) +static ssize_t smu_read_events (void ) {/* Not implemented */ msleep_interruptible (1000 );return 0 ; } - -static ssize_t smu_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t smu_read (struct kiocb *iocb,struct iov_iter *to) { -struct smu_private *pp = file->private_data; +struct smu_private *pp = iocb->ki_filp->private_data;if (pp->mode == smu_file_commands) -return smu_read_command (file, pp, buf, count); +return smu_read_command (pp, iocb, to);if (pp->mode == smu_file_events) -return smu_read_events (file, pp, buf, count); +return smu_read_events ();return -EBADFD ; }
@@ -1315,8 +1311,8 @@ static int smu_release(struct inode *inode, struct file *file)static const struct file_operations smu_device_fops = { .llseek = no_llseek, - .read = smu_read, - .write = smu_write, + .read_iter = smu_read, + .write_iter = smu_write, .poll = smu_fpoll, .open = smu_open, .release = smu_release,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 399/437 macintosh: via-pmu: convert to read/write iterators
In reply to Jens Axboe--- drivers/macintosh/via-pmu.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/macintosh/via-pmu.c +8 -11
@@ -2165,12 +2165,11 @@ pmu_open(struct inode *inode, struct file *file)return 0 ; } -static ssize_t -pmu_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t pmu_read (struct kiocb *iocb,struct iov_iter *to) { -struct pmu_private *pp = file->private_data; +struct pmu_private *pp = iocb->ki_filp->private_data;DECLARE_WAITQUEUE (wait, current); +size_t count =iov_iter_count (to);unsigned long flags;int ret =0 ;
@@ -2190,7 +2189,7 @@ pmu_read(struct file *file, char __user *buf,spin_unlock_irqrestore (&pp->lock, flags);if (ret > count) ret = count; -if (ret >0 &©_to_user (buf, rp->data, ret)) +if (ret >0 && !copy_to_iter_full (rp->data, ret, to)) ret = -EFAULT ;if (++i >=RB_SIZE ) i =0 ;
@@ -2199,7 +2198,7 @@ pmu_read(struct file *file, char __user *buf, }if (ret >=0 )break ; -if (file->f_flags &O_NONBLOCK ) +if (iocb->ki_filp->f_flags &O_NONBLOCK )break ; ret = -ERESTARTSYS ;if (signal_pending (current))
@@ -2215,9 +2214,7 @@ pmu_read(struct file *file, char __user *buf,return ret; } -static ssize_t -pmu_write (struct file *file,const char __user *buf, -size_t count,loff_t *ppos) +static ssize_t pmu_write (struct kiocb *iocb,struct iov_iter *from) {return 0 ; }
@@ -2464,8 +2461,8 @@ static long compat_pmu_ioctl (struct file *filp, u_int cmd, u_long arg)#endif static const struct file_operations pmu_device_fops = { - .read = pmu_read, - .write = pmu_write, + .read_iter = pmu_read, + .write_iter = pmu_write, .poll = pmu_fpoll, .unlocked_ioctl = pmu_unlocked_ioctl, #ifdef CONFIG_COMPAT
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 400/437 drivers/extcon: convert to read/write iterators
In reply to Jens Axboe--- drivers/extcon/extcon-rtk-type-c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/extcon/extcon-rtk-type-c.c +2 -2
@@ -796,7 +796,7 @@ static int type_c_parameter_open(struct inode *inode, struct file *file)static const struct file_operations type_c_parameter_fops = { .open = type_c_parameter_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, };
@@ -838,7 +838,7 @@ static int type_c_status_open(struct inode *inode, struct file *file)static const struct file_operations type_c_status_fops = { .open = type_c_status_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 401/437 drivers/gnss: convert to read/write iterators
In reply to Jens Axboe--- drivers/gnss/core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gnss/core.c +7 -7
@@ -119,11 +119,12 @@ static ssize_t gnss_read(struct file *file, char __user *buf,return ret; } +FOPS_READ_ITER_HELPER (gnss_read); -static ssize_t gnss_write (struct file *file,const char __user *buf, -size_t count,loff_t *pos) +static ssize_t gnss_write (struct kiocb *iocb,struct iov_iter *from) { -struct gnss_device *gdev = file->private_data; +struct gnss_device *gdev = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);size_t written =0 ;int ret;
@@ -148,7 +149,7 @@ static ssize_t gnss_write(struct file *file, const char __user *buf,if (n >GNSS_WRITE_BUF_SIZE ) n =GNSS_WRITE_BUF_SIZE ; -if (copy_from_user (gdev->write_buf, buf, n)) { +if (!copy_from_iter_full (gdev->write_buf, n, from)) { ret = -EFAULT ; goto out_unlock; }
@@ -170,7 +171,6 @@ static ssize_t gnss_write(struct file *file, const char __user *buf,break ; written += ret; - buf += ret;if (written == count)break ;
@@ -203,8 +203,8 @@ static const struct file_operations gnss_fops = { .owner = THIS_MODULE, .open = gnss_open, .release = gnss_release, - .read = gnss_read, - .write = gnss_write, + .read_iter = gnss_read_iter, + .write_iter = gnss_write, .poll = gnss_poll, .llseek = no_llseek, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 402/437 drivers/rapidio: convert to read/write iterators
In reply to Jens Axboe--- drivers/rapidio/devices/rio_mport_cdev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/rapidio/devices/rio_mport_cdev.c +7 -7
@@ -2297,12 +2297,13 @@ static ssize_t mport_read(struct file *filp, char __user *buf, size_t count,return ret; } +FOPS_READ_ITER_HELPER (mport_read); -static ssize_t mport_write (struct file *filp,const char __user *buf, -size_t count,loff_t *ppos) +static ssize_t mport_write (struct kiocb *iocb,struct iov_iter *from) { -struct mport_cdev_priv *priv = filp->private_data; +struct mport_cdev_priv *priv = iocb->ki_filp->private_data;struct rio_mport *mport = priv->md->mport; +size_t count =iov_iter_count (from);struct rio_event event;int len, ret;
@@ -2314,7 +2315,7 @@ static ssize_t mport_write(struct file *filp, const char __user *buf, len =0 ;while ((count - len) >= (int )sizeof (event)) { -if (copy_from_user (&event, buf,sizeof (event))) +if (!copy_from_iter_full (&event,sizeof (event), from))return -EFAULT ;if (event.header !=RIO_DOORBELL )
@@ -2327,7 +2328,6 @@ static ssize_t mport_write(struct file *filp, const char __user *buf,return ret; len +=sizeof (event); - buf +=sizeof (event); }return len;
@@ -2338,8 +2338,8 @@ static const struct file_operations mport_fops = { .open = mport_cdev_open, .release = mport_cdev_release, .poll = mport_cdev_poll, - .read = mport_read, - .write = mport_write, + .read_iter = mport_read_iter, + .write_iter = mport_write, .mmap = mport_cdev_mmap, .fasync = mport_cdev_fasync, .unlocked_ioctl = mport_cdev_ioctl
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 403/437 drivers/media/platform/mediatek/vcodec: convert to read/write iterators
In reply to Jens AxboeFrom: Krzysztof Kanas <[email protected]>
--- .../mediatek/vcodec/common/mtk_vcodec_dbgfs.c | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c +10 -11
@@ -70,15 +70,15 @@ static void mtk_vdec_dbgfs_get_help(char *buf, int *used, int total) *used += curr_len; } -static ssize_t mtk_vdec_dbgfs_write (struct file *filp,const char __user *ubuf, -size_t count,loff_t *ppos) +static ssize_t mtk_vdec_dbgfs_write (struct kiocb *iocb,struct iov_iter *from) { -struct mtk_vcodec_dec_dev *vcodec_dev = filp->private_data; +struct mtk_vcodec_dec_dev *vcodec_dev = iocb->ki_filp->private_data;struct mtk_vcodec_dbgfs *dbgfs = &vcodec_dev->dbgfs; +size_t count =iov_iter_count (from);mutex_lock (&dbgfs->dbgfs_lock); - dbgfs->buf_size =simple_write_to_buffer (dbgfs->dbgfs_buf,sizeof (dbgfs->dbgfs_buf), - ppos, ubuf, count); + dbgfs->buf_size =simple_copy_to_iter (dbgfs->dbgfs_buf, &iocb->ki_pos, +sizeof (dbgfs->dbgfs_buf), from);mutex_unlock (&dbgfs->dbgfs_lock);if (dbgfs->buf_size >0 )return count;
@@ -86,10 +86,9 @@ static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf,return dbgfs->buf_size; } -static ssize_t mtk_vdec_dbgfs_read (struct file *filp,char __user *ubuf, -size_t count,loff_t *ppos) +static ssize_t mtk_vdec_dbgfs_read (struct kiocb *iocb,struct iov_iter *to) { -struct mtk_vcodec_dec_dev *vcodec_dev = filp->private_data; +struct mtk_vcodec_dec_dev *vcodec_dev = iocb->ki_filp->private_data;struct mtk_vcodec_dbgfs *dbgfs = &vcodec_dev->dbgfs;struct mtk_vcodec_dbgfs_inst *dbgfs_inst;struct mtk_vcodec_dec_ctx *ctx;
@@ -133,15 +132,15 @@ static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf, }mutex_unlock (&dbgfs->dbgfs_lock); read_buffer: - ret =simple_read_from_buffer (ubuf, count, ppos, buf, used_len); + ret =simple_copy_to_iter (buf, &iocb->ki_pos, used_len, to);kfree (buf);return ret; }static const struct file_operations vdec_fops = { .open = simple_open, - .write = mtk_vdec_dbgfs_write, - .read = mtk_vdec_dbgfs_read, + .write_iter = mtk_vdec_dbgfs_write, + .read_iter = mtk_vdec_dbgfs_read, };void mtk_vcodec_dbgfs_create (struct mtk_vcodec_dec_ctx *ctx)
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 404/437 infiniband/core: convert to read/write iterators
In reply to Jens Axboe--- drivers/infiniband/core/ucma.c | 3 ++- drivers/infiniband/core/user_mad.c | 6 ++++-- drivers/infiniband/core/uverbs_main.c | 11 +++++++---- 3 files changed, 13 insertions(+), 7 deletions(-)
drivers/infiniband/core/ucma.c +2 -1
@@ -1746,6 +1746,7 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf,return ret; } +FOPS_WRITE_ITER_HELPER (ucma_write);static __poll_t ucma_poll (struct file *filp,struct poll_table_struct *wait) {
@@ -1815,7 +1816,7 @@ static const struct file_operations ucma_fops = { .owner = THIS_MODULE, .open = ucma_open, .release = ucma_close, - .write = ucma_write, + .write_iter = ucma_write_iter, .poll = ucma_poll, .llseek = no_llseek, };
drivers/infiniband/core/user_mad.c +4 -2
@@ -429,6 +429,7 @@ static ssize_t ib_umad_read(struct file *filp, char __user *buf, }return ret; } +FOPS_READ_ITER_HELPER (ib_umad_read);static int copy_rmpp_mad (struct ib_mad_send_buf *msg,const char __user *buf) {
@@ -660,6 +661,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,kfree (packet);return ret; } +FOPS_WRITE_ITER_HELPER (ib_umad_write);static __poll_t ib_umad_poll (struct file *filp,struct poll_table_struct *wait) {
@@ -1064,8 +1066,8 @@ static int ib_umad_close(struct inode *inode, struct file *filp)static const struct file_operations umad_fops = { .owner =THIS_MODULE , - .read = ib_umad_read, - .write = ib_umad_write, + .read_iter = ib_umad_read_iter, + .write_iter = ib_umad_write_iter, .poll = ib_umad_poll, .unlocked_ioctl = ib_umad_ioctl, #ifdef CONFIG_COMPAT
drivers/infiniband/core/uverbs_main.c +7 -4
@@ -285,6 +285,7 @@ static ssize_t ib_uverbs_async_event_read(struct file *filp, char __user *buf,return ib_uverbs_event_read (&file->ev_queue, filp, buf, count, pos,sizeof (struct ib_uverbs_async_event_desc )); } +FOPS_READ_ITER_HELPER (ib_uverbs_async_event_read);static ssize_t ib_uverbs_comp_event_read (struct file *filp,char __user *buf,size_t count,loff_t *pos)
@@ -296,6 +297,7 @@ static ssize_t ib_uverbs_comp_event_read(struct file *filp, char __user *buf, pos, sizeof(struct ib_uverbs_comp_event_desc)); } +FOPS_READ_ITER_HELPER (ib_uverbs_comp_event_read); static __poll_t ib_uverbs_event_poll(struct ib_uverbs_event_queue *ev_queue, struct file *filp,
@@ -349,7 +351,7 @@ static int ib_uverbs_comp_event_fasync(int fd, struct file *filp, int on)const struct file_operations uverbs_event_fops = { .owner =THIS_MODULE , - .read = ib_uverbs_comp_event_read, + .read_iter = ib_uverbs_comp_event_read_iter, .poll = ib_uverbs_comp_event_poll, .release = uverbs_uobject_fd_release, .fasync = ib_uverbs_comp_event_fasync,
@@ -358,7 +360,7 @@ const struct file_operations uverbs_event_fops = {const struct file_operations uverbs_async_event_fops = { .owner =THIS_MODULE , - .read = ib_uverbs_async_event_read, + .read_iter = ib_uverbs_async_event_read_iter, .poll = ib_uverbs_async_event_poll, .release = uverbs_async_event_release, .fasync = ib_uverbs_async_event_fasync,
@@ -684,6 +686,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,srcu_read_unlock (&file->device->disassociate_srcu, srcu_key);return (ret) ? : count; } +FOPS_WRITE_ITER_HELPER (ib_uverbs_write);static const struct vm_operations_struct rdma_umap_ops;
@@ -988,7 +991,7 @@ static int ib_uverbs_close(struct inode *inode, struct file *filp)static const struct file_operations uverbs_fops = { .owner =THIS_MODULE , - .write = ib_uverbs_write, + .write_iter = ib_uverbs_write_iter, .open = ib_uverbs_open, .release = ib_uverbs_close, .llseek = no_llseek,
@@ -998,7 +1001,7 @@ static const struct file_operations uverbs_fops = {static const struct file_operations uverbs_mmap_fops = { .owner =THIS_MODULE , - .write = ib_uverbs_write, + .write_iter = ib_uverbs_write_iter, .mmap = ib_uverbs_mmap, .open = ib_uverbs_open, .release = ib_uverbs_close,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 405/437 infiniband/cxgb4: convert to read/write iterators
In reply to Jens Axboe--- drivers/infiniband/hw/cxgb4/device.c | 35 +++++++++++++--------------- 1 file changed, 16 insertions(+), 19 deletions(-)
drivers/infiniband/hw/cxgb4/device.c +16 -19
@@ -81,12 +81,11 @@ struct c4iw_debugfs_data {int pos; }; -static ssize_t debugfs_read (struct file *file,char __user *buf,size_t count, -loff_t *ppos) +static ssize_t debugfs_read (struct kiocb *iocb,struct iov_iter *to) { -struct c4iw_debugfs_data *d = file->private_data; +struct c4iw_debugfs_data *d = iocb->ki_filp->private_data; -return simple_read_from_buffer (buf, count, ppos, d->buf, d->pos); +return simple_copy_to_iter (d->buf, &iocb->ki_pos, d->pos, to); }void c4iw_log_wr_stats (struct t4_wq *wq,struct t4_cqe *cqe)
@@ -175,25 +174,24 @@ static int wr_log_open(struct inode *inode, struct file *file)return single_open (file, wr_log_show, inode->i_private); } -static ssize_t wr_log_clear (struct file *file,const char __user *buf, -size_t count,loff_t *pos) +static ssize_t wr_log_clear (struct kiocb *iocb,struct iov_iter *from) { -struct c4iw_dev *dev = ((struct seq_file *)file->private_data)->private; +struct c4iw_dev *dev = ((struct seq_file *)iocb->ki_filp->private_data)->private;int i;if (dev->rdev.wr_log)for (i =0 ; i < dev->rdev.wr_log_size; i++) dev->rdev.wr_log[i].valid =0 ; -return count; +return iov_iter_count (from); }static const struct file_operations wr_log_debugfs_fops = { .owner =THIS_MODULE , .open = wr_log_open, .release = single_release, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, - .write = wr_log_clear, + .write_iter = wr_log_clear, };static struct sockaddr_in zero_sin = {
@@ -365,7 +363,7 @@ static const struct file_operations qp_debugfs_fops = { .owner = THIS_MODULE, .open = qp_open, .release = qp_release, - .read = debugfs_read, + .read_iter = debugfs_read, .llseek = default_llseek, };
@@ -460,7 +458,7 @@ static const struct file_operations stag_debugfs_fops = { .owner = THIS_MODULE, .open = stag_open, .release = stag_release, - .read = debugfs_read, + .read_iter = debugfs_read, .llseek = default_llseek, };
@@ -515,10 +513,9 @@ static int stats_open(struct inode *inode, struct file *file)return single_open (file, stats_show, inode->i_private); } -static ssize_t stats_clear (struct file *file,const char __user *buf, -size_t count,loff_t *pos) +static ssize_t stats_clear (struct kiocb *iocb,struct iov_iter *from) { -struct c4iw_dev *dev = ((struct seq_file *)file->private_data)->private; +struct c4iw_dev *dev = ((struct seq_file *)iocb->ki_filp->private_data)->private;mutex_lock (&dev->rdev.stats.lock); dev->rdev.stats.pd.max =0 ;
@@ -543,16 +540,16 @@ static ssize_t stats_clear(struct file *file, const char __user *buf, dev->rdev.stats.act_ofld_conn_fails =0 ; dev->rdev.stats.pas_ofld_conn_fails =0 ;mutex_unlock (&dev->rdev.stats.lock); -return count; +return iov_iter_count (from); }static const struct file_operations stats_debugfs_fops = { .owner =THIS_MODULE , .open = stats_open, .release = single_release, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, - .write = stats_clear, + .write_iter = stats_clear, };static int dump_ep (struct c4iw_ep *ep,struct c4iw_debugfs_data *epd)
@@ -722,7 +719,7 @@ static const struct file_operations ep_debugfs_fops = { .owner = THIS_MODULE, .open = ep_open, .release = ep_release, - .read = debugfs_read, + .read_iter = debugfs_read, };static void setup_debugfs (struct c4iw_dev *devp)
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 406/437 infiniband/hfi1: convert to read/write iterators
In reply to Jens Axboe--- drivers/infiniband/hw/hfi1/debugfs.c | 162 +++++++++++++-------------- drivers/infiniband/hw/hfi1/debugfs.h | 6 +- drivers/infiniband/hw/hfi1/fault.c | 27 +++-- 3 files changed, 91 insertions(+), 104 deletions(-)
drivers/infiniband/hw/hfi1/debugfs.c +76 -86
@@ -23,16 +23,15 @@static struct dentry *hfi1_dbg_root;/* wrappers to enforce srcu in seq file */ -ssize_t hfi1_seq_read (struct file *file,char __user *buf,size_t size, -loff_t *ppos) +ssize_t hfi1_seq_read (struct kiocb *iocb,struct iov_iter *to) { -struct dentry *d = file->f_path.dentry; +struct dentry *d = iocb->ki_filp->f_path.dentry;ssize_t r; r =debugfs_file_get (d);if (unlikely (r))return r; - r =seq_read (file, buf, size, ppos); + r =seq_read_iter (iocb, to);debugfs_file_put (d);return r; }
@@ -414,33 +413,27 @@ DEBUGFS_SEQ_FILE_OPEN(pios)DEBUGFS_FILE_OPS (pios);/* read the per-device counters */ -static ssize_t dev_counters_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t dev_counters_read (struct kiocb *iocb,struct iov_iter *to) {u64 *counters;size_t avail;struct hfi1_devdata *dd; -ssize_t rval; - dd =private2dd (file); + dd =private2dd (iocb->ki_filp); avail =hfi1_read_cntrs (dd,NULL , &counters); - rval =simple_read_from_buffer (buf, count, ppos, counters, avail); -return rval; +return simple_copy_to_iter (counters, &iocb->ki_pos, avail, to); }/* read the per-device counters */ -static ssize_t dev_names_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t dev_names_read (struct kiocb *iocb,struct iov_iter *to) {char *names;size_t avail;struct hfi1_devdata *dd; -ssize_t rval; - dd =private2dd (file); + dd =private2dd (iocb->ki_filp); avail =hfi1_read_cntrs (dd, &names,NULL ); - rval =simple_read_from_buffer (buf, count, ppos, names, avail); -return rval; +return simple_copy_to_iter (names, &iocb->ki_pos, avail, to); }struct counter_info {
@@ -454,33 +447,27 @@ struct counter_info {*/ /* read the per-port names (same for each port) */ -static ssize_t portnames_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t portnames_read (struct kiocb *iocb,struct iov_iter *to) {char *names;size_t avail;struct hfi1_devdata *dd; -ssize_t rval; - dd =private2dd (file); + dd =private2dd (iocb->ki_filp); avail =hfi1_read_portcntrs (dd->pport, &names,NULL ); - rval =simple_read_from_buffer (buf, count, ppos, names, avail); -return rval; +return simple_copy_to_iter (names, &iocb->ki_pos, avail, to); }/* read the per-port counters */ -static ssize_t portcntrs_debugfs_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t portcntrs_debugfs_read (struct kiocb *iocb,struct iov_iter *to) {u64 *counters;size_t avail;struct hfi1_pportdata *ppd; -ssize_t rval; - ppd =private2ppd (file); + ppd =private2ppd (iocb->ki_filp); avail =hfi1_read_portcntrs (ppd,NULL , &counters); - rval =simple_read_from_buffer (buf, count, ppos, counters, avail); -return rval; +return simple_copy_to_iter (counters, &iocb->ki_pos, avail, to); } static void check_dyn_flag(u64 scratch0, char *p, int size, int *used,
@@ -497,8 +484,7 @@ static void check_dyn_flag(u64 scratch0, char *p, int size, int *used, } } -static ssize_t asic_flags_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t asic_flags_read (struct kiocb *iocb,struct iov_iter *to) {struct hfi1_pportdata *ppd;struct hfi1_devdata *dd;
@@ -509,7 +495,7 @@ static ssize_t asic_flags_read(struct file *file, char __user *buf,int used;int i; - ppd =private2ppd (file); + ppd =private2ppd (iocb->ki_filp); dd = ppd->dd; size =PAGE_SIZE ; used =0 ;
@@ -541,14 +527,14 @@ static ssize_t asic_flags_read(struct file *file, char __user *buf, } used +=scnprintf (tmp + used, size - used,"Write bits to clear\n" ); - ret =simple_read_from_buffer (buf, count, ppos, tmp, used); + ret =simple_copy_to_iter (tmp, &iocb->ki_pos, used, to);kfree (tmp);return ret; } -static ssize_t asic_flags_write (struct file *file,const char __user *buf, -size_t count,loff_t *ppos) +static ssize_t asic_flags_write (struct kiocb *iocb,struct iov_iter *from) { +size_t count =iov_iter_count (from);struct hfi1_pportdata *ppd;struct hfi1_devdata *dd;char *buff;
@@ -557,11 +543,11 @@ static ssize_t asic_flags_write(struct file *file, const char __user *buf,u64 scratch0;u64 clear; - ppd =private2ppd (file); + ppd =private2ppd (iocb->ki_filp); dd = ppd->dd;/* zero terminate and read the expected integer */ - buff =memdup_user_nul (buf, count); + buff =iterdup_nul (from, count);if (IS_ERR (buff))return PTR_ERR (buff);
@@ -592,16 +578,16 @@ static ssize_t asic_flags_write(struct file *file, const char __user *buf, }/* read the dc8051 memory */ -static ssize_t dc8051_memory_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t dc8051_memory_read (struct kiocb *iocb,struct iov_iter *to) { -struct hfi1_pportdata *ppd =private2ppd (file); +struct hfi1_pportdata *ppd =private2ppd (iocb->ki_filp); +size_t count =iov_iter_count (to);ssize_t rval;void *tmp;loff_t start, end;/* the checks below expect the position to be positive */ -if (*ppos <0 ) +if (iocb->ki_pos <0 )return -EINVAL ; tmp =kzalloc (DC8051_DATA_MEM_SIZE ,GFP_KERNEL );
@@ -614,9 +600,9 @@ static ssize_t dc8051_memory_read(struct file *file, char __user *buf,* Adjust start and end to fit. Skip reading anything if out of * range. */ - start = *ppos & ~0x7 ;/* round down */ + start = iocb->ki_pos & ~0x7 ;/* round down */ if (start <DC8051_DATA_MEM_SIZE ) { - end = (*ppos + count +7 ) & ~0x7 ;/* round up */ + end = (iocb->ki_pos + count +7 ) & ~0x7 ;/* round up */ if (end >DC8051_DATA_MEM_SIZE ) end =DC8051_DATA_MEM_SIZE ; rval = read_8051_data(ppd->dd, start, end - start,
@@ -625,98 +611,96 @@ static ssize_t dc8051_memory_read(struct file *file, char __user *buf, goto done; } - rval =simple_read_from_buffer (buf, count, ppos, tmp, -DC8051_DATA_MEM_SIZE ); + rval =simple_copy_to_iter (tmp, &iocb->ki_pos,DC8051_DATA_MEM_SIZE , to); done:kfree (tmp);return rval; } -static ssize_t debugfs_lcb_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t debugfs_lcb_read (struct kiocb *iocb,struct iov_iter *to) { -struct hfi1_pportdata *ppd =private2ppd (file); +struct hfi1_pportdata *ppd =private2ppd (iocb->ki_filp); +size_t count =iov_iter_count (to);struct hfi1_devdata *dd = ppd->dd;unsigned long total, csr_off;u64 data; -if (*ppos <0 ) +if (iocb->ki_pos <0 )return -EINVAL ;/* only read 8 byte quantities */ if ((count %8 ) !=0 )return -EINVAL ;/* offset must be 8-byte aligned */ -if ((*ppos %8 ) !=0 ) +if ((iocb->ki_pos %8 ) !=0 )return -EINVAL ;/* do nothing if out of range or zero count */ -if (*ppos >= (LCB_END -LCB_START ) || !count) +if (iocb->ki_pos >= (LCB_END -LCB_START ) || !count)return 0 ;/* reduce count if needed */ -if (*ppos + count >LCB_END -LCB_START ) - count = (LCB_END -LCB_START ) - *ppos; +if (iocb->ki_pos + count >LCB_END -LCB_START ) + count = (LCB_END -LCB_START ) - iocb->ki_pos; - csr_off =LCB_START + *ppos; + csr_off =LCB_START + iocb->ki_pos;for (total =0 ; total < count; total +=8 , csr_off +=8 ) {if (read_lcb_csr (dd, csr_off, (u64 *)&data))break ;/* failed */ -if (put_user (data, (unsigned long __user *)(buf + total))) +if (!copy_to_iter_full (&data,sizeof (data), to))break ; } - *ppos += total; + iocb->ki_pos += total;return total; } -static ssize_t debugfs_lcb_write (struct file *file,const char __user *buf, -size_t count,loff_t *ppos) +static ssize_t debugfs_lcb_write (struct kiocb *iocb,struct iov_iter *from) { -struct hfi1_pportdata *ppd =private2ppd (file); +struct hfi1_pportdata *ppd =private2ppd (iocb->ki_filp); +size_t count =iov_iter_count (from);struct hfi1_devdata *dd = ppd->dd;unsigned long total, csr_off, data; -if (*ppos <0 ) +if (iocb->ki_pos <0 )return -EINVAL ;/* only write 8 byte quantities */ if ((count %8 ) !=0 )return -EINVAL ;/* offset must be 8-byte aligned */ -if ((*ppos %8 ) !=0 ) +if ((iocb->ki_pos %8 ) !=0 )return -EINVAL ;/* do nothing if out of range or zero count */ -if (*ppos >= (LCB_END -LCB_START ) || !count) +if (iocb->ki_pos >= (LCB_END -LCB_START ) || !count)return 0 ;/* reduce count if needed */ -if (*ppos + count >LCB_END -LCB_START ) - count = (LCB_END -LCB_START ) - *ppos; +if (iocb->ki_pos + count >LCB_END -LCB_START ) + count = (LCB_END -LCB_START ) - iocb->ki_pos; - csr_off =LCB_START + *ppos; + csr_off =LCB_START + iocb->ki_pos;for (total =0 ; total < count; total +=8 , csr_off +=8 ) { -if (get_user (data, (unsigned long __user *)(buf + total))) +if (!copy_from_iter_full (&data,sizeof (data), from))break ;if (write_lcb_csr (dd, csr_off, data))break ;/* failed */ } - *ppos += total; + iocb->ki_pos += total;return total; }/* * read the per-port QSFP data for ppd */ -static ssize_t qsfp_debugfs_dump (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t qsfp_debugfs_dump (struct kiocb *iocb,struct iov_iter *to) {struct hfi1_pportdata *ppd;char *tmp;int ret; - ppd =private2ppd (file); + ppd =private2ppd (iocb->ki_filp); tmp =kmalloc (PAGE_SIZE ,GFP_KERNEL );if (!tmp)return -ENOMEM ; ret =qsfp_dump (ppd, tmp,PAGE_SIZE );if (ret >0 ) - ret =simple_read_from_buffer (buf, count, ppos, tmp, ret); + ret =simple_copy_to_iter (tmp, &iocb->ki_pos, ret, to);kfree (tmp);return ret; }
@@ -767,6 +751,7 @@ static ssize_t i2c1_debugfs_write(struct file *file, const char __user *buf, {return __i2c_debugfs_write (file, buf, count, ppos,0 ); } +FOPS_WRITE_ITER_HELPER (i2c1_debugfs_write);/* Do an i2c write operation on chain for HFI 1. */ static ssize_t i2c2_debugfs_write(struct file *file, const char __user *buf,
@@ -774,6 +759,7 @@ static ssize_t i2c2_debugfs_write(struct file *file, const char __user *buf, {return __i2c_debugfs_write (file, buf, count, ppos,1 ); } +FOPS_WRITE_ITER_HELPER (i2c2_debugfs_write);/* Do an i2c read operation on the chain for the given HFI. */ static ssize_t __i2c_debugfs_read(struct file *file, char __user *buf,
@@ -827,6 +813,7 @@ static ssize_t i2c1_debugfs_read(struct file *file, char __user *buf, {return __i2c_debugfs_read (file, buf, count, ppos,0 ); } +FOPS_READ_ITER_HELPER (i2c1_debugfs_read);/* Do an i2c read operation on chain for HFI 1. */ static ssize_t i2c2_debugfs_read(struct file *file, char __user *buf,
@@ -834,6 +821,7 @@ static ssize_t i2c2_debugfs_read(struct file *file, char __user *buf, {return __i2c_debugfs_read (file, buf, count, ppos,1 ); } +FOPS_READ_ITER_HELPER (i2c2_debugfs_read);/* Do a QSFP write operation on the i2c chain for the given HFI. */ static ssize_t __qsfp_debugfs_write(struct file *file, const char __user *buf,
@@ -874,6 +862,7 @@ static ssize_t qsfp1_debugfs_write(struct file *file, const char __user *buf, {return __qsfp_debugfs_write (file, buf, count, ppos,0 ); } +FOPS_WRITE_ITER_HELPER (qsfp1_debugfs_write);/* Do a QSFP write operation on i2c chain for HFI 1. */ static ssize_t qsfp2_debugfs_write(struct file *file, const char __user *buf,
@@ -881,6 +870,7 @@ static ssize_t qsfp2_debugfs_write(struct file *file, const char __user *buf, {return __qsfp_debugfs_write (file, buf, count, ppos,1 ); } +FOPS_WRITE_ITER_HELPER (qsfp2_debugfs_write);/* Do a QSFP read operation on the i2c chain for the given HFI. */ static ssize_t __qsfp_debugfs_read(struct file *file, char __user *buf,
@@ -932,6 +922,7 @@ static ssize_t qsfp1_debugfs_read(struct file *file, char __user *buf, {return __qsfp_debugfs_read (file, buf, count, ppos,0 ); } +FOPS_READ_ITER_HELPER (qsfp1_debugfs_read);/* Do a QSFP read operation on i2c chain for HFI 1. */ static ssize_t qsfp2_debugfs_read(struct file *file, char __user *buf,
@@ -939,6 +930,7 @@ static ssize_t qsfp2_debugfs_read(struct file *file, char __user *buf, {return __qsfp_debugfs_read (file, buf, count, ppos,1 ); } +FOPS_READ_ITER_HELPER (qsfp2_debugfs_read);static int __i2c_debugfs_open (struct inode *in,struct file *fp,u32 target) {
@@ -1043,22 +1035,20 @@ static int exprom_wp_set(struct hfi1_devdata *dd, bool disable)return 0 ; } -static ssize_t exprom_wp_debugfs_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t exprom_wp_debugfs_read (struct kiocb *iocb,struct iov_iter *to) {return 0 ; } -static ssize_t exprom_wp_debugfs_write (struct file *file, -const char __user *buf,size_t count, -loff_t *ppos) +static ssize_t exprom_wp_debugfs_write (struct kiocb *iocb,struct iov_iter *from) { -struct hfi1_pportdata *ppd =private2ppd (file); +struct hfi1_pportdata *ppd =private2ppd (iocb->ki_filp); +size_t count =iov_iter_count (from);char cdata;if (count !=1 )return -EINVAL ; -if (get_user (cdata, buf)) +if (get_iter (cdata, from))return -EFAULT ;if (cdata =='0' )exprom_wp_set (ppd->dd, false);
@@ -1096,8 +1086,8 @@ static int exprom_wp_debugfs_release(struct inode *in, struct file *fp) .name = nm, \ .ops = { \ .owner = THIS_MODULE, \ - .read = readroutine, \ - .write = writeroutine, \ + .read_iter = readroutine, \ + .write_iter = writeroutine, \ .llseek = generic_file_llseek, \ }, \ }
@@ -1107,8 +1097,8 @@ static int exprom_wp_debugfs_release(struct inode *in, struct file *fp) .name = nm, \ .ops = { \ .owner = THIS_MODULE, \ - .read = readf, \ - .write = writef, \ + .read_iter = readf, \ + .write_iter = writef, \ .llseek = generic_file_llseek, \ .open = openf, \ .release = releasef \
@@ -1123,14 +1113,14 @@ static const struct counter_info cntr_ops[] = {static const struct counter_info port_cntr_ops[] = {DEBUGFS_OPS ("port%dcounters" , portcntrs_debugfs_read,NULL ), -DEBUGFS_XOPS ("i2c1" , i2c1_debugfs_read, i2c1_debugfs_write, +DEBUGFS_XOPS ("i2c1" , i2c1_debugfs_read_iter, i2c1_debugfs_write_iter, i2c1_debugfs_open, i2c1_debugfs_release), -DEBUGFS_XOPS ("i2c2" , i2c2_debugfs_read, i2c2_debugfs_write, +DEBUGFS_XOPS ("i2c2" , i2c2_debugfs_read_iter, i2c2_debugfs_write_iter, i2c2_debugfs_open, i2c2_debugfs_release),DEBUGFS_OPS ("qsfp_dump%d" , qsfp_debugfs_dump,NULL ), -DEBUGFS_XOPS ("qsfp1" , qsfp1_debugfs_read, qsfp1_debugfs_write, +DEBUGFS_XOPS ("qsfp1" , qsfp1_debugfs_read_iter, qsfp1_debugfs_write_iter, qsfp1_debugfs_open, qsfp1_debugfs_release), -DEBUGFS_XOPS ("qsfp2" , qsfp2_debugfs_read, qsfp2_debugfs_write, +DEBUGFS_XOPS ("qsfp2" , qsfp2_debugfs_read_iter, qsfp2_debugfs_write_iter, qsfp2_debugfs_open, qsfp2_debugfs_release), DEBUGFS_XOPS("exprom_wp", exprom_wp_debugfs_read, exprom_wp_debugfs_write, exprom_wp_debugfs_open,
@@ -1222,7 +1212,7 @@ void hfi1_dbg_ibdev_init(struct hfi1_ibdev *ibd) port_cntr_ops[i].name, j + 1);debugfs_create_file (name, - !port_cntr_ops[i].ops.write ? + !port_cntr_ops[i].ops.write_iter ?S_IRUGO :S_IRUGO |S_IWUSR , root, ppd, &port_cntr_ops[i].ops);
drivers/infiniband/hw/hfi1/debugfs.h +2 -4
@@ -33,14 +33,12 @@ static int _##name##_open(struct inode *inode, struct file *s) \ static const struct file_operations _##name##_file_ops = { \ .owner = THIS_MODULE, \ .open = _##name##_open, \ - .read = hfi1_seq_read, \ + .read_iter = hfi1_seq_read, \ .llseek = hfi1_seq_lseek, \ .release = seq_release \ } - -ssize_t hfi1_seq_read (struct file *file,char __user *buf,size_t size, -loff_t *ppos); +ssize_t hfi1_seq_read (struct kiocb *iocb,struct iov_iter *to);loff_t hfi1_seq_lseek (struct file *file,loff_t offset,int whence);#ifdef CONFIG_DEBUG_FS
drivers/infiniband/hw/hfi1/fault.c +13 -14
@@ -86,25 +86,25 @@ static int fault_opcodes_open(struct inode *inode, struct file *file)return nonseekable_open (inode, file); } -static ssize_t fault_opcodes_write (struct file *file,const char __user *buf, -size_t len,loff_t *pos) +static ssize_t fault_opcodes_write (struct kiocb *iocb,struct iov_iter *from) {ssize_t ret =0 ;/* 1280 = 256 opcodes * 4 chars/opcode + 255 commas + NULL */ size_t copy, datalen =1280 ;char *data, *token, *ptr, *end; -struct fault *fault = file->private_data; +struct fault *fault = iocb->ki_filp->private_data; +size_t len =iov_iter_count (from); data =kcalloc (datalen,sizeof (*data),GFP_KERNEL );if (!data)return -ENOMEM ; copy =min (len, datalen -1 ); -if (copy_from_user (data, buf, copy)) { +if (!copy_from_iter_full (data, copy, from)) { ret = -EFAULT ; goto free_data; } - ret =debugfs_file_get (file->f_path.dentry); + ret =debugfs_file_get (iocb->ki_filp->f_path.dentry);if (unlikely (ret)) goto free_data; ptr = data;
@@ -154,26 +154,25 @@ static ssize_t fault_opcodes_write(struct file *file, const char __user *buf, } ret = len; -debugfs_file_put (file->f_path.dentry); +debugfs_file_put (iocb->ki_filp->f_path.dentry); free_data:kfree (data);return ret; } -static ssize_t fault_opcodes_read (struct file *file,char __user *buf, -size_t len,loff_t *pos) +static ssize_t fault_opcodes_read (struct kiocb *iocb,struct iov_iter *to) {ssize_t ret =0 ;char *data;size_t datalen =1280 , size =0 ;/* see fault_opcodes_write() */ unsigned long bit =0 , zero =0 ; -struct fault *fault = file->private_data; +struct fault *fault = iocb->ki_filp->private_data;size_t bitsize =sizeof (fault->opcodes) *BITS_PER_BYTE ; data =kcalloc (datalen,sizeof (*data),GFP_KERNEL );if (!data)return -ENOMEM ; - ret =debugfs_file_get (file->f_path.dentry); + ret =debugfs_file_get (iocb->ki_filp->f_path.dentry);if (unlikely (ret)) goto free_data; bit =find_first_bit (fault->opcodes, bitsize);
@@ -189,10 +188,10 @@ static ssize_t fault_opcodes_read(struct file *file, char __user *buf, bit); bit =find_next_bit (fault->opcodes, bitsize, zero); } -debugfs_file_put (file->f_path.dentry); +debugfs_file_put (iocb->ki_filp->f_path.dentry); data[size -1 ] ='\n' ; data[size] ='\0' ; - ret =simple_read_from_buffer (buf, len, pos, data, size); + ret =simple_copy_to_iter (data, &iocb->ki_pos, size, to); free_data:kfree (data);return ret;
@@ -201,8 +200,8 @@ static ssize_t fault_opcodes_read(struct file *file, char __user *buf,static const struct file_operations __fault_opcodes_fops = { .owner =THIS_MODULE , .open = fault_opcodes_open, - .read = fault_opcodes_read, - .write = fault_opcodes_write, + .read_iter = fault_opcodes_read, + .write_iter = fault_opcodes_write, .llseek = no_llseek };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 407/437 infiniband/mlx5: convert to read/write iterators
In reply to Jens Axboe--- drivers/infiniband/hw/mlx5/cong.c | 19 ++++++++-------- drivers/infiniband/hw/mlx5/devx.c | 24 +++++++++---------- drivers/infiniband/hw/mlx5/main.c | 20 ++++++++-------- drivers/infiniband/hw/mlx5/mr.c | 38 +++++++++++++++---------------- 4 files changed, 49 insertions(+), 52 deletions(-)
drivers/infiniband/hw/mlx5/cong.c +9 -10
@@ -368,10 +368,10 @@ static int mlx5_ib_set_cc_params(struct mlx5_ib_dev *dev, u32 port_num,return err; } -static ssize_t set_param (struct file *filp,const char __user *buf, -size_t count,loff_t *pos) +static ssize_t set_param (struct kiocb *iocb,struct iov_iter *from) { -struct mlx5_ib_dbg_param *param = filp->private_data; +struct mlx5_ib_dbg_param *param = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);int offset = param->offset;char lbuf[11 ] = { };u32 var;
@@ -380,7 +380,7 @@ static ssize_t set_param(struct file *filp, const char __user *buf,if (count >sizeof (lbuf))return -EINVAL ; -if (copy_from_user (lbuf, buf, count)) +if (!copy_from_iter_full (lbuf, count, from))return -EFAULT ; lbuf[sizeof (lbuf) -1 ] ='\0' ;
@@ -392,10 +392,9 @@ static ssize_t set_param(struct file *filp, const char __user *buf,return ret ? ret : count; } -static ssize_t get_param (struct file *filp,char __user *buf,size_t count, -loff_t *pos) +static ssize_t get_param (struct kiocb *iocb,struct iov_iter *to) { -struct mlx5_ib_dbg_param *param = filp->private_data; +struct mlx5_ib_dbg_param *param = iocb->ki_filp->private_data;int offset = param->offset;u32 var =0 ;int ret;
@@ -409,14 +408,14 @@ static ssize_t get_param(struct file *filp, char __user *buf, size_t count,if (ret <0 )return ret; -return simple_read_from_buffer (buf, count, pos, lbuf, ret); +return simple_copy_to_iter (lbuf, &iocb->ki_pos, ret, to); }static const struct file_operations dbg_cc_fops = { .owner =THIS_MODULE , .open = simple_open, - .write = set_param, - .read = get_param, + .write_iter = set_param, + .read_iter = get_param, };void mlx5_ib_cleanup_cong_debugfs (struct mlx5_ib_dev *dev,u32 port_num)
drivers/infiniband/hw/mlx5/devx.c +12 -12
@@ -2595,11 +2595,11 @@ void mlx5_ib_devx_cleanup(struct mlx5_ib_dev *dev) } } -static ssize_t devx_async_cmd_event_read (struct file *filp,char __user *buf, -size_t count,loff_t *pos) +static ssize_t devx_async_cmd_event_read (struct kiocb *iocb,struct iov_iter *to) { -struct devx_async_cmd_event_file *comp_ev_file = filp->private_data; +struct devx_async_cmd_event_file *comp_ev_file = iocb->ki_filp->private_data;struct devx_async_event_queue *ev_queue = &comp_ev_file->ev_queue; +size_t count =iov_iter_count (to);struct devx_async_data *event;int ret =0 ;size_t eventsz;
@@ -2609,7 +2609,7 @@ static ssize_t devx_async_cmd_event_read(struct file *filp, char __user *buf,while (list_empty (&ev_queue->event_list)) {spin_unlock_irq (&ev_queue->lock); -if (filp->f_flags &O_NONBLOCK ) +if (iocb->ki_filp->f_flags &O_NONBLOCK )return -EAGAIN ; if (wait_event_interruptible(
@@ -2639,7 +2639,7 @@ static ssize_t devx_async_cmd_event_read(struct file *filp, char __user *buf,list_del (ev_queue->event_list.next);spin_unlock_irq (&ev_queue->lock); -if (copy_to_user (buf, &event->hdr, eventsz)) +if (!copy_to_iter_full (&event->hdr, eventsz, to)) ret = -EFAULT ;else ret = eventsz;
@@ -2670,18 +2670,18 @@ static __poll_t devx_async_cmd_event_poll(struct file *filp,static const struct file_operations devx_async_cmd_event_fops = { .owner =THIS_MODULE , - .read = devx_async_cmd_event_read, + .read_iter = devx_async_cmd_event_read, .poll = devx_async_cmd_event_poll, .release = uverbs_uobject_fd_release, .llseek = no_llseek, }; -static ssize_t devx_async_event_read (struct file *filp,char __user *buf, -size_t count,loff_t *pos) +static ssize_t devx_async_event_read (struct kiocb *iocb,struct iov_iter *to) { -struct devx_async_event_file *ev_file = filp->private_data; +struct devx_async_event_file *ev_file = iocb->ki_filp->private_data;struct devx_event_subscription *event_sub;struct devx_async_event_data *event; +size_t count =iov_iter_count (to);int ret =0 ;size_t eventsz;bool omit_data;
@@ -2701,7 +2701,7 @@ static ssize_t devx_async_event_read(struct file *filp, char __user *buf,while (list_empty (&ev_file->event_list)) {spin_unlock_irq (&ev_file->lock); -if (filp->f_flags &O_NONBLOCK ) +if (iocb->ki_filp->f_flags &O_NONBLOCK )return -EAGAIN ; if (wait_event_interruptible(ev_file->poll_wait,
@@ -2743,7 +2743,7 @@ static ssize_t devx_async_event_read(struct file *filp, char __user *buf,spin_unlock_irq (&ev_file->lock); -if (copy_to_user (buf, event_data, eventsz)) +if (!copy_to_iter_full (event_data, eventsz, to))/* This points to an application issue, not a kernel concern */ ret = -EFAULT ;else
@@ -2785,7 +2785,7 @@ static void devx_free_subscription(struct rcu_head *rcu)static const struct file_operations devx_async_event_fops = { .owner =THIS_MODULE , - .read = devx_async_event_read, + .read_iter = devx_async_event_read, .poll = devx_async_event_poll, .release = uverbs_uobject_fd_release, .llseek = no_llseek,
drivers/infiniband/hw/mlx5/main.c +10 -10
@@ -3154,25 +3154,25 @@ static int mlx5_ib_rn_get_params(struct ib_device *device, u32 port_num,return mlx5_rdma_rn_get_params (to_mdev (device)->mdev, device, params); } -static ssize_t delay_drop_timeout_read (struct file *filp,char __user *buf, -size_t count,loff_t *pos) +static ssize_t delay_drop_timeout_read (struct kiocb *iocb,struct iov_iter *to) { -struct mlx5_ib_delay_drop *delay_drop = filp->private_data; +struct mlx5_ib_delay_drop *delay_drop = iocb->ki_filp->private_data;char lbuf[20 ];int len; len =snprintf (lbuf,sizeof (lbuf),"%u\n" , delay_drop->timeout); -return simple_read_from_buffer (buf, count, pos, lbuf, len); +return simple_copy_to_iter (lbuf, &iocb->ki_pos, len, to); } -static ssize_t delay_drop_timeout_write (struct file *filp,const char __user *buf, -size_t count,loff_t *pos) +static ssize_t delay_drop_timeout_write (struct kiocb *iocb, +struct iov_iter *from) { -struct mlx5_ib_delay_drop *delay_drop = filp->private_data; +struct mlx5_ib_delay_drop *delay_drop = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);u32 timeout;u32 var; -if (kstrtouint_from_user (buf, count,0 , &var)) +if (kstrtouint_from_iter (from, count,0 , &var))return -EFAULT ; timeout = min_t(u32, roundup(var, 100), MLX5_MAX_DELAY_DROP_TIMEOUT_MS *
@@ -3189,8 +3189,8 @@ static ssize_t delay_drop_timeout_write(struct file *filp, const char __user *bustatic const struct file_operations fops_delay_drop_timeout = { .owner =THIS_MODULE , .open = simple_open, - .write = delay_drop_timeout_write, - .read = delay_drop_timeout_read, + .write_iter = delay_drop_timeout_write, + .read_iter = delay_drop_timeout_read, }; static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev,
drivers/infiniband/hw/mlx5/mr.c +18 -20
@@ -366,14 +366,14 @@ static int resize_available_mrs(struct mlx5_cache_ent *ent, unsigned int target, } } -static ssize_t size_write (struct file *filp,const char __user *buf, -size_t count,loff_t *pos) +static ssize_t size_write (struct kiocb *iocb,struct iov_iter *from) { -struct mlx5_cache_ent *ent = filp->private_data; +struct mlx5_cache_ent *ent = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);u32 target;int err; - err =kstrtou32_from_user (buf, count,0 , &target); + err =kstrtou32_from_iter (from, count,0 , &target);if (err)return err;
@@ -404,10 +404,9 @@ static ssize_t size_write(struct file *filp, const char __user *buf,return err; } -static ssize_t size_read (struct file *filp,char __user *buf,size_t count, -loff_t *pos) +static ssize_t size_read (struct kiocb *iocb,struct iov_iter *to) { -struct mlx5_cache_ent *ent = filp->private_data; +struct mlx5_cache_ent *ent = iocb->ki_filp->private_data;char lbuf[20 ];int err;
@@ -416,24 +415,24 @@ static ssize_t size_read(struct file *filp, char __user *buf, size_t count,if (err <0 )return err; -return simple_read_from_buffer (buf, count, pos, lbuf, err); +return simple_copy_to_iter (lbuf, &iocb->ki_pos, err, to); }static const struct file_operations size_fops = { .owner =THIS_MODULE , .open = simple_open, - .write = size_write, - .read = size_read, + .write_iter = size_write, + .read_iter = size_read, }; -static ssize_t limit_write (struct file *filp,const char __user *buf, -size_t count,loff_t *pos) +static ssize_t limit_write (struct kiocb *iocb,struct iov_iter *from) { -struct mlx5_cache_ent *ent = filp->private_data; +struct mlx5_cache_ent *ent = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);u32 var;int err; - err =kstrtou32_from_user (buf, count,0 , &var); + err =kstrtou32_from_iter (from, count,0 , &var);if (err)return err;
@@ -450,10 +449,9 @@ static ssize_t limit_write(struct file *filp, const char __user *buf,return count; } -static ssize_t limit_read (struct file *filp,char __user *buf,size_t count, -loff_t *pos) +static ssize_t limit_read (struct kiocb *iocb,struct iov_iter *to) { -struct mlx5_cache_ent *ent = filp->private_data; +struct mlx5_cache_ent *ent = iocb->ki_filp->private_data;char lbuf[20 ];int err;
@@ -461,14 +459,14 @@ static ssize_t limit_read(struct file *filp, char __user *buf, size_t count,if (err <0 )return err; -return simple_read_from_buffer (buf, count, pos, lbuf, err); +return simple_copy_to_iter (lbuf, &iocb->ki_pos, err, to); }static const struct file_operations limit_fops = { .owner =THIS_MODULE , .open = simple_open, - .write = limit_write, - .read = limit_read, + .write_iter = limit_write, + .read_iter = limit_read, };static bool someone_adding (struct mlx5_mkey_cache *cache)
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 408/437 infiniband/ocrdma: convert to read/write iterators
In reply to Jens Axboe--- drivers/infiniband/hw/ocrdma/ocrdma_stats.c | 26 ++++++++++----------- 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_stats.c +12 -14
@@ -631,20 +631,19 @@ static void ocrdma_update_stats(struct ocrdma_dev *dev) } } -static ssize_t ocrdma_dbgfs_ops_write (struct file *filp, -const char __user *buffer, -size_t count,loff_t *ppos) +static ssize_t ocrdma_dbgfs_ops_write (struct kiocb *iocb,struct iov_iter *from) {char tmp_str[32 ];long reset;int status; -struct ocrdma_stats *pstats = filp->private_data; +struct ocrdma_stats *pstats = iocb->ki_filp->private_data;struct ocrdma_dev *dev = pstats->dev; +size_t count =iov_iter_count (from); -if (*ppos !=0 || count ==0 || count >sizeof (tmp_str)) +if (iocb->ki_pos !=0 || count ==0 || count >sizeof (tmp_str)) goto err; -if (copy_from_user (tmp_str, buffer, count)) +if (!copy_from_iter_full (tmp_str, count, from)) goto err; tmp_str[count-1 ] ='\0' ;
@@ -683,16 +682,16 @@ void ocrdma_pma_counters(struct ocrdma_dev *dev, struct ib_mad *out_mad) pma_cnt->port_rcv_packets =cpu_to_be32 (ocrdma_sysfs_rcv_pkts (dev)); } -static ssize_t ocrdma_dbgfs_ops_read (struct file *filp,char __user *buffer, -size_t usr_buf_len,loff_t *ppos) +static ssize_t ocrdma_dbgfs_ops_read (struct kiocb *iocb,struct iov_iter *to) { -struct ocrdma_stats *pstats = filp->private_data; +struct ocrdma_stats *pstats = iocb->ki_filp->private_data; +size_t usr_buf_len =iov_iter_count (to);struct ocrdma_dev *dev = pstats->dev;ssize_t status =0 ;char *data =NULL ;/* No partial reads */ -if (*ppos !=0 ) +if (iocb->ki_pos !=0 )return 0 ;mutex_lock (&dev->stats_lock);
@@ -741,8 +740,7 @@ static ssize_t ocrdma_dbgfs_ops_read(struct file *filp, char __user *buffer, goto exit; } - status =simple_read_from_buffer (buffer, usr_buf_len, ppos, data, -strlen (data)); + status =simple_copy_to_iter (data, &iocb->ki_pos,strlen (data), to); exit:mutex_unlock (&dev->stats_lock);return status;
@@ -751,8 +749,8 @@ static ssize_t ocrdma_dbgfs_ops_read(struct file *filp, char __user *buffer,static const struct file_operations ocrdma_dbg_ops = { .owner =THIS_MODULE , .open = simple_open, - .read = ocrdma_dbgfs_ops_read, - .write = ocrdma_dbgfs_ops_write, + .read_iter = ocrdma_dbgfs_ops_read, + .write_iter = ocrdma_dbgfs_ops_write, };void ocrdma_add_port_stats (struct ocrdma_dev *dev)
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 409/437 infiniband/qib: convert to read/write iterators
In reply to Jens Axboe--- drivers/infiniband/hw/qib/qib_debugfs.c | 2 +- drivers/infiniband/hw/qib/qib_diag.c | 18 ++-- drivers/infiniband/hw/qib/qib_file_ops.c | 4 +- drivers/infiniband/hw/qib/qib_fs.c | 119 +++++++++++------------ 4 files changed, 68 insertions(+), 75 deletions(-)
drivers/infiniband/hw/qib/qib_debugfs.c +1 -1
@@ -61,7 +61,7 @@ static int _##name##_open(struct inode *inode, struct file *s) \ static const struct file_operations _##name##_file_ops = { \ .owner = THIS_MODULE, \ .open = _##name##_open, \ - .read = seq_read, \ + .read_iter = seq_read_iter, \ .llseek = seq_lseek, \ .release = seq_release \ };
drivers/infiniband/hw/qib/qib_diag.c +9 -9
@@ -130,15 +130,13 @@ static void return_client(struct qib_diag_client *dc)static int qib_diag_open (struct inode *in,struct file *fp);static int qib_diag_release (struct inode *in,struct file *fp); -static ssize_t qib_diag_read (struct file *fp,char __user *data, -size_t count,loff_t *off); -static ssize_t qib_diag_write (struct file *fp,const char __user *data, -size_t count,loff_t *off); +static ssize_t qib_diag_read_iter (struct kiocb *iocb,struct iov_iter *to); +static ssize_t qib_diag_write_iter (struct kiocb *iocb,struct iov_iter *from);static const struct file_operations diag_file_ops = { .owner =THIS_MODULE , - .write = qib_diag_write, - .read = qib_diag_read, + .write_iter = qib_diag_write_iter, + .read_iter = qib_diag_read_iter, .open = qib_diag_open, .release = qib_diag_release, .llseek = default_llseek,
@@ -148,12 +146,11 @@ static atomic_t diagpkt_count = ATOMIC_INIT(0);static struct cdev *diagpkt_cdev;static struct device *diagpkt_device; -static ssize_t qib_diagpkt_write (struct file *fp,const char __user *data, -size_t count,loff_t *off); +static ssize_t qib_diagpkt_write_iter (struct kiocb *iocb,struct iov_iter *from);static const struct file_operations diagpkt_file_ops = { .owner =THIS_MODULE , - .write = qib_diagpkt_write, + .write_iter = qib_diagpkt_write_iter, .llseek = noop_llseek, };
@@ -672,6 +669,7 @@ static ssize_t qib_diagpkt_write(struct file *fp,vfree (tmpbuf);return ret; } +FOPS_WRITE_ITER_HELPER (qib_diagpkt_write);static int qib_diag_release (struct inode *in,struct file *fp) {
@@ -829,6 +827,7 @@ static ssize_t qib_diag_read(struct file *fp, char __user *data, bail:return ret; } +FOPS_READ_ITER_HELPER (qib_diag_read);static ssize_t qib_diag_write (struct file *fp,const char __user *data,size_t count,loff_t *off)
@@ -904,3 +903,4 @@ static ssize_t qib_diag_write(struct file *fp, const char __user *data, bail:return ret; } +FOPS_WRITE_ITER_HELPER (qib_diag_write);
drivers/infiniband/hw/qib/qib_file_ops.c +3 -1
@@ -68,7 +68,6 @@ static int qib_mmapf(struct file *, struct vm_area_struct *);*/ static const struct file_operations qib_file_ops = { .owner =THIS_MODULE , - .write = qib_write, .write_iter = qib_write_iter, .open = qib_open, .release = qib_close,
@@ -2244,6 +2243,9 @@ static ssize_t qib_write_iter(struct kiocb *iocb, struct iov_iter *from)struct qib_ctxtdata *rcd =ctxt_fp (iocb->ki_filp);struct qib_user_sdma_queue *pq = fp->pq; +if (!(iocb->ki_flags &IOCB_VECTORED )) +vfs_write_iter (iocb, from, qib_write); +if (!user_backed_iter (from) || !from->nr_segs || !pq)return -EINVAL ;
drivers/infiniband/hw/qib/qib_fs.c +55 -64
266 lines not on this page · raw message
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 410/437 infiniband/hns: convert to read/write iterators
In reply to Jens Axboe--- drivers/infiniband/hw/hns/hns_roce_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_debugfs.c +1 -1
@@ -21,7 +21,7 @@ static const struct file_operations hns_debugfs_seqfile_fops = { .owner = THIS_MODULE, .open = hns_debugfs_seqfile_open, .release = single_release, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 411/437 infiniband/usnic: convert to read/write iterators
In reply to Jens Axboe--- drivers/infiniband/hw/usnic/usnic_debugfs.c | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/infiniband/hw/usnic/usnic_debugfs.c +11 -11
@@ -42,13 +42,13 @@static struct dentry *debugfs_root;static struct dentry *flows_dentry; -static ssize_t usnic_debugfs_buildinfo_read (struct file *f,char __user *data, -size_t count,loff_t *ppos) +static ssize_t usnic_debugfs_buildinfo_read (struct kiocb *iocb, +struct iov_iter *to) {char buf[500 ];int res; -if (*ppos >0 ) +if (iocb->ki_pos >0 )return 0 ; res = scnprintf(buf, sizeof(buf),
@@ -56,29 +56,29 @@ static ssize_t usnic_debugfs_buildinfo_read(struct file *f, char __user *data,"build date: %s\n" , DRV_VERSION, DRV_RELDATE); -return simple_read_from_buffer (data, count, ppos, buf, res); +return simple_copy_to_iter (buf, &iocb->ki_pos, res, to); }static const struct file_operations usnic_debugfs_buildinfo_ops = { .owner =THIS_MODULE , .open = simple_open, - .read = usnic_debugfs_buildinfo_read + .read_iter = usnic_debugfs_buildinfo_read }; -static ssize_t flowinfo_read (struct file *f,char __user *data, -size_t count,loff_t *ppos) +static ssize_t flowinfo_read (struct kiocb *iocb,struct iov_iter *to) {struct usnic_ib_qp_grp_flow *qp_flow; +size_t count =iov_iter_count (to);int n;int left;char *ptr;char buf[512 ]; - qp_flow = f->private_data; + qp_flow = iocb->ki_filp->private_data; ptr = buf; left = count; -if (*ppos >0 ) +if (iocb->ki_pos >0 )return 0 ;spin_lock (&qp_flow->qp_grp->lock);
@@ -100,13 +100,13 @@ static ssize_t flowinfo_read(struct file *f, char __user *data, }spin_unlock (&qp_flow->qp_grp->lock); -return simple_read_from_buffer (data, count, ppos, buf, ptr - buf); +return simple_copy_to_iter (buf, &iocb->ki_pos, ptr - buf, to); }static const struct file_operations flowinfo_ops = { .owner =THIS_MODULE , .open = simple_open, - .read = flowinfo_read, + .read_iter = flowinfo_read, };void usnic_debugfs_init (void )
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 412/437 hv: convert to read/write iterators
In reply to Jens Axboe--- drivers/hv/hv_utils_transport.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/hv/hv_utils_transport.c +10 -10
@@ -24,13 +24,13 @@ static void hvt_reset(struct hvutil_transport *hvt) hvt->on_reset (); } -static ssize_t hvt_op_read (struct file *file,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t hvt_op_read (struct kiocb *iocb,struct iov_iter *to) { +size_t count =iov_iter_count (to);struct hvutil_transport *hvt;int ret; - hvt = container_of(file->f_op, struct hvutil_transport, fops); + hvt = container_of(iocb->ki_filp->f_op, struct hvutil_transport, fops);if (wait_event_interruptible (hvt->outmsg_q, hvt->outmsg_len >0 || hvt->mode !=HVUTIL_TRANSPORT_CHARDEV ))
@@ -53,7 +53,7 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf, goto out_unlock; } -if (!copy_to_user (buf, hvt->outmsg, hvt->outmsg_len)) +if (copy_to_iter_full (hvt->outmsg, hvt->outmsg_len, to)) ret = hvt->outmsg_len;else ret = -EFAULT ;
@@ -71,16 +71,16 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf,return ret; } -static ssize_t hvt_op_write (struct file *file,const char __user *buf, -size_t count,loff_t *ppos) +static ssize_t hvt_op_write (struct kiocb *iocb,struct iov_iter *from) { +size_t count =iov_iter_count (from);struct hvutil_transport *hvt;u8 *inmsg;int ret; - hvt = container_of(file->f_op, struct hvutil_transport, fops); + hvt = container_of(iocb->ki_filp->f_op, struct hvutil_transport, fops); - inmsg =memdup_user (buf, count); + inmsg =iterdup (from, count);if (IS_ERR (inmsg))return PTR_ERR (inmsg);
@@ -285,8 +285,8 @@ struct hvutil_transport *hvutil_transport_init(const char *name, hvt->mdev.name = name; hvt->fops.owner =THIS_MODULE ; - hvt->fops.read = hvt_op_read; - hvt->fops.write = hvt_op_write; + hvt->fops.read_iter = hvt_op_read; + hvt->fops.write_iter = hvt_op_write; hvt->fops.poll = hvt_op_poll; hvt->fops.open = hvt_op_open; hvt->fops.release = hvt_op_release;
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 413/437 media/rc: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/rc/imon.c | 26 ++++++++++++-------------- drivers/media/rc/lirc_dev.c | 15 ++++++++------- 2 files changed, 20 insertions(+), 21 deletions(-)
drivers/media/rc/imon.c +12 -14
@@ -65,12 +65,10 @@ static int display_open(struct inode *inode, struct file *file);static int display_close (struct inode *inode,struct file *file);/* VFD write operation */ -static ssize_t vfd_write (struct file *file,const char __user *buf, -size_t n_bytes,loff_t *pos); +static ssize_t vfd_write (struct kiocb *iocb,struct iov_iter *from);/* LCD file_operations override function prototypes */ -static ssize_t lcd_write (struct file *file,const char __user *buf, -size_t n_bytes,loff_t *pos); +static ssize_t lcd_write (struct kiocb *iocb,struct iov_iter *from);/*** G L O B A L S ***/
@@ -179,7 +177,7 @@ struct imon_context {static const struct file_operations vfd_fops = { .owner =THIS_MODULE , .open = display_open, - .write = vfd_write, + .write_iter = vfd_write, .release = display_close, .llseek = noop_llseek, };
@@ -188,7 +186,7 @@ static const struct file_operations vfd_fops = {static const struct file_operations lcd_fops = { .owner =THIS_MODULE , .open = display_open, - .write = lcd_write, + .write_iter = lcd_write, .release = display_close, .llseek = noop_llseek, };
@@ -938,16 +936,16 @@ static const struct attribute_group imon_rf_attr_group = {* than 32 bytes are provided spaces will be appended to * generate a full screen. */ -static ssize_t vfd_write (struct file *file,const char __user *buf, -size_t n_bytes,loff_t *pos) +static ssize_t vfd_write (struct kiocb *iocb,struct iov_iter *from) {int i;int offset;int seq;int retval =0 ; -struct imon_context *ictx = file->private_data; +struct imon_context *ictx = iocb->ki_filp->private_data;static const unsigned char vfd_packet6[] = {0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0xFF ,0xFF }; +size_t n_bytes =iov_iter_count (from);if (ictx->disconnected)return -ENODEV ;
@@ -967,7 +965,7 @@ static ssize_t vfd_write(struct file *file, const char __user *buf, goto exit; } -if (copy_from_user (ictx->tx.data_buf, buf, n_bytes)) { +if (!copy_from_iter_full (ictx->tx.data_buf, n_bytes, from)) { retval = -EFAULT ; goto exit; }
@@ -1023,11 +1021,11 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,* display whatever diacritics you need, and so on), but it's also * a lot more complicated than most LCDs... */ -static ssize_t lcd_write (struct file *file,const char __user *buf, -size_t n_bytes,loff_t *pos) +static ssize_t lcd_write (struct kiocb *iocb,struct iov_iter *from) {int retval =0 ; -struct imon_context *ictx = file->private_data; +struct imon_context *ictx = iocb->ki_filp->private_data; +size_t n_bytes =iov_iter_count (from);if (ictx->disconnected)return -ENODEV ;
@@ -1047,7 +1045,7 @@ static ssize_t lcd_write(struct file *file, const char __user *buf, goto exit; } -if (copy_from_user (ictx->usb_tx_buf, buf,8 )) { +if (!copy_from_iter_full (ictx->usb_tx_buf,8 , from)) { retval = -EFAULT ; goto exit; }
drivers/media/rc/lirc_dev.c +8 -7
@@ -211,10 +211,10 @@ static int lirc_close(struct inode *inode, struct file *file)return 0 ; } -static ssize_t lirc_transmit (struct file *file,const char __user *buf, -size_t n,loff_t *ppos) +static ssize_t lirc_transmit (struct kiocb *iocb,struct iov_iter *from) { -struct lirc_fh *fh = file->private_data; +struct lirc_fh *fh = iocb->ki_filp->private_data; +size_t n =iov_iter_count (from);struct rc_dev *dev = fh->rc;unsigned int *txbuf;struct ir_raw_event *raw =NULL ;
@@ -247,7 +247,7 @@ static ssize_t lirc_transmit(struct file *file, const char __user *buf, goto out_unlock; } -if (copy_from_user (&scan, buf,sizeof (scan))) { +if (!copy_from_iter_full (&scan,sizeof (scan), from)) { ret = -EFAULT ; goto out_unlock; }
@@ -309,7 +309,7 @@ static ssize_t lirc_transmit(struct file *file, const char __user *buf, goto out_unlock; } - txbuf =memdup_user (buf, n); + txbuf =iterdup (from, n);if (IS_ERR (txbuf)) { ret =PTR_ERR (txbuf); goto out_unlock;
@@ -694,13 +694,14 @@ static ssize_t lirc_read(struct file *file, char __user *buffer, size_t length,else /* LIRC_MODE_SCANCODE */ return lirc_read_scancode (file, buffer, length); } +FOPS_READ_ITER_HELPER (lirc_read);static const struct file_operations lirc_fops = { .owner =THIS_MODULE , - .write = lirc_transmit, + .write_iter = lirc_transmit, .unlocked_ioctl = lirc_ioctl, .compat_ioctl = compat_ptr_ioctl, - .read = lirc_read, + .read_iter = lirc_read_iter, .poll = lirc_poll, .open = lirc_open, .release = lirc_close,
Signature · 1 line
2.43.0
Mauro Carvalho Chehab
maintainerRe: [PATCH 413/437] media/rc: convert to read/write iterators
Em Thu, 11 Apr 2024 09:19:13 -0600
Jens Axboe <[email protected]> escreveu:
Quoted 1 line
Signed-off-by Jens Axboe <[email protected]>
Please add a patch description to media patches. Also, please c/c [email protected], as otherwise patchwork.linuxtv.org won't track it, and such patches will be silently ignored[1].
[1] I only got aware of this series due to https://lwn.net/Articles/972081/
Regards,
Mauro
Quoted 148 lines
--- drivers/media/rc/imon.c | 26 ++++++++++++-------------- drivers/media/rc/lirc_dev.c | 15 ++++++++------- 2 files changed, 20 insertions(+), 21 deletions(-)drivers/media/rc/imon.c +12
-14@@ -65,12 +65,10 @@ static int display_open(struct inode *inode, struct file *file);static int display_close (struct inode *inode,struct file *file);/* VFD write operation */ -static ssize_t vfd_write (struct file *file,const char __user *buf, -size_t n_bytes,loff_t *pos); +static ssize_t vfd_write (struct kiocb *iocb,struct iov_iter *from);/* LCD file_operations override function prototypes */ -static ssize_t lcd_write (struct file *file,const char __user *buf, -size_t n_bytes,loff_t *pos); +static ssize_t lcd_write (struct kiocb *iocb,struct iov_iter *from);/*** G L O B A L S ***/ @@ -179,7 +177,7 @@ struct imon_context {static const struct file_operations vfd_fops = { .owner =THIS_MODULE , .open = display_open, - .write = vfd_write, + .write_iter = vfd_write, .release = display_close, .llseek = noop_llseek, };@@ -188,7 +186,7 @@ static const struct file_operations vfd_fops = {static const struct file_operations lcd_fops = { .owner =THIS_MODULE , .open = display_open, - .write = lcd_write, + .write_iter = lcd_write, .release = display_close, .llseek = noop_llseek, };@@ -938,16 +936,16 @@ static const struct attribute_group imon_rf_attr_group = {* than 32 bytes are provided spaces will be appended to * generate a full screen. */ -static ssize_t vfd_write (struct file *file,const char __user *buf, -size_t n_bytes,loff_t *pos) +static ssize_t vfd_write (struct kiocb *iocb,struct iov_iter *from) {int i;int offset;int seq;int retval =0 ; -struct imon_context *ictx = file->private_data; +struct imon_context *ictx = iocb->ki_filp->private_data;static const unsigned char vfd_packet6[] = {0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0xFF ,0xFF }; +size_t n_bytes =iov_iter_count (from);if (ictx->disconnected)return -ENODEV ;@@ -967,7 +965,7 @@ static ssize_t vfd_write(struct file *file, const char __user *buf, goto exit; } -if (copy_from_user (ictx->tx.data_buf, buf, n_bytes)) { +if (!copy_from_iter_full (ictx->tx.data_buf, n_bytes, from)) { retval = -EFAULT ; goto exit; }@@ -1023,11 +1021,11 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,* display whatever diacritics you need, and so on), but it's also * a lot more complicated than most LCDs... */ -static ssize_t lcd_write (struct file *file,const char __user *buf, -size_t n_bytes,loff_t *pos) +static ssize_t lcd_write (struct kiocb *iocb,struct iov_iter *from) {int retval =0 ; -struct imon_context *ictx = file->private_data; +struct imon_context *ictx = iocb->ki_filp->private_data; +size_t n_bytes =iov_iter_count (from);if (ictx->disconnected)return -ENODEV ;@@ -1047,7 +1045,7 @@ static ssize_t lcd_write(struct file *file, const char __user *buf, goto exit; } -if (copy_from_user (ictx->usb_tx_buf, buf,8 )) { +if (!copy_from_iter_full (ictx->usb_tx_buf,8 , from)) { retval = -EFAULT ; goto exit; }drivers/media/rc/lirc_dev.c +8
-7@@ -211,10 +211,10 @@ static int lirc_close(struct inode *inode, struct file *file)return 0 ; } -static ssize_t lirc_transmit (struct file *file,const char __user *buf, -size_t n,loff_t *ppos) +static ssize_t lirc_transmit (struct kiocb *iocb,struct iov_iter *from) { -struct lirc_fh *fh = file->private_data; +struct lirc_fh *fh = iocb->ki_filp->private_data; +size_t n =iov_iter_count (from);struct rc_dev *dev = fh->rc;unsigned int *txbuf;struct ir_raw_event *raw =NULL ;@@ -247,7 +247,7 @@ static ssize_t lirc_transmit(struct file *file, const char __user *buf, goto out_unlock; } -if (copy_from_user (&scan, buf,sizeof (scan))) { +if (!copy_from_iter_full (&scan,sizeof (scan), from)) { ret = -EFAULT ; goto out_unlock; }@@ -309,7 +309,7 @@ static ssize_t lirc_transmit(struct file *file, const char __user *buf, goto out_unlock; } - txbuf =memdup_user (buf, n); + txbuf =iterdup (from, n);if (IS_ERR (txbuf)) { ret =PTR_ERR (txbuf); goto out_unlock;@@ -694,13 +694,14 @@ static ssize_t lirc_read(struct file *file, char __user *buffer, size_t length,else /* LIRC_MODE_SCANCODE */ return lirc_read_scancode (file, buffer, length); } +FOPS_READ_ITER_HELPER (lirc_read);static const struct file_operations lirc_fops = { .owner =THIS_MODULE , - .write = lirc_transmit, + .write_iter = lirc_transmit, .unlocked_ioctl = lirc_ioctl, .compat_ioctl = compat_ptr_ioctl, - .read = lirc_read, + .read_iter = lirc_read_iter, .poll = lirc_poll, .open = lirc_open, .release = lirc_close,
Jens Axboe
maintainerRe: [PATCH 413/437] media/rc: convert to read/write iterators
Quoted 8 lines · Mauro Carvalho Chehab
Em Thu, 11 Apr 2024 09:19:13 -0600
Jens Axboe <[email protected]> escreveu:Quoted 1 line
Signed-off-by Jens Axboe <[email protected]>Please add a patch description to media patches. Also, please c/c [email protected], as otherwise patchwork.linuxtv.org won't track it, and such patches will be silently ignored[1].
Certainly, it's all just a RFC to get the full picture idea out in the open. Any individual patches/series will go out separately to the respective lists and maintainers, and it'll have actual commit message as well at that point.
Signature · 1 line
Jens Axboe
Jens Axboe
maintainerPATCH 414/437 media/dvb-core: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/dvb-core/dmxdev.c | 9 ++++++--- drivers/media/dvb-core/dvb_ca_en50221.c | 25 +++++++++++-------------- 2 files changed, 17 insertions(+), 17 deletions(-)
drivers/media/dvb-core/dmxdev.c +6 -3
@@ -261,6 +261,7 @@ static ssize_t dvb_dvr_write(struct file *file, const char __user *buf,mutex_unlock (&dmxdev->mutex);return ret; } +FOPS_WRITE_ITER_HELPER (dvb_dvr_write);static ssize_t dvb_dvr_read (struct file *file,char __user *buf,size_t count,loff_t *ppos)
@@ -275,6 +276,7 @@ static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count, file->f_flags &O_NONBLOCK , buf, count, ppos); } +FOPS_READ_ITER_HELPER (dvb_dvr_read);static int dvb_dvr_set_buffer_size (struct dmxdev *dmxdev,unsigned long size)
@@ -1025,6 +1027,7 @@ dvb_demux_read(struct file *file, char __user *buf, size_t count,mutex_unlock (&dmxdevfilter->mutex);return ret; } +FOPS_READ_ITER_HELPER (dvb_demux_read);static int dvb_demux_do_ioctl (struct file *file,unsigned int cmd,void *parg)
@@ -1258,7 +1261,7 @@ static int dvb_demux_release(struct inode *inode, struct file *file)static const struct file_operations dvb_demux_fops = { .owner =THIS_MODULE , - .read = dvb_demux_read, + .read_iter = dvb_demux_read_iter, .unlocked_ioctl = dvb_demux_ioctl, .compat_ioctl = dvb_demux_ioctl, .open = dvb_demux_open,
@@ -1385,8 +1388,8 @@ static int dvb_dvr_mmap(struct file *file, struct vm_area_struct *vma)static const struct file_operations dvb_dvr_fops = { .owner =THIS_MODULE , - .read = dvb_dvr_read, - .write = dvb_dvr_write, + .read_iter = dvb_dvr_read_iter, + .write_iter = dvb_dvr_write_iter, .unlocked_ioctl = dvb_dvr_ioctl, .open = dvb_dvr_open, .release = dvb_dvr_release,
drivers/media/dvb-core/dvb_ca_en50221.c +11 -14
@@ -1436,19 +1436,16 @@ static long dvb_ca_en50221_io_ioctl(struct file *file,/** * dvb_ca_en50221_io_write - Implementation of write() syscall. * -* @file: File structure. -* @buf: Source buffer. -* @count: Size of source buffer. -* @ppos: Position in file (ignored). +* @iocb: metadata for IO +* @from: buffer to read from * * return: Number of bytes read, or <0 on error. */ -static ssize_t dvb_ca_en50221_io_write (struct file *file, -const char __user *buf,size_t count, -loff_t *ppos) +static ssize_t dvb_ca_en50221_io_write (struct kiocb *iocb,struct iov_iter *from) { -struct dvb_device *dvbdev = file->private_data; +struct dvb_device *dvbdev = iocb->ki_filp->private_data;struct dvb_ca_private *ca = dvbdev->priv; +size_t count =iov_iter_count (from);struct dvb_ca_slot *sl;u8 slot, connection_id;int status;
@@ -1468,11 +1465,10 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,return -EINVAL ;/* extract slot & connection id */ -if (copy_from_user (&slot, buf,1 )) +if (!copy_from_iter_full (&slot,1 , from))return -EFAULT ; -if (copy_from_user (&connection_id, buf +1 ,1 )) +if (!copy_from_iter_full (&connection_id,1 , from))return -EFAULT ; - buf +=2 ; count -=2 ;if (slot >= ca->slot_count)
@@ -1496,7 +1492,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file, fragbuf[0 ] = connection_id; fragbuf[1 ] = ((fragpos + fraglen) < count) ?0x80 :0x00 ; - status =copy_from_user (fragbuf +2 , buf + fragpos, fraglen); + status = !copy_from_iter_full (fragbuf +2 , fraglen, from);if (status) { status = -EFAULT ; goto exit;
@@ -1699,6 +1695,7 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf, exit:return status; } +FOPS_READ_ITER_HELPER (dvb_ca_en50221_io_read);/** * dvb_ca_en50221_io_open - Implementation of file open syscall.
@@ -1834,8 +1831,8 @@ static __poll_t dvb_ca_en50221_io_poll(struct file *file, poll_table *wait)static const struct file_operations dvb_ca_fops = { .owner =THIS_MODULE , - .read = dvb_ca_en50221_io_read, - .write = dvb_ca_en50221_io_write, + .read_iter = dvb_ca_en50221_io_read_iter, + .write_iter = dvb_ca_en50221_io_write, .unlocked_ioctl = dvb_ca_en50221_io_ioctl, .open = dvb_ca_en50221_io_open, .release = dvb_ca_en50221_io_release,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 415/437 media/common: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/common/siano/smsdvb-debugfs.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/media/common/siano/smsdvb-debugfs.c +8 -9
@@ -280,15 +280,14 @@ static __poll_t smsdvb_stats_poll(struct file *file, poll_table *wait)return rc >0 ?EPOLLIN |EPOLLRDNORM :0 ; } -static ssize_t smsdvb_stats_read (struct file *file,char __user *user_buf, -size_t nbytes,loff_t *ppos) +static ssize_t smsdvb_stats_read (struct kiocb *iocb,struct iov_iter *to) {int rc =0 , len; -struct smsdvb_debugfs *debug_data = file->private_data; +struct smsdvb_debugfs *debug_data = iocb->ki_filp->private_data;kref_get (&debug_data->refcount); -if (file->f_flags &O_NONBLOCK ) { +if (iocb->ki_filp->f_flags &O_NONBLOCK ) { rc =smsdvb_stats_wait_read (debug_data);if (!rc) { rc = -EWOULDBLOCK ;
@@ -306,14 +305,14 @@ static ssize_t smsdvb_stats_read(struct file *file, char __user *user_buf, goto ret; } - len = debug_data->stats_count - *ppos; + len = debug_data->stats_count - iocb->ki_pos;if (len >=0 ) - rc =simple_read_from_buffer (user_buf, nbytes, ppos, - debug_data->stats_data, len); + rc =simple_copy_to_iter (debug_data->stats_data, &iocb->ki_pos, + len, to);else rc =0 ; -if (*ppos >= debug_data->stats_count) { +if (iocb->ki_pos >= debug_data->stats_count) {spin_lock (&debug_data->lock); debug_data->stats_was_read = true;spin_unlock (&debug_data->lock);
@@ -341,7 +340,7 @@ static int smsdvb_stats_release(struct inode *inode, struct file *file)static const struct file_operations debugfs_stats_ops = { .open = smsdvb_stats_open, .poll = smsdvb_stats_poll, - .read = smsdvb_stats_read, + .read_iter = smsdvb_stats_read, .release = smsdvb_stats_release, .llseek = generic_file_llseek, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 416/437 media/platform: amphion: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/platform/amphion/vpu_dbg.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/media/platform/amphion/vpu_dbg.c +11 -13
@@ -353,21 +353,19 @@ static int vpu_dbg_inst_open(struct inode *inode, struct file *filp)return single_open (filp, vpu_dbg_instance, inode->i_private); } -static ssize_t vpu_dbg_inst_write (struct file *file, -const char __user *user_buf,size_t size,loff_t *ppos) +static ssize_t vpu_dbg_inst_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 vpu_inst *inst = s->private;vpu_session_debug (inst); -return size; +return iov_iter_count (from); } -static ssize_t vpu_dbg_core_write (struct file *file, -const char __user *user_buf,size_t size,loff_t *ppos) +static ssize_t vpu_dbg_core_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 vpu_core *core = s->private;pm_runtime_resume_and_get (core->dev);
@@ -382,7 +380,7 @@ static ssize_t vpu_dbg_core_write(struct file *file,mutex_unlock (&core->lock);pm_runtime_put_sync (core->dev); -return size; +return iov_iter_count (from); }static int vpu_dbg_core_open (struct inode *inode,struct file *filp)
@@ -399,23 +397,23 @@ static const struct file_operations vpu_dbg_inst_fops = { .owner = THIS_MODULE, .open = vpu_dbg_inst_open, .release = single_release, - .read = seq_read, - .write = vpu_dbg_inst_write, + .read_iter = seq_read_iter, + .write_iter = vpu_dbg_inst_write, };static const struct file_operations vpu_dbg_core_fops = { .owner =THIS_MODULE , .open = vpu_dbg_core_open, .release = single_release, - .read = seq_read, - .write = vpu_dbg_core_write, + .read_iter = seq_read_iter, + .write_iter = vpu_dbg_core_write, };static const struct file_operations vpu_dbg_fwlog_fops = { .owner =THIS_MODULE , .open = vpu_dbg_fwlog_open, .release = single_release, - .read = seq_read, + .read_iter = seq_read_iter, };int vpu_inst_create_dbgfs_file (struct vpu_inst *inst)
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 417/437 media/platform: mediatek: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/platform/mediatek/vpu/mtk_vpu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/media/platform/mediatek/vpu/mtk_vpu.c +4 -5
@@ -648,14 +648,13 @@ static void vpu_init_ipi_handler(void *data, unsigned int len, void *priv) }#ifdef CONFIG_DEBUG_FS -static ssize_t vpu_debug_read (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) +static ssize_t vpu_debug_read (struct kiocb *iocb,struct iov_iter *to) {char buf[256 ];unsigned int len;unsigned int running, pc, vpu_to_host, host_to_vpu, wdt, idle, ra, sp;int ret; -struct device *dev = file->private_data; +struct device *dev = iocb->ki_filp->private_data;struct mtk_vpu *vpu =dev_get_drvdata (dev); ret =vpu_clock_enable (vpu);
@@ -692,12 +691,12 @@ static ssize_t vpu_debug_read(struct file *file, char __user *user_buf, len = snprintf(buf, sizeof(buf), "VPU not running\n"); } -return simple_read_from_buffer (user_buf, count, ppos, buf, len); +return simple_copy_to_iter (buf, &iocb->ki_pos, len, to); }static const struct file_operations vpu_debug_fops = { .open = simple_open, - .read = vpu_debug_read, + .read_iter = vpu_debug_read, };#endif /* CONFIG_DEBUG_FS */
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 418/437 media: cec: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/cec/core/cec-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/cec/core/cec-core.c +6 -6
@@ -200,16 +200,16 @@ static void cec_devnode_unregister(struct cec_adapter *adap) }#ifdef CONFIG_DEBUG_FS -static ssize_t cec_error_inj_write (struct file *file, -const char __user *ubuf,size_t count,loff_t *ppos) +static ssize_t cec_error_inj_write (struct kiocb *iocb,struct iov_iter *from) { -struct seq_file *sf = file->private_data; +struct seq_file *sf = iocb->ki_filp->private_data;struct cec_adapter *adap = sf->private; +size_t count =iov_iter_count (from);char *buf;char *line;char *p; - buf =memdup_user_nul (ubuf,min_t (size_t,PAGE_SIZE , count)); + buf =iterdup_nul (from,min_t (size_t,PAGE_SIZE , count));if (IS_ERR (buf))return PTR_ERR (buf); p = buf;
@@ -241,8 +241,8 @@ static int cec_error_inj_open(struct inode *inode, struct file *file)static const struct file_operations cec_error_inj_fops = { .open = cec_error_inj_open, - .write = cec_error_inj_write, - .read = seq_read, + .write_iter = cec_error_inj_write, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 419/437 media: media-devnode: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/mc/mc-devnode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/mc/mc-devnode.c +4 -2
@@ -78,6 +78,7 @@ static ssize_t media_read(struct file *filp, char __user *buf,return -EIO ;return devnode->fops->read (filp, buf, sz, off); } +FOPS_READ_ITER_HELPER (media_read);static ssize_t media_write (struct file *filp,const char __user *buf,size_t sz,loff_t *off)
@@ -90,6 +91,7 @@ static ssize_t media_write(struct file *filp, const char __user *buf,return -EIO ;return devnode->fops->write (filp, buf, sz, off); } +FOPS_WRITE_ITER_HELPER (media_write);static __poll_t media_poll (struct file *filp,struct poll_table_struct *poll)
@@ -195,8 +197,8 @@ static int media_release(struct inode *inode, struct file *filp)static const struct file_operations media_devnode_fops = { .owner =THIS_MODULE , - .read = media_read, - .write = media_write, + .read_iter = media_read_iter, + .write_iter = media_write_iter, .open = media_open, .unlocked_ioctl = media_ioctl, #ifdef CONFIG_COMPAT
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 420/437 media: bt8xx: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/pci/bt8xx/dst_ca.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/pci/bt8xx/dst_ca.c +4 -4
@@ -622,14 +622,14 @@ static int dst_ca_release(struct inode *inode, struct file *file)return 0 ; } -static ssize_t dst_ca_read (struct file *file,char __user *buffer,size_t length,loff_t *offset) +static ssize_t dst_ca_read (struct kiocb *iocb,struct iov_iter *to) {dprintk (verbose,DST_CA_DEBUG ,1 ," Device read." );return 0 ; } -static ssize_t dst_ca_write (struct file *file,const char __user *buffer,size_t length,loff_t *offset) +static ssize_t dst_ca_write (struct kiocb *iocb,struct iov_iter *from) {dprintk (verbose,DST_CA_DEBUG ,1 ," Device write." );
@@ -641,8 +641,8 @@ static const struct file_operations dst_ca_fops = { .unlocked_ioctl = dst_ca_ioctl, .open = dst_ca_open, .release = dst_ca_release, - .read = dst_ca_read, - .write = dst_ca_write, + .read_iter = dst_ca_read, + .write_iter = dst_ca_write, .llseek = noop_llseek, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 421/437 media: dbbridge: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/pci/ddbridge/ddbridge-core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/pci/ddbridge/ddbridge-core.c +4 -2
@@ -731,6 +731,7 @@ static ssize_t ts_write(struct file *file, const __user char *buf, }return (left == count) ? -EAGAIN : (count - left); } +FOPS_WRITE_ITER_HELPER (ts_write);static ssize_t ts_read (struct file *file,__user char *buf,size_t count,loff_t *ppos)
@@ -761,6 +762,7 @@ static ssize_t ts_read(struct file *file, __user char *buf, }return (count && (left == count)) ? -EAGAIN : (count - left); } +FOPS_READ_ITER_HELPER (ts_read);static __poll_t ts_poll (struct file *file,poll_table *wait) {
@@ -838,8 +840,8 @@ static int ts_open(struct inode *inode, struct file *file)static const struct file_operations ci_fops = { .owner =THIS_MODULE , - .read = ts_read, - .write = ts_write, + .read_iter = ts_read_iter, + .write_iter = ts_write_iter, .open = ts_open, .release = ts_release, .poll = ts_poll,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 422/437 media: ngene: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/pci/ngene/ngene-dvb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/pci/ngene/ngene-dvb.c +4 -2
@@ -49,6 +49,7 @@ static ssize_t ts_write(struct file *file, const char __user *buf,return count; } +FOPS_WRITE_ITER_HELPER (ts_write);static ssize_t ts_read (struct file *file,char __user *buf,size_t count,loff_t *ppos)
@@ -73,6 +74,7 @@ static ssize_t ts_read(struct file *file, char __user *buf, }return count; } +FOPS_READ_ITER_HELPER (ts_read);static __poll_t ts_poll (struct file *file,poll_table *wait) {
@@ -96,8 +98,8 @@ static __poll_t ts_poll(struct file *file, poll_table *wait)static const struct file_operations ci_fops = { .owner =THIS_MODULE , - .read = ts_read, - .write = ts_write, + .read_iter = ts_read_iter, + .write_iter = ts_write_iter, .open = dvb_generic_open, .release = dvb_generic_release, .poll = ts_poll,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 423/437 media: radio-si476x: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/radio/radio-si476x.c | 60 +++++++++++++----------------- 1 file changed, 25 insertions(+), 35 deletions(-)
drivers/media/radio/radio-si476x.c +25 -35
@@ -1178,12 +1178,11 @@ static const struct video_device si476x_viddev_template = { -static ssize_t si476x_radio_read_acf_blob (struct file *file, -char __user *user_buf, -size_t count,loff_t *ppos) +static ssize_t si476x_radio_read_acf_blob (struct kiocb *iocb, +struct iov_iter *to) {int err; -struct si476x_radio *radio = file->private_data; +struct si476x_radio *radio = iocb->ki_filp->private_data;struct si476x_acf_status_report report;si476x_core_lock (radio->core);
@@ -1196,22 +1195,20 @@ static ssize_t si476x_radio_read_acf_blob(struct file *file,if (err <0 )return err; -return simple_read_from_buffer (user_buf, count, ppos, &report, -sizeof (report)); +return simple_copy_to_iter (&report, &iocb->ki_pos,sizeof (report), to); }static const struct file_operations radio_acf_fops = { .open = simple_open, .llseek = default_llseek, - .read = si476x_radio_read_acf_blob, + .read_iter = si476x_radio_read_acf_blob, }; -static ssize_t si476x_radio_read_rds_blckcnt_blob (struct file *file, -char __user *user_buf, -size_t count,loff_t *ppos) +static ssize_t si476x_radio_read_rds_blckcnt_blob (struct kiocb *iocb, +struct iov_iter *to) {int err; -struct si476x_radio *radio = file->private_data; +struct si476x_radio *radio = iocb->ki_filp->private_data;struct si476x_rds_blockcount_report report;si476x_core_lock (radio->core);
@@ -1225,22 +1222,20 @@ static ssize_t si476x_radio_read_rds_blckcnt_blob(struct file *file,if (err <0 )return err; -return simple_read_from_buffer (user_buf, count, ppos, &report, -sizeof (report)); +return simple_copy_to_iter (&report, &iocb->ki_pos,sizeof (report), to); }static const struct file_operations radio_rds_blckcnt_fops = { .open = simple_open, .llseek = default_llseek, - .read = si476x_radio_read_rds_blckcnt_blob, + .read_iter = si476x_radio_read_rds_blckcnt_blob, }; -static ssize_t si476x_radio_read_agc_blob (struct file *file, -char __user *user_buf, -size_t count,loff_t *ppos) +static ssize_t si476x_radio_read_agc_blob (struct kiocb *iocb, +struct iov_iter *to) {int err; -struct si476x_radio *radio = file->private_data; +struct si476x_radio *radio = iocb->ki_filp->private_data;struct si476x_agc_status_report report;si476x_core_lock (radio->core);
@@ -1253,22 +1248,20 @@ static ssize_t si476x_radio_read_agc_blob(struct file *file,if (err <0 )return err; -return simple_read_from_buffer (user_buf, count, ppos, &report, -sizeof (report)); +return simple_copy_to_iter (&report, &iocb->ki_pos,sizeof (report), to); }static const struct file_operations radio_agc_fops = { .open = simple_open, .llseek = default_llseek, - .read = si476x_radio_read_agc_blob, + .read_iter = si476x_radio_read_agc_blob, }; -static ssize_t si476x_radio_read_rsq_blob (struct file *file, -char __user *user_buf, -size_t count,loff_t *ppos) +static ssize_t si476x_radio_read_rsq_blob (struct kiocb *iocb, +struct iov_iter *to) {int err; -struct si476x_radio *radio = file->private_data; +struct si476x_radio *radio = iocb->ki_filp->private_data;struct si476x_rsq_status_report report;struct si476x_rsq_status_args args = { .primary = false,
@@ -1288,22 +1281,20 @@ static ssize_t si476x_radio_read_rsq_blob(struct file *file,if (err <0 )return err; -return simple_read_from_buffer (user_buf, count, ppos, &report, -sizeof (report)); +return simple_copy_to_iter (&report, &iocb->ki_pos,sizeof (report), to); }static const struct file_operations radio_rsq_fops = { .open = simple_open, .llseek = default_llseek, - .read = si476x_radio_read_rsq_blob, + .read_iter = si476x_radio_read_rsq_blob, }; -static ssize_t si476x_radio_read_rsq_primary_blob (struct file *file, -char __user *user_buf, -size_t count,loff_t *ppos) +static ssize_t si476x_radio_read_rsq_primary_blob (struct kiocb *iocb, +struct iov_iter *to) {int err; -struct si476x_radio *radio = file->private_data; +struct si476x_radio *radio = iocb->ki_filp->private_data;struct si476x_rsq_status_report report;struct si476x_rsq_status_args args = { .primary = true,
@@ -1323,14 +1314,13 @@ static ssize_t si476x_radio_read_rsq_primary_blob(struct file *file,if (err <0 )return err; -return simple_read_from_buffer (user_buf, count, ppos, &report, -sizeof (report)); +return simple_copy_to_iter (&report, &iocb->ki_pos,sizeof (report), to); }static const struct file_operations radio_rsq_primary_fops = { .open = simple_open, .llseek = default_llseek, - .read = si476x_radio_read_rsq_primary_blob, + .read_iter = si476x_radio_read_rsq_primary_blob, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 424/437 media: usb: uvc: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/usb/uvc/uvc_debugfs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/media/usb/uvc/uvc_debugfs.c +4 -6
@@ -39,13 +39,11 @@ static int uvc_debugfs_stats_open(struct inode *inode, struct file *file)return 0 ; } -static ssize_t uvc_debugfs_stats_read (struct file *file,char __user *user_buf, -size_t nbytes,loff_t *ppos) +static ssize_t uvc_debugfs_stats_read (struct kiocb *iocb,struct iov_iter *to) { -struct uvc_debugfs_buffer *buf = file->private_data; +struct uvc_debugfs_buffer *buf = iocb->ki_filp->private_data; -return simple_read_from_buffer (user_buf, nbytes, ppos, buf->data, - buf->count); +return simple_copy_to_iter (buf->data, &iocb->ki_pos, buf->count, to); }static int uvc_debugfs_stats_release (struct inode *inode,struct file *file)
@@ -60,7 +58,7 @@ static const struct file_operations uvc_debugfs_stats_fops = { .owner = THIS_MODULE, .open = uvc_debugfs_stats_open, .llseek = no_llseek, - .read = uvc_debugfs_stats_read, + .read_iter = uvc_debugfs_stats_read, .release = uvc_debugfs_stats_release, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 425/437 media: v4l2-dev: convert to read/write iterators
In reply to Jens Axboe--- drivers/media/v4l2-core/v4l2-dev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-dev.c +4 -2
@@ -318,6 +318,7 @@ static ssize_t v4l2_read(struct file *filp, char __user *buf, video_device_node_name(vdev), sz, ret);return ret; } +FOPS_READ_ITER_HELPER (v4l2_read);static ssize_t v4l2_write (struct file *filp,const char __user *buf,size_t sz,loff_t *off)
@@ -335,6 +336,7 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf, video_device_node_name(vdev), sz, ret);return ret; } +FOPS_WRITE_ITER_HELPER (v4l2_write);static __poll_t v4l2_poll (struct file *filp,struct poll_table_struct *poll) {
@@ -472,8 +474,8 @@ static int v4l2_release(struct inode *inode, struct file *filp)static const struct file_operations v4l2_fops = { .owner =THIS_MODULE , - .read = v4l2_read, - .write = v4l2_write, + .read_iter = v4l2_read_iter, + .write_iter = v4l2_write_iter, .open = v4l2_open, .get_unmapped_area = v4l2_get_unmapped_area, .mmap = v4l2_mmap,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 426/437 firmware: xilinx: convert to read/write iterators
In reply to Jens Axboe--- drivers/firmware/xilinx/zynqmp-debug.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/firmware/xilinx/zynqmp-debug.c +11 -11
@@ -143,9 +143,8 @@ static int process_api_request(u32 pm_id, u64 *pm_api_arg, u32 *pm_api_ret)* Return: Number of bytes copied if PM-API request succeeds, * the corresponding error code otherwise */ -static ssize_t zynqmp_pm_debugfs_api_write (struct file *file, -const char __user *ptr,size_t len, -loff_t *off) +static ssize_t zynqmp_pm_debugfs_api_write (struct kiocb *iocb, +struct iov_iter *from) {char *kern_buff, *tmp_buff;char *pm_api_req;
@@ -153,16 +152,17 @@ static ssize_t zynqmp_pm_debugfs_api_write(struct file *file,u64 pm_api_arg[4 ] = {0 ,0 ,0 ,0 };/* Return values from PM APIs calls */ u32 pm_api_ret[4 ] = {0 ,0 ,0 ,0 }; +size_t len =iov_iter_count (from);int ret;int i =0 ;strcpy (debugfs_buf,"" ); -if (*off !=0 || len <=1 || len >PAGE_SIZE -1 ) +if (iocb->ki_pos !=0 || len <=1 || len >PAGE_SIZE -1 )return -EINVAL ; - kern_buff =memdup_user_nul (ptr, len); + kern_buff =iterdup_user (from, len);if (IS_ERR (kern_buff))return PTR_ERR (kern_buff); tmp_buff = kern_buff;
@@ -201,18 +201,18 @@ static ssize_t zynqmp_pm_debugfs_api_write(struct file *file,* Return: Length of the version string on success * else error code */ -static ssize_t zynqmp_pm_debugfs_api_read (struct file *file,char __user *ptr, -size_t len,loff_t *off) +static ssize_t zynqmp_pm_debugfs_api_read (struct kiocb *iocb, +struct iov_iter *to) { -return simple_read_from_buffer (ptr, len, off, debugfs_buf, -strlen (debugfs_buf)); +return simple_copy_to_iter (debugfs_buf, &iocb->ki_pos, +strlen (debugfs_buf), to); }/* Setup debugfs fops */ static const struct file_operations fops_zynqmp_pm_dbgfs = { .owner =THIS_MODULE , - .write = zynqmp_pm_debugfs_api_write, - .read = zynqmp_pm_debugfs_api_read, + .write_iter = zynqmp_pm_debugfs_api_write, + .read_iter = zynqmp_pm_debugfs_api_read, };/**
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 427/437 hwtracing: coresight: convert to read/write iterators
In reply to Jens Axboe--- .../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(-)
drivers/hwtracing/coresight/coresight-cpu-debug.c +7 -8
@@ -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 )
drivers/hwtracing/coresight/coresight-etb10.c +9 -9
@@ -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, };
drivers/hwtracing/coresight/coresight-tmc-core.c +7 -7
@@ -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, };
drivers/hwtracing/coresight/ultrasoc-smb.c +6 -6
@@ -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, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 428/437 sbus: oradax: convert to read/write iterators
In reply to Jens Axboe--- drivers/sbus/char/oradax.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-)
drivers/sbus/char/oradax.c +17 -20
@@ -204,24 +204,21 @@ struct dax_ctx {/* driver public entry points */ static int dax_open (struct inode *inode,struct file *file); -static ssize_t dax_read (struct file *filp,char __user *buf, -size_t count,loff_t *ppos); -static ssize_t dax_write (struct file *filp,const char __user *buf, -size_t count,loff_t *ppos); +static ssize_t dax_read (struct kiocb *iocb,struct iov_iter *to); +static ssize_t dax_write (struct kiocb *iocb,struct iov_iter *from);static int dax_devmap (struct file *f,struct vm_area_struct *vma);static int dax_close (struct inode *i,struct file *f);static const struct file_operations dax_fops = { .owner =THIS_MODULE , .open = dax_open, - .read = dax_read, - .write = dax_write, + .read_iter = dax_read, + .write_iter = dax_write, .mmap = dax_devmap, .release = dax_close, }; -static int dax_ccb_exec (struct dax_ctx *ctx,const char __user *buf, -size_t count,loff_t *ppos); +static int dax_ccb_exec (struct dax_ctx *ctx,loff_t *ppos,struct iov_iter *from);static int dax_ccb_info (u64 ca,struct ccb_info_result *info);static int dax_ccb_kill (u64 ca,u16 *kill_res);
@@ -541,10 +538,10 @@ static int dax_close(struct inode *ino, struct file *f)return 0 ; } -static ssize_t dax_read (struct file *f,char __user *buf, -size_t count,loff_t *ppos) +static ssize_t dax_read (struct kiocb *iocb,struct iov_iter *to) { -struct dax_ctx *ctx = f->private_data; +struct dax_ctx *ctx = iocb->ki_filp->private_data; +size_t count =iov_iter_count (to);if (ctx->client != current)return -EUSERS ;
@@ -553,15 +550,15 @@ static ssize_t dax_read(struct file *f, char __user *buf,if (count !=sizeof (union ccb_result ))return -EINVAL ; -if (copy_to_user (buf, &ctx->result,sizeof (union ccb_result ))) +if (!copy_to_iter_full (&ctx->result,sizeof (union ccb_result ), to))return -EFAULT ;return count; } -static ssize_t dax_write (struct file *f,const char __user *buf, -size_t count,loff_t *ppos) +static ssize_t dax_write (struct kiocb *iocb,struct iov_iter *from) { -struct dax_ctx *ctx = f->private_data; +struct dax_ctx *ctx = iocb->ki_filp->private_data; +size_t count =iov_iter_count (from);struct dax_command hdr;unsigned long ca;int i, idx, ret;
@@ -573,7 +570,7 @@ static ssize_t dax_write(struct file *f, const char __user *buf,return -EINVAL ;if (count %sizeof (struct dax_ccb ) ==0 ) -return dax_ccb_exec (ctx, buf, count, ppos);/* CCB EXEC */ +return dax_ccb_exec (ctx, &iocb->ki_pos, from);/* CCB EXEC */ if (count !=sizeof (struct dax_command ))return -EINVAL ;
@@ -582,7 +579,7 @@ static ssize_t dax_write(struct file *f, const char __user *buf,if (ctx->owner != current)return -EUSERS ; -if (copy_from_user (&hdr, buf,sizeof (hdr))) +if (!copy_from_iter_full (&hdr,sizeof (hdr), from))return -EFAULT ; ca = ctx->ca_buf_ra + hdr.ca_offset;
@@ -846,9 +843,9 @@ static int dax_preprocess_usr_ccbs(struct dax_ctx *ctx, int idx, int nelem)return DAX_SUBMIT_OK ; } -static int dax_ccb_exec (struct dax_ctx *ctx,const char __user *buf, -size_t count,loff_t *ppos) +static int dax_ccb_exec (struct dax_ctx *ctx,loff_t *ppos,struct iov_iter *from) { +size_t count =iov_iter_count (from);unsigned long accepted_len, hv_rv;int i, idx, nccbs, naccepted;
@@ -873,7 +870,7 @@ static int dax_ccb_exec(struct dax_ctx *ctx, const char __user *buf,* Copy CCBs into kernel buffer to prevent modification by the * user in between validation and submission. */ -if (copy_from_user (ctx->ccb_buf, buf, count)) { +if (!copy_from_iter_full (ctx->ccb_buf, count, from)) {dax_dbg ("copyin of user CCB buffer failed" ); ctx->result.exec.status =DAX_SUBMIT_ERR_CCB_ARR_MMU_MISS ;return 0 ;
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 429/437 sbus: envctrl: convert to read/write iterators
In reply to Jens Axboe--- drivers/sbus/char/envctrl.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/sbus/char/envctrl.c +13 -14
@@ -533,8 +533,7 @@ static unsigned char envctrl_i2c_voltage_status(struct i2c_child_t *pchild,/* Function Description: Read a byte from /dev/envctrl. Mapped to user read(). * Return: Number of read bytes. 0 for error. */ -static ssize_t -envctrl_read (struct file *file,char __user *buf,size_t count,loff_t *ppos) +static ssize_t envctrl_read (struct kiocb *iocb,struct iov_iter *to) {struct i2c_child_t *pchild;unsigned char data[10 ];
@@ -545,14 +544,14 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)* Get the data and put back to the user buffer. */ -switch ((int )(long )file->private_data) { +switch ((int )(long )iocb->ki_filp->private_data) {case ENVCTRL_RD_WARNING_TEMPERATURE :if (warning_temperature ==0 )return 0 ; data[0 ] = (unsigned char )(warning_temperature); ret =1 ; -if (copy_to_user (buf, data, ret)) +if (!copy_to_iter_full (data, ret, to)) ret = -EFAULT ;break ;
@@ -562,7 +561,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) data[0 ] = (unsigned char )(shutdown_temperature); ret =1 ; -if (copy_to_user (buf, data, ret)) +if (!copy_to_iter_full (data, ret, to)) ret = -EFAULT ;break ;
@@ -570,7 +569,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)if (!(pchild =envctrl_get_i2c_child (ENVCTRL_MTHRBDTEMP_MON )))return 0 ; ret =envctrl_read_noncpu_info (pchild,ENVCTRL_MTHRBDTEMP_MON , data); -if (copy_to_user (buf, data, ret)) +if (!copy_to_iter_full (data, ret, to)) ret = -EFAULT ;break ;
@@ -580,7 +579,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) ret =envctrl_read_cpu_info (read_cpu, pchild,ENVCTRL_CPUTEMP_MON , data);/* Reset cpu to the default cpu0. */ -if (copy_to_user (buf, data, ret)) +if (!copy_to_iter_full (data, ret, to)) ret = -EFAULT ;break ;
@@ -590,7 +589,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) ret =envctrl_read_cpu_info (read_cpu, pchild,ENVCTRL_CPUVOLTAGE_MON , data);/* Reset cpu to the default cpu0. */ -if (copy_to_user (buf, data, ret)) +if (!copy_to_iter_full (data, ret, to)) ret = -EFAULT ;break ;
@@ -598,7 +597,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)if (!(pchild =envctrl_get_i2c_child (ENVCTRL_SCSITEMP_MON )))return 0 ; ret =envctrl_read_noncpu_info (pchild,ENVCTRL_SCSITEMP_MON , data); -if (copy_to_user (buf, data, ret)) +if (!copy_to_iter_full (data, ret, to)) ret = -EFAULT ;break ;
@@ -606,7 +605,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)if (!(pchild =envctrl_get_i2c_child (ENVCTRL_ETHERTEMP_MON )))return 0 ; ret =envctrl_read_noncpu_info (pchild,ENVCTRL_ETHERTEMP_MON , data); -if (copy_to_user (buf, data, ret)) +if (!copy_to_iter_full (data, ret, to)) ret = -EFAULT ;break ;
@@ -615,7 +614,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)return 0 ; data[0 ] =envctrl_i2c_read_8574 (pchild->addr); ret =envctrl_i2c_fan_status (pchild,data[0 ], data); -if (copy_to_user (buf, data, ret)) +if (!copy_to_iter_full (data, ret, to)) ret = -EFAULT ;break ;
@@ -624,7 +623,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)return 0 ; data[0 ] =envctrl_i2c_read_8574 (pchild->addr); ret =envctrl_i2c_globaladdr (pchild, data[0 ], data); -if (copy_to_user (buf, data, ret)) +if (!copy_to_iter_full (data, ret, to)) ret = -EFAULT ;break ;
@@ -635,7 +634,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)return 0 ; data[0 ] =envctrl_i2c_read_8574 (pchild->addr); ret =envctrl_i2c_voltage_status (pchild, data[0 ], data); -if (copy_to_user (buf, data, ret)) +if (!copy_to_iter_full (data, ret, to)) ret = -EFAULT ;break ;
@@ -711,7 +710,7 @@ envctrl_release(struct inode *inode, struct file *file)static const struct file_operations envctrl_fops = { .owner =THIS_MODULE , - .read = envctrl_read, + .read_iter = envctrl_read, .unlocked_ioctl = envctrl_ioctl, .compat_ioctl = compat_ptr_ioctl, .open = envctrl_open,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 430/437 sbus: flash: convert to read/write iterators
In reply to Jens Axboe--- drivers/sbus/char/flash.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/sbus/char/flash.c +6 -8
@@ -98,11 +98,10 @@ flash_llseek(struct file *file, long long offset, int origin)return file->f_pos; } -static ssize_t -flash_read (struct file * file,char __user * buf, -size_t count,loff_t *ppos) +static ssize_t flash_read (struct kiocb *iocb,struct iov_iter *to) { -loff_t p = *ppos; +size_t count =iov_iter_count (to); +loff_t p = iocb->ki_pos;int i;if (count > flash.read_size - p)
@@ -110,12 +109,11 @@ flash_read(struct file * file, char __user * buf,for (i =0 ; i < count; i++) {u8 data =upa_readb (flash.read_base + p + i); -if (put_user (data, buf)) +if (put_iter (data, to))return -EFAULT ; - buf++; } - *ppos += count; + iocb->ki_pos += count;return count; }
@@ -148,7 +146,7 @@ static const struct file_operations flash_fops = {*/ .owner = THIS_MODULE, .llseek = flash_llseek, - .read = flash_read, + .read_iter = flash_read, .mmap = flash_mmap, .open = flash_open, .release = flash_release,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 431/437 pci: hotplug: cpqphp: convert to read/write iterators
In reply to Jens Axboe--- drivers/pci/hotplug/cpqphp_sysfs.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/pci/hotplug/cpqphp_sysfs.c +4 -5
@@ -157,11 +157,10 @@ static loff_t lseek(struct file *file, loff_t off, int whence)return fixed_size_llseek (file, off, whence, dbg->size); } -static ssize_t read (struct file *file,char __user *buf, -size_t nbytes,loff_t *ppos) +static ssize_t read (struct kiocb *iocb,struct iov_iter *to) { -struct ctrl_dbg *dbg = file->private_data; -return simple_read_from_buffer (buf, nbytes, ppos, dbg->data, dbg->size); +struct ctrl_dbg *dbg = iocb->ki_filp->private_data; +return simple_copy_from_iter (dbg->data, &iocb->ki_pos, dbg->size, to); }static int release (struct inode *inode,struct file *file)
@@ -177,7 +176,7 @@ static const struct file_operations debug_ops = { .owner = THIS_MODULE, .open = open, .llseek = lseek, - .read = read, + .read_iter = read, .release = release, };
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 432/437 seq_file: switch to using ->read_iter()
In reply to Jens AxboeThere's a seq_read_iter() helper already, use it.
--- include/linux/seq_file.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/seq_file.h +4 -4
@@ -188,7 +188,7 @@ 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, \ + .read_iter = seq_read_iter, \ .llseek = seq_lseek, \ .release = seq_release, \ }
@@ -202,7 +202,7 @@ 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, \ + .read_iter = seq_read_iter, \ .llseek = seq_lseek, \ .release = single_release, \ }
@@ -216,8 +216,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_iter, \ .llseek = seq_lseek, \ .release = single_release, \ }
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 433/437 fs/debugfs: remove (now) dead non-iterator debugfs_attr functions
In reply to Jens Axboe--- fs/debugfs/file.c | 46 ----------------------------------------- include/linux/debugfs.h | 6 ------ 2 files changed, 52 deletions(-)
fs/debugfs/file.c +0 -46
@@ -451,21 +451,6 @@ const struct file_operations debugfs_full_proxy_file_operations = { .open = full_proxy_open, }; -ssize_t debugfs_attr_read (struct file *file,char __user *buf, -size_t len,loff_t *ppos) -{ -struct dentry *dentry =F_DENTRY (file); -ssize_t ret; - - ret =debugfs_file_get (dentry); -if (unlikely (ret)) -return ret; - ret =simple_attr_read (file, buf, len, ppos); -debugfs_file_put (dentry); -return ret; -} -EXPORT_SYMBOL_GPL (debugfs_attr_read); -ssize_t debugfs_attr_read_iter (struct kiocb *iocb,struct iov_iter *to) {struct dentry *dentry =F_DENTRY (iocb->ki_filp);
@@ -480,37 +465,6 @@ ssize_t debugfs_attr_read_iter(struct kiocb *iocb, struct iov_iter *to) }EXPORT_SYMBOL_GPL (debugfs_attr_read_iter); -static ssize_t debugfs_attr_write_xsigned (struct file *file,const char __user *buf, -size_t len,loff_t *ppos,bool is_signed) -{ -struct dentry *dentry =F_DENTRY (file); -ssize_t ret; - - ret =debugfs_file_get (dentry); -if (unlikely (ret)) -return ret; -if (is_signed) - ret =simple_attr_write_signed (file, buf, len, ppos); -else - ret =simple_attr_write (file, buf, len, ppos); -debugfs_file_put (dentry); -return ret; -} - -ssize_t debugfs_attr_write (struct file *file,const char __user *buf, -size_t len,loff_t *ppos) -{ -return debugfs_attr_write_xsigned (file, buf, len, ppos, false); -} -EXPORT_SYMBOL_GPL (debugfs_attr_write); - -ssize_t debugfs_attr_write_signed (struct file *file,const char __user *buf, -size_t len,loff_t *ppos) -{ -return debugfs_attr_write_xsigned (file, buf, len, ppos, true); -} -EXPORT_SYMBOL_GPL (debugfs_attr_write_signed); -static ssize_t debugfs_attr_write_iter_xsigned (struct kiocb *iocb,struct iov_iter *from,bool is_signed)
include/linux/debugfs.h +0 -6
@@ -104,14 +104,8 @@ const struct file_operations *debugfs_real_fops(const struct file *filp);int debugfs_file_get (struct dentry *dentry);void debugfs_file_put (struct dentry *dentry); -ssize_t debugfs_attr_read (struct file *file,char __user *buf, -size_t len,loff_t *ppos);ssize_t debugfs_attr_read_iter (struct kiocb *iocb,struct iov_iter *to); -ssize_t debugfs_attr_write (struct file *file,const char __user *buf, -size_t len,loff_t *ppos);ssize_t debugfs_attr_write_iter (struct kiocb *iocb,struct iov_iter *from); -ssize_t debugfs_attr_write_signed (struct file *file,const char __user *buf, -size_t len,loff_t *ppos);ssize_t debugfs_attr_write_iter_signed (struct kiocb *iocb,struct iov_iter *from); struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 434/437 lib/string_helpers: kill parse_int_array_user()
In reply to Jens AxboeIt's no longer used, get rid of it.
--- include/linux/string_helpers.h | 1 - lib/string_helpers.c | 61 ++++++++++------------------------ 2 files changed, 18 insertions(+), 44 deletions(-)
include/linux/string_helpers.h +0 -1
@@ -32,7 +32,6 @@ enum string_size_units {int string_get_size (u64 size,u64 blk_size,const enum string_size_units units,char *buf,int len); -int parse_int_array_user (const char __user *from,size_t count,int **array);int parse_int_array_iter (struct iov_iter *from,int **array);#define UNESCAPE_SPACE BIT(0)
lib/string_helpers.c +18 -43
77 lines not on this page · raw message
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 435/437 fs: kill off non-iter variants of simple_attr_{read,write}*
In reply to Jens AxboeThey are no longer used, kill them with fire.
--- fs/libfs.c | 89 ---------------------------------------------- include/linux/fs.h | 6 ---- 2 files changed, 95 deletions(-)
fs/libfs.c +0 -89
@@ -1337,44 +1337,6 @@ int simple_attr_release(struct inode *inode, struct file *file) }EXPORT_SYMBOL_GPL (simple_attr_release);/* GPL-only? This? Really? */ -/* read from the buffer that is filled with the get function */ -ssize_t simple_attr_read (struct file *file,char __user *buf, -size_t len,loff_t *ppos) -{ -struct simple_attr *attr; -size_t size; -ssize_t ret; - - attr = file->private_data; - -if (!attr->get) -return -EACCES ; - - ret =mutex_lock_interruptible (&attr->mutex); -if (ret) -return ret; - -if (*ppos && attr->get_buf[0 ]) { -/* continued read */ - size =strlen (attr->get_buf); - }else { -/* first read */ -u64 val; - ret = attr->get (attr->data, &val); -if (ret) - goto out; - - size =scnprintf (attr->get_buf,sizeof (attr->get_buf), - attr->fmt, (unsigned long long )val); - } - - ret =simple_read_from_buffer (buf, len, ppos, attr->get_buf, size); -out: -mutex_unlock (&attr->mutex); -return ret; -} -EXPORT_SYMBOL_GPL (simple_attr_read); -/* read from the buffer that is filled with the get function */ ssize_t simple_attr_read_iter (struct kiocb *iocb,struct iov_iter *to) {
@@ -1462,57 +1424,6 @@ ssize_t simple_attr_write_iter_signed(struct kiocb *iocb, struct iov_iter *from) }EXPORT_SYMBOL_GPL (simple_attr_write_iter_signed); -/* interpret the buffer as a number to call the set function with */ -static ssize_t simple_attr_write_xsigned (struct file *file,const char __user *buf, -size_t len,loff_t *ppos,bool is_signed) -{ -struct simple_attr *attr; -unsigned long long val; -size_t size; -ssize_t ret; - - attr = file->private_data; -if (!attr->set) -return -EACCES ; - - ret =mutex_lock_interruptible (&attr->mutex); -if (ret) -return ret; - - ret = -EFAULT ; - size =min (sizeof (attr->set_buf) -1 , len); -if (copy_from_user (attr->set_buf, buf, size)) - goto out; - - attr->set_buf[size] ='\0' ; -if (is_signed) - ret =kstrtoll (attr->set_buf,0 , &val); -else - ret =kstrtoull (attr->set_buf,0 , &val); -if (ret) - goto out; - ret = attr->set (attr->data, val); -if (ret ==0 ) - ret = len;/* on success, claim we got the whole input */ -out: -mutex_unlock (&attr->mutex); -return ret; -} - -ssize_t simple_attr_write (struct file *file,const char __user *buf, -size_t len,loff_t *ppos) -{ -return simple_attr_write_xsigned (file, buf, len, ppos, false); -} -EXPORT_SYMBOL_GPL (simple_attr_write); - -ssize_t simple_attr_write_signed (struct file *file,const char __user *buf, -size_t len,loff_t *ppos) -{ -return simple_attr_write_xsigned (file, buf, len, ppos, true); -} -EXPORT_SYMBOL_GPL (simple_attr_write_signed); -/** * generic_encode_ino32_fh - generic export_operations->encode_fh function * @inode: the object to encode
include/linux/fs.h +0 -6
@@ -3552,12 +3552,6 @@ int simple_attr_open(struct inode *inode, struct file *file, int (*get)(void *, u64 *), int (*set)(void *, u64), const char *fmt);int simple_attr_release (struct inode *inode,struct file *file); -ssize_t simple_attr_read (struct file *file,char __user *buf, -size_t len,loff_t *ppos); -ssize_t simple_attr_write (struct file *file,const char __user *buf, -size_t len,loff_t *ppos); -ssize_t simple_attr_write_signed (struct file *file,const char __user *buf, -size_t len,loff_t *ppos);ssize_t simple_attr_read_iter (struct kiocb *iocb,struct iov_iter *to);ssize_t simple_attr_write_iter (struct kiocb *iocb,struct iov_iter *from);ssize_t simple_attr_write_iter_signed (struct kiocb *iocb,struct iov_iter *from);
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 436/437 kstrtox: remove (now) dead helpers
In reply to Jens AxboeThis drops:
kstrtoll_from_user()kstrtol_from_user()kstrtouint_from_user()kstrtou16_from_user()kstrtos16_from_user()kstrtos8_from_user()kstrtou64_from_user()kstrtos64_from_user()kstrtou32_from_user()kstrtos32_from_user()
as they are no longer used in the code base.
--- include/linux/kstrtox.h | 26 -------------------------- lib/kstrtox.c | 6 ------ 2 files changed, 32 deletions(-)
include/linux/kstrtox.h +0 -26
@@ -98,15 +98,9 @@ int __must_check kstrtos8(const char *s, unsigned int base, s8 *res);int __must_check kstrtobool (const char *s,bool *res);int __must_check kstrtoull_from_user (const char __user *s,size_t count,unsigned int base,unsigned long long *res); -int __must_check kstrtoll_from_user (const char __user *s,size_t count,unsigned int base,long long *res);int __must_check kstrtoul_from_user (const char __user *s,size_t count,unsigned int base,unsigned long *res); -int __must_check kstrtol_from_user (const char __user *s,size_t count,unsigned int base,long *res); -int __must_check kstrtouint_from_user (const char __user *s,size_t count,unsigned int base,unsigned int *res);int __must_check kstrtoint_from_user (const char __user *s,size_t count,unsigned int base,int *res); -int __must_check kstrtou16_from_user (const char __user *s,size_t count,unsigned int base,u16 *res); -int __must_check kstrtos16_from_user (const char __user *s,size_t count,unsigned int base,s16 *res);int __must_check kstrtou8_from_user (const char __user *s,size_t count,unsigned int base,u8 *res); -int __must_check kstrtos8_from_user (const char __user *s,size_t count,unsigned int base,s8 *res);int __must_check kstrtobool_from_user (const char __user *s,size_t count,bool *res);struct iov_iter ;
@@ -119,36 +113,16 @@ int __must_check kstrtou16_from_iter(struct iov_iter *s, size_t count, unsignedint __must_check kstrtou8_from_iter (struct iov_iter *s,size_t count,unsigned int base,u8 *res);int __must_check kstrtobool_from_iter (struct iov_iter *src,size_t count,bool *res); -static inline int __must_check kstrtou64_from_user (const char __user *s,size_t count,unsigned int base,u64 *res) -{ -return kstrtoull_from_user (s, count, base, res); -} -static inline int __must_check kstrtou64_from_iter (struct iov_iter *src,size_t count,unsigned int base,u64 *res) {return kstrtoull_from_iter (src, count, base, res); } -static inline int __must_check kstrtos64_from_user (const char __user *s,size_t count,unsigned int base,s64 *res) -{ -return kstrtoll_from_user (s, count, base, res); -} - -static inline int __must_check kstrtou32_from_user (const char __user *s,size_t count,unsigned int base,u32 *res) -{ -return kstrtouint_from_user (s, count, base, res); -} -static inline int __must_check kstrtou32_from_iter (struct iov_iter *src,size_t count,unsigned int base,u32 *res) {return kstrtouint_from_iter (src, count, base, res); } -static inline int __must_check kstrtos32_from_user (const char __user *s,size_t count,unsigned int base,s32 *res) -{ -return kstrtoint_from_user (s, count, base, res); -} -static inline int __must_check kstrtos32_from_iter (struct iov_iter *src,size_t count,unsigned int base,s32 *res) {return kstrtoint_from_iter (src, count, base, res);
lib/kstrtox.c +0 -6
@@ -438,15 +438,9 @@ int f(const char __user *s, size_t count, unsigned int base, type *res) \EXPORT_SYMBOL (f)kstrto_from_user (kstrtoull_from_user, kstrtoull,unsigned long long ); -kstrto_from_user(kstrtoll_from_user, kstrtoll, long long); kstrto_from_user(kstrtoul_from_user, kstrtoul, unsigned long); -kstrto_from_user (kstrtol_from_user, kstrtol, long); -kstrto_from_user(kstrtouint_from_user, kstrtouint, unsigned int);kstrto_from_user (kstrtoint_from_user, kstrtoint, int); -kstrto_from_user (kstrtou16_from_user, kstrtou16, u16); -kstrto_from_user (kstrtos16_from_user, kstrtos16, s16);kstrto_from_user (kstrtou8_from_user, kstrtou8, u8); -kstrto_from_user (kstrtos8_from_user, kstrtos8, s8);#define kstrto_from_iter (f, g, type) \ int f(struct iov_iter *s, size_t count, unsigned int base, type *res) \
Signature · 1 line
2.43.0
Jens Axboe
maintainerPATCH 437/437 REMOVE ->read() and ->write()
In reply to Jens AxboeTest patch just to check coverage.
--- fs/file_table.c | 4 +-- fs/open.c | 4 +-- fs/read_write.c | 16 +++-------- include/linux/fs.h | 2 -- io_uring/rw.c | 70 ---------------------------------------------- 5 files changed, 8 insertions(+), 88 deletions(-)
fs/file_table.c +2 -2
@@ -292,10 +292,10 @@ static void file_init_path(struct file *file, const struct path *path,if (fop->llseek) file->f_mode |=FMODE_LSEEK ;if ((file->f_mode &FMODE_READ ) && -likely (fop->read || fop->read_iter)) +likely (fop->read_iter)) file->f_mode |=FMODE_CAN_READ ;if ((file->f_mode &FMODE_WRITE ) && -likely (fop->write || fop->write_iter)) +likely (fop->write_iter)) file->f_mode |=FMODE_CAN_WRITE ; file->f_iocb_flags =iocb_flags (file); file->f_mode |=FMODE_OPENED ;
fs/open.c +2 -2
@@ -958,10 +958,10 @@ static int do_dentry_open(struct file *f, } f->f_mode |=FMODE_OPENED ;if ((f->f_mode &FMODE_READ ) && -likely (f->f_op->read || f->f_op->read_iter)) +likely (f->f_op->read_iter)) f->f_mode |=FMODE_CAN_READ ;if ((f->f_mode &FMODE_WRITE ) && -likely (f->f_op->write || f->f_op->write_iter)) +likely (f->f_op->write_iter)) f->f_mode |=FMODE_CAN_WRITE ;if ((f->f_mode &FMODE_LSEEK ) && !f->f_op->llseek) f->f_mode &= ~FMODE_LSEEK ;
fs/read_write.c +4 -12
@@ -425,7 +425,7 @@ ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)* Also fail if ->read_iter and ->read are both wired up as that * implies very convoluted semantics. */ -if (unlikely (!file->f_op->read_iter || file->f_op->read)) +if (unlikely (!file->f_op->read_iter))return warn_unsupported (file,"read" );init_sync_kiocb (&kiocb, file);
@@ -470,9 +470,7 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)if (count >MAX_RW_COUNT ) count =MAX_RW_COUNT ; -if (file->f_op->read) - ret = file->f_op->read (file, buf, count, pos); -else if (file->f_op->read_iter) +if (file->f_op->read_iter) ret =new_sync_read (file, buf, count, pos);else ret = -EINVAL ;
@@ -515,7 +513,7 @@ ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff_t *po* Also fail if ->write_iter and ->write are both wired up as that * implies very convoluted semantics. */ -if (unlikely (!file->f_op->write_iter || file->f_op->write)) +if (unlikely (!file->f_op->write_iter))return warn_unsupported (file,"write" );init_sync_kiocb (&kiocb, file);
@@ -584,9 +582,7 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_if (count >MAX_RW_COUNT ) count =MAX_RW_COUNT ;file_start_write (file); -if (file->f_op->write) - ret = file->f_op->write (file, buf, count, pos); -else if (file->f_op->write_iter) +if (file->f_op->write_iter) ret =new_sync_write (file, buf, count, pos);else ret = -EINVAL ;
@@ -972,8 +968,6 @@ static ssize_t vfs_readv(struct file *file, const struct iovec __user *vec,if (file->f_op->read_iter) ret =do_iter_readv_writev (file, &iter, pos,READ , flags); -else - ret =do_loop_readv (file, &iter, pos, flags, file->f_op->read); out:if (ret >=0 )fsnotify_access (file);
@@ -1011,8 +1005,6 @@ static ssize_t vfs_writev(struct file *file, const struct iovec __user *vec,file_start_write (file);if (file->f_op->write_iter) ret =do_iter_readv_writev (file, &iter, pos,WRITE , flags); -else - ret =do_loop_writev (file, &iter, pos, flags, file->f_op->write);if (ret >0 )fsnotify_modify (file);file_end_write (file);
include/linux/fs.h +0 -2
@@ -2009,8 +2009,6 @@ struct offset_ctx;struct file_operations {struct module *owner;loff_t (*llseek) (struct file *,loff_t ,int ); -ssize_t (*read) (struct file *,char __user *,size_t ,loff_t *); -ssize_t (*write) (struct file *,const char __user *,size_t ,loff_t *);ssize_t (*read_iter) (struct kiocb *,struct iov_iter *);ssize_t (*write_iter) (struct kiocb *,struct iov_iter *); int (*iopoll)(struct kiocb *kiocb, struct io_comp_batch *,
io_uring/rw.c +0 -70
88 lines not on this page · raw message
Signature · 1 line
2.43.0
Al Viro
maintainerQuoted 19 lines · Jens Axboe
Hi,
This patchset will obviously be split, commit messages updated, and specific driver patches targeted to where they belong. But I figured it'd be useful to blast out the full set at least once for reference, and then I'll continue down the right path for the next one.
Subject line says it all, really. 10 years ago we added ->read_iter() and ->write_iter() to struct
file_operations. These are great, as they pass in aniov_iterrather than a user buffer + length, and they also take a struct kiocb rather than just a file. Since then we've had two paths for any read or write - one legacy one that can't do per-IO hints like "This read should be non-blocking", they strictly only work withO_NONBLOCKon the file, and a newer one that supports everything the old path does and a bunch more. We've had a few issues with theiov_iterbased path being slower, but those have basically been resolved with solutions likeITER_UBUFto optimize the single segment case that is often the fast path.
Quoted 6 lines
There are basically three parts to this series:
1) Add generic helpers that we need to convert drivers.
2) Convert any use offops->read()and ->write()
3) Kill off old cruft.
3a) Profit.
The fundamental problem with that is that a bunch of drivers do care about the vector boundaries. Very much so. It's very common to have this kind of situation:
write() parses the buffer sloppily, and ignores the junk in
the end, claiming that everything that been written.
writev() feeds each vector to write().
From a cursory look through that pile, you seem to have broken writev() on at least some (if not all) of those.
Al Viro
maintainerQuoted 34 lines · Al Viro
Quoted 19 lines · Jens Axboe
Hi,
This patchset will obviously be split, commit messages updated, and specific driver patches targeted to where they belong. But I figured it'd be useful to blast out the full set at least once for reference, and then I'll continue down the right path for the next one.
Subject line says it all, really. 10 years ago we added ->read_iter() and ->write_iter() to struct
file_operations. These are great, as they pass in aniov_iterrather than a user buffer + length, and they also take a struct kiocb rather than just a file. Since then we've had two paths for any read or write - one legacy one that can't do per-IO hints like "This read should be non-blocking", they strictly only work withO_NONBLOCKon the file, and a newer one that supports everything the old path does and a bunch more. We've had a few issues with theiov_iterbased path being slower, but those have basically been resolved with solutions likeITER_UBUFto optimize the single segment case that is often the fast path.Quoted 6 lines
There are basically three parts to this series:
1) Add generic helpers that we need to convert drivers.
2) Convert any use offops->read()and ->write()
3) Kill off old cruft.
3a) Profit.The fundamental problem with that is that a bunch of drivers do care about the vector boundaries. Very much so. It's very common to have this kind of situation:
write()parses the buffer sloppily, and ignores the junk in
the end, claiming that everything that been written.
writev()feeds each vector towrite().
Quoted 2 lines
From a cursory look through that pile, you seem to have broken
writev()on at least some (if not all) of those.
OK, it's 'some', not 'all', but AFAICS you'd been far too optimistic about the number of instances that do not need your vfs_write_iter() wrappers...
Jens Axboe
maintainerQuoted 34 lines · Al Viro
Quoted 19 lines · Jens Axboe
Hi,
This patchset will obviously be split, commit messages updated, and specific driver patches targeted to where they belong. But I figured it'd be useful to blast out the full set at least once for reference, and then I'll continue down the right path for the next one.
Subject line says it all, really. 10 years ago we added ->read_iter() and ->write_iter() to struct
file_operations. These are great, as they pass in aniov_iterrather than a user buffer + length, and they also take a struct kiocb rather than just a file. Since then we've had two paths for any read or write - one legacy one that can't do per-IO hints like "This read should be non-blocking", they strictly only work withO_NONBLOCKon the file, and a newer one that supports everything the old path does and a bunch more. We've had a few issues with theiov_iterbased path being slower, but those have basically been resolved with solutions likeITER_UBUFto optimize the single segment case that is often the fast path.Quoted 6 lines
There are basically three parts to this series:
1) Add generic helpers that we need to convert drivers.
2) Convert any use offops->read()and ->write()
3) Kill off old cruft.
3a) Profit.The fundamental problem with that is that a bunch of drivers do care about the vector boundaries. Very much so. It's very common to have this kind of situation:
write()parses the buffer sloppily, and ignores the junk in
the end, claiming that everything that been written.
writev()feeds each vector towrite().
Quoted 2 lines
From a cursory look through that pile, you seem to have broken
writev()on at least some (if not all) of those.
I'm aware of some drivers that do different things from write vs writev, or read vs readv for instance. But those I did cater to, by having a flag they can now check.
Can you be a bit more specific on an example of a driver that does the above?
Signature · 1 line
Jens Axboe
Al Viro
maintainerQuoted 6 lines · Jens Axboe
I'm aware of some drivers that do different things from write vs writev, or read vs readv for instance. But those I did cater to, by having a flag they can now check.
Can you be a bit more specific on an example of a driver that does the above?
Consider e.g. your #39. Current mainline: 1 call of ->set() for each segment passed to writev() on any of those. With your patch: call segments concatenated and if the concatenation looks like a number, a single call of ->set().
If nothing else, it's a user-visible ABI change. And in cases when ->set() has non-trivial side effects, it just might break a real-world code that is currently correct.
I picked that one because I didn't want to dig through the drivers - I'm pretty sure that there's more to be found there.
It's not just "write() and writev() parse the data in different way" - we do have a couple of those, but that's a minor problem.
"write(fd, buf, len1); write(fd, buf + len1, len1 + len2); is not the same thing as write(fd, buf, len1 + len2)" is not rare for character devices and for regular files on procfs/debugfs/etc.
For any of those you need to use you vfs_write_iter() helper or you'll be breaking userland ABI. The cost of audit of several thousands of ->write() (and ->read() - similar problem applies there) instances, checking that property is the main reason this conversion hadn't been already done.
Jens Axboe
maintainerQuoted 28 lines · Al Viro
Quoted 6 lines · Jens Axboe
I'm aware of some drivers that do different things from write vs writev, or read vs readv for instance. But those I did cater to, by having a flag they can now check.
Can you be a bit more specific on an example of a driver that does the above?
Consider e.g. your #39. Current mainline: 1 call of ->set() for each segment passed to
writev()on any of those. With your patch: call segments concatenated and if the concatenation looks like a number, a single call of ->set().If nothing else, it's a user-visible ABI change. And in cases when ->set() has non-trivial side effects, it just might break a real-world code that is currently correct.
I picked that one because I didn't want to dig through the drivers - I'm pretty sure that there's more to be found there.
It's not just "
write()andwritev()parse the data in different way" - we do have a couple of those, but that's a minor problem."
write(fd, buf, len1);write(fd, buf + len1, len1 + len2); is not the same thing aswrite(fd, buf, len1 + len2)" is not rare for character devices and for regular files on procfs/debugfs/etc.
Quoted 5 lines
For any of those you need to use you
vfs_write_iter()helper or you'll be breaking userland ABI. The cost of audit of several thousands of ->write() (and ->read() - similar problem applies there) instances, checking that property is the main reason this conversion hadn't been already done.
Thanks Al, I see what you mean now, and yes that certainly makes sense. I'll go over the conversions and see what might be affected, and for those we'll probably just play it safe initially and use the FOPS iterators helpers to avoid changing behavior.
Signature · 1 line
Jens Axboe