• Home
  • Raw
  • Download

Lines Matching refs:parman

44 	int (*item_add)(struct parman *parman, struct parman_prio *prio,
46 void (*item_remove)(struct parman *parman, struct parman_prio *prio,
50 struct parman { struct
59 static int parman_enlarge(struct parman *parman) in parman_enlarge() argument
61 unsigned long new_count = parman->limit_count + in parman_enlarge()
62 parman->ops->resize_step; in parman_enlarge()
65 err = parman->ops->resize(parman->priv, new_count); in parman_enlarge()
68 parman->limit_count = new_count; in parman_enlarge()
72 static int parman_shrink(struct parman *parman) in parman_shrink() argument
74 unsigned long new_count = parman->limit_count - in parman_shrink()
75 parman->ops->resize_step; in parman_shrink()
78 if (new_count < parman->ops->base_count) in parman_shrink()
80 err = parman->ops->resize(parman->priv, new_count); in parman_shrink()
83 parman->limit_count = new_count; in parman_shrink()
114 static unsigned long parman_lsort_new_index_find(struct parman *parman, 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()
125 static void __parman_prio_move(struct parman *parman, struct parman_prio *prio, in __parman_prio_move() argument
129 parman->ops->move(parman->priv, item->index, to_index, count); in __parman_prio_move()
132 static void parman_prio_shift_down(struct parman *parman, in parman_prio_shift_down() argument
142 __parman_prio_move(parman, prio, item, to_index, 1); in parman_prio_shift_down()
147 static void parman_prio_shift_up(struct parman *parman, in parman_prio_shift_up() argument
157 __parman_prio_move(parman, prio, item, to_index, 1); in parman_prio_shift_up()
162 static void parman_prio_item_remove(struct parman *parman, in parman_prio_item_remove() argument
175 __parman_prio_move(parman, prio, last_item, to_index, 1); in parman_prio_item_remove()
181 static int parman_lsort_item_add(struct parman *parman, in parman_lsort_item_add() argument
189 if (parman->count + 1 > parman->limit_count) { in parman_lsort_item_add()
190 err = parman_enlarge(parman); in parman_lsort_item_add()
195 new_index = parman_lsort_new_index_find(parman, prio); in parman_lsort_item_add()
196 list_for_each_entry_reverse(prio2, &parman->prio_list, list) { in parman_lsort_item_add()
199 parman_prio_shift_down(parman, prio2); in parman_lsort_item_add()
203 parman->count++; in parman_lsort_item_add()
207 static void parman_lsort_item_remove(struct parman *parman, 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()
214 parman->count--; in parman_lsort_item_remove()
215 if (parman->limit_count - parman->count >= parman->ops->resize_step) in parman_lsort_item_remove()
216 parman_shrink(parman); in parman_lsort_item_remove()
267 struct parman *parman_create(const struct parman_ops *ops, void *priv) in parman_create()
269 struct parman *parman; in parman_create() local
271 parman = kzalloc(sizeof(*parman), GFP_KERNEL); in parman_create()
272 if (!parman) in parman_create()
274 INIT_LIST_HEAD(&parman->prio_list); in parman_create()
275 parman->ops = ops; in parman_create()
276 parman->priv = priv; in parman_create()
277 parman->limit_count = ops->base_count; in parman_create()
278 parman->algo = parman_algos[ops->algo]; in parman_create()
279 return parman; in parman_create()
289 void parman_destroy(struct parman *parman) in parman_destroy() argument
291 WARN_ON(!list_empty(&parman->prio_list)); in parman_destroy()
292 kfree(parman); in parman_destroy()
307 void parman_prio_init(struct parman *parman, struct parman_prio *prio, in parman_prio_init() argument
317 list_for_each(pos, &parman->prio_list) { in parman_prio_init()
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()