Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

macintosh: Use device_type helpers to access the node type

Remove directly accessing device_node.type pointer and use the
accessors instead. This will eventually allow removing the type
pointer.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Rob Herring and committed by
Michael Ellerman
bf82d375 15b680c4

+22 -30
+2 -2
drivers/macintosh/macio_asic.c
··· 220 220 return 1; 221 221 222 222 /* Some older IDE resources have bogus sizes */ 223 - if (!(strcmp(np->name, "IDE") && strcmp(np->name, "ATA") && 224 - strcmp(np->type, "ide") && strcmp(np->type, "ata"))) { 223 + if (!strcmp(np->name, "IDE") || !strcmp(np->name, "ATA") || 224 + of_node_is_type(np, "ide") || of_node_is_type(np, "ata")) { 225 225 if (index == 0 && (res->end - res->start) > 0xfff) 226 226 res->end = res->start + 0xfff; 227 227 if (index == 1 && (res->end - res->start) > 0xff)
+6 -12
drivers/macintosh/macio_sysfs.c
··· 3 3 #include <linux/stat.h> 4 4 #include <asm/macio.h> 5 5 6 - 7 - #define macio_config_of_attr(field, format_string) \ 8 - static ssize_t \ 9 - field##_show (struct device *dev, struct device_attribute *attr, \ 10 - char *buf) \ 11 - { \ 12 - struct macio_dev *mdev = to_macio_device (dev); \ 13 - return sprintf (buf, format_string, mdev->ofdev.dev.of_node->field); \ 14 - } \ 15 - static DEVICE_ATTR_RO(field); 16 - 17 6 static ssize_t 18 7 compatible_show (struct device *dev, struct device_attribute *attr, char *buf) 19 8 { ··· 54 65 } 55 66 static DEVICE_ATTR_RO(name); 56 67 57 - macio_config_of_attr (type, "%s\n"); 68 + static ssize_t type_show(struct device *dev, 69 + struct device_attribute *attr, char *buf) 70 + { 71 + return sprintf(buf, "%s\n", of_node_get_device_type(dev->of_node)); 72 + } 73 + static DEVICE_ATTR_RO(type); 58 74 59 75 static struct attribute *macio_dev_attrs[] = { 60 76 &dev_attr_name.attr,
+4 -4
drivers/macintosh/windfarm_fcu_controls.c
··· 439 439 DBG(" control: %pOFn, type: %s\n", np, of_node_get_device_type(np)); 440 440 441 441 /* Detect control type */ 442 - if (!strcmp(np->type, "fan-rpm-control") || 443 - !strcmp(np->type, "fan-rpm")) 442 + if (of_node_is_type(np, "fan-rpm-control") || 443 + of_node_is_type(np, "fan-rpm")) 444 444 type = FCU_FAN_RPM; 445 - if (!strcmp(np->type, "fan-pwm-control") || 446 - !strcmp(np->type, "fan-pwm")) 445 + if (of_node_is_type(np, "fan-pwm-control") || 446 + of_node_is_type(np, "fan-pwm")) 447 447 type = FCU_FAN_PWM; 448 448 /* Only care about fans for now */ 449 449 if (type == -1)
+4 -5
drivers/macintosh/windfarm_smu_sat.c
··· 197 197 struct wf_sat *sat; 198 198 struct wf_sat_sensor *sens; 199 199 const u32 *reg; 200 - const char *loc, *type; 200 + const char *loc; 201 201 u8 chip, core; 202 202 struct device_node *child; 203 203 int shift, cpu, index; ··· 220 220 child = NULL; 221 221 while ((child = of_get_next_child(dev, child)) != NULL) { 222 222 reg = of_get_property(child, "reg", NULL); 223 - type = of_get_property(child, "device_type", NULL); 224 223 loc = of_get_property(child, "location", NULL); 225 224 if (reg == NULL || loc == NULL) 226 225 continue; ··· 248 249 continue; 249 250 } 250 251 251 - if (strcmp(type, "voltage-sensor") == 0) { 252 + if (of_node_is_type(child, "voltage-sensor")) { 252 253 name = "cpu-voltage"; 253 254 shift = 4; 254 255 vsens[core] = index; 255 - } else if (strcmp(type, "current-sensor") == 0) { 256 + } else if (of_node_is_type(child, "current-sensor")) { 256 257 name = "cpu-current"; 257 258 shift = 8; 258 259 isens[core] = index; 259 - } else if (strcmp(type, "temp-sensor") == 0) { 260 + } else if (of_node_is_type(child, "temp-sensor")) { 260 261 name = "cpu-temp"; 261 262 shift = 10; 262 263 } else
+6 -7
drivers/macintosh/windfarm_smu_sensors.c
··· 197 197 static struct smu_ad_sensor *smu_ads_create(struct device_node *node) 198 198 { 199 199 struct smu_ad_sensor *ads; 200 - const char *c, *l; 200 + const char *l; 201 201 const u32 *v; 202 202 203 203 ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL); 204 204 if (ads == NULL) 205 205 return NULL; 206 - c = of_get_property(node, "device_type", NULL); 207 206 l = of_get_property(node, "location", NULL); 208 - if (c == NULL || l == NULL) 207 + if (l == NULL) 209 208 goto fail; 210 209 211 210 /* We currently pick the sensors based on the OF name and location ··· 214 215 * the names and locations consistents so I'll stick with the names 215 216 * and locations for now. 216 217 */ 217 - if (!strcmp(c, "temp-sensor") && 218 + if (of_node_is_type(node, "temp-sensor") && 218 219 !strcmp(l, "CPU T-Diode")) { 219 220 ads->sens.ops = &smu_cputemp_ops; 220 221 ads->sens.name = "cpu-temp"; ··· 223 224 SMU_SDB_CPUDIODE_ID); 224 225 goto fail; 225 226 } 226 - } else if (!strcmp(c, "current-sensor") && 227 + } else if (of_node_is_type(node, "current-sensor") && 227 228 !strcmp(l, "CPU Current")) { 228 229 ads->sens.ops = &smu_cpuamp_ops; 229 230 ads->sens.name = "cpu-current"; ··· 232 233 SMU_SDB_CPUVCP_ID); 233 234 goto fail; 234 235 } 235 - } else if (!strcmp(c, "voltage-sensor") && 236 + } else if (of_node_is_type(node, "voltage-sensor") && 236 237 !strcmp(l, "CPU Voltage")) { 237 238 ads->sens.ops = &smu_cpuvolt_ops; 238 239 ads->sens.name = "cpu-voltage"; ··· 241 242 SMU_SDB_CPUVCP_ID); 242 243 goto fail; 243 244 } 244 - } else if (!strcmp(c, "power-sensor") && 245 + } else if (of_node_is_type(node, "power-sensor") && 245 246 !strcmp(l, "Slots Power")) { 246 247 ads->sens.ops = &smu_slotspow_ops; 247 248 ads->sens.name = "slots-power";