diff options
author | Rob Herring <robh@kernel.org> | 2018-12-05 14:50:28 -0500 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2018-12-22 05:29:56 -0500 |
commit | f1e0addca8bd7386f8cabbc64c9988fff91c131f (patch) | |
tree | 86accf6f05d6b6e05457436f08783e8f460f494a /drivers/macintosh | |
parent | c1fa31b0fc90a80d64a334e5d35dca211f9187f6 (diff) |
macintosh: Use of_node_name_{eq, prefix} for node name comparisons
Convert string compares of DT node names to use of_node_name_{eq,prefix}
helpers instead. This removes direct access to the node name pointer.
This changes a single case insensitive node name comparison to case
sensitive for "ata4". This is the only instance of a case insensitive
comparison for all the open coded node name comparisons on powerpc.
Searching the commit history, there doesn't appear to be any reason for
it to be case insensitive.
A couple of open coded iterating thru the child node names are converted
to use for_each_child_of_node() instead.
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/macintosh')
-rw-r--r-- | drivers/macintosh/ans-lcd.c | 2 | ||||
-rw-r--r-- | drivers/macintosh/macio_asic.c | 33 | ||||
-rw-r--r-- | drivers/macintosh/rack-meter.c | 13 | ||||
-rw-r--r-- | drivers/macintosh/via-pmu.c | 4 | ||||
-rw-r--r-- | drivers/macintosh/windfarm_lm87_sensor.c | 4 | ||||
-rw-r--r-- | drivers/macintosh/windfarm_smu_controls.c | 4 | ||||
-rw-r--r-- | drivers/macintosh/windfarm_smu_sensors.c | 2 |
7 files changed, 30 insertions, 32 deletions
diff --git a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c index c8e078b911c7..ef0c2366cf59 100644 --- a/drivers/macintosh/ans-lcd.c +++ b/drivers/macintosh/ans-lcd.c | |||
@@ -160,7 +160,7 @@ anslcd_init(void) | |||
160 | struct device_node* node; | 160 | struct device_node* node; |
161 | 161 | ||
162 | node = of_find_node_by_name(NULL, "lcd"); | 162 | node = of_find_node_by_name(NULL, "lcd"); |
163 | if (!node || !node->parent || strcmp(node->parent->name, "gc")) { | 163 | if (!node || !of_node_name_eq(node->parent, "gc")) { |
164 | of_node_put(node); | 164 | of_node_put(node); |
165 | return -ENODEV; | 165 | return -ENODEV; |
166 | } | 166 | } |
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c index bc8418801224..3543a82081de 100644 --- a/drivers/macintosh/macio_asic.c +++ b/drivers/macintosh/macio_asic.c | |||
@@ -190,11 +190,11 @@ static int macio_resource_quirks(struct device_node *np, struct resource *res, | |||
190 | return 0; | 190 | return 0; |
191 | 191 | ||
192 | /* Grand Central has too large resource 0 on some machines */ | 192 | /* Grand Central has too large resource 0 on some machines */ |
193 | if (index == 0 && !strcmp(np->name, "gc")) | 193 | if (index == 0 && of_node_name_eq(np, "gc")) |
194 | res->end = res->start + 0x1ffff; | 194 | res->end = res->start + 0x1ffff; |
195 | 195 | ||
196 | /* Airport has bogus resource 2 */ | 196 | /* Airport has bogus resource 2 */ |
197 | if (index >= 2 && !strcmp(np->name, "radio")) | 197 | if (index >= 2 && of_node_name_eq(np, "radio")) |
198 | return 1; | 198 | return 1; |
199 | 199 | ||
200 | #ifndef CONFIG_PPC64 | 200 | #ifndef CONFIG_PPC64 |
@@ -207,20 +207,20 @@ static int macio_resource_quirks(struct device_node *np, struct resource *res, | |||
207 | * level of hierarchy, but I don't really feel the need | 207 | * level of hierarchy, but I don't really feel the need |
208 | * for it | 208 | * for it |
209 | */ | 209 | */ |
210 | if (!strcmp(np->name, "escc")) | 210 | if (of_node_name_eq(np, "escc")) |
211 | return 1; | 211 | return 1; |
212 | 212 | ||
213 | /* ESCC has bogus resources >= 3 */ | 213 | /* ESCC has bogus resources >= 3 */ |
214 | if (index >= 3 && !(strcmp(np->name, "ch-a") && | 214 | if (index >= 3 && (of_node_name_eq(np, "ch-a") || |
215 | strcmp(np->name, "ch-b"))) | 215 | of_node_name_eq(np, "ch-b"))) |
216 | return 1; | 216 | return 1; |
217 | 217 | ||
218 | /* Media bay has too many resources, keep only first one */ | 218 | /* Media bay has too many resources, keep only first one */ |
219 | if (index > 0 && !strcmp(np->name, "media-bay")) | 219 | if (index > 0 && of_node_name_eq(np, "media-bay")) |
220 | return 1; | 220 | return 1; |
221 | 221 | ||
222 | /* Some older IDE resources have bogus sizes */ | 222 | /* Some older IDE resources have bogus sizes */ |
223 | if (!strcmp(np->name, "IDE") || !strcmp(np->name, "ATA") || | 223 | if (of_node_name_eq(np, "IDE") || of_node_name_eq(np, "ATA") || |
224 | of_node_is_type(np, "ide") || of_node_is_type(np, "ata")) { | 224 | of_node_is_type(np, "ide") || of_node_is_type(np, "ata")) { |
225 | if (index == 0 && (res->end - res->start) > 0xfff) | 225 | if (index == 0 && (res->end - res->start) > 0xfff) |
226 | res->end = res->start + 0xfff; | 226 | res->end = res->start + 0xfff; |
@@ -260,7 +260,7 @@ static void macio_add_missing_resources(struct macio_dev *dev) | |||
260 | irq_base = 64; | 260 | irq_base = 64; |
261 | 261 | ||
262 | /* Fix SCC */ | 262 | /* Fix SCC */ |
263 | if (strcmp(np->name, "ch-a") == 0) { | 263 | if (of_node_name_eq(np, "ch-a")) { |
264 | macio_create_fixup_irq(dev, 0, 15 + irq_base); | 264 | macio_create_fixup_irq(dev, 0, 15 + irq_base); |
265 | macio_create_fixup_irq(dev, 1, 4 + irq_base); | 265 | macio_create_fixup_irq(dev, 1, 4 + irq_base); |
266 | macio_create_fixup_irq(dev, 2, 5 + irq_base); | 266 | macio_create_fixup_irq(dev, 2, 5 + irq_base); |
@@ -268,18 +268,18 @@ static void macio_add_missing_resources(struct macio_dev *dev) | |||
268 | } | 268 | } |
269 | 269 | ||
270 | /* Fix media-bay */ | 270 | /* Fix media-bay */ |
271 | if (strcmp(np->name, "media-bay") == 0) { | 271 | if (of_node_name_eq(np, "media-bay")) { |
272 | macio_create_fixup_irq(dev, 0, 29 + irq_base); | 272 | macio_create_fixup_irq(dev, 0, 29 + irq_base); |
273 | printk(KERN_INFO "macio: fixed media-bay irq on gatwick\n"); | 273 | printk(KERN_INFO "macio: fixed media-bay irq on gatwick\n"); |
274 | } | 274 | } |
275 | 275 | ||
276 | /* Fix left media bay childs */ | 276 | /* Fix left media bay childs */ |
277 | if (dev->media_bay != NULL && strcmp(np->name, "floppy") == 0) { | 277 | if (dev->media_bay != NULL && of_node_name_eq(np, "floppy")) { |
278 | macio_create_fixup_irq(dev, 0, 19 + irq_base); | 278 | macio_create_fixup_irq(dev, 0, 19 + irq_base); |
279 | macio_create_fixup_irq(dev, 1, 1 + irq_base); | 279 | macio_create_fixup_irq(dev, 1, 1 + irq_base); |
280 | printk(KERN_INFO "macio: fixed left floppy irqs\n"); | 280 | printk(KERN_INFO "macio: fixed left floppy irqs\n"); |
281 | } | 281 | } |
282 | if (dev->media_bay != NULL && strcasecmp(np->name, "ata4") == 0) { | 282 | if (dev->media_bay != NULL && of_node_name_eq(np, "ata4")) { |
283 | macio_create_fixup_irq(dev, 0, 14 + irq_base); | 283 | macio_create_fixup_irq(dev, 0, 14 + irq_base); |
284 | macio_create_fixup_irq(dev, 0, 3 + irq_base); | 284 | macio_create_fixup_irq(dev, 0, 3 + irq_base); |
285 | printk(KERN_INFO "macio: fixed left ide irqs\n"); | 285 | printk(KERN_INFO "macio: fixed left ide irqs\n"); |
@@ -438,11 +438,8 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip, | |||
438 | 438 | ||
439 | static int macio_skip_device(struct device_node *np) | 439 | static int macio_skip_device(struct device_node *np) |
440 | { | 440 | { |
441 | if (strncmp(np->name, "battery", 7) == 0) | 441 | return of_node_name_prefix(np, "battery") || |
442 | return 1; | 442 | of_node_name_prefix(np, "escc-legacy"); |
443 | if (strncmp(np->name, "escc-legacy", 11) == 0) | ||
444 | return 1; | ||
445 | return 0; | ||
446 | } | 443 | } |
447 | 444 | ||
448 | /** | 445 | /** |
@@ -489,9 +486,9 @@ static void macio_pci_add_devices(struct macio_chip *chip) | |||
489 | root_res); | 486 | root_res); |
490 | if (mdev == NULL) | 487 | if (mdev == NULL) |
491 | of_node_put(np); | 488 | of_node_put(np); |
492 | else if (strncmp(np->name, "media-bay", 9) == 0) | 489 | else if (of_node_name_prefix(np, "media-bay")) |
493 | mbdev = mdev; | 490 | mbdev = mdev; |
494 | else if (strncmp(np->name, "escc", 4) == 0) | 491 | else if (of_node_name_prefix(np, "escc")) |
495 | sdev = mdev; | 492 | sdev = mdev; |
496 | } | 493 | } |
497 | 494 | ||
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c index 1f29d2413c74..3940e2a032f7 100644 --- a/drivers/macintosh/rack-meter.c +++ b/drivers/macintosh/rack-meter.c | |||
@@ -376,18 +376,19 @@ static int rackmeter_probe(struct macio_dev* mdev, | |||
376 | pr_debug("rackmeter_probe()\n"); | 376 | pr_debug("rackmeter_probe()\n"); |
377 | 377 | ||
378 | /* Get i2s-a node */ | 378 | /* Get i2s-a node */ |
379 | while ((i2s = of_get_next_child(mdev->ofdev.dev.of_node, i2s)) != NULL) | 379 | for_each_child_of_node(mdev->ofdev.dev.of_node, i2s) |
380 | if (strcmp(i2s->name, "i2s-a") == 0) | 380 | if (of_node_name_eq(i2s, "i2s-a")) |
381 | break; | 381 | break; |
382 | |||
382 | if (i2s == NULL) { | 383 | if (i2s == NULL) { |
383 | pr_debug(" i2s-a child not found\n"); | 384 | pr_debug(" i2s-a child not found\n"); |
384 | goto bail; | 385 | goto bail; |
385 | } | 386 | } |
386 | /* Get lightshow or virtual sound */ | 387 | /* Get lightshow or virtual sound */ |
387 | while ((np = of_get_next_child(i2s, np)) != NULL) { | 388 | for_each_child_of_node(i2s, np) { |
388 | if (strcmp(np->name, "lightshow") == 0) | 389 | if (of_node_name_eq(np, "lightshow")) |
389 | break; | 390 | break; |
390 | if ((strcmp(np->name, "sound") == 0) && | 391 | if (of_node_name_eq(np, "sound") && |
391 | of_get_property(np, "virtual", NULL) != NULL) | 392 | of_get_property(np, "virtual", NULL) != NULL) |
392 | break; | 393 | break; |
393 | } | 394 | } |
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 60f57e2abf21..ac0cf37d6239 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -318,8 +318,8 @@ int __init find_via_pmu(void) | |||
318 | PMU_INT_ADB | | 318 | PMU_INT_ADB | |
319 | PMU_INT_TICK; | 319 | PMU_INT_TICK; |
320 | 320 | ||
321 | if (vias->parent->name && ((strcmp(vias->parent->name, "ohare") == 0) | 321 | if (of_node_name_eq(vias->parent, "ohare") || |
322 | || of_device_is_compatible(vias->parent, "ohare"))) | 322 | of_device_is_compatible(vias->parent, "ohare")) |
323 | pmu_kind = PMU_OHARE_BASED; | 323 | pmu_kind = PMU_OHARE_BASED; |
324 | else if (of_device_is_compatible(vias->parent, "paddington")) | 324 | else if (of_device_is_compatible(vias->parent, "paddington")) |
325 | pmu_kind = PMU_PADDINGTON_BASED; | 325 | pmu_kind = PMU_PADDINGTON_BASED; |
diff --git a/drivers/macintosh/windfarm_lm87_sensor.c b/drivers/macintosh/windfarm_lm87_sensor.c index 35aa571d498a..09724acd70b6 100644 --- a/drivers/macintosh/windfarm_lm87_sensor.c +++ b/drivers/macintosh/windfarm_lm87_sensor.c | |||
@@ -110,8 +110,8 @@ static int wf_lm87_probe(struct i2c_client *client, | |||
110 | * the Xserve G5 has several lm87's. However, for now we only | 110 | * the Xserve G5 has several lm87's. However, for now we only |
111 | * care about the internal temperature sensor | 111 | * care about the internal temperature sensor |
112 | */ | 112 | */ |
113 | while ((np = of_get_next_child(client->dev.of_node, np)) != NULL) { | 113 | for_each_child_of_node(client->dev.of_node, np) { |
114 | if (strcmp(np->name, "int-temp")) | 114 | if (!of_node_name_eq(np, "int-temp")) |
115 | continue; | 115 | continue; |
116 | loc = of_get_property(np, "location", NULL); | 116 | loc = of_get_property(np, "location", NULL); |
117 | if (!loc) | 117 | if (!loc) |
diff --git a/drivers/macintosh/windfarm_smu_controls.c b/drivers/macintosh/windfarm_smu_controls.c index 86d65462a61c..2cb9652a9998 100644 --- a/drivers/macintosh/windfarm_smu_controls.c +++ b/drivers/macintosh/windfarm_smu_controls.c | |||
@@ -267,7 +267,7 @@ static int __init smu_controls_init(void) | |||
267 | 267 | ||
268 | /* Look for RPM fans */ | 268 | /* Look for RPM fans */ |
269 | for (fans = NULL; (fans = of_get_next_child(smu, fans)) != NULL;) | 269 | for (fans = NULL; (fans = of_get_next_child(smu, fans)) != NULL;) |
270 | if (!strcmp(fans->name, "rpm-fans") || | 270 | if (of_node_name_eq(fans, "rpm-fans") || |
271 | of_device_is_compatible(fans, "smu-rpm-fans")) | 271 | of_device_is_compatible(fans, "smu-rpm-fans")) |
272 | break; | 272 | break; |
273 | for (fan = NULL; | 273 | for (fan = NULL; |
@@ -287,7 +287,7 @@ static int __init smu_controls_init(void) | |||
287 | 287 | ||
288 | /* Look for PWM fans */ | 288 | /* Look for PWM fans */ |
289 | for (fans = NULL; (fans = of_get_next_child(smu, fans)) != NULL;) | 289 | for (fans = NULL; (fans = of_get_next_child(smu, fans)) != NULL;) |
290 | if (!strcmp(fans->name, "pwm-fans")) | 290 | if (of_node_name_eq(fans, "pwm-fans")) |
291 | break; | 291 | break; |
292 | for (fan = NULL; | 292 | for (fan = NULL; |
293 | fans && (fan = of_get_next_child(fans, fan)) != NULL;) { | 293 | fans && (fan = of_get_next_child(fans, fan)) != NULL;) { |
diff --git a/drivers/macintosh/windfarm_smu_sensors.c b/drivers/macintosh/windfarm_smu_sensors.c index 1ba86de93f92..a58f6733381a 100644 --- a/drivers/macintosh/windfarm_smu_sensors.c +++ b/drivers/macintosh/windfarm_smu_sensors.c | |||
@@ -424,7 +424,7 @@ static int __init smu_sensors_init(void) | |||
424 | /* Look for sensors subdir */ | 424 | /* Look for sensors subdir */ |
425 | for (sensors = NULL; | 425 | for (sensors = NULL; |
426 | (sensors = of_get_next_child(smu, sensors)) != NULL;) | 426 | (sensors = of_get_next_child(smu, sensors)) != NULL;) |
427 | if (!strcmp(sensors->name, "sensors")) | 427 | if (of_node_name_eq(sensors, "sensors")) |
428 | break; | 428 | break; |
429 | 429 | ||
430 | of_node_put(smu); | 430 | of_node_put(smu); |