]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 4.4
authorSasha Levin <sashal@kernel.org>
Tue, 9 Jun 2020 12:03:27 +0000 (08:03 -0400)
committerSasha Levin <sashal@kernel.org>
Tue, 9 Jun 2020 12:04:48 +0000 (08:04 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-4.4/iio-vcnl4000-fix-i2c-swapped-word-reading.patch [new file with mode: 0644]
queue-4.4/series

diff --git a/queue-4.4/iio-vcnl4000-fix-i2c-swapped-word-reading.patch b/queue-4.4/iio-vcnl4000-fix-i2c-swapped-word-reading.patch
new file mode 100644 (file)
index 0000000..1c4cc8f
--- /dev/null
@@ -0,0 +1,55 @@
+From d27e0a4b197ae81590b15fade347d18e3815d086 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 3 May 2020 11:29:55 +0200
+Subject: iio: vcnl4000: Fix i2c swapped word reading.
+
+From: Mathieu Othacehe <m.othacehe@gmail.com>
+
+[ Upstream commit 18dfb5326370991c81a6d1ed6d1aeee055cb8c05 ]
+
+The bytes returned by the i2c reading need to be swapped
+unconditionally. Otherwise, on be16 platforms, an incorrect value will be
+returned.
+
+Taking the slow path via next merge window as its been around a while
+and we have a patch set dependent on this which would be held up.
+
+Fixes: 62a1efb9f868 ("iio: add vcnl4000 combined ALS and proximity sensor")
+Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com>
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iio/light/vcnl4000.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
+index c9d85bbc9230..a17891511be5 100644
+--- a/drivers/iio/light/vcnl4000.c
++++ b/drivers/iio/light/vcnl4000.c
+@@ -56,7 +56,6 @@ static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask,
+                               u8 rdy_mask, u8 data_reg, int *val)
+ {
+       int tries = 20;
+-      __be16 buf;
+       int ret;
+       ret = i2c_smbus_write_byte_data(data->client, VCNL4000_COMMAND,
+@@ -80,12 +79,11 @@ static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask,
+               return -EIO;
+       }
+-      ret = i2c_smbus_read_i2c_block_data(data->client,
+-              data_reg, sizeof(buf), (u8 *) &buf);
++      ret = i2c_smbus_read_word_swapped(data->client, data_reg);
+       if (ret < 0)
+               return ret;
+-      *val = be16_to_cpu(buf);
++      *val = ret;
+       return 0;
+ }
+-- 
+2.25.1
+
index 50c29d176888885902a89d275376f7e6a9a38047..e85db6441547209737c6063f2b525cb4088d306c 100644 (file)
@@ -26,3 +26,4 @@ usb-serial-usb_wwan-do-not-resubmit-rx-urb-on-fatal-errors.patch
 usb-serial-option-add-telit-le910c1-eux-compositions.patch
 vt-keyboard-avoid-signed-integer-overflow-in-k_ascii.patch
 staging-rtl8712-fix-ieee80211_addba_param_buf_size_mask.patch
+iio-vcnl4000-fix-i2c-swapped-word-reading.patch