Lines Matching refs:prio
44 int (*item_add)(struct parman *parman, struct parman_prio *prio,
46 void (*item_remove)(struct parman *parman, struct parman_prio *prio,
87 static bool parman_prio_used(struct parman_prio *prio) in parman_prio_used() argument
89 return !list_empty(&prio->item_list); in parman_prio_used()
92 static struct parman_item *parman_prio_first_item(struct parman_prio *prio) in parman_prio_first_item() argument
94 return list_first_entry(&prio->item_list, in parman_prio_first_item()
98 static unsigned long parman_prio_first_index(struct parman_prio *prio) in parman_prio_first_index() argument
100 return parman_prio_first_item(prio)->index; in parman_prio_first_index()
103 static struct parman_item *parman_prio_last_item(struct parman_prio *prio) in parman_prio_last_item() argument
105 return list_last_entry(&prio->item_list, in parman_prio_last_item()
109 static unsigned long parman_prio_last_index(struct parman_prio *prio) in parman_prio_last_index() argument
111 return parman_prio_last_item(prio)->index; in parman_prio_last_index()
115 struct parman_prio *prio) in parman_lsort_new_index_find() argument
117 list_for_each_entry_from_reverse(prio, &parman->prio_list, list) { in parman_lsort_new_index_find()
118 if (!parman_prio_used(prio)) in parman_lsort_new_index_find()
120 return parman_prio_last_index(prio) + 1; in parman_lsort_new_index_find()
125 static void __parman_prio_move(struct parman *parman, struct parman_prio *prio, in __parman_prio_move() argument
133 struct parman_prio *prio) in parman_prio_shift_down() argument
138 if (!parman_prio_used(prio)) in parman_prio_shift_down()
140 item = parman_prio_first_item(prio); in parman_prio_shift_down()
141 to_index = parman_prio_last_index(prio) + 1; in parman_prio_shift_down()
142 __parman_prio_move(parman, prio, item, to_index, 1); in parman_prio_shift_down()
143 list_move_tail(&item->list, &prio->item_list); in parman_prio_shift_down()
148 struct parman_prio *prio) in parman_prio_shift_up() argument
153 if (!parman_prio_used(prio)) in parman_prio_shift_up()
155 item = parman_prio_last_item(prio); in parman_prio_shift_up()
156 to_index = parman_prio_first_index(prio) - 1; in parman_prio_shift_up()
157 __parman_prio_move(parman, prio, item, to_index, 1); in parman_prio_shift_up()
158 list_move(&item->list, &prio->item_list); in parman_prio_shift_up()
163 struct parman_prio *prio, in parman_prio_item_remove() argument
169 last_item = parman_prio_last_item(prio); in parman_prio_item_remove()
175 __parman_prio_move(parman, prio, last_item, to_index, 1); in parman_prio_item_remove()
182 struct parman_prio *prio, in parman_lsort_item_add() argument
195 new_index = parman_lsort_new_index_find(parman, prio); in parman_lsort_item_add()
197 if (prio2 == prio) in parman_lsort_item_add()
202 list_add_tail(&item->list, &prio->item_list); in parman_lsort_item_add()
208 struct parman_prio *prio, in parman_lsort_item_remove() argument
211 parman_prio_item_remove(parman, prio, item); in parman_lsort_item_remove()
212 list_for_each_entry_continue(prio, &parman->prio_list, list) in parman_lsort_item_remove()
213 parman_prio_shift_up(parman, prio); in parman_lsort_item_remove()
307 void parman_prio_init(struct parman *parman, struct parman_prio *prio, in parman_prio_init() argument
313 INIT_LIST_HEAD(&prio->item_list); in parman_prio_init()
314 prio->priority = priority; in parman_prio_init()
319 if (prio2->priority > prio->priority) in parman_prio_init()
322 list_add_tail(&prio->list, pos); in parman_prio_init()
332 void parman_prio_fini(struct parman_prio *prio) in parman_prio_fini() argument
334 WARN_ON(parman_prio_used(prio)); in parman_prio_fini()
335 list_del(&prio->list); in parman_prio_fini()
351 int parman_item_add(struct parman *parman, struct parman_prio *prio, in parman_item_add() argument
354 return parman->algo->item_add(parman, prio, item); in parman_item_add()
366 void parman_item_remove(struct parman *parman, struct parman_prio *prio, in parman_item_remove() argument
369 parman->algo->item_remove(parman, prio, item); in parman_item_remove()