Thread (5 messages) flat view 5 messages, 2 authors, 2022-06-20

Re: [PATCH v8 5/6] serial: Support for RS-485 multipoint addresses

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2022-06-20 11:48:46
Also in: linux-arch, linux-doc, linux-serial, lkml

On Mon, Jun 20, 2022 at 02:26:17PM +0300, Ilpo Järvinen wrote:
On Mon, 20 Jun 2022, Andy Shevchenko wrote:
quoted
On Mon, Jun 20, 2022 at 09:40:29AM +0300, Ilpo Järvinen wrote:
...
quoted
quoted
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 :-).
Agree!

...
quoted
quoted
-	__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 ...?
quoted
+		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?
Yes, either drop this versioning, or replace with a comment on top of a union
like:

	/* The fields are defined by flags */

-- 
With Best Regards,
Andy Shevchenko

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help