From: Joshua Crofts <joshua.crofts1@gmail.com>
To: andriy.shevchenko@intel.com
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
linux-staging@lists.linux.dev,
Joshua Crofts <joshua.crofts1@gmail.com>
Subject: [RFC] media: atomisp: change copy_from_compatible to iov_iter
Date: Wed, 8 Apr 2026 13:46:11 +0000 [thread overview]
Message-ID: <20260408134612.1380-1-joshua.crofts1@gmail.com> (raw)
In-Reply-To: <adUeywfiQzZ5JgEd@ashevche-desk.local>
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.
Thanks for your response!
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
drivers/staging/media/atomisp/pci/atomisp_cmd.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index b3e971be0e..3b987e8e8c 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -15,6 +15,7 @@
#include <linux/kfifo.h>
#include <linux/pm_runtime.h>
#include <linux/timer.h>
+#include <linux/uio.h>
#include <asm/iosf_mbi.h>
@@ -1676,7 +1677,8 @@ int atomisp_3a_stat(struct atomisp_sub_device *asd, int flag,
{
struct atomisp_device *isp = asd->isp;
struct atomisp_s3a_buf *s3a_buf;
- unsigned long ret;
+ struct iov_iter iter;
+ int ret;
if (flag != 0)
return -EINVAL;
@@ -1709,13 +1711,12 @@ int atomisp_3a_stat(struct atomisp_sub_device *asd, int flag,
config->exp_id = s3a_buf->s3a_data->exp_id;
config->isp_config_id = s3a_buf->s3a_data->isp_config_id;
- 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;
- }
/* Move to free buffer list */
list_del_init(&s3a_buf->list);
--
2.47.3
next prev parent reply other threads:[~2026-04-08 13:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 14:46 [RFC] staging: media: atomisp: change copy_from_compatible to iov_iter Joshua Crofts
2026-04-07 15:06 ` Andy Shevchenko
2026-04-07 15:12 ` Andy Shevchenko
2026-04-08 13:46 ` Joshua Crofts [this message]
2026-04-08 13:50 ` [RFC] " Joshua Crofts
2026-04-08 14:25 ` Andy Shevchenko
2026-04-08 14:29 ` Andy Shevchenko
2026-04-08 14:43 ` Joshua Crofts
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=20260408134612.1380-1-joshua.crofts1@gmail.com \
--to=joshua.crofts1@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/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