All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Crescent CY Hsieh <crescentcy.hsieh@moxa.com>,
	Jiri Slaby <jirislaby@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-serial <linux-serial@vger.kernel.org>
Subject: Re: [PATCH v3] tty: serial: Add RS422 flag to struct serial_rs485
Date: Thu, 9 Nov 2023 15:16:33 +0100	[thread overview]
Message-ID: <2023110919-properly-each-55f5@gregkh> (raw)
In-Reply-To: <c247dda3-40d0-f1ab-fe59-2649f779f3@linux.intel.com>

On Thu, Nov 09, 2023 at 03:35:50PM +0200, Ilpo Järvinen wrote:
> On Wed, 8 Nov 2023, Crescent CY Hsieh wrote:
> 
> > Add "SER_RS485_MODE_RS422" flag to struct serial_rs485, so that serial
> > port can switch interface into RS422 if supported by using ioctl command
> > "TIOCSRS485".
> > 
> > By treating RS422 as a mode of RS485, which means while enabling RS422
> > there are two flags need to be set (SER_RS485_ENABLED and
> > SER_RS485_MODE_RS422), it would make things much easier. For example
> > some places that checks for "SER_RS485_ENABLED" won't need to be rewritten.
> > 
> > There are only two things need to be noticed:
> > 
> > - While enabling RS422, other RS485 flags should not be set.
> > - RS422 doesn't need to deal with termination, so while disabling RS485
> >   or enabling RS422, uart_set_rs485_termination() shall return.
> > 
> > Signed-off-by: Crescent CY Hsieh <crescentcy.hsieh@moxa.com>
> > 
> > ---
> > Changes from v2 to v3:
> > - Remove "SER_RS422_ENABLED" flag from legacy flags.
> > - Revise "SER_RS422_ENABLED" into "SER_RS485_MODE_RS422".
> > - Remove the code which checks the conflicts between SER_RS485_ENABLED
> >   and SER_RS422_ENABLED.
> > - Add return check in uart_set_rs485_termination().
> > 
> > Changes from v1 to v2:
> > - Revise the logic that checks whether RS422/RS485 are enabled
> >   simultaneously.
> > 
> > v2: https://lore.kernel.org/all/20231101064404.45711-1-crescentcy.hsieh@moxa.com/
> > v1: https://lore.kernel.org/all/20231030053632.5109-1-crescentcy.hsieh@moxa.com/
> > 
> > ---
> 
> > --- a/include/uapi/linux/serial.h
> > +++ b/include/uapi/linux/serial.h
> > @@ -137,17 +137,19 @@ struct serial_icounter_struct {
> >   * * %SER_RS485_ADDRB		- Enable RS485 addressing mode.
> >   * * %SER_RS485_ADDR_RECV - Receive address filter (enables @addr_recv). Requires %SER_RS485_ADDRB.
> >   * * %SER_RS485_ADDR_DEST - Destination address (enables @addr_dest). Requires %SER_RS485_ADDRB.
> > + * * %SER_RS485_MODE_RS422	- Enable RS422. Requires %SER_RS485_ENABLED.
> >   */
> >  struct serial_rs485 {
> >  	__u32	flags;
> > -#define SER_RS485_ENABLED		(1 << 0)
> > -#define SER_RS485_RTS_ON_SEND		(1 << 1)
> > -#define SER_RS485_RTS_AFTER_SEND	(1 << 2)
> > -#define SER_RS485_RX_DURING_TX		(1 << 4)
> > -#define SER_RS485_TERMINATE_BUS		(1 << 5)
> > -#define SER_RS485_ADDRB			(1 << 6)
> > -#define SER_RS485_ADDR_RECV		(1 << 7)
> > -#define SER_RS485_ADDR_DEST		(1 << 8)
> > +#define SER_RS485_ENABLED		BIT(0)
> > +#define SER_RS485_RTS_ON_SEND		BIT(1)
> > +#define SER_RS485_RTS_AFTER_SEND	BIT(2)
> > +#define SER_RS485_RX_DURING_TX		BIT(3)
> > +#define SER_RS485_TERMINATE_BUS		BIT(4)
> > +#define SER_RS485_ADDRB			BIT(5)
> > +#define SER_RS485_ADDR_RECV		BIT(6)
> > +#define SER_RS485_ADDR_DEST		BIT(7)
> > +#define SER_RS485_MODE_RS422		BIT(8)
> 
> Is BIT() allowed in uapi headers these days?

No, but there is something else that is, can't find it at the moment...

      reply	other threads:[~2023-11-09 14:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08  6:07 [PATCH v3] tty: serial: Add RS422 flag to struct serial_rs485 Crescent CY Hsieh
2023-11-09 13:35 ` Ilpo Järvinen
2023-11-09 14:16   ` Greg Kroah-Hartman [this message]

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=2023110919-properly-each-55f5@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=crescentcy.hsieh@moxa.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.