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

Commit 90e1aa53 authored by Nicholas Troast's avatar Nicholas Troast Committed by Ankit Sharma
Browse files

power: pmic-voter: add is_client_vote_enabled API



A client vote can be enabled or disabled. Add an API which allows
consumers to check the enable/disable status of a client vote.

Change-Id: Ic4e9224c19e63fb88216da0cb775994e3e87c1f7
Signed-off-by: default avatarNicholas Troast <ntroast@codeaurora.org>
parent 373c7ca9
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -187,6 +187,38 @@ void unlock_votable(struct votable *votable)
	mutex_unlock(&votable->vote_lock);
}

/**
 * is_client_vote_enabled() -
 * is_client_vote_enabled_locked() -
 *		The unlocked and locked variants of getting whether a client's
		vote is enabled.
 * @votable:	the votable object
 * @client_str: client of interest
 *
 * Returns:
 *	True if the client's vote is enabled; false otherwise.
 */
bool is_client_vote_enabled_locked(struct votable *votable,
							const char *client_str)
{
	int client_id = get_client_id(votable, client_str);

	if (client_id < 0)
		return false;

	return votable->votes[client_id].enabled;
}

bool is_client_vote_enabled(struct votable *votable, const char *client_str)
{
	bool enabled;

	lock_votable(votable);
	enabled = is_client_vote_enabled_locked(votable, client_str);
	unlock_votable(votable);
	return enabled;
}

/**
 * get_client_vote() -
 * get_client_vote_locked() -
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ enum votable_type {
	NUM_VOTABLE_TYPES,
};

bool is_client_vote_enabled(struct votable *votable, const char *client_str);
bool is_client_vote_enabled_locked(struct votable *votable,
							const char *client_str);
int get_client_vote(struct votable *votable, const char *client_str);
int get_client_vote_locked(struct votable *votable, const char *client_str);
int get_effective_result(struct votable *votable);