From: "Nuno Sá" <nuno.sa@analog.com>
To: linux-iio@vger.kernel.org
Cc: Olivier Moysan <olivier.moysan@foss.st.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 2/2] iio: core: make use of simple_write_to_buffer()
Date: Tue, 18 Feb 2025 10:31:26 +0000 [thread overview]
Message-ID: <20250218-dev-iio-misc-v1-2-bf72b20a1eb8@analog.com> (raw)
In-Reply-To: <20250218-dev-iio-misc-v1-0-bf72b20a1eb8@analog.com>
Instead of open coding (kind of) simple_write_to_buffer(), use it.
While at it, use ascii representation to terminate the string as that is
the more common way of doing it.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/industrialio-core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index a2117ad1337d55468c0f21c274fcbedd352c97ff..b9f4113ae5fc3ee1ef76be6808cc437286690dae 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -410,11 +410,12 @@ static ssize_t iio_debugfs_write_reg(struct file *file,
char buf[80];
int ret;
- count = min(count, sizeof(buf) - 1);
- if (copy_from_user(buf, userbuf, count))
- return -EFAULT;
+ ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, userbuf,
+ count);
+ if (ret < 0)
+ return ret;
- buf[count] = 0;
+ buf[count] = '\0';
ret = sscanf(buf, "%i %i", ®, &val);
--
2.48.1
WARNING: multiple messages have this Message-ID (diff)
From: "Nuno Sá via B4 Relay" <devnull+nuno.sa.analog.com@kernel.org>
To: linux-iio@vger.kernel.org
Cc: Olivier Moysan <olivier.moysan@foss.st.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 2/2] iio: core: make use of simple_write_to_buffer()
Date: Tue, 18 Feb 2025 10:31:26 +0000 [thread overview]
Message-ID: <20250218-dev-iio-misc-v1-2-bf72b20a1eb8@analog.com> (raw)
In-Reply-To: <20250218-dev-iio-misc-v1-0-bf72b20a1eb8@analog.com>
From: Nuno Sá <nuno.sa@analog.com>
Instead of open coding (kind of) simple_write_to_buffer(), use it.
While at it, use ascii representation to terminate the string as that is
the more common way of doing it.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/industrialio-core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index a2117ad1337d55468c0f21c274fcbedd352c97ff..b9f4113ae5fc3ee1ef76be6808cc437286690dae 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -410,11 +410,12 @@ static ssize_t iio_debugfs_write_reg(struct file *file,
char buf[80];
int ret;
- count = min(count, sizeof(buf) - 1);
- if (copy_from_user(buf, userbuf, count))
- return -EFAULT;
+ ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, userbuf,
+ count);
+ if (ret < 0)
+ return ret;
- buf[count] = 0;
+ buf[count] = '\0';
ret = sscanf(buf, "%i %i", ®, &val);
--
2.48.1
next prev parent reply other threads:[~2025-02-18 10:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-18 10:31 [PATCH 0/2] iio: small fixes and improvements Nuno Sá
2025-02-18 10:31 ` Nuno Sá via B4 Relay
2025-02-18 10:31 ` [PATCH 1/2] iio: backend: make sure to NULL terminate stack buffer Nuno Sá
2025-02-18 10:31 ` Nuno Sá via B4 Relay
2025-02-18 15:52 ` David Lechner
2025-02-18 16:36 ` Nuno Sá
2025-02-18 16:57 ` David Lechner
2025-02-18 10:31 ` Nuno Sá [this message]
2025-02-18 10:31 ` [PATCH 2/2] iio: core: make use of simple_write_to_buffer() Nuno Sá via B4 Relay
2025-02-18 17:29 ` [PATCH 0/2] iio: small fixes and improvements David Lechner
2025-02-22 14:23 ` Jonathan Cameron
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=20250218-dev-iio-misc-v1-2-bf72b20a1eb8@analog.com \
--to=nuno.sa@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=olivier.moysan@foss.st.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.