diff options
Diffstat (limited to 'drivers/tty/serial/serial_core.c')
-rw-r--r-- | drivers/tty/serial/serial_core.c | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 3a14cccbd7ff..854995e1cae7 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Driver core for serial ports | 3 | * Driver core for serial ports |
3 | * | 4 | * |
@@ -5,20 +6,6 @@ | |||
5 | * | 6 | * |
6 | * Copyright 1999 ARM Limited | 7 | * Copyright 1999 ARM Limited |
7 | * Copyright (C) 2000-2001 Deep Blue Solutions Ltd. | 8 | * Copyright (C) 2000-2001 Deep Blue Solutions Ltd. |
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | */ | 9 | */ |
23 | #include <linux/module.h> | 10 | #include <linux/module.h> |
24 | #include <linux/tty.h> | 11 | #include <linux/tty.h> |
@@ -1482,10 +1469,10 @@ out: | |||
1482 | static void uart_close(struct tty_struct *tty, struct file *filp) | 1469 | static void uart_close(struct tty_struct *tty, struct file *filp) |
1483 | { | 1470 | { |
1484 | struct uart_state *state = tty->driver_data; | 1471 | struct uart_state *state = tty->driver_data; |
1485 | struct tty_port *port; | ||
1486 | 1472 | ||
1487 | if (!state) { | 1473 | if (!state) { |
1488 | struct uart_driver *drv = tty->driver->driver_state; | 1474 | struct uart_driver *drv = tty->driver->driver_state; |
1475 | struct tty_port *port; | ||
1489 | 1476 | ||
1490 | state = drv->state + tty->index; | 1477 | state = drv->state + tty->index; |
1491 | port = &state->port; | 1478 | port = &state->port; |
@@ -1495,7 +1482,6 @@ static void uart_close(struct tty_struct *tty, struct file *filp) | |||
1495 | return; | 1482 | return; |
1496 | } | 1483 | } |
1497 | 1484 | ||
1498 | port = &state->port; | ||
1499 | pr_debug("uart_close(%d) called\n", tty->index); | 1485 | pr_debug("uart_close(%d) called\n", tty->index); |
1500 | 1486 | ||
1501 | tty_port_close(tty->port, tty, filp); | 1487 | tty_port_close(tty->port, tty, filp); |
@@ -3026,5 +3012,41 @@ EXPORT_SYMBOL(uart_resume_port); | |||
3026 | EXPORT_SYMBOL(uart_add_one_port); | 3012 | EXPORT_SYMBOL(uart_add_one_port); |
3027 | EXPORT_SYMBOL(uart_remove_one_port); | 3013 | EXPORT_SYMBOL(uart_remove_one_port); |
3028 | 3014 | ||
3015 | /** | ||
3016 | * of_get_rs485_mode() - Implement parsing rs485 properties | ||
3017 | * @np: uart node | ||
3018 | * @rs485conf: output parameter | ||
3019 | * | ||
3020 | * This function implements the device tree binding described in | ||
3021 | * Documentation/devicetree/bindings/serial/rs485.txt. | ||
3022 | */ | ||
3023 | void of_get_rs485_mode(struct device_node *np, struct serial_rs485 *rs485conf) | ||
3024 | { | ||
3025 | u32 rs485_delay[2]; | ||
3026 | int ret; | ||
3027 | |||
3028 | ret = of_property_read_u32_array(np, "rs485-rts-delay", rs485_delay, 2); | ||
3029 | if (!ret) { | ||
3030 | rs485conf->delay_rts_before_send = rs485_delay[0]; | ||
3031 | rs485conf->delay_rts_after_send = rs485_delay[1]; | ||
3032 | } else { | ||
3033 | rs485conf->delay_rts_before_send = 0; | ||
3034 | rs485conf->delay_rts_after_send = 0; | ||
3035 | } | ||
3036 | |||
3037 | /* | ||
3038 | * clear full-duplex and enabled flags to get to a defined state with | ||
3039 | * the two following properties. | ||
3040 | */ | ||
3041 | rs485conf->flags &= ~(SER_RS485_RX_DURING_TX | SER_RS485_ENABLED); | ||
3042 | |||
3043 | if (of_property_read_bool(np, "rs485-rx-during-tx")) | ||
3044 | rs485conf->flags |= SER_RS485_RX_DURING_TX; | ||
3045 | |||
3046 | if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time")) | ||
3047 | rs485conf->flags |= SER_RS485_ENABLED; | ||
3048 | } | ||
3049 | EXPORT_SYMBOL_GPL(of_get_rs485_mode); | ||
3050 | |||
3029 | MODULE_DESCRIPTION("Serial driver core"); | 3051 | MODULE_DESCRIPTION("Serial driver core"); |
3030 | MODULE_LICENSE("GPL"); | 3052 | MODULE_LICENSE("GPL"); |