summaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>2014-08-05 11:45:59 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-08 15:26:26 -0700
commite676253b19b2d269cccf67fdb1592120a0cd0676 (patch)
tree34618c8fbe8069d007fb2a38ff8b2679dc6a10ea /drivers/tty/serial
parent27d5775e75ec70c104479bd7fcdceb0d6e0203a8 (diff)
downloadlinux-e676253b19b2d269cccf67fdb1592120a0cd0676.tar.gz
linux-e676253b19b2d269cccf67fdb1592120a0cd0676.tar.bz2
linux-e676253b19b2d269cccf67fdb1592120a0cd0676.zip
serial/8250: Add support for RS485 IOCTLs
This patch allow the users of the 8250 infrastructure to define a handler for RS485 configration. If no handler is defined the 8250 driver will work as usual. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Acked-by: Alan Cox <alan@linux.intel.com> -- v2:Change suggested by Alan "One Thousand Gnomes": - Move rs485 structure further down on the uart_8250_port structure drivers/tty/serial/8250/8250_core.c | 39 +++++++++++++++++++++++++++++++++++++ include/linux/serial_8250.h | 3 +++ 2 files changed, 42 insertions(+) Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r--drivers/tty/serial/8250/8250_core.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 1d42dba6121d..b28ed1beb50f 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -2843,6 +2843,42 @@ serial8250_verify_port(struct uart_port *port, struct serial_struct *ser)
return 0;
}
+static int serial8250_ioctl(struct uart_port *port, unsigned int cmd,
+ unsigned long arg)
+{
+ struct uart_8250_port *up =
+ container_of(port, struct uart_8250_port, port);
+ int ret;
+ struct serial_rs485 rs485_config;
+
+ if (!up->rs485_config)
+ return -ENOIOCTLCMD;
+
+ switch (cmd) {
+ case TIOCSRS485:
+ if (copy_from_user(&rs485_config, (void __user *)arg,
+ sizeof(rs485_config)))
+ return -EFAULT;
+
+ ret = up->rs485_config(up, &rs485_config);
+ if (ret)
+ return ret;
+
+ memcpy(&up->rs485, &rs485_config, sizeof(rs485_config));
+
+ return 0;
+ case TIOCGRS485:
+ if (copy_to_user((void __user *)arg, &up->rs485,
+ sizeof(up->rs485)))
+ return -EFAULT;
+ return 0;
+ default:
+ break;
+ }
+
+ return -ENOIOCTLCMD;
+}
+
static const char *
serial8250_type(struct uart_port *port)
{
@@ -2872,6 +2908,7 @@ static struct uart_ops serial8250_pops = {
.request_port = serial8250_request_port,
.config_port = serial8250_config_port,
.verify_port = serial8250_verify_port,
+ .ioctl = serial8250_ioctl,
#ifdef CONFIG_CONSOLE_POLL
.poll_get_char = serial8250_get_poll_char,
.poll_put_char = serial8250_put_poll_char,
@@ -3388,6 +3425,8 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
uart->port.fifosize = up->port.fifosize;
uart->tx_loadsz = up->tx_loadsz;
uart->capabilities = up->capabilities;
+ uart->rs485_config = up->rs485_config;
+ uart->rs485 = up->rs485;
/* Take tx_loadsz from fifosize if it wasn't set separately */
if (uart->port.fifosize && !uart->tx_loadsz)