Re: [PATCH 1/4] USB: UHCI: Use pointers for register access functions

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

 



On Mon, 9 May 2011, Jan Andersson wrote:

> This patch changes the uhci_{read,write}* functions into using function
> pointers from the uhci_hcd struct when accessing registers. This is done in
> order to reduce the amount of code that need to be ifdef:ed around
> uhci_{read,write}* when later adding (dynamic) support for big endian mmio.
> 
> This change leads to a bit more work for the processor when running with
> a PCI-only UHCI kernel. Considering how relatively slow PCI accesses are
> it should not matter much, and it saves us the trouble of having a special
> case for PCI-only configurations in uhci-hcd.h.
> 
> Also added 'const' to uhci_hcd argument.
> 
> Signed-off-by: Jan Andersson <jan@xxxxxxxxxxx>
> ---
> 
> My guess is that the change in this patch may not be to everyones (anyones?)
> liking. Another solution would be to use someting more similar to the previous
> version, like:
> 
>  #if !defined(CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC)
>  static inline u32 uhci_readl(struct uhci_hcd *uhci, int reg)
>  {
> 	return inl(uhci->io_addr + reg);
>  }
>  #else
>  #define uhci_has_pci_registers(u)	((u)->io_addr != 0)
>  static inline u32 uhci_readl(struct uhci_hcd *uhci, int reg)
>  {
> 	if (uhci_has_pci_registers(uhci))
> 		return inl(uhci->io_addr + reg);
> 	else
> 		return uhci->ureadl(uhci->regs, reg);
>  }
>  #endif
> 
> ...  or more similar to the solution in used for the EHCI HCD (leads to the
> largest amount of special case ifdefs, at least in my attempts, but no extra
> function call):
> 
>  #if !defined(CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC)
>  static inline u32 uhci_readl(struct uhci_hcd *uhci, int reg)
>  {
>         return inl(uhci->io_addr + reg);
>  }
>  #else
>  #define uhci_has_pci_registers(u)      ((u)->io_addr != 0)
>  static inline u32 uhci_readl(struct uhci_hcd *uhci, int reg)
>  {
> 	if (uhci_has_pci_registers(uhci))
> 		return inl(uhci->io_addr + reg);
>   #if defined(CONFIG_USB_UHCI_BIG_ENDIAN_MMIO)
> 	elsif uhci_big_endian_mmio(uhci)
> 		return readl_be(uhci->regs, reg);
>   #endif
>         else
>  		return readl(uhci->regs, reg);
>  }
>  #endif

I would really like to see no change to the object code in the PCI-only 
case.

For the various non-PCI cases, imitating EHCI may be messy but it has 
the advantage of following a well-established precedent.

Alan Stern


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux