Abhijeet Dharmapurikar | ebb5e5c | 2016-05-17 20:09:16 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2016 The Linux Foundation. All rights reserved. |
Nicholas Troast | 6e8c038 | 2016-02-12 15:34:57 -0800 | [diff] [blame] | 2 | * |
| 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 | |
| 18 | struct votable; |
| 19 | |
| 20 | enum votable_type { |
| 21 | VOTE_MIN, |
| 22 | VOTE_MAX, |
| 23 | VOTE_SET_ANY, |
| 24 | NUM_VOTABLE_TYPES, |
| 25 | }; |
| 26 | |
Nicholas Troast | cf3ce17 | 2017-03-15 10:05:51 -0700 | [diff] [blame] | 27 | bool is_client_vote_enabled(struct votable *votable, const char *client_str); |
| 28 | bool is_client_vote_enabled_locked(struct votable *votable, |
| 29 | const char *client_str); |
Abhijeet Dharmapurikar | ebb5e5c | 2016-05-17 20:09:16 -0700 | [diff] [blame] | 30 | int get_client_vote(struct votable *votable, const char *client_str); |
| 31 | int get_client_vote_locked(struct votable *votable, const char *client_str); |
Nicholas Troast | 6e8c038 | 2016-02-12 15:34:57 -0800 | [diff] [blame] | 32 | int get_effective_result(struct votable *votable); |
| 33 | int get_effective_result_locked(struct votable *votable); |
Abhijeet Dharmapurikar | ebb5e5c | 2016-05-17 20:09:16 -0700 | [diff] [blame] | 34 | const char *get_effective_client(struct votable *votable); |
| 35 | const char *get_effective_client_locked(struct votable *votable); |
| 36 | int vote(struct votable *votable, const char *client_str, bool state, int val); |
| 37 | int rerun_election(struct votable *votable); |
| 38 | struct votable *find_votable(const char *name); |
Abhijeet Dharmapurikar | 8e9e757 | 2016-06-06 16:13:14 -0700 | [diff] [blame] | 39 | struct votable *create_votable(const char *name, |
Abhijeet Dharmapurikar | c0ff65a | 2016-06-06 16:45:34 -0700 | [diff] [blame] | 40 | int votable_type, |
Abhijeet Dharmapurikar | 8e9e757 | 2016-06-06 16:13:14 -0700 | [diff] [blame] | 41 | int (*callback)(struct votable *votable, |
| 42 | void *data, |
Nicholas Troast | 6e8c038 | 2016-02-12 15:34:57 -0800 | [diff] [blame] | 43 | int effective_result, |
Abhijeet Dharmapurikar | 8e9e757 | 2016-06-06 16:13:14 -0700 | [diff] [blame] | 44 | const char *effective_client), |
| 45 | void *data); |
| 46 | void destroy_votable(struct votable *votable); |
Nicholas Troast | 6e8c038 | 2016-02-12 15:34:57 -0800 | [diff] [blame] | 47 | void lock_votable(struct votable *votable); |
Abhijeet Dharmapurikar | ebb5e5c | 2016-05-17 20:09:16 -0700 | [diff] [blame] | 48 | void unlock_votable(struct votable *votable); |
Nicholas Troast | 6e8c038 | 2016-02-12 15:34:57 -0800 | [diff] [blame] | 49 | |
| 50 | #endif /* __PMIC_VOTER_H */ |