Re: [PATCH 3/7] USB: UHCI: Move PCI specific functions to uhci-pci.c

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

 



On Wed, 4 May 2011, Jan Andersson wrote:

> This patch is part of a series that extend the UHCI HCD to support
> non-PCI controllers.
> 
> This patch moves PCI specific functions to uhci-pci.c and includes
> this file in uhci-hcd.c. It also renames the function uhci_init to
> uhci_pci_init.

...

> -static int uhci_init(struct usb_hcd *hcd)
> -{
> -	struct uhci_hcd *uhci = hcd_to_uhci(hcd);
> -	unsigned io_size = (unsigned) hcd->rsrc_len;
> -	int port;
> -
> -	uhci->io_addr = (unsigned long) hcd->rsrc_start;
> -
> -	/* The UHCI spec says devices must have 2 ports, and goes on to say
> -	 * they may have more but gives no way to determine how many there
> -	 * are.  However according to the UHCI spec, Bit 7 of the port
> -	 * status and control register is always set to 1.  So we try to
> -	 * use this to our advantage.  Another common failure mode when
> -	 * a nonexistent register is addressed is to return all ones, so
> -	 * we test for that also.
> -	 */
> -	for (port = 0; port < (io_size - USBPORTSC1) / 2; port++) {
> -		unsigned int portstatus;
> -
> -		portstatus = inw(uhci->io_addr + USBPORTSC1 + (port * 2));
> -		if (!(portstatus & 0x0080) || portstatus == 0xffff)
> -			break;
> -	}
> -	if (debug)
> -		dev_info(uhci_dev(uhci), "detected %d ports\n", port);
> -
> -	/* Anything greater than 7 is weird so we'll ignore it. */
> -	if (port > UHCI_RH_MAXCHILD) {
> -		dev_info(uhci_dev(uhci), "port count misdetected? "
> -				"forcing to 2 ports\n");
> -		port = 2;
> -	}
> -	uhci->rh_numports = port;

This port-detection logic will be common to all platforms.  It should 
remain in uhci-hcd as a subroutine that can be called from the 
platform-specific init routine.

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