Linux-Media Archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: Re: [PATCH 413/437] media/rc: convert to read/write iterators
Date: Sat, 4 May 2024 13:31:09 +0100	[thread overview]
Message-ID: <20240504133055.0ca70f7a@sal.lan> (raw)
In-Reply-To: <20240411153126.16201-414-axboe@kernel.dk>

Em Thu, 11 Apr 2024 09:19:13 -0600
Jens Axboe <axboe@kernel.dk> escreveu:

> Signed-off-by: Jens Axboe <axboe@kernel.dk>

Please add a patch description to media patches. Also, please
c/c linux-media@vger.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,

       reply	other threads:[~2024-05-04 12:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240411153126.16201-1-axboe@kernel.dk>
     [not found] ` <20240411153126.16201-414-axboe@kernel.dk>
2024-05-04 12:31   ` Mauro Carvalho Chehab [this message]
2024-05-05 13:16     ` [PATCH 413/437] media/rc: convert to read/write iterators Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240504133055.0ca70f7a@sal.lan \
    --to=mchehab@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).