Re: [RFC] media: atomisp: change copy_from_compatible to iov_iter
From: Andy Shevchenko
Date: Wed Apr 08 2026 - 10:30:08 EST
On Wed, Apr 08, 2026 at 01:46:11PM +0000, Joshua Crofts wrote:
> Since the atomisp driver concerns transferring video
> data, it would probably be better to use an iov_iter
> than copy_to_user calls (scatter-gather i/o and better
> pointer safety). Per yesterday's emails, I'm sending an
> an example of a function in atomisp_cmd.c where I've
> implemented iov_iter usage.
>
> Note, this isn't a patch, more of a question whether this
> style of changing the copy_to_user calls is valid (or if
> I'm writing garbage code). I'd rather get your opinion
> than submitting a patch first.
...
> - ret = copy_to_user(config->data, asd->params.s3a_user_stat->data,
> - asd->params.s3a_output_bytes);
> - if (ret) {
> - dev_err(isp->dev, "copy to user failed: copied %lu bytes\n",
> - ret);
> + ret = import_ubuf(ITER_DEST, (void __user *)config->data, asd->params.s3a_output_bytes, &iter);
> + if (ret)
> + return ret;
> +
> + if (copy_to_iter(asd->params.s3a_user_stat->data, asd->params.s3a_output_bytes, &iter) != asd->params.s3a_output_bytes)
> return -EFAULT;
> - }
It doesn't change any architectural decision here. Basically you need to have
s3a_output_bytes to be already iov_iter at this point. So, import_ubuf() has to
happen somewhere else.
--
With Best Regards,
Andy Shevchenko