On Fri, May 1, 2020 at 4:42 AM Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: > On Thu, 30 Apr 2020, Arnd Bergmann wrote: > > No, they don't. > > /* PORTSC: offset 0x44 */ > > - u32 port_status[0]; /* up to N_PORTS */ > > + union { > > + u32 port_status[9]; /* up to N_PORTS */ > > This array can have up to 15 elements, meaning that it can extend out > to offset 0x80. Ok, thanks for the clarification! > > /* EHCI 1.1 addendum */ > > #define PORTSC_SUSPEND_STS_ACK 0 > > #define PORTSC_SUSPEND_STS_NYET 1 > > @@ -165,7 +166,8 @@ struct ehci_regs { > > #define PORT_CONNECT (1<<0) /* device connected */ > > #define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) > > > > - u32 reserved3[9]; > > + u32 reserved3[9]; > > + }; > > > > /* USBMODE: offset 0x68 */ > > u32 usbmode; /* USB Device mode */ > > As you see, this next field actually lies inside the preceding array. > It's not a real conflict; any hardware which supports the usbmode field > uses only the first element of the port_status array. > > I don't know how you want to handle this. Doing > > #define usbmode port_status[9] > > doesn't seem like a very good approach, but I can't think of anything > better at the moment. Maybe just set the array size to 9, as you did, > but with a comment explaining what's really going on. The easiest change would be to use an anonymous struct like this /* PORTSC: offset 0x44 */ union { u32 port_status[15]; /* up to N_PORTS */ /* EHCI 1.1 addendum */ #define PORTSC_SUSPEND_STS_ACK 0 ... #define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) struct { u32 reserved3[9]; /* USBMODE: offset 0x68 */ u32 usbmode; /* USB Device mode */ #define USBMODE_SDIS (1<<3) /* Stream disable */ #define USBMODE_BE (1<<2) /* BE/LE endianness select */ #define USBMODE_CM_HC (3<<0) /* host controller mode */ #define USBMODE_CM_IDLE (0<<0) /* idle state */ u32 reserved4[5]; }; }; u32 reserved5; It doesn't really improve readability, but it should correctly reflect the layout as you described it. Arnd