]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.92/iio-core-return-error-for-failed-read_reg.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.4.92 / iio-core-return-error-for-failed-read_reg.patch
1 From 3d62c78a6eb9a7d67bace9622b66ad51e81c5f9b Mon Sep 17 00:00:00 2001
2 From: Matt Fornero <matt.fornero@mathworks.com>
3 Date: Tue, 5 Sep 2017 16:34:10 +0200
4 Subject: iio: core: Return error for failed read_reg
5
6 From: Matt Fornero <matt.fornero@mathworks.com>
7
8 commit 3d62c78a6eb9a7d67bace9622b66ad51e81c5f9b upstream.
9
10 If an IIO device returns an error code for a read access via debugfs, it
11 is currently ignored by the IIO core (other than emitting an error
12 message). Instead, return this error code to user space, so upper layers
13 can detect it correctly.
14
15 Signed-off-by: Matt Fornero <matt.fornero@mathworks.com>
16 Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
17 Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19
20 ---
21 drivers/iio/industrialio-core.c | 4 +++-
22 1 file changed, 3 insertions(+), 1 deletion(-)
23
24 --- a/drivers/iio/industrialio-core.c
25 +++ b/drivers/iio/industrialio-core.c
26 @@ -221,8 +221,10 @@ static ssize_t iio_debugfs_read_reg(stru
27 ret = indio_dev->info->debugfs_reg_access(indio_dev,
28 indio_dev->cached_reg_addr,
29 0, &val);
30 - if (ret)
31 + if (ret) {
32 dev_err(indio_dev->dev.parent, "%s: read failed\n", __func__);
33 + return ret;
34 + }
35
36 len = snprintf(buf, sizeof(buf), "0x%X\n", val);
37