Re: USB Storage Device Not Working

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Mon, 19 Nov 2007, balajirrao wrote:

> I have made the necessary corrections and this patch works perfectly.
> Please tell me if there's a mistake, i will correct and send it
> immediatly.

On the whole this looks good.  But there's still one or two things to 
fix...

> --- linux-2.6.24-rc3.orig/drivers/usb/host/ehci-hub.c
> +++ linux-2.6.24-rc3/drivers/usb/host/ehci-hub.c
> @@ -864,3 +864,33 @@ error:
>  	spin_unlock_irqrestore (&ehci->lock, flags);
>  	return retval;
>  }
> +
> +static void ehci_relinquish_port (struct usb_hcd *hcd, int portnum) {

Don't include a space before the '(' character.

> +	struct 		ehci_hcd *ehci;
> +	int 		port_status;
> +	u32 __iomem	*status_reg;
> +	int		try;
> +	
> +	ehci = hcd_to_ehci(hcd);
> +	status_reg = &ehci->regs->port_status[--portnum];
> +	port_status = ehci_readl(ehci, status_reg);
> +
> +	if (ehci_is_TDI(ehci))
> +		return;
> +
> +	for (try = 4; try > 0; --try) {
> +		spin_lock_irq(&ehci->lock);
> +		port_status = ehci_readl(ehci, status_reg);
> +		if ((port_status & PORT_OWNER) == PORT_OWNER)	
> +			try = 0;
> +		else {
> +			port_status ^= PORT_OWNER;
> +			port_status &= ~(PORT_PE | PORT_RWC_BITS);
> +			ehci_writel(ehci, port_status, status_reg);
> +		}
> +		spin_unlock_irq(&ehci->lock);
> +		if (try > 1)
> +			msleep(5);
> +	}
> +}

This routine duplicates code that is already present in
store_companion().  You should separate out the common part and put it
in its own subroutine, so that it can be called from both
ehci_relinquish_port() and store_companion().  That way the code will
exist in only one place.  Doing this will also fix the issues Felipe
raised.

Alan Stern




-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.