On Thu, 11 Jun 2009, Pan, Jacob jun wrote: > >> On the other side, I think it is also the right thing to do to enable > >> only the appropriate wake bits. > > > >No, it is not the right thing to do. In fact, it is a race. What > >happens if the connect state changes between the time when you read the > >port status and when you set the wakeup bits? You'd end up with the > >wrong bit set. > > > >Alan Stern > [[JPAN]] in this case, would the port change event result in an interrupt and eventually set the right bits? Here is the flow I can think of in case of no device attached. > 1. HCD read portsc, show not connected > 2. PCD occurred due to a device connection > 3. HCD write to portsc for wake on connect (wrong as you mentioned) > 4. HCD process PCD then find out connected, then set wake on disconnect bit (corrected) > > HCD=host controller driver > PCD=port change detection > Sorry for the acronyms, just try to be clear and lazy :). Yes, I guess you're right. Even if step 4 didn't happen, there would still be a wakeup interrupt pending thanks to step 2. It would be a good idea to explain this in the code. And also to explain why you don't simply set both bits. 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