Linux Serial subsystem development
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Crescent Hsieh <crescentcy.hsieh@moxa.com>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH 5/6] tty: serial: 8250: Add support for Moxa PCIe boards to switch interface
Date: Sat, 8 Jun 2024 12:51:02 +0300	[thread overview]
Message-ID: <ZmQphhYQi7tSjBIM@surfacebook.localdomain> (raw)
In-Reply-To: <20240607114336.4496-6-crescentcy.hsieh@moxa.com>

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



  reply	other threads:[~2024-06-08  9:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07 11:43 [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Crescent Hsieh
2024-06-07 11:43 ` [PATCH 1/6] tty: serial: 8250: Fix the amount of ports doesn't match the device Crescent Hsieh
2024-06-08  9:58   ` Andy Shevchenko
2024-06-11  7:39   ` Jiri Slaby
2024-06-07 11:43 ` [PATCH 2/6] tty: serial: 8250: Add 2 ports PCI configuration for 921600 BAR 2 Crescent Hsieh
2024-06-07 11:43 ` [PATCH 3/6] tty: mxser: serial: 8250: Relocate device IDs from mxser to 8250_pci Crescent Hsieh
2024-06-11  7:42   ` Jiri Slaby
2024-06-13 10:03     ` Crescent CY Hsieh
2024-06-07 11:43 ` [PATCH 4/6] tty: serial: 8250: Add check for setting default serial interface Crescent Hsieh
2024-06-08  9:57   ` Andy Shevchenko
2024-06-07 11:43 ` [PATCH 5/6] tty: serial: 8250: Add support for Moxa PCIe boards to switch interface Crescent Hsieh
2024-06-08  9:51   ` Andy Shevchenko [this message]
2024-06-07 11:43 ` [PATCH 6/6] tty: serial: 8250: Add support for MUEX50 UART Crescent Hsieh
2024-06-08  9:52   ` Andy Shevchenko
2024-06-08  9:47 ` [PATCH 0/6] Adjustments and Enhancements for MOXA PCI Serial Boards Andy Shevchenko
2024-06-13 10:15   ` Crescent CY Hsieh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZmQphhYQi7tSjBIM@surfacebook.localdomain \
    --to=andy.shevchenko@gmail.com \
    --cc=crescentcy.hsieh@moxa.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox