diff options
| author | Nuno Sá <nuno.sa@analog.com> | 2025-02-18 13:31:26 +0300 |
|---|---|---|
| committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2025-03-04 16:17:50 +0300 |
| commit | 6d5dd486c715908b5a6ed02315a15ff044a91025 (patch) | |
| tree | d9f11cce1b349436c511a76b700f49740e6d27ec | |
| parent | 035b4989211dc1c8626e186d655ae8ca5141bb73 (diff) | |
| download | linux-6d5dd486c715908b5a6ed02315a15ff044a91025.tar.xz | |
iio: core: make use of simple_write_to_buffer()
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>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250218-dev-iio-misc-v1-2-bf72b20a1eb8@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| -rw-r--r-- | drivers/iio/industrialio-core.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index a2117ad1337d..b9f4113ae5fc 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); |
