diff options
author | Grant Likely <grant.likely@linaro.org> | 2014-03-28 11:12:18 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@linaro.org> | 2014-06-26 12:12:23 -0400 |
commit | a752ee56ad84bf9a35b8323af1ad22b03c1df2c4 (patch) | |
tree | ca01e3094f6fcd5b101dcc7edf716a25df3029d5 /drivers/tty/hvc | |
parent | 003882180340a2808151d320dedd853f4cff5e4b (diff) |
tty: Update hypervisor tty drivers to use core stdout parsing code.
The evh_bytechan, hvc_opal and hvc_vio drivers all open code the parsing
of the stdout node in the device tree. This patch simplifies the driver
by removing the duplicated functionality.
Signed-off-by: Grant Likely <grant.likely@linaro.org>
Diffstat (limited to 'drivers/tty/hvc')
-rw-r--r-- | drivers/tty/hvc/hvc_opal.c | 15 | ||||
-rw-r--r-- | drivers/tty/hvc/hvc_vio.c | 29 |
2 files changed, 13 insertions, 31 deletions
diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c index a585079b4b38..a2cc5f834c63 100644 --- a/drivers/tty/hvc/hvc_opal.c +++ b/drivers/tty/hvc/hvc_opal.c | |||
@@ -342,22 +342,13 @@ static void udbg_init_opal_common(void) | |||
342 | 342 | ||
343 | void __init hvc_opal_init_early(void) | 343 | void __init hvc_opal_init_early(void) |
344 | { | 344 | { |
345 | struct device_node *stdout_node = NULL; | 345 | struct device_node *stdout_node = of_node_get(of_stdout); |
346 | const __be32 *termno; | 346 | const __be32 *termno; |
347 | const char *name = NULL; | ||
348 | const struct hv_ops *ops; | 347 | const struct hv_ops *ops; |
349 | u32 index; | 348 | u32 index; |
350 | 349 | ||
351 | /* find the boot console from /chosen/stdout */ | 350 | /* If the console wasn't in /chosen, try /ibm,opal */ |
352 | if (of_chosen) | 351 | if (!stdout_node) { |
353 | name = of_get_property(of_chosen, "linux,stdout-path", NULL); | ||
354 | if (name) { | ||
355 | stdout_node = of_find_node_by_path(name); | ||
356 | if (!stdout_node) { | ||
357 | pr_err("hvc_opal: Failed to locate default console!\n"); | ||
358 | return; | ||
359 | } | ||
360 | } else { | ||
361 | struct device_node *opal, *np; | 352 | struct device_node *opal, *np; |
362 | 353 | ||
363 | /* Current OPAL takeover doesn't provide the stdout | 354 | /* Current OPAL takeover doesn't provide the stdout |
diff --git a/drivers/tty/hvc/hvc_vio.c b/drivers/tty/hvc/hvc_vio.c index b594abfbf21e..5618b5fc7500 100644 --- a/drivers/tty/hvc/hvc_vio.c +++ b/drivers/tty/hvc/hvc_vio.c | |||
@@ -404,42 +404,35 @@ module_exit(hvc_vio_exit); | |||
404 | 404 | ||
405 | void __init hvc_vio_init_early(void) | 405 | void __init hvc_vio_init_early(void) |
406 | { | 406 | { |
407 | struct device_node *stdout_node; | ||
408 | const __be32 *termno; | 407 | const __be32 *termno; |
409 | const char *name; | 408 | const char *name; |
410 | const struct hv_ops *ops; | 409 | const struct hv_ops *ops; |
411 | 410 | ||
412 | /* find the boot console from /chosen/stdout */ | 411 | /* find the boot console from /chosen/stdout */ |
413 | if (!of_chosen) | 412 | if (!of_stdout) |
414 | return; | 413 | return; |
415 | name = of_get_property(of_chosen, "linux,stdout-path", NULL); | 414 | name = of_get_property(of_stdout, "name", NULL); |
416 | if (name == NULL) | ||
417 | return; | ||
418 | stdout_node = of_find_node_by_path(name); | ||
419 | if (!stdout_node) | ||
420 | return; | ||
421 | name = of_get_property(stdout_node, "name", NULL); | ||
422 | if (!name) { | 415 | if (!name) { |
423 | printk(KERN_WARNING "stdout node missing 'name' property!\n"); | 416 | printk(KERN_WARNING "stdout node missing 'name' property!\n"); |
424 | goto out; | 417 | return; |
425 | } | 418 | } |
426 | 419 | ||
427 | /* Check if it's a virtual terminal */ | 420 | /* Check if it's a virtual terminal */ |
428 | if (strncmp(name, "vty", 3) != 0) | 421 | if (strncmp(name, "vty", 3) != 0) |
429 | goto out; | 422 | return; |
430 | termno = of_get_property(stdout_node, "reg", NULL); | 423 | termno = of_get_property(of_stdout, "reg", NULL); |
431 | if (termno == NULL) | 424 | if (termno == NULL) |
432 | goto out; | 425 | return; |
433 | hvterm_priv0.termno = of_read_number(termno, 1); | 426 | hvterm_priv0.termno = of_read_number(termno, 1); |
434 | spin_lock_init(&hvterm_priv0.buf_lock); | 427 | spin_lock_init(&hvterm_priv0.buf_lock); |
435 | hvterm_privs[0] = &hvterm_priv0; | 428 | hvterm_privs[0] = &hvterm_priv0; |
436 | 429 | ||
437 | /* Check the protocol */ | 430 | /* Check the protocol */ |
438 | if (of_device_is_compatible(stdout_node, "hvterm1")) { | 431 | if (of_device_is_compatible(of_stdout, "hvterm1")) { |
439 | hvterm_priv0.proto = HV_PROTOCOL_RAW; | 432 | hvterm_priv0.proto = HV_PROTOCOL_RAW; |
440 | ops = &hvterm_raw_ops; | 433 | ops = &hvterm_raw_ops; |
441 | } | 434 | } |
442 | else if (of_device_is_compatible(stdout_node, "hvterm-protocol")) { | 435 | else if (of_device_is_compatible(of_stdout, "hvterm-protocol")) { |
443 | hvterm_priv0.proto = HV_PROTOCOL_HVSI; | 436 | hvterm_priv0.proto = HV_PROTOCOL_HVSI; |
444 | ops = &hvterm_hvsi_ops; | 437 | ops = &hvterm_hvsi_ops; |
445 | hvsilib_init(&hvterm_priv0.hvsi, hvc_get_chars, hvc_put_chars, | 438 | hvsilib_init(&hvterm_priv0.hvsi, hvc_get_chars, hvc_put_chars, |
@@ -447,7 +440,7 @@ void __init hvc_vio_init_early(void) | |||
447 | /* HVSI, perform the handshake now */ | 440 | /* HVSI, perform the handshake now */ |
448 | hvsilib_establish(&hvterm_priv0.hvsi); | 441 | hvsilib_establish(&hvterm_priv0.hvsi); |
449 | } else | 442 | } else |
450 | goto out; | 443 | return; |
451 | udbg_putc = udbg_hvc_putc; | 444 | udbg_putc = udbg_hvc_putc; |
452 | udbg_getc = udbg_hvc_getc; | 445 | udbg_getc = udbg_hvc_getc; |
453 | udbg_getc_poll = udbg_hvc_getc_poll; | 446 | udbg_getc_poll = udbg_hvc_getc_poll; |
@@ -456,14 +449,12 @@ void __init hvc_vio_init_early(void) | |||
456 | * backend for HVSI, only do udbg | 449 | * backend for HVSI, only do udbg |
457 | */ | 450 | */ |
458 | if (hvterm_priv0.proto == HV_PROTOCOL_HVSI) | 451 | if (hvterm_priv0.proto == HV_PROTOCOL_HVSI) |
459 | goto out; | 452 | return; |
460 | #endif | 453 | #endif |
461 | /* Check whether the user has requested a different console. */ | 454 | /* Check whether the user has requested a different console. */ |
462 | if (!strstr(cmd_line, "console=")) | 455 | if (!strstr(cmd_line, "console=")) |
463 | add_preferred_console("hvc", 0, NULL); | 456 | add_preferred_console("hvc", 0, NULL); |
464 | hvc_instantiate(0, 0, ops); | 457 | hvc_instantiate(0, 0, ops); |
465 | out: | ||
466 | of_node_put(stdout_node); | ||
467 | } | 458 | } |
468 | 459 | ||
469 | /* call this from early_init() for a working debug console on | 460 | /* call this from early_init() for a working debug console on |