[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240504133055.0ca70f7a@sal.lan>
Date: Sat, 4 May 2024 13:31:09 +0100
From: Mauro Carvalho Chehab <mchehab@...nel.org>
To: Jens Axboe <axboe@...nel.dk>
Cc: linux-kernel@...r.kernel.org, linux-media@...r.kernel.org
Subject: Re: [PATCH 413/437] media/rc: convert to read/write iterators
Em Thu, 11 Apr 2024 09:19:13 -0600
Jens Axboe <axboe@...nel.dk> escreveu:
> Signed-off-by: Jens Axboe <axboe@...nel.dk>
Please add a patch description to media patches. Also, please
c/c linux-media@...r.kernel.org, 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
> ---
> drivers/media/rc/imon.c | 26 ++++++++++++--------------
> drivers/media/rc/lirc_dev.c | 15 ++++++++-------
> 2 files changed, 20 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
> index 5719dda6e0f0..cfcf8101164a 100644
> --- a/drivers/media/rc/imon.c
> +++ b/drivers/media/rc/imon.c
> @@ -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;
> }
> diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
> index caad59f76793..e88ba11192ea 100644
> --- a/drivers/media/rc/lirc_dev.c
> +++ b/drivers/media/rc/lirc_dev.c
> @@ -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,
Powered by blists - more mailing lists