[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Ym0yBti0J5w2S59W@rowland.harvard.edu>
Date: Sat, 30 Apr 2022 08:56:38 -0400
From: Alan Stern <stern@...land.harvard.edu>
To: Niklas Schnelle <schnelle@...ux.ibm.com>
Cc: Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
linux-pci@...r.kernel.org, Arnd Bergmann <arnd@...nel.org>,
Mathias Nyman <mathias.nyman@...el.com>,
"open list:USB SUBSYSTEM" <linux-usb@...r.kernel.org>
Subject: Re: [RFC v2 35/39] usb: handle HAS_IOPORT dependencies
On Fri, Apr 29, 2022 at 03:51:02PM +0200, Niklas Schnelle wrote:
> 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. Similarly
> drivers requiring these functions need to depend on HAS_IOPORT.
>
> Co-developed-by: Arnd Bergmann <arnd@...nel.org>
> Signed-off-by: Niklas Schnelle <schnelle@...ux.ibm.com>
> ---
...
> diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
> index ef08d68b9714..4fd06b48149d 100644
> --- a/drivers/usb/host/pci-quirks.c
> +++ b/drivers/usb/host/pci-quirks.c
> @@ -632,7 +590,53 @@ bool usb_amd_pt_check_port(struct device *device, int port)
> return !(value & BIT(port_shift));
> }
> EXPORT_SYMBOL_GPL(usb_amd_pt_check_port);
> +#endif
> @@ -1273,7 +1280,8 @@ static void quirk_usb_early_handoff(struct pci_dev *pdev)
> "Can't enable PCI device, BIOS handoff failed.\n");
> return;
> }
> - if (pdev->class == PCI_CLASS_SERIAL_USB_UHCI)
> + if (IS_ENABLED(CONFIG_USB_UHCI_HCD) &&
> + pdev->class == PCI_CLASS_SERIAL_USB_UHCI)
> quirk_usb_handoff_uhci(pdev);
We discussed this already. quirk_usb_handoff_uhci() is supposed to be
called even when CONFIG_USB_UHCI_HCD isn't enabled.
...
> diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
> index 8ae5ccd26753..be4aee1f0ca5 100644
> --- a/drivers/usb/host/uhci-hcd.h
> +++ b/drivers/usb/host/uhci-hcd.h
> @@ -505,36 +505,43 @@ static inline bool uhci_is_aspeed(const struct uhci_hcd *uhci)
> * 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)
> +#endif
Should have a blank line here.
> #ifndef CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC
> /* Support PCI only */
> static inline u32 uhci_readl(const struct uhci_hcd *uhci, int reg)
> {
> - return inl(uhci->io_addr + reg);
> + return UHCI_IN(inl(uhci->io_addr + reg));
> }
>
> static inline void uhci_writel(const struct uhci_hcd *uhci, u32 val, int reg)
> {
> - outl(val, uhci->io_addr + reg);
> + UHCI_OUT(outl(val, uhci->io_addr + reg));
> }
>
> static inline u16 uhci_readw(const struct uhci_hcd *uhci, int reg)
> {
> - return inw(uhci->io_addr + reg);
> + return UHCI_IN(inw(uhci->io_addr + reg));
> }
>
> static inline void uhci_writew(const struct uhci_hcd *uhci, u16 val, int reg)
> {
> - outw(val, uhci->io_addr + reg);
> + UHCI_OUT(outw(val, uhci->io_addr + reg));
> }
>
> static inline u8 uhci_readb(const struct uhci_hcd *uhci, int reg)
> {
> - return inb(uhci->io_addr + reg);
> + return UHCI_IN(inb(uhci->io_addr + reg));
> }
>
> static inline void uhci_writeb(const struct uhci_hcd *uhci, u8 val, int reg)
> {
> - outb(val, uhci->io_addr + reg);
> + UHCI_OUT(outb(val, uhci->io_addr + reg));
> }
>
> #else
I thought you were going to update the definition of
uhci_has_pci_registers(). It shouldn't do a test at runtime if
CONFIG_HAS_IOPORT is disabled.
Alan Stern
Powered by blists - more mailing lists