blob: f202bf7040559681962ba94e7c47c074f3bb0cab [file] [log] [blame]
Abhijeet Dharmapurikarebb5e5c2016-05-17 20:09:16 -07001/* Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
Nicholas Troast6e8c0382016-02-12 15:34:57 -08002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef __PMIC_VOTER_H
14#define __PMIC_VOTER_H
15
16#include <linux/mutex.h>
17
18struct votable;
19
20enum votable_type {
21 VOTE_MIN,
22 VOTE_MAX,
23 VOTE_SET_ANY,
24 NUM_VOTABLE_TYPES,
25};
26
Nicholas Troastcf3ce172017-03-15 10:05:51 -070027bool is_client_vote_enabled(struct votable *votable, const char *client_str);
28bool is_client_vote_enabled_locked(struct votable *votable,
29 const char *client_str);
Abhijeet Dharmapurikarebb5e5c2016-05-17 20:09:16 -070030int get_client_vote(struct votable *votable, const char *client_str);
31int get_client_vote_locked(struct votable *votable, const char *client_str);
Nicholas Troast6e8c0382016-02-12 15:34:57 -080032int get_effective_result(struct votable *votable);
33int get_effective_result_locked(struct votable *votable);
Abhijeet Dharmapurikarebb5e5c2016-05-17 20:09:16 -070034const char *get_effective_client(struct votable *votable);
35const char *get_effective_client_locked(struct votable *votable);
36int vote(struct votable *votable, const char *client_str, bool state, int val);
37int rerun_election(struct votable *votable);
38struct votable *find_votable(const char *name);
Abhijeet Dharmapurikar8e9e7572016-06-06 16:13:14 -070039struct votable *create_votable(const char *name,
Abhijeet Dharmapurikarc0ff65a2016-06-06 16:45:34 -070040 int votable_type,
Abhijeet Dharmapurikar8e9e7572016-06-06 16:13:14 -070041 int (*callback)(struct votable *votable,
42 void *data,
Nicholas Troast6e8c0382016-02-12 15:34:57 -080043 int effective_result,
Abhijeet Dharmapurikar8e9e7572016-06-06 16:13:14 -070044 const char *effective_client),
45 void *data);
46void destroy_votable(struct votable *votable);
Nicholas Troast6e8c0382016-02-12 15:34:57 -080047void lock_votable(struct votable *votable);
Abhijeet Dharmapurikarebb5e5c2016-05-17 20:09:16 -070048void unlock_votable(struct votable *votable);
Nicholas Troast6e8c0382016-02-12 15:34:57 -080049
50#endif /* __PMIC_VOTER_H */