From 8fe0cd660f0caeab3780a2ce10657975aee696b1 Mon Sep 17 00:00:00 2001 From: Erwan Le Ray Date: Sun, 12 Apr 2020 19:06:20 +0200 Subject: [PATCH] include: uapi: serial: add support of rts delays in nanoseconds Add support of rs485 delay in nanoseconds. With fast data rates (1Mbaut or more), 1ms become quite long. Users need to be able to set shorter delays than 1 ms in order not to slow down the channel unnecessarily. This enables faster communication channels without changing the baudrate. Signed-off-by: Erwan Le Ray Signed-off-by: Borut Seljak Signed-off-by: Valentin Caron Change-Id: I72cdf03197b7c3abfc1f2fa0c03e91b665461be1 --- drivers/tty/serial/serial_core.c | 4 ++-- include/uapi/linux/serial.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 23a7ab0de444..acbb47c640bf 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3464,10 +3464,10 @@ EXPORT_SYMBOL_GPL(uart_get_rs485_mode); /* Compile-time assertions for serial_rs485 layout */ static_assert(offsetof(struct serial_rs485, padding) == - (offsetof(struct serial_rs485, delay_rts_after_send) + sizeof(__u32))); + (offsetof(struct serial_rs485, delay_rts_after_send_ns) + sizeof(__u32))); static_assert(offsetof(struct serial_rs485, padding1) == offsetof(struct serial_rs485, padding[1])); -static_assert((offsetof(struct serial_rs485, padding[4]) + sizeof(__u32)) == +static_assert((offsetof(struct serial_rs485, padding[2]) + sizeof(__u32)) == sizeof(struct serial_rs485)); MODULE_DESCRIPTION("Serial driver core"); diff --git a/include/uapi/linux/serial.h b/include/uapi/linux/serial.h index cea06924b295..faa8828efd6a 100644 --- a/include/uapi/linux/serial.h +++ b/include/uapi/linux/serial.h @@ -134,16 +134,18 @@ struct serial_rs485 { __u32 delay_rts_before_send; /* Delay before send (milliseconds) */ __u32 delay_rts_after_send; /* Delay after send (milliseconds) */ + __u32 delay_rts_before_send_ns; /* Delay before send (nanoseconds) */ + __u32 delay_rts_after_send_ns; /* Delay after send (nanoseconds) */ /* The fields below are defined by flags */ union { - __u32 padding[5]; /* Memory is cheap, new structs are a pain */ + __u32 padding[3]; /* Memory is cheap, new structs are a pain */ struct { __u8 addr_recv; __u8 addr_dest; __u8 padding0[2]; - __u32 padding1[4]; + __u32 padding1[2]; }; }; };