.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Windfarm PowerMac thermal control. SMU based sensors |
---|
3 | 4 | * |
---|
4 | 5 | * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp. |
---|
5 | 6 | * <benh@kernel.crashing.org> |
---|
6 | | - * |
---|
7 | | - * Released under the term of the GNU GPL v2. |
---|
8 | 7 | */ |
---|
9 | 8 | |
---|
10 | 9 | #include <linux/types.h> |
---|
.. | .. |
---|
197 | 196 | static struct smu_ad_sensor *smu_ads_create(struct device_node *node) |
---|
198 | 197 | { |
---|
199 | 198 | struct smu_ad_sensor *ads; |
---|
200 | | - const char *c, *l; |
---|
| 199 | + const char *l; |
---|
201 | 200 | const u32 *v; |
---|
202 | 201 | |
---|
203 | 202 | ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL); |
---|
204 | 203 | if (ads == NULL) |
---|
205 | 204 | return NULL; |
---|
206 | | - c = of_get_property(node, "device_type", NULL); |
---|
207 | 205 | l = of_get_property(node, "location", NULL); |
---|
208 | | - if (c == NULL || l == NULL) |
---|
| 206 | + if (l == NULL) |
---|
209 | 207 | goto fail; |
---|
210 | 208 | |
---|
211 | 209 | /* We currently pick the sensors based on the OF name and location |
---|
.. | .. |
---|
215 | 213 | * the names and locations consistents so I'll stick with the names |
---|
216 | 214 | * and locations for now. |
---|
217 | 215 | */ |
---|
218 | | - if (!strcmp(c, "temp-sensor") && |
---|
| 216 | + if (of_node_is_type(node, "temp-sensor") && |
---|
219 | 217 | !strcmp(l, "CPU T-Diode")) { |
---|
220 | 218 | ads->sens.ops = &smu_cputemp_ops; |
---|
221 | 219 | ads->sens.name = "cpu-temp"; |
---|
.. | .. |
---|
224 | 222 | SMU_SDB_CPUDIODE_ID); |
---|
225 | 223 | goto fail; |
---|
226 | 224 | } |
---|
227 | | - } else if (!strcmp(c, "current-sensor") && |
---|
| 225 | + } else if (of_node_is_type(node, "current-sensor") && |
---|
228 | 226 | !strcmp(l, "CPU Current")) { |
---|
229 | 227 | ads->sens.ops = &smu_cpuamp_ops; |
---|
230 | 228 | ads->sens.name = "cpu-current"; |
---|
.. | .. |
---|
233 | 231 | SMU_SDB_CPUVCP_ID); |
---|
234 | 232 | goto fail; |
---|
235 | 233 | } |
---|
236 | | - } else if (!strcmp(c, "voltage-sensor") && |
---|
| 234 | + } else if (of_node_is_type(node, "voltage-sensor") && |
---|
237 | 235 | !strcmp(l, "CPU Voltage")) { |
---|
238 | 236 | ads->sens.ops = &smu_cpuvolt_ops; |
---|
239 | 237 | ads->sens.name = "cpu-voltage"; |
---|
.. | .. |
---|
242 | 240 | SMU_SDB_CPUVCP_ID); |
---|
243 | 241 | goto fail; |
---|
244 | 242 | } |
---|
245 | | - } else if (!strcmp(c, "power-sensor") && |
---|
| 243 | + } else if (of_node_is_type(node, "power-sensor") && |
---|
246 | 244 | !strcmp(l, "Slots Power")) { |
---|
247 | 245 | ads->sens.ops = &smu_slotspow_ops; |
---|
248 | 246 | ads->sens.name = "slots-power"; |
---|
.. | .. |
---|
275 | 273 | struct list_head link; |
---|
276 | 274 | struct wf_sensor *volts; |
---|
277 | 275 | struct wf_sensor *amps; |
---|
278 | | - int fake_volts : 1; |
---|
279 | | - int quadratic : 1; |
---|
| 276 | + unsigned int fake_volts : 1; |
---|
| 277 | + unsigned int quadratic : 1; |
---|
280 | 278 | struct wf_sensor sens; |
---|
281 | 279 | }; |
---|
282 | 280 | #define to_smu_cpu_power(c) container_of(c, struct smu_cpu_power_sensor, sens) |
---|
.. | .. |
---|
423 | 421 | return -ENODEV; |
---|
424 | 422 | |
---|
425 | 423 | /* 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")) |
---|
429 | 426 | break; |
---|
430 | 427 | |
---|
431 | 428 | of_node_put(smu); |
---|