Commit dc54ce3e authored by Niklas Schnelle's avatar Niklas Schnelle Committed by Greg Kroah-Hartman

usb: uhci: handle HAS_IOPORT dependencies

In a future patch HAS_IOPORT=n will result in inb()/outb() and friends
not being declared. We thus need to guard sections of code calling them
as alternative access methods with CONFIG_HAS_IOPORT checks. For
uhci-hcd there are a lot of I/O port uses that do have MMIO alternatives
all selected by uhci_has_pci_registers() so this can be handled by
UHCI_IN/OUT macros and making uhci_has_pci_registers() constant 0 if
CONFIG_HAS_IOPORT is unset.
Co-developed-by: default avatarArnd Bergmann <arnd@kernel.org>
Signed-off-by: default avatarArnd Bergmann <arnd@kernel.org>
Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20230522105049.1467313-38-schnelle@linux.ibm.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent be3d5a49
...@@ -841,7 +841,7 @@ static int uhci_count_ports(struct usb_hcd *hcd) ...@@ -841,7 +841,7 @@ static int uhci_count_ports(struct usb_hcd *hcd)
static const char hcd_name[] = "uhci_hcd"; static const char hcd_name[] = "uhci_hcd";
#ifdef CONFIG_USB_PCI #if defined(CONFIG_USB_PCI) && defined(CONFIG_HAS_IOPORT)
#include "uhci-pci.c" #include "uhci-pci.c"
#define PCI_DRIVER uhci_pci_driver #define PCI_DRIVER uhci_pci_driver
#endif #endif
......
...@@ -505,6 +505,14 @@ static inline bool uhci_is_aspeed(const struct uhci_hcd *uhci) ...@@ -505,6 +505,14 @@ static inline bool uhci_is_aspeed(const struct uhci_hcd *uhci)
* we use memory mapped registers. * we use memory mapped registers.
*/ */
#ifdef CONFIG_HAS_IOPORT
#define UHCI_IN(x) x
#define UHCI_OUT(x) x
#else
#define UHCI_IN(x) 0
#define UHCI_OUT(x) do { } while (0)
#endif
#ifndef CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC #ifndef CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC
/* Support PCI only */ /* Support PCI only */
static inline u32 uhci_readl(const struct uhci_hcd *uhci, int reg) static inline u32 uhci_readl(const struct uhci_hcd *uhci, int reg)
...@@ -539,7 +547,7 @@ static inline void uhci_writeb(const struct uhci_hcd *uhci, u8 val, int reg) ...@@ -539,7 +547,7 @@ static inline void uhci_writeb(const struct uhci_hcd *uhci, u8 val, int reg)
#else #else
/* Support non-PCI host controllers */ /* Support non-PCI host controllers */
#ifdef CONFIG_USB_PCI #if defined(CONFIG_USB_PCI) && defined(HAS_IOPORT)
/* Support PCI and non-PCI host controllers */ /* Support PCI and non-PCI host controllers */
#define uhci_has_pci_registers(u) ((u)->io_addr != 0) #define uhci_has_pci_registers(u) ((u)->io_addr != 0)
#else #else
...@@ -587,7 +595,7 @@ static inline int uhci_aspeed_reg(unsigned int reg) ...@@ -587,7 +595,7 @@ static inline int uhci_aspeed_reg(unsigned int reg)
static inline u32 uhci_readl(const struct uhci_hcd *uhci, int reg) static inline u32 uhci_readl(const struct uhci_hcd *uhci, int reg)
{ {
if (uhci_has_pci_registers(uhci)) if (uhci_has_pci_registers(uhci))
return inl(uhci->io_addr + reg); return UHCI_IN(inl(uhci->io_addr + reg));
else if (uhci_is_aspeed(uhci)) else if (uhci_is_aspeed(uhci))
return readl(uhci->regs + uhci_aspeed_reg(reg)); return readl(uhci->regs + uhci_aspeed_reg(reg));
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
...@@ -601,7 +609,7 @@ static inline u32 uhci_readl(const struct uhci_hcd *uhci, int reg) ...@@ -601,7 +609,7 @@ static inline u32 uhci_readl(const struct uhci_hcd *uhci, int reg)
static inline void uhci_writel(const struct uhci_hcd *uhci, u32 val, int reg) static inline void uhci_writel(const struct uhci_hcd *uhci, u32 val, int reg)
{ {
if (uhci_has_pci_registers(uhci)) if (uhci_has_pci_registers(uhci))
outl(val, uhci->io_addr + reg); UHCI_OUT(outl(val, uhci->io_addr + reg));
else if (uhci_is_aspeed(uhci)) else if (uhci_is_aspeed(uhci))
writel(val, uhci->regs + uhci_aspeed_reg(reg)); writel(val, uhci->regs + uhci_aspeed_reg(reg));
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
...@@ -615,7 +623,7 @@ static inline void uhci_writel(const struct uhci_hcd *uhci, u32 val, int reg) ...@@ -615,7 +623,7 @@ static inline void uhci_writel(const struct uhci_hcd *uhci, u32 val, int reg)
static inline u16 uhci_readw(const struct uhci_hcd *uhci, int reg) static inline u16 uhci_readw(const struct uhci_hcd *uhci, int reg)
{ {
if (uhci_has_pci_registers(uhci)) if (uhci_has_pci_registers(uhci))
return inw(uhci->io_addr + reg); return UHCI_IN(inw(uhci->io_addr + reg));
else if (uhci_is_aspeed(uhci)) else if (uhci_is_aspeed(uhci))
return readl(uhci->regs + uhci_aspeed_reg(reg)); return readl(uhci->regs + uhci_aspeed_reg(reg));
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
...@@ -629,7 +637,7 @@ static inline u16 uhci_readw(const struct uhci_hcd *uhci, int reg) ...@@ -629,7 +637,7 @@ static inline u16 uhci_readw(const struct uhci_hcd *uhci, int reg)
static inline void uhci_writew(const struct uhci_hcd *uhci, u16 val, int reg) static inline void uhci_writew(const struct uhci_hcd *uhci, u16 val, int reg)
{ {
if (uhci_has_pci_registers(uhci)) if (uhci_has_pci_registers(uhci))
outw(val, uhci->io_addr + reg); UHCI_OUT(outw(val, uhci->io_addr + reg));
else if (uhci_is_aspeed(uhci)) else if (uhci_is_aspeed(uhci))
writel(val, uhci->regs + uhci_aspeed_reg(reg)); writel(val, uhci->regs + uhci_aspeed_reg(reg));
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
...@@ -643,7 +651,7 @@ static inline void uhci_writew(const struct uhci_hcd *uhci, u16 val, int reg) ...@@ -643,7 +651,7 @@ static inline void uhci_writew(const struct uhci_hcd *uhci, u16 val, int reg)
static inline u8 uhci_readb(const struct uhci_hcd *uhci, int reg) static inline u8 uhci_readb(const struct uhci_hcd *uhci, int reg)
{ {
if (uhci_has_pci_registers(uhci)) if (uhci_has_pci_registers(uhci))
return inb(uhci->io_addr + reg); return UHCI_IN(inb(uhci->io_addr + reg));
else if (uhci_is_aspeed(uhci)) else if (uhci_is_aspeed(uhci))
return readl(uhci->regs + uhci_aspeed_reg(reg)); return readl(uhci->regs + uhci_aspeed_reg(reg));
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
...@@ -657,7 +665,7 @@ static inline u8 uhci_readb(const struct uhci_hcd *uhci, int reg) ...@@ -657,7 +665,7 @@ static inline u8 uhci_readb(const struct uhci_hcd *uhci, int reg)
static inline void uhci_writeb(const struct uhci_hcd *uhci, u8 val, int reg) static inline void uhci_writeb(const struct uhci_hcd *uhci, u8 val, int reg)
{ {
if (uhci_has_pci_registers(uhci)) if (uhci_has_pci_registers(uhci))
outb(val, uhci->io_addr + reg); UHCI_OUT(outb(val, uhci->io_addr + reg));
else if (uhci_is_aspeed(uhci)) else if (uhci_is_aspeed(uhci))
writel(val, uhci->regs + uhci_aspeed_reg(reg)); writel(val, uhci->regs + uhci_aspeed_reg(reg));
#ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO #ifdef CONFIG_USB_UHCI_BIG_ENDIAN_MMIO
...@@ -668,6 +676,8 @@ static inline void uhci_writeb(const struct uhci_hcd *uhci, u8 val, int reg) ...@@ -668,6 +676,8 @@ static inline void uhci_writeb(const struct uhci_hcd *uhci, u8 val, int reg)
writeb(val, uhci->regs + reg); writeb(val, uhci->regs + reg);
} }
#endif /* CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC */ #endif /* CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC */
#undef UHCI_IN
#undef UHCI_OUT
/* /*
* The GRLIB GRUSBHC controller can use big endian format for its descriptors. * The GRLIB GRUSBHC controller can use big endian format for its descriptors.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment