diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2006-02-13 23:09:10 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-03-20 04:12:42 -0500 |
commit | 1ddb7c98d44b898cfe0443c1e242cebfb0479d46 (patch) | |
tree | 995bd63451677335e59d981c57e7369238afecb4 /drivers/serial | |
parent | 10951ee61056a9f91c00c16746f2042672d7af7c (diff) |
[SPARC64]: Prevent registering wrong serial console.
If the console is not for a particular Sun serial
controller, set the drv->cons to NULL.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/sunsab.c | 17 | ||||
-rw-r--r-- | drivers/serial/sunsu.c | 22 | ||||
-rw-r--r-- | drivers/serial/sunzilog.c | 34 |
3 files changed, 47 insertions, 26 deletions
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c index 85664228a0b6..02f62da546b5 100644 --- a/drivers/serial/sunsab.c +++ b/drivers/serial/sunsab.c | |||
@@ -955,14 +955,13 @@ static struct console sunsab_console = { | |||
955 | .index = -1, | 955 | .index = -1, |
956 | .data = &sunsab_reg, | 956 | .data = &sunsab_reg, |
957 | }; | 957 | }; |
958 | #define SUNSAB_CONSOLE (&sunsab_console) | ||
959 | 958 | ||
960 | static void __init sunsab_console_init(void) | 959 | static inline struct console *SUNSAB_CONSOLE(void) |
961 | { | 960 | { |
962 | int i; | 961 | int i; |
963 | 962 | ||
964 | if (con_is_present()) | 963 | if (con_is_present()) |
965 | return; | 964 | return NULL; |
966 | 965 | ||
967 | for (i = 0; i < num_channels; i++) { | 966 | for (i = 0; i < num_channels; i++) { |
968 | int this_minor = sunsab_reg.minor + i; | 967 | int this_minor = sunsab_reg.minor + i; |
@@ -971,13 +970,14 @@ static void __init sunsab_console_init(void) | |||
971 | break; | 970 | break; |
972 | } | 971 | } |
973 | if (i == num_channels) | 972 | if (i == num_channels) |
974 | return; | 973 | return NULL; |
975 | 974 | ||
976 | sunsab_console.index = i; | 975 | sunsab_console.index = i; |
977 | register_console(&sunsab_console); | 976 | |
977 | return &sunsab_console; | ||
978 | } | 978 | } |
979 | #else | 979 | #else |
980 | #define SUNSAB_CONSOLE (NULL) | 980 | #define SUNSAB_CONSOLE() (NULL) |
981 | #define sunsab_console_init() do { } while (0) | 981 | #define sunsab_console_init() do { } while (0) |
982 | #endif | 982 | #endif |
983 | 983 | ||
@@ -1124,7 +1124,6 @@ static int __init sunsab_init(void) | |||
1124 | 1124 | ||
1125 | sunsab_reg.minor = sunserial_current_minor; | 1125 | sunsab_reg.minor = sunserial_current_minor; |
1126 | sunsab_reg.nr = num_channels; | 1126 | sunsab_reg.nr = num_channels; |
1127 | sunsab_reg.cons = SUNSAB_CONSOLE; | ||
1128 | 1127 | ||
1129 | ret = uart_register_driver(&sunsab_reg); | 1128 | ret = uart_register_driver(&sunsab_reg); |
1130 | if (ret < 0) { | 1129 | if (ret < 0) { |
@@ -1143,10 +1142,10 @@ static int __init sunsab_init(void) | |||
1143 | return ret; | 1142 | return ret; |
1144 | } | 1143 | } |
1145 | 1144 | ||
1145 | sunsab_reg.cons = SUNSAB_CONSOLE(); | ||
1146 | |||
1146 | sunserial_current_minor += num_channels; | 1147 | sunserial_current_minor += num_channels; |
1147 | 1148 | ||
1148 | sunsab_console_init(); | ||
1149 | |||
1150 | for (i = 0; i < num_channels; i++) { | 1149 | for (i = 0; i < num_channels; i++) { |
1151 | struct uart_sunsab_port *up = &sunsab_ports[i]; | 1150 | struct uart_sunsab_port *up = &sunsab_ports[i]; |
1152 | 1151 | ||
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index 4e453fa966ae..3313cb2a355a 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c | |||
@@ -1464,18 +1464,17 @@ static struct console sunsu_cons = { | |||
1464 | .index = -1, | 1464 | .index = -1, |
1465 | .data = &sunsu_reg, | 1465 | .data = &sunsu_reg, |
1466 | }; | 1466 | }; |
1467 | #define SUNSU_CONSOLE (&sunsu_cons) | ||
1468 | 1467 | ||
1469 | /* | 1468 | /* |
1470 | * Register console. | 1469 | * Register console. |
1471 | */ | 1470 | */ |
1472 | 1471 | ||
1473 | static int __init sunsu_serial_console_init(void) | 1472 | static inline struct console *SUNSU_CONSOLE(void) |
1474 | { | 1473 | { |
1475 | int i; | 1474 | int i; |
1476 | 1475 | ||
1477 | if (con_is_present()) | 1476 | if (con_is_present()) |
1478 | return 0; | 1477 | return NULL; |
1479 | 1478 | ||
1480 | for (i = 0; i < UART_NR; i++) { | 1479 | for (i = 0; i < UART_NR; i++) { |
1481 | int this_minor = sunsu_reg.minor + i; | 1480 | int this_minor = sunsu_reg.minor + i; |
@@ -1484,16 +1483,16 @@ static int __init sunsu_serial_console_init(void) | |||
1484 | break; | 1483 | break; |
1485 | } | 1484 | } |
1486 | if (i == UART_NR) | 1485 | if (i == UART_NR) |
1487 | return 0; | 1486 | return NULL; |
1488 | if (sunsu_ports[i].port_node == 0) | 1487 | if (sunsu_ports[i].port_node == 0) |
1489 | return 0; | 1488 | return NULL; |
1490 | 1489 | ||
1491 | sunsu_cons.index = i; | 1490 | sunsu_cons.index = i; |
1492 | register_console(&sunsu_cons); | 1491 | |
1493 | return 0; | 1492 | return &sunsu_cons; |
1494 | } | 1493 | } |
1495 | #else | 1494 | #else |
1496 | #define SUNSU_CONSOLE (NULL) | 1495 | #define SUNSU_CONSOLE() (NULL) |
1497 | #define sunsu_serial_console_init() do { } while (0) | 1496 | #define sunsu_serial_console_init() do { } while (0) |
1498 | #endif | 1497 | #endif |
1499 | 1498 | ||
@@ -1523,16 +1522,17 @@ static int __init sunsu_serial_init(void) | |||
1523 | } | 1522 | } |
1524 | 1523 | ||
1525 | sunsu_reg.minor = sunserial_current_minor; | 1524 | sunsu_reg.minor = sunserial_current_minor; |
1526 | sunserial_current_minor += instance; | ||
1527 | 1525 | ||
1528 | sunsu_reg.nr = instance; | 1526 | sunsu_reg.nr = instance; |
1529 | sunsu_reg.cons = SUNSU_CONSOLE; | ||
1530 | 1527 | ||
1531 | ret = uart_register_driver(&sunsu_reg); | 1528 | ret = uart_register_driver(&sunsu_reg); |
1532 | if (ret < 0) | 1529 | if (ret < 0) |
1533 | return ret; | 1530 | return ret; |
1534 | 1531 | ||
1535 | sunsu_serial_console_init(); | 1532 | sunserial_current_minor += instance; |
1533 | |||
1534 | sunsu_reg.cons = SUNSU_CONSOLE(); | ||
1535 | |||
1536 | for (i = 0; i < UART_NR; i++) { | 1536 | for (i = 0; i < UART_NR; i++) { |
1537 | struct uart_sunsu_port *up = &sunsu_ports[i]; | 1537 | struct uart_sunsu_port *up = &sunsu_ports[i]; |
1538 | 1538 | ||
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c index 5cc4d4c2935c..5aa74e7a954e 100644 --- a/drivers/serial/sunzilog.c +++ b/drivers/serial/sunzilog.c | |||
@@ -1390,7 +1390,6 @@ static struct console sunzilog_console = { | |||
1390 | .index = -1, | 1390 | .index = -1, |
1391 | .data = &sunzilog_reg, | 1391 | .data = &sunzilog_reg, |
1392 | }; | 1392 | }; |
1393 | #define SUNZILOG_CONSOLE (&sunzilog_console) | ||
1394 | 1393 | ||
1395 | static int __init sunzilog_console_init(void) | 1394 | static int __init sunzilog_console_init(void) |
1396 | { | 1395 | { |
@@ -1413,8 +1412,31 @@ static int __init sunzilog_console_init(void) | |||
1413 | register_console(&sunzilog_console); | 1412 | register_console(&sunzilog_console); |
1414 | return 0; | 1413 | return 0; |
1415 | } | 1414 | } |
1415 | |||
1416 | static inline struct console *SUNZILOG_CONSOLE(void) | ||
1417 | { | ||
1418 | int i; | ||
1419 | |||
1420 | if (con_is_present()) | ||
1421 | return NULL; | ||
1422 | |||
1423 | for (i = 0; i < NUM_CHANNELS; i++) { | ||
1424 | int this_minor = sunzilog_reg.minor + i; | ||
1425 | |||
1426 | if ((this_minor - 64) == (serial_console - 1)) | ||
1427 | break; | ||
1428 | } | ||
1429 | if (i == NUM_CHANNELS) | ||
1430 | return NULL; | ||
1431 | |||
1432 | sunzilog_console.index = i; | ||
1433 | sunzilog_port_table[i].flags |= SUNZILOG_FLAG_IS_CONS; | ||
1434 | |||
1435 | return &sunzilog_console; | ||
1436 | } | ||
1437 | |||
1416 | #else | 1438 | #else |
1417 | #define SUNZILOG_CONSOLE (NULL) | 1439 | #define SUNZILOG_CONSOLE() (NULL) |
1418 | #define sunzilog_console_init() do { } while (0) | 1440 | #define sunzilog_console_init() do { } while (0) |
1419 | #endif | 1441 | #endif |
1420 | 1442 | ||
@@ -1666,14 +1688,14 @@ static int __init sunzilog_ports_init(void) | |||
1666 | } | 1688 | } |
1667 | 1689 | ||
1668 | sunzilog_reg.nr = uart_count; | 1690 | sunzilog_reg.nr = uart_count; |
1669 | sunzilog_reg.cons = SUNZILOG_CONSOLE; | ||
1670 | |||
1671 | sunzilog_reg.minor = sunserial_current_minor; | 1691 | sunzilog_reg.minor = sunserial_current_minor; |
1672 | sunserial_current_minor += uart_count; | ||
1673 | 1692 | ||
1674 | ret = uart_register_driver(&sunzilog_reg); | 1693 | ret = uart_register_driver(&sunzilog_reg); |
1675 | if (ret == 0) { | 1694 | if (ret == 0) { |
1676 | sunzilog_console_init(); | 1695 | sunzilog_reg.cons = SUNZILOG_CONSOLE(); |
1696 | |||
1697 | sunserial_current_minor += uart_count; | ||
1698 | |||
1677 | for (i = 0; i < NUM_CHANNELS; i++) { | 1699 | for (i = 0; i < NUM_CHANNELS; i++) { |
1678 | struct uart_sunzilog_port *up = &sunzilog_port_table[i]; | 1700 | struct uart_sunzilog_port *up = &sunzilog_port_table[i]; |
1679 | 1701 | ||