Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757055AbWLEXun (ORCPT ); Tue, 5 Dec 2006 18:50:43 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756952AbWLEXun (ORCPT ); Tue, 5 Dec 2006 18:50:43 -0500 Received: from ebiederm.dsl.xmission.com ([166.70.28.69]:38861 "EHLO ebiederm.dsl.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757092AbWLEXul (ORCPT ); Tue, 5 Dec 2006 18:50:41 -0500 From: ebiederm@xmission.com (Eric W. Biederman) To: "Lu, Yinghai" Cc: "David Brownell" , "Peter Stuge" , linux-usb-devel@lists.sourceforge.net, "Stefan Reinauer" , "Greg KH" , linux-kernel@vger.kernel.org, linuxbios@linuxbios.org, "Andi Kleen" Subject: Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support. References: <5986589C150B2F49A46483AC44C7BCA490728A@ssvlexmb2.amd.com> Date: Tue, 05 Dec 2006 16:50:05 -0700 In-Reply-To: <5986589C150B2F49A46483AC44C7BCA490728A@ssvlexmb2.amd.com> (Yinghai Lu's message of "Tue, 5 Dec 2006 15:29:32 -0800") Message-ID: User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1503 Lines: 47 "Lu, Yinghai" writes: > -----Original Message----- > From: linuxbios-bounces@linuxbios.org > [mailto:linuxbios-bounces@linuxbios.org] On Behalf Of > ebiederm@xmission.com > Sent: Tuesday, December 05, 2006 3:01 AM > >>+static int ehci_wait_for_port(int port) >>+{ >>+ unsigned status; >>+ int ret, reps; >>+ for (reps = 0; reps >= 0; reps++) { >>+ status = readl(&ehci_regs->status); >>+ if (status & STS_PCD) { >>+ ret = ehci_reset_port(port); >>+ if (ret == 0) >>+ return 0; >>+ } >>+ } >>+ return -ENOTCONN; >>+} >>+ > > What do you mean by > + for (reps = 0; reps >= 0; reps++) { > ? If you will not reps is negative. Roughly it is a loop that will timeout eventually if a usb debug cable is not present. Putting some deliberate delays in there so I could be certain of timing out after a second or two would probably be better, but I don't have anything that resembles a good timer at that point. The problem is you have to wait until the ehci notices your usb debug cable before you reset it and get it going and that can be a non-trivial amount of time. So the loop is 100% necessary. So since I didn't know how many loop iterations made sense I allowed it to loop for 2^31 times or until reps goes negative. Eric - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/