Skip to content

Commit

Permalink
fix: wait for reads to end before sleeping, prevent reads when asleep.
Browse files Browse the repository at this point in the history
…fixes #10
  • Loading branch information
lazd committed Jan 9, 2020
1 parent d4e7651 commit fe852e1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions VoodooI2CGoodix/VoodooI2CGoodixTouchDriver.cpp
Expand Up @@ -391,8 +391,21 @@ void VoodooI2CGoodixTouchDriver::stop(IOService* provider) {
}

IOReturn VoodooI2CGoodixTouchDriver::setPowerState(unsigned long powerState, IOService* whatDevice) {
if (whatDevice != this) {
return kIOReturnInvalid;
if (powerState == 0) {
if (awake) {
awake = false;
while (read_in_progress) {
IOLog("%s::Waiting for read to finish before sleeping...\n", getName());
IOSleep(10);
}
IOLog("%s::Going to sleep\n", getName());
}
}
else {
if (!awake) {
awake = true;
IOLog("%s::Waking up\n", getName());
}
}

return kIOPMAckImplied;
Expand Down

0 comments on commit fe852e1

Please sign in to comment.