bcm27xx: 6.1: add kernel patches
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-6.1 / 950-0687-hwmon-emc2305-Add-calls-to-initialise-of-cooling-map.patch
1 From 76f8210c9498983b492645ec2c90c5c547ae415b Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Fri, 21 Apr 2023 14:49:38 +0100
4 Subject: [PATCH] hwmon: emc2305: Add calls to initialise of cooling
5 maps
6
7 Commit 46ef9d4ed26b ("hwmon: emc2305: fixups for driver submitted to
8 mailing lists") missed adding the call to thermal_of_cooling_device_register
9 required to configure any cooling maps for the device, hence stopping it
10 from actually ever changing speed.
11
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
13 ---
14 drivers/hwmon/emc2305.c | 22 ++++++++++++++++------
15 1 file changed, 16 insertions(+), 6 deletions(-)
16
17 --- a/drivers/hwmon/emc2305.c
18 +++ b/drivers/hwmon/emc2305.c
19 @@ -348,9 +348,17 @@ static int emc2305_set_single_tz(struct
20 cdev_idx = (idx) ? idx - 1 : 0;
21 pwm = data->pwm_min[cdev_idx];
22
23 - data->cdev_data[cdev_idx].cdev =
24 - thermal_cooling_device_register(emc2305_fan_name[idx], data,
25 - &emc2305_cooling_ops);
26 + if (dev->of_node)
27 + data->cdev_data[cdev_idx].cdev =
28 + devm_thermal_of_cooling_device_register(dev, dev->of_node,
29 + emc2305_fan_name[idx],
30 + data,
31 + &emc2305_cooling_ops);
32 + else
33 + data->cdev_data[cdev_idx].cdev =
34 + thermal_cooling_device_register(emc2305_fan_name[idx],
35 + data,
36 + &emc2305_cooling_ops);
37
38 if (IS_ERR(data->cdev_data[cdev_idx].cdev)) {
39 dev_err(dev, "Failed to register cooling device %s\n", emc2305_fan_name[idx]);
40 @@ -403,9 +411,11 @@ static void emc2305_unset_tz(struct devi
41 int i;
42
43 /* Unregister cooling device. */
44 - for (i = 0; i < EMC2305_PWM_MAX; i++)
45 - if (data->cdev_data[i].cdev)
46 - thermal_cooling_device_unregister(data->cdev_data[i].cdev);
47 + if (!dev->of_node) {
48 + for (i = 0; i < EMC2305_PWM_MAX; i++)
49 + if (data->cdev_data[i].cdev)
50 + thermal_cooling_device_unregister(data->cdev_data[i].cdev);
51 + }
52 }
53
54 static umode_t