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

sparc: 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.

Replace the open coded iterating over child nodes with
for_each_child_of_node() while we're here.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Rob Herring and committed by
David S. Miller
88ca0557 29c990df

+26 -45
+2 -2
arch/sparc/kernel/of_device_32.c
··· 22 22 23 23 static int of_bus_pci_match(struct device_node *np) 24 24 { 25 - if (!strcmp(np->type, "pci") || !strcmp(np->type, "pciex")) { 25 + if (of_node_is_type(np, "pci") || of_node_is_type(np, "pciex")) { 26 26 /* Do not do PCI specific frobbing if the 27 27 * PCI bridge lacks a ranges property. We 28 28 * want to pass it through up to the next ··· 107 107 108 108 static int of_bus_ambapp_match(struct device_node *np) 109 109 { 110 - return !strcmp(np->type, "ambapp"); 110 + return of_node_is_type(np, "ambapp"); 111 111 } 112 112 113 113 static void of_bus_ambapp_count_cells(struct device_node *child,
+2 -7
arch/sparc/kernel/pci.c
··· 267 267 struct dev_archdata *sd; 268 268 struct platform_device *op; 269 269 struct pci_dev *dev; 270 - const char *type; 271 270 u32 class; 272 271 273 272 dev = pci_alloc_dev(bus); ··· 285 286 if (of_node_name_eq(node, "ebus")) 286 287 of_propagate_archdata(op); 287 288 288 - type = of_get_property(node, "device_type", NULL); 289 - if (type == NULL) 290 - type = ""; 291 - 292 289 if (ofpci_verbose) 293 290 pci_info(bus," create device, devfn: %x, type: %s\n", 294 - devfn, type); 291 + devfn, of_node_get_device_type(node)); 295 292 296 293 dev->sysdata = node; 297 294 dev->dev.parent = bus->bridge; ··· 335 340 /* a PCI-PCI bridge */ 336 341 dev->hdr_type = PCI_HEADER_TYPE_BRIDGE; 337 342 dev->rom_base_reg = PCI_ROM_ADDRESS1; 338 - } else if (!strcmp(type, "cardbus")) { 343 + } else if (of_node_is_type(node, "cardbus")) { 339 344 dev->hdr_type = PCI_HEADER_TYPE_CARDBUS; 340 345 } else { 341 346 dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
+1 -1
arch/sparc/kernel/process_32.c
··· 110 110 void machine_power_off(void) 111 111 { 112 112 if (auxio_power_register && 113 - (strcmp(of_console_device->type, "serial") || scons_pwroff)) { 113 + (!of_node_is_type(of_console_device, "serial") || scons_pwroff)) { 114 114 u8 power_register = sbus_readb(auxio_power_register); 115 115 power_register |= AUXIO_POWER_OFF; 116 116 sbus_writeb(power_register, auxio_power_register);
+7 -13
arch/sparc/kernel/prom_32.c
··· 182 182 struct device_node *parent = dp->parent; 183 183 184 184 if (parent != NULL) { 185 - if (!strcmp(parent->type, "pci") || 186 - !strcmp(parent->type, "pciex")) 185 + if (of_node_is_type(parent, "pci") || 186 + of_node_is_type(parent, "pciex")) 187 187 return pci_path_component(dp, tmp_buf); 188 - if (!strcmp(parent->type, "sbus")) 188 + if (of_node_is_type(parent, "sbus")) 189 189 return sbus_path_component(dp, tmp_buf); 190 - if (!strcmp(parent->type, "ebus")) 190 + if (of_node_is_type(parent, "ebus")) 191 191 return ebus_path_component(dp, tmp_buf); 192 - if (!strcmp(parent->type, "ambapp")) 192 + if (of_node_is_type(parent, "ambapp")) 193 193 return ambapp_path_component(dp, tmp_buf); 194 194 195 195 /* "isa" is handled with platform naming */ ··· 284 284 prom_halt(); 285 285 } 286 286 dp = of_find_node_by_phandle(node); 287 - type = of_get_property(dp, "device_type", NULL); 288 287 289 - if (!type) { 290 - prom_printf("Console stdout lacks " 291 - "device_type property.\n"); 292 - prom_halt(); 293 - } 294 - 295 - if (strcmp(type, "display") && strcmp(type, "serial")) { 288 + if (!of_node_is_type(dp, "display") && 289 + !of_node_is_type(dp, "serial")) { 296 290 prom_printf("Console device_type is neither display " 297 291 "nor serial.\n"); 298 292 prom_halt();
+9 -15
arch/sparc/kernel/prom_64.c
··· 318 318 struct device_node *parent = dp->parent; 319 319 320 320 if (parent != NULL) { 321 - if (!strcmp(parent->type, "pci") || 322 - !strcmp(parent->type, "pciex")) { 321 + if (of_node_is_type(parent, "pci") || 322 + of_node_is_type(parent, "pciex")) { 323 323 pci_path_component(dp, tmp_buf); 324 324 return; 325 325 } 326 - if (!strcmp(parent->type, "sbus")) { 326 + if (of_node_is_type(parent, "sbus")) { 327 327 sbus_path_component(dp, tmp_buf); 328 328 return; 329 329 } 330 - if (!strcmp(parent->type, "upa")) { 330 + if (of_node_is_type(parent, "upa")) { 331 331 upa_path_component(dp, tmp_buf); 332 332 return; 333 333 } 334 - if (!strcmp(parent->type, "ebus")) { 334 + if (of_node_is_type(parent, "ebus")) { 335 335 ebus_path_component(dp, tmp_buf); 336 336 return; 337 337 } ··· 340 340 usb_path_component(dp, tmp_buf); 341 341 return; 342 342 } 343 - if (!strcmp(parent->type, "i2c")) { 343 + if (of_node_is_type(parent, "i2c")) { 344 344 i2c_path_component(dp, tmp_buf); 345 345 return; 346 346 } 347 - if (!strcmp(parent->type, "firewire")) { 347 + if (of_node_is_type(parent, "firewire")) { 348 348 ieee1394_path_component(dp, tmp_buf); 349 349 return; 350 350 } 351 - if (!strcmp(parent->type, "virtual-devices")) { 351 + if (of_node_is_type(parent, "virtual-devices")) { 352 352 vdev_path_component(dp, tmp_buf); 353 353 return; 354 354 } ··· 605 605 { 606 606 char *msg = "OF stdout device is: %s\n"; 607 607 struct device_node *dp; 608 - const char *type; 609 608 phandle node; 610 609 611 610 of_console_path = prom_early_alloc(256); ··· 627 628 } 628 629 629 630 dp = of_find_node_by_phandle(node); 630 - type = of_get_property(dp, "device_type", NULL); 631 - if (!type) { 632 - prom_printf("Console stdout lacks device_type property.\n"); 633 - prom_halt(); 634 - } 635 631 636 - if (strcmp(type, "display") && strcmp(type, "serial")) { 632 + if (!of_node_is_type(dp, "display") && !of_node_is_type(dp, "serial")) { 637 633 prom_printf("Console device_type is neither display " 638 634 "nor serial.\n"); 639 635 prom_halt();
+1 -1
arch/sparc/kernel/prom_irqtrans.c
··· 193 193 * the DMA synchronization handling 194 194 */ 195 195 while (parent) { 196 - if (!strcmp(parent->type, "pci")) 196 + if (of_node_is_type(parent, "pci")) 197 197 break; 198 198 parent = parent->parent; 199 199 }
+2 -1
arch/sparc/kernel/reboot.c
··· 7 7 #include <linux/reboot.h> 8 8 #include <linux/export.h> 9 9 #include <linux/pm.h> 10 + #include <linux/of.h> 10 11 11 12 #include <asm/oplib.h> 12 13 #include <asm/prom.h> ··· 26 25 27 26 void machine_power_off(void) 28 27 { 29 - if (strcmp(of_console_device->type, "serial") || scons_pwroff) 28 + if (!of_node_is_type(of_console_device, "serial") || scons_pwroff) 30 29 prom_halt_power_off(); 31 30 32 31 prom_halt();
+2 -5
arch/sparc/kernel/vio.c
··· 366 366 if (parent == NULL) { 367 367 dp = cdev_node; 368 368 } else if (to_vio_dev(parent) == root_vdev) { 369 - dp = of_get_next_child(cdev_node, NULL); 370 - while (dp) { 371 - if (!strcmp(dp->type, type)) 369 + for_each_child_of_node(cdev_node, dp) { 370 + if (of_node_is_type(dp, type)) 372 371 break; 373 - 374 - dp = of_get_next_child(cdev_node, dp); 375 372 } 376 373 } else { 377 374 dp = to_vio_dev(parent)->dp;