]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.10
authorSasha Levin <sashal@kernel.org>
Mon, 27 Mar 2023 01:40:37 +0000 (21:40 -0400)
committerSasha Levin <sashal@kernel.org>
Mon, 27 Mar 2023 01:40:37 +0000 (21:40 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.10/hwmon-fix-potential-sensor-registration-fail-if-of_n.patch [new file with mode: 0644]
queue-5.10/hwmon-it87-fix-voltage-scaling-for-chips-with-10.9mv.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/hwmon-fix-potential-sensor-registration-fail-if-of_n.patch b/queue-5.10/hwmon-fix-potential-sensor-registration-fail-if-of_n.patch
new file mode 100644 (file)
index 0000000..73eef54
--- /dev/null
@@ -0,0 +1,58 @@
+From ed7acc03b5084daa26dd0ed2e7d1c2beefa9824a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 21 Mar 2023 14:02:23 +0800
+Subject: hwmon: fix potential sensor registration fail if of_node is missing
+
+From: Phinex Hung <phinex@realtek.com>
+
+[ Upstream commit 2315332efcbe7124252f080e03b57d3d2f1f4771 ]
+
+It is not sufficient to check of_node in current device.
+In some cases, this would cause the sensor registration to fail.
+
+This patch looks for device's ancestors to find a valid of_node if any.
+
+Fixes: d560168b5d0f ("hwmon: (core) New hwmon registration API")
+Signed-off-by: Phinex Hung <phinex@realtek.com>
+Link: https://lore.kernel.org/r/20230321060224.3819-1-phinex@realtek.com
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hwmon/hwmon.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
+index d649fea829994..045dc3fd7953e 100644
+--- a/drivers/hwmon/hwmon.c
++++ b/drivers/hwmon/hwmon.c
+@@ -700,6 +700,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
+ {
+       struct hwmon_device *hwdev;
+       struct device *hdev;
++      struct device *tdev = dev;
+       int i, err, id;
+       /* Complain about invalid characters in hwmon name attribute */
+@@ -757,7 +758,9 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
+       hwdev->name = name;
+       hdev->class = &hwmon_class;
+       hdev->parent = dev;
+-      hdev->of_node = dev ? dev->of_node : NULL;
++      while (tdev && !tdev->of_node)
++              tdev = tdev->parent;
++      hdev->of_node = tdev ? tdev->of_node : NULL;
+       hwdev->chip = chip;
+       dev_set_drvdata(hdev, drvdata);
+       dev_set_name(hdev, HWMON_ID_FORMAT, id);
+@@ -769,7 +772,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
+       INIT_LIST_HEAD(&hwdev->tzdata);
+-      if (dev && dev->of_node && chip && chip->ops->read &&
++      if (hdev->of_node && chip && chip->ops->read &&
+           chip->info[0]->type == hwmon_chip &&
+           (chip->info[0]->config[0] & HWMON_C_REGISTER_TZ)) {
+               err = hwmon_thermal_register_sensors(hdev);
+-- 
+2.39.2
+
diff --git a/queue-5.10/hwmon-it87-fix-voltage-scaling-for-chips-with-10.9mv.patch b/queue-5.10/hwmon-it87-fix-voltage-scaling-for-chips-with-10.9mv.patch
new file mode 100644 (file)
index 0000000..cd3983e
--- /dev/null
@@ -0,0 +1,47 @@
+From bca8371b6386420008c899e925a6a6b6042bf0b4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 18 Mar 2023 19:05:42 +1100
+Subject: hwmon (it87): Fix voltage scaling for chips with 10.9mV  ADCs
+
+From: Frank Crawford <frank@crawford.emu.id.au>
+
+[ Upstream commit 968b66ffeb7956acc72836a7797aeb7b2444ec51 ]
+
+Fix voltage scaling for chips that have 10.9mV ADCs, where scaling was
+not performed.
+
+Fixes: ead8080351c9 ("hwmon: (it87) Add support for IT8732F")
+Signed-off-by: Frank Crawford <frank@crawford.emu.id.au>
+Link: https://lore.kernel.org/r/20230318080543.1226700-2-frank@crawford.emu.id.au
+[groeck: Update subject and description to focus on bug fix]
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hwmon/it87.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
+index fac9b5c68a6a0..85413d3dc3940 100644
+--- a/drivers/hwmon/it87.c
++++ b/drivers/hwmon/it87.c
+@@ -486,6 +486,8 @@ static const struct it87_devices it87_devices[] = {
+ #define has_pwm_freq2(data)   ((data)->features & FEAT_PWM_FREQ2)
+ #define has_six_temp(data)    ((data)->features & FEAT_SIX_TEMP)
+ #define has_vin3_5v(data)     ((data)->features & FEAT_VIN3_5V)
++#define has_scaling(data)     ((data)->features & (FEAT_12MV_ADC | \
++                                                   FEAT_10_9MV_ADC))
+ struct it87_sio_data {
+       int sioaddr;
+@@ -3098,7 +3100,7 @@ static int it87_probe(struct platform_device *pdev)
+                        "Detected broken BIOS defaults, disabling PWM interface\n");
+       /* Starting with IT8721F, we handle scaling of internal voltages */
+-      if (has_12mv_adc(data)) {
++      if (has_scaling(data)) {
+               if (sio_data->internal & BIT(0))
+                       data->in_scaled |= BIT(3);      /* in3 is AVCC */
+               if (sio_data->internal & BIT(1))
+-- 
+2.39.2
+
index 023ff80001182be4fe463435b7f7cbe2b8076912..75c3d6eb31f2fa7a21e76429550ac7004552b2c4 100644 (file)
@@ -56,3 +56,5 @@ bluetooth-l2cap-fix-not-checking-for-maximum-number-.patch
 bluetooth-l2cap-fix-responding-with-wrong-pdu-type.patch
 bluetooth-btsdio-fix-use-after-free-bug-in-btsdio_re.patch
 platform-chrome-cros_ec_chardev-fix-kernel-data-leak.patch
+hwmon-fix-potential-sensor-registration-fail-if-of_n.patch
+hwmon-it87-fix-voltage-scaling-for-chips-with-10.9mv.patch