Skip to content

Commit c7213fc

Browse files
author
Jesper Nilsson
committed
CRIS: Fix RS485 delay handling.
Very recently, the RS485 interface has been fixed by adding two further fields (see commit 1b63318). Check the value of the flag SER_RS485_RTS_BEFORE_SEND before delaying. Signed-off-by: Claudio Scordino <[email protected]> Signed-off-by: Jesper Nilsson <[email protected]>
1 parent 94479c0 commit c7213fc

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

drivers/serial/crisv10.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,11 +1411,12 @@ e100_enable_rs485(struct tty_struct *tty, struct serial_rs485 *r)
14111411
CONFIG_ETRAX_RS485_LTC1387_RXEN_PORT_G_BIT, 1);
14121412
#endif
14131413

1414-
info->rs485.flags = r->flags;
1415-
if (r->delay_rts_before_send >= 1000)
1414+
info->rs485 = *r;
1415+
1416+
/* Maximum delay before RTS equal to 1000 */
1417+
if (info->rs485.delay_rts_before_send >= 1000)
14161418
info->rs485.delay_rts_before_send = 1000;
1417-
else
1418-
info->rs485.delay_rts_before_send = r->delay_rts_before_send;
1419+
14191420
/* printk("rts: on send = %i, after = %i, enabled = %i",
14201421
info->rs485.rts_on_send,
14211422
info->rs485.rts_after_sent,
@@ -3234,9 +3235,9 @@ rs_write(struct tty_struct *tty,
32343235
e100_disable_rx(info);
32353236
e100_enable_rx_irq(info);
32363237
#endif
3237-
3238-
if (info->rs485.delay_rts_before_send > 0)
3239-
msleep(info->rs485.delay_rts_before_send);
3238+
if ((info->rs485.flags & SER_RS485_RTS_BEFORE_SEND) &&
3239+
(info->rs485.delay_rts_before_send > 0))
3240+
msleep(info->rs485.delay_rts_before_send);
32403241
}
32413242
#endif /* CONFIG_ETRAX_RS485 */
32423243

@@ -3694,6 +3695,11 @@ rs_ioctl(struct tty_struct *tty, struct file * file,
36943695

36953696
rs485data.delay_rts_before_send = rs485ctrl.delay_rts_before_send;
36963697
rs485data.flags = 0;
3698+
if (rs485data.delay_rts_before_send != 0)
3699+
rs485data.flags |= SER_RS485_RTS_BEFORE_SEND;
3700+
else
3701+
rs485data.flags &= ~(SER_RS485_RTS_BEFORE_SEND);
3702+
36973703
if (rs485ctrl.enabled)
36983704
rs485data.flags |= SER_RS485_ENABLED;
36993705
else
@@ -4527,6 +4533,7 @@ static int __init rs_init(void)
45274533
/* Set sane defaults */
45284534
info->rs485.flags &= ~(SER_RS485_RTS_ON_SEND);
45294535
info->rs485.flags |= SER_RS485_RTS_AFTER_SEND;
4536+
info->rs485.flags &= ~(SER_RS485_RTS_BEFORE_SEND);
45304537
info->rs485.delay_rts_before_send = 0;
45314538
info->rs485.flags &= ~(SER_RS485_ENABLED);
45324539
#endif

0 commit comments

Comments
 (0)