Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74fcf976 authored by Umang Agrawal's avatar Umang Agrawal Committed by Gerrit - the friendly Code Review server
Browse files

power: smb5-lib: Fix wake lock acquisition



Currently, pm_stay_awake and pm_relax are called directly from the
alarm callback routines since we are in atomic context. However,
pm_stay_awake/pm_relax are not ref counted which leaves a possibility
of the wakelock being cleared by any other thread of this module.

Fix this by explicitly voting to awake votable, to ensure pm_relax
isn't called before the complete execution of the routine.

Change-Id: I3b28315648261eacfa3247d8fcb76673d506629b
Signed-off-by: default avatarUmang Agrawal <uagrawal@codeaurora.org>
parent 9867d2cc
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -5795,6 +5795,12 @@ static void smblib_moisture_protection_work(struct work_struct *work)
	bool usb_plugged_in;
	bool usb_plugged_in;
	u8 stat;
	u8 stat;


	/*
	 * Hold awake votable to prevent pm_relax being called prior to
	 * completion of this work.
	 */
	vote(chg->awake_votable, MOISTURE_VOTER, true, 0);

	/*
	/*
	 * Disable 1% duty cycle on CC_ID pin and enable uUSB factory mode
	 * Disable 1% duty cycle on CC_ID pin and enable uUSB factory mode
	 * detection to track any change on RID, as interrupts are disable.
	 * detection to track any change on RID, as interrupts are disable.
@@ -5859,7 +5865,7 @@ static void smblib_moisture_protection_work(struct work_struct *work)
	}
	}


out:
out:
	pm_relax(chg->dev);
	vote(chg->awake_votable, MOISTURE_VOTER, false, 0);
}
}


static enum alarmtimer_restart moisture_protection_alarm_cb(struct alarm *alarm,
static enum alarmtimer_restart moisture_protection_alarm_cb(struct alarm *alarm,