Re: [RFC v2 35/39] usb: handle HAS_IOPORT dependencies

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2022-04-30 at 08:56 -0400, Alan Stern wrote:
> 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@xxxxxxxxxx>
> > Signed-off-by: Niklas Schnelle <schnelle@xxxxxxxxxxxxx>
> > ---
> 
> ...
> 
> > 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.

Sorry I missed this part. Done.

> 
> ...
> 
> > 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.

Done

> 
> >  #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

Good point. Done.





[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux