hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/macintosh/windfarm_smu_sensors.c
....@@ -1,10 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Windfarm PowerMac thermal control. SMU based sensors
34 *
45 * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
56 * <benh@kernel.crashing.org>
6
- *
7
- * Released under the term of the GNU GPL v2.
87 */
98
109 #include <linux/types.h>
....@@ -197,15 +196,14 @@
197196 static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
198197 {
199198 struct smu_ad_sensor *ads;
200
- const char *c, *l;
199
+ const char *l;
201200 const u32 *v;
202201
203202 ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL);
204203 if (ads == NULL)
205204 return NULL;
206
- c = of_get_property(node, "device_type", NULL);
207205 l = of_get_property(node, "location", NULL);
208
- if (c == NULL || l == NULL)
206
+ if (l == NULL)
209207 goto fail;
210208
211209 /* We currently pick the sensors based on the OF name and location
....@@ -215,7 +213,7 @@
215213 * the names and locations consistents so I'll stick with the names
216214 * and locations for now.
217215 */
218
- if (!strcmp(c, "temp-sensor") &&
216
+ if (of_node_is_type(node, "temp-sensor") &&
219217 !strcmp(l, "CPU T-Diode")) {
220218 ads->sens.ops = &smu_cputemp_ops;
221219 ads->sens.name = "cpu-temp";
....@@ -224,7 +222,7 @@
224222 SMU_SDB_CPUDIODE_ID);
225223 goto fail;
226224 }
227
- } else if (!strcmp(c, "current-sensor") &&
225
+ } else if (of_node_is_type(node, "current-sensor") &&
228226 !strcmp(l, "CPU Current")) {
229227 ads->sens.ops = &smu_cpuamp_ops;
230228 ads->sens.name = "cpu-current";
....@@ -233,7 +231,7 @@
233231 SMU_SDB_CPUVCP_ID);
234232 goto fail;
235233 }
236
- } else if (!strcmp(c, "voltage-sensor") &&
234
+ } else if (of_node_is_type(node, "voltage-sensor") &&
237235 !strcmp(l, "CPU Voltage")) {
238236 ads->sens.ops = &smu_cpuvolt_ops;
239237 ads->sens.name = "cpu-voltage";
....@@ -242,7 +240,7 @@
242240 SMU_SDB_CPUVCP_ID);
243241 goto fail;
244242 }
245
- } else if (!strcmp(c, "power-sensor") &&
243
+ } else if (of_node_is_type(node, "power-sensor") &&
246244 !strcmp(l, "Slots Power")) {
247245 ads->sens.ops = &smu_slotspow_ops;
248246 ads->sens.name = "slots-power";
....@@ -275,8 +273,8 @@
275273 struct list_head link;
276274 struct wf_sensor *volts;
277275 struct wf_sensor *amps;
278
- int fake_volts : 1;
279
- int quadratic : 1;
276
+ unsigned int fake_volts : 1;
277
+ unsigned int quadratic : 1;
280278 struct wf_sensor sens;
281279 };
282280 #define to_smu_cpu_power(c) container_of(c, struct smu_cpu_power_sensor, sens)
....@@ -423,9 +421,8 @@
423421 return -ENODEV;
424422
425423 /* Look for sensors subdir */
426
- for (sensors = NULL;
427
- (sensors = of_get_next_child(smu, sensors)) != NULL;)
428
- if (!strcmp(sensors->name, "sensors"))
424
+ for_each_child_of_node(smu, sensors)
425
+ if (of_node_name_eq(sensors, "sensors"))
429426 break;
430427
431428 of_node_put(smu);