Re: [PATCH V2] serial: Add ioctl to enable auto rs485 mode with some Exar UARTs

Christopher Gibson
2009-01-07T13:48:24Z

On Fri, 2009-01-02 at 17:26 +0100, Matthias Fuchs wrote:
> Some Exar UARTs support a auto rs485 mode. In this mode
> the UART's RTS# pin is activated during transmitting and
> can be used to enable a rs485 line driver.
--->8----

> +
> + case TIOCGRS485:
> + {
> + struct serial_rs485 rs485ctrl;

Should the TIOCGRS485 call set delay_rts_before_send structure element
to 0 to demonstrate that there is no delay ability? memset(&rs485ctrl,
0, sizeof(struct serial_rs485)); missing?

> +
> + if (port->type != PORT_16850)
> + return -ENOTTY;
> +
> + spin_lock_irqsave(&up->port.lock, flags);
> + serial_outp(up, UART_LCR, 0xbf);
> + if (serial_inp(up, UART_FCTR) & UART_FCTR_RS485)
> + rs485ctrl.flags = SER_RS485_ENABLED;
> + else
> + rs485ctrl.flags = 0;
> + serial_outp(up, UART_LCR, 0);
> + spin_unlock_irqrestore(&up->port.lock, flags);
> +
> + if (copy_to_user((struct serial_rs485 *)arg,
> + &rs485ctrl,
> + sizeof(rs485ctrl)))
> + return -EFAULT;
> + return 0;
> + }

--
Christopher Gibson <chris@toftronix.com.au>