public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-serial <linux-serial@vger.kernel.org>,
	"Greg KH" <gregkh@linuxfoundation.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Arnd Bergmann" <arnd@arndb.de>,
	linux-doc@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	linux-arch@vger.kernel.org, "Lukas Wunner" <lukas@wunner.de>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Lino Sanfilippo" <LinoSanfilippo@gmx.de>,
	linux-api@vger.kernel.org
Subject: Re: [PATCH v8 5/6] serial: Support for RS-485 multipoint addresses
Date: Mon, 20 Jun 2022 14:26:17 +0300 (EEST)	[thread overview]
Message-ID: <a9b8ec3a-4f40-c0f5-e1a-bb577d5937ff@linux.intel.com> (raw)
In-Reply-To: <YrBS03ymAWVajy7e@smile.fi.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2279 bytes --]

On Mon, 20 Jun 2022, Andy Shevchenko wrote:

> On Mon, Jun 20, 2022 at 09:40:29AM +0300, Ilpo Järvinen wrote:
> > Add support for RS-485 multipoint addressing using 9th bit [*]. The
> > addressing mode is configured through ->rs485_config().
> > 
> > ADDRB in termios indicates 9th bit addressing mode is enabled. In this
> > mode, 9th bit is used to indicate an address (byte) within the
> > communication line. ADDRB can only be enabled/disabled through
> > ->rs485_config() that is also responsible for setting the destination and
> > receiver (filter) addresses.
> 
> > The changes to serial_rs485 struct were test built with a few traps to
> > detect mislayouting on archs lkp/0day builts for (all went fine):
> >   BUILD_BUG_ON(((&rs485.delay_rts_after_send) + 1) != &rs485.padding[0]);
> >   BUILD_BUG_ON(&rs485.padding[1] != &rs485.padding1[0]);
> >   BUILD_BUG_ON(sizeof(rs485) != ((u8 *)(&rs485.padding[4]) -
> > 				 ((u8 *)&rs485.flags) + sizeof(__u32)));
> 
> You may add static_asserts() for the above mentioned cases.

I'll add into the end of serial_core.h but in a cleaned up form
using offsetof(). Those above look rather ugly :-).

> > [*] Technically, RS485 is just an electronic spec and does not itself
> > specify the 9th bit addressing mode but 9th bit seems at least
> > "semi-standard" way to do addressing with RS485.
> 
> ...
> 
> > -	__u32	padding[5];		/* Memory is cheap, new structs
> > -					   are a royal PITA .. */
> > +	union {
> > +		/* v1 */
> > +		__u32	padding[5];		/* Memory is cheap, new structs are a pain */
> > +
> > +		/* v2 (adds addressing mode fields) */
> 
> How user space will inform a kernel that it's trying v2?
>
> Usually when we have a union, it should be accompanied with the enum or version
> or something to tell which part of it is in use. I can imagine that in this case
> it's implied by the IOCTL parameters that never should be used on a garbage.
> 
> Either add a commit message / UAPI comment or add a version field or ...?
> 
> > +		struct {
> > +			__u8	addr_recv;
> > +			__u8	addr_dest;

The flags in .flags indicate when these two new fields are in use. Do you 
think I need something beyond that. Maybe I should remove those comments 
so they don't mislead you to think it's a "version" for real?


-- 
 i.

  reply	other threads:[~2022-06-20 11:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220620064030.7938-1-ilpo.jarvinen@linux.intel.com>
2022-06-20  6:40 ` [PATCH v8 1/6] serial: 8250: make saved LSR larger Ilpo Järvinen
2022-06-20  6:40 ` [PATCH v8 2/6] serial: 8250: create lsr_save_mask Ilpo Järvinen
2022-06-20  6:40 ` [PATCH v8 3/6] serial: 8250_lpss: Use 32-bit reads Ilpo Järvinen
2022-06-20  6:40 ` [PATCH v8 4/6] serial: take termios_rwsem for ->rs485_config() & pass termios as param Ilpo Järvinen
2022-06-20  6:40 ` [PATCH v8 5/6] serial: Support for RS-485 multipoint addresses Ilpo Järvinen
2022-06-20 10:58   ` Andy Shevchenko
2022-06-20 11:26     ` Ilpo Järvinen [this message]
2022-06-20 11:48       ` Andy Shevchenko
2022-06-20  6:40 ` [PATCH v8 6/6] serial: 8250_dwlib: Support for 9th bit multipoint addressing Ilpo Järvinen

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=a9b8ec3a-4f40-c0f5-e1a-bb577d5937ff@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=LinoSanfilippo@gmx.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=corbet@lwn.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=u.kleine-koenig@pengutronix.de \
    /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