libpayload: usbhub: Don't clear PSC unless it was set
The current USB hub code always clears the port status change after checking it, regardless of whether it was set in the first place. Since this check runs on every poll, it might create a race condition where the port status changes right between the GET_PORT_STATUS and the CLEAR_FEATURE(C_PORT_CONNECT), thus clearing the statrus change flag before it was ever read. Let's add one extra if() to avoid that possible headache. BUG=chrome-os-partner:21969 TEST=None Change-Id: Idd46c2199dc6c240bd9ef068fbe70cccc88bac42 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168098
This commit is contained in:
parent
68c24ca057
commit
f7f6f008f7
1 changed files with 2 additions and 1 deletions
|
|
@ -48,7 +48,8 @@ usb_hub_port_status_changed(usbdev_t *const dev, const int port)
|
|||
{
|
||||
unsigned short buf[2] = { 0, 0 };
|
||||
get_status (dev, port, DR_PORT, 4, buf);
|
||||
clear_feature (dev, port, SEL_C_PORT_CONNECTION, DR_PORT);
|
||||
if (buf[1] & PORT_CONNECTION)
|
||||
clear_feature (dev, port, SEL_C_PORT_CONNECTION, DR_PORT);
|
||||
return buf[1] & PORT_CONNECTION;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue