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

tty: Use of_node_name_{eq,prefix} for node name comparisons

Convert string compares of DT node names to use of_node_name_eq helper
instead. This removes direct access to the node name pointer.

For hvc, the code can also be simplified by using of_stdout pointer
instead of searching again for the stdout node.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-serial@vger.kernel.org
Cc: sparclinux@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Rob Herring and committed by
Greg Kroah-Hartman
778ec49c d7240214

+10 -19
+1 -1
drivers/tty/hvc/hvc_opal.c
··· 353 353 if (!opal) 354 354 return; 355 355 for_each_child_of_node(opal, np) { 356 - if (!strcmp(np->name, "serial")) { 356 + if (of_node_name_eq(np, "serial")) { 357 357 stdout_node = np; 358 358 break; 359 359 }
+1 -10
drivers/tty/hvc/hvc_vio.c
··· 371 371 void __init hvc_vio_init_early(void) 372 372 { 373 373 const __be32 *termno; 374 - const char *name; 375 374 const struct hv_ops *ops; 376 375 377 376 /* find the boot console from /chosen/stdout */ 378 - if (!of_stdout) 379 - return; 380 - name = of_get_property(of_stdout, "name", NULL); 381 - if (!name) { 382 - printk(KERN_WARNING "stdout node missing 'name' property!\n"); 383 - return; 384 - } 385 - 386 377 /* Check if it's a virtual terminal */ 387 - if (strncmp(name, "vty", 3) != 0) 378 + if (!of_node_name_prefix(of_stdout, "vty")) 388 379 return; 389 380 termno = of_get_property(of_stdout, "reg", NULL); 390 381 if (termno == NULL)
+2 -2
drivers/tty/serial/pmac_zilog.c
··· 1648 1648 */ 1649 1649 node_a = node_b = NULL; 1650 1650 for (np = NULL; (np = of_get_next_child(node_p, np)) != NULL;) { 1651 - if (strncmp(np->name, "ch-a", 4) == 0) 1651 + if (of_node_name_prefix(np, "ch-a")) 1652 1652 node_a = of_node_get(np); 1653 - else if (strncmp(np->name, "ch-b", 4) == 0) 1653 + else if (of_node_name_prefix(np, "ch-b")) 1654 1654 node_b = of_node_get(np); 1655 1655 } 1656 1656 if (!node_a && !node_b) {
+4 -4
drivers/tty/serial/suncore.c
··· 89 89 int baud, bits, stop, cflag; 90 90 char parity; 91 91 92 - if (!strcmp(uart_dp->name, "rsc") || 93 - !strcmp(uart_dp->name, "rsc-console") || 94 - !strcmp(uart_dp->name, "rsc-control")) { 92 + if (of_node_name_eq(uart_dp, "rsc") || 93 + of_node_name_eq(uart_dp, "rsc-console") || 94 + of_node_name_eq(uart_dp, "rsc-control")) { 95 95 mode = of_get_property(uart_dp, 96 96 "ssp-console-modes", NULL); 97 97 if (!mode) 98 98 mode = "115200,8,n,1,-"; 99 - } else if (!strcmp(uart_dp->name, "lom-console")) { 99 + } else if (of_node_name_eq(uart_dp, "lom-console")) { 100 100 mode = "9600,8,n,1,-"; 101 101 } else { 102 102 struct device_node *dp;
+2 -2
drivers/tty/serial/sunsu.c
··· 1482 1482 up->port.ops = &sunsu_pops; 1483 1483 1484 1484 ignore_line = false; 1485 - if (!strcmp(dp->name, "rsc-console") || 1486 - !strcmp(dp->name, "lom-console")) 1485 + if (of_node_name_eq(dp, "rsc-console") || 1486 + of_node_name_eq(dp, "lom-console")) 1487 1487 ignore_line = true; 1488 1488 1489 1489 sunserial_console_match(SUNSU_CONSOLE(), dp,