[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZmQphhYQi7tSjBIM@surfacebook.localdomain>
Date: Sat, 8 Jun 2024 12:51:02 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Crescent Hsieh <crescentcy.hsieh@...a.com>
Cc: Jiri Slaby <jirislaby@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org
Subject: Re: [PATCH 5/6] tty: serial: 8250: Add support for Moxa PCIe boards
to switch interface
Fri, Jun 07, 2024 at 07:43:35PM +0800, Crescent Hsieh kirjoitti:
> This patch adds support for Moxa PCIe serial boards to switch the serial
> interface by using ioctl() command "TIOCSRS485" with the flags of struct
> "serial_rs485":
>
> - RS232 = (no flags are set)
> - RS422 = SER_RS485_ENABLED | SER_RS485_MODE_RS422
> - RS485_2W (half-duplex) = SER_RS485_ENABLED
> - RS485_4W (full-duplex) = SER_RS485_ENABLED | SER_RS485_RX_DURING_TX
>
...
> + if (rs485->flags & SER_RS485_ENABLED) {
> + if (rs485->flags & SER_RS485_MODE_RS422)
> + mode = MOXA_RS422;
> + else if (rs485->flags & SER_RS485_RX_DURING_TX)
> + mode = MOXA_RS485_4W;
> + else
> + mode = MOXA_RS485_2W;
> + } else {
> + if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232))
} else if ... {
> + return -ENODEV;
> + }
...
> + if (pci_moxa_is_pcie(dev->device) || pci_moxa_is_mini_pcie(dev->device)) {
> + if (pci_moxa_supported_rs(dev) & MOXA_SUPP_RS485) {
Two if:s can be replaced with if (foo && bar), but it's up to you.
> + port->port.rs485_config = pci_moxa_rs485_config;
> + port->port.rs485_supported = pci_moxa_rs485_supported;
> +
> + if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232))
> + port->port.rs485.flags = SER_RS485_ENABLED | SER_RS485_MODE_RS422;
> + }
> + }
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists