Drop the driver version of the line-coding request and use the protocol
definition directly as was originally intended instead.

This specifically avoids having the two versions of what is supposed to
be the same struct ever getting out of sync.

Note that this has in fact already happened once when the protocol
definition had its implicit padding removed while the driver struct
wasn't updated. The fact that we used the size of the then larger driver
struct when memcpying its content to the stack didn't exactly make
things better. A later addition of a flow-control field incidentally
made the structures match again.

Signed-off-by: Johan Hovold <jo...@kernel.org>
---
 drivers/staging/greybus/uart.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 55c51143bb09..84de56800a21 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -40,14 +40,6 @@
 #define GB_UART_FIRMWARE_CREDITS       4096
 #define GB_UART_CREDIT_WAIT_TIMEOUT_MSEC       10000
 
-struct gb_tty_line_coding {
-       __le32  rate;
-       __u8    format;
-       __u8    parity;
-       __u8    data_bits;
-       __u8    flow_control;
-};
-
 struct gb_tty {
        struct gbphy_device *gbphy_dev;
        struct tty_port port;
@@ -66,7 +58,7 @@ struct gb_tty {
        struct mutex mutex;
        u8 ctrlin;      /* input control lines */
        u8 ctrlout;     /* output control lines */
-       struct gb_tty_line_coding line_coding;
+       struct gb_uart_set_line_coding_request line_coding;
        struct work_struct tx_work;
        struct kfifo write_fifo;
        bool close_pending;
@@ -288,12 +280,9 @@ static void  gb_uart_tx_write_work(struct work_struct 
*work)
 
 static int send_line_coding(struct gb_tty *tty)
 {
-       struct gb_uart_set_line_coding_request request;
-
-       memcpy(&request, &tty->line_coding,
-              sizeof(tty->line_coding));
        return gb_operation_sync(tty->connection, GB_UART_TYPE_SET_LINE_CODING,
-                                &request, sizeof(request), NULL, 0);
+                                &tty->line_coding, sizeof(tty->line_coding),
+                                NULL, 0);
 }
 
 static int send_control(struct gb_tty *gb_tty, u8 control)
@@ -493,9 +482,9 @@ static int gb_tty_break_ctl(struct tty_struct *tty, int 
state)
 static void gb_tty_set_termios(struct tty_struct *tty,
                               struct ktermios *termios_old)
 {
+       struct gb_uart_set_line_coding_request newline;
        struct gb_tty *gb_tty = tty->driver_data;
        struct ktermios *termios = &tty->termios;
-       struct gb_tty_line_coding newline;
        u8 newctrl = gb_tty->ctrlout;
 
        newline.rate = cpu_to_le32(tty_get_baud_rate(tty));
-- 
2.26.2

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to