Skip to content

Commit e4788ed

Browse files
keesgregkh
authored andcommitted
USB: EHCI: Add alias for Broadcom INSNREG
Refactor struct ehci_regs to avoid accessing beyond the end of port_status. This change results in no difference in the final object code. Avoids several warnings when building with -Warray-bounds: drivers/usb/host/ehci-brcm.c: In function 'ehci_brcm_reset': drivers/usb/host/ehci-brcm.c:113:32: warning: array subscript 16 is above array bounds of 'u32[15]' {aka 'unsigned int[15]'} [-Warray-bounds] 113 | ehci_writel(ehci, 0x00800040, &ehci->regs->port_status[0x10]); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from drivers/usb/host/ehci.h:274, from drivers/usb/host/ehci-brcm.c:15: ./include/linux/usb/ehci_def.h:132:7: note: while referencing 'port_status' 132 | u32 port_status[HCS_N_PORTS_MAX]; | ^~~~~~~~~~~ Note that the documentation around this proprietary register was confusing. If "USB_EHCI_INSNREG00" is at port_status[0x0f], its offset would be 0x80 (not 0x90). The comments have been adjusted to fix this apparent typo. Fixes: 9df2315 ("usb: ehci: Add new EHCI driver for Broadcom STB SoC's") Cc: Al Cooper <[email protected]> Cc: Alan Stern <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: [email protected] Cc: [email protected] Suggested-by: Arnd Bergmann <[email protected]> Acked-by: Alan Stern <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 72dd184 commit e4788ed

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

drivers/usb/host/ehci-brcm.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ static int ehci_brcm_reset(struct usb_hcd *hcd)
108108
/*
109109
* SWLINUX-1705: Avoid OUT packet underflows during high memory
110110
* bus usage
111-
* port_status[0x0f] = Broadcom-proprietary USB_EHCI_INSNREG00 @ 0x90
112111
*/
113-
ehci_writel(ehci, 0x00800040, &ehci->regs->port_status[0x10]);
114-
ehci_writel(ehci, 0x00000001, &ehci->regs->port_status[0x12]);
112+
ehci_writel(ehci, 0x00800040, &ehci->regs->brcm_insnreg[1]);
113+
ehci_writel(ehci, 0x00000001, &ehci->regs->brcm_insnreg[3]);
115114

116115
return ehci_setup(hcd);
117116
}
@@ -223,11 +222,9 @@ static int __maybe_unused ehci_brcm_resume(struct device *dev)
223222
/*
224223
* SWLINUX-1705: Avoid OUT packet underflows during high memory
225224
* bus usage
226-
* port_status[0x0f] = Broadcom-proprietary USB_EHCI_INSNREG00
227-
* @ 0x90
228225
*/
229-
ehci_writel(ehci, 0x00800040, &ehci->regs->port_status[0x10]);
230-
ehci_writel(ehci, 0x00000001, &ehci->regs->port_status[0x12]);
226+
ehci_writel(ehci, 0x00800040, &ehci->regs->brcm_insnreg[1]);
227+
ehci_writel(ehci, 0x00000001, &ehci->regs->brcm_insnreg[3]);
231228

232229
ehci_resume(hcd, false);
233230

include/linux/usb/ehci_def.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,23 @@ struct ehci_regs {
176176
#define USBMODE_CM_HC (3<<0) /* host controller mode */
177177
#define USBMODE_CM_IDLE (0<<0) /* idle state */
178178
};
179-
u32 reserved4;
180179

181180
/* Moorestown has some non-standard registers, partially due to the fact that
182181
* its EHCI controller has both TT and LPM support. HOSTPCx are extensions to
183182
* PORTSCx
184183
*/
185-
/* HOSTPC: offset 0x84 */
186-
u32 hostpc[HCS_N_PORTS_MAX];
184+
union {
185+
struct {
186+
u32 reserved4;
187+
/* HOSTPC: offset 0x84 */
188+
u32 hostpc[HCS_N_PORTS_MAX];
187189
#define HOSTPC_PHCD (1<<22) /* Phy clock disable */
188190
#define HOSTPC_PSPD (3<<25) /* Port speed detection */
191+
};
192+
193+
/* Broadcom-proprietary USB_EHCI_INSNREG00 @ 0x80 */
194+
u32 brcm_insnreg[4];
195+
};
189196

190197
u32 reserved5[2];
191198

0 commit comments

Comments
 (0)