sb_pqueue.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * sb_pqueue.h
  3. * Samsung Mobile Priority Queue Header
  4. *
  5. * Copyright (C) 2021 Samsung Electronics, Inc.
  6. *
  7. *
  8. * This software is licensed under the terms of the GNU General Public
  9. * License version 2, as published by the Free Software Foundation, and
  10. * may be copied, distributed, and modified under those terms.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. */
  18. #ifndef __SB_PQUEUE_H
  19. #define __SB_PQUEUE_H __FILE__
  20. #include <linux/err.h>
  21. #include <linux/battery/sb_def.h>
  22. #define PQF_REMOVE 0x1
  23. #define PQF_PRIORITY 0x2
  24. struct sb_pqueue;
  25. /* priority condition : data1 > data2 = true, data1 < data2 = false */
  26. typedef bool (*cmp_func)(sb_data *data1, sb_data *data2);
  27. #define SB_PQUEUE_DISABLE (-3660)
  28. #if IS_ENABLED(CONFIG_SB_PQUEUE)
  29. struct sb_pqueue *sb_pq_create(unsigned int flag, unsigned int size, cmp_func cmp);
  30. void sb_pq_destroy(struct sb_pqueue *pq);
  31. sb_data *sb_pq_pop(struct sb_pqueue *pq);
  32. int sb_pq_push(struct sb_pqueue *pq, unsigned int idx, sb_data *data);
  33. int sb_pq_get_en(struct sb_pqueue *pq, unsigned int idx);
  34. int sb_pq_set_pri(struct sb_pqueue *pq, unsigned int idx, int pri);
  35. int sb_pq_get_pri(struct sb_pqueue *pq, unsigned int idx);
  36. int sb_pq_set_data(struct sb_pqueue *pq, unsigned int idx, sb_data *data);
  37. sb_data *sb_pq_get_data(struct sb_pqueue *pq, unsigned int idx);
  38. sb_data *sb_pq_top(struct sb_pqueue *pq);
  39. int sb_pq_remove(struct sb_pqueue *pq, unsigned int idx);
  40. #else
  41. static inline struct sb_pqueue *sb_pq_create(unsigned int flag, unsigned int size, cmp_func cmp)
  42. { return ERR_PTR(SB_PQUEUE_DISABLE); }
  43. static inline void sb_pq_destroy(struct sb_pqueue *pq) {}
  44. static inline sb_data *sb_pq_pop(struct sb_pqueue *pq)
  45. { return ERR_PTR(SB_PQUEUE_DISABLE); }
  46. static inline int sb_pq_push(struct sb_pqueue *pq, unsigned int idx, sb_data *data)
  47. { return SB_PQUEUE_DISABLE; }
  48. static inline int sb_pq_get_en(struct sb_pqueue *pq, unsigned int idx)
  49. { return SB_PQUEUE_DISABLE; }
  50. static inline int sb_pq_set_pri(struct sb_pqueue *pq, unsigned int idx, int pri)
  51. { return SB_PQUEUE_DISABLE; }
  52. static inline int sb_pq_get_pri(struct sb_pqueue *pq, unsigned int idx)
  53. { return SB_PQUEUE_DISABLE; }
  54. static inline int sb_pq_set_data(struct sb_pqueue *pq, unsigned int idx, sb_data *data)
  55. { return SB_PQUEUE_DISABLE; }
  56. static inline sb_data *sb_pq_get_data(struct sb_pqueue *pq, unsigned int idx)
  57. { return ERR_PTR(SB_PQUEUE_DISABLE); }
  58. static inline sb_data *sb_pq_top(struct sb_pqueue *pq)
  59. { return ERR_PTR(SB_PQUEUE_DISABLE); }
  60. static inline int sb_pq_remove(struct sb_pqueue *pq, unsigned int idx)
  61. { return SB_PQUEUE_DISABLE; }
  62. #endif
  63. #endif /* __SB_PQUEUE_H */