pmic-voter.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __PMIC_VOTER_H
  7. #define __PMIC_VOTER_H
  8. #include <linux/mutex.h>
  9. struct votable;
  10. enum votable_type {
  11. VOTE_MIN,
  12. VOTE_MAX,
  13. VOTE_SET_ANY,
  14. NUM_VOTABLE_TYPES,
  15. };
  16. extern bool is_client_vote_enabled(struct votable *votable, const char *client_str);
  17. extern bool is_client_vote_enabled_locked(struct votable *votable,
  18. const char *client_str);
  19. extern bool is_override_vote_enabled(struct votable *votable);
  20. extern bool is_override_vote_enabled_locked(struct votable *votable);
  21. extern int get_client_vote(struct votable *votable, const char *client_str);
  22. extern int get_client_vote_locked(struct votable *votable, const char *client_str);
  23. extern int get_effective_result(struct votable *votable);
  24. extern int get_effective_result_locked(struct votable *votable);
  25. extern const char *get_effective_client(struct votable *votable);
  26. extern const char *get_effective_client_locked(struct votable *votable);
  27. extern int vote(struct votable *votable, const char *client_str, bool state, int val);
  28. extern int vote_override(struct votable *votable, const char *override_client,
  29. bool state, int val);
  30. extern int rerun_election(struct votable *votable);
  31. extern struct votable *find_votable(const char *name);
  32. extern struct votable *create_votable(const char *name,
  33. int votable_type,
  34. int (*callback)(struct votable *votable,
  35. void *data,
  36. int effective_result,
  37. const char *effective_client),
  38. void *data);
  39. extern void destroy_votable(struct votable *votable);
  40. extern void lock_votable(struct votable *votable);
  41. extern void unlock_votable(struct votable *votable);
  42. #endif /* __PMIC_VOTER_H */