]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.0/hwmon-occ-fix-power-sensor-indexing.patch
Linux 4.19.35
[thirdparty/kernel/stable-queue.git] / queue-5.0 / hwmon-occ-fix-power-sensor-indexing.patch
1 From 8e6af454117a51dbf6c8a47c00180a0c235052fe Mon Sep 17 00:00:00 2001
2 From: Eddie James <eajames@linux.ibm.com>
3 Date: Tue, 19 Mar 2019 16:01:58 -0500
4 Subject: hwmon: (occ) Fix power sensor indexing
5
6 From: Eddie James <eajames@linux.ibm.com>
7
8 commit 8e6af454117a51dbf6c8a47c00180a0c235052fe upstream.
9
10 In the case of power sensor version 0xA0, the sensor indexing overlapped
11 with the "caps" power sensors, resulting in probe failure and kernel
12 warnings. Fix this by specifying the next index for each power sensor
13 version.
14
15 Fixes: 54076cb3b5ff ("hwmon (occ): Add sensor attributes and register ...")
16 Cc: stable@vger.kernel.org
17 Signed-off-by: Eddie James <eajames@linux.ibm.com>
18 Tested-by: Joel Stanley <joel@jms.id.au>
19 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22 ---
23 drivers/hwmon/occ/common.c | 6 ++++--
24 1 file changed, 4 insertions(+), 2 deletions(-)
25
26 --- a/drivers/hwmon/occ/common.c
27 +++ b/drivers/hwmon/occ/common.c
28 @@ -889,6 +889,8 @@ static int occ_setup_sensor_attrs(struct
29 s++;
30 }
31 }
32 +
33 + s = (sensors->power.num_sensors * 4) + 1;
34 } else {
35 for (i = 0; i < sensors->power.num_sensors; ++i) {
36 s = i + 1;
37 @@ -917,11 +919,11 @@ static int occ_setup_sensor_attrs(struct
38 show_power, NULL, 3, i);
39 attr++;
40 }
41 - }
42
43 - if (sensors->caps.num_sensors >= 1) {
44 s = sensors->power.num_sensors + 1;
45 + }
46
47 + if (sensors->caps.num_sensors >= 1) {
48 snprintf(attr->name, sizeof(attr->name), "power%d_label", s);
49 attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_caps, NULL,
50 0, 0);