From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Thu, 18 Oct 2012 11:04:01 +0200 Subject: [U-Boot] [PATCH] powerpc/usb: fix bug of CPU hang when missing USB PHY clock In-Reply-To: <3F453DDFF675A64A89321A1F3528102182C009@039-SN1MPN1-003.039d.mgd.msft.net> References: <1350528023-17907-1-git-send-email-Shengzhou.Liu@freescale.com> <201210180915.49387.marex@denx.de> <3F453DDFF675A64A89321A1F3528102182C009@039-SN1MPN1-003.039d.mgd.msft.net> Message-ID: <201210181104.01357.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Liu Shengzhou-B36685, > > -----Original Message----- > > From: Marek Vasut [mailto:marex at denx.de] > > Sent: Thursday, October 18, 2012 3:16 PM > > To: Liu Shengzhou-B36685 > > Cc: u-boot at lists.denx.de; Stefan Roese; agust at denx.de > > Subject: Re: [PATCH] powerpc/usb: fix bug of CPU hang when missing USB > > PHY clock > > > > Dear Liu Shengzhou-B36685, > > > > > > -----Original Message----- > > > > > > > > > +/* Check USB PHY clock valid */ > > > > > +static int usb_phy_clk_valid(struct usb_ehci *ehci) { > > > > > + if ((!(in_be32(&ehci->control) & PHY_CLK_VALID)) && > > > > > + (!in_be32(&ehci->prictrl))) { > > > > > > > > (!A && !B) condition can certainly be done without the double > > > > negation ;-) > > > > > > [Shengzhou] Yes, using !(A||B) is also okay:) > > > > Good, you did your logic homework well. Now go one step further: > > > > if (a || b) > > > > return 1; > > [Shengzhou] No, this doesn't work, b is 0 at initial time, but b is 1 at > the second time, a is depend on the register PHY_CLK_VALID bit, We just > want to check it at the first time and then think it is always valid after > that, it's using a trick:) Good point, I was just testing you of course ;-) Best regards, Marek Vasut