> -----Original Message----- > From: Andy Fleming [mailto:aflem...@gmail.com] > Sent: Saturday, October 20, 2012 5:22 AM > To: Marek Vasut > Cc: Liu Shengzhou-B36685; u-boot@lists.denx.de; Stefan Roese > Subject: Re: [U-Boot] [PATCH] powerpc/usb: fix bug of CPU hang when > missing USB PHY clock > > On Thu, Oct 18, 2012 at 4:04 AM, Marek Vasut <ma...@denx.de> wrote: > > Dear Liu Shengzhou-B36685, > > >> > > > > >> > > > > +/* 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 ;-) > > > I may just be dim. Why is this a good point? If > in_be32(&ehci->prictrl) is non-zero, then this function will return '1'. > If (in_be32(&ehci->control) & PHY_CLK_VALID) is non-zero, this function > will return 1. > > What am I missing? > > Andy [Shengzhou] Because the indication of PHY_CLK_VALID is time-sensitive, we just think the value read at the first time is reliable, then PHY_CLK_VALID will be zero after that though actually PHY clock is still valid.
_______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot