Lines Matching refs:mgr
15 void resource_id_init(resource_id_t *mgr, int size, void **res) in resource_id_init() argument
17 if (mgr) in resource_id_init()
19 mgr->size = size; in resource_id_init()
20 mgr->_res = res; in resource_id_init()
21 mgr->noused = 0; in resource_id_init()
22 mgr->_free = RT_NULL; in resource_id_init()
23 rt_spin_lock_init(&(mgr->spinlock)); in resource_id_init()
27 int resource_id_get(resource_id_t *mgr) in resource_id_get() argument
32 level = rt_spin_lock_irqsave(&(mgr->spinlock)); in resource_id_get()
33 if (mgr->_free) in resource_id_get()
35 cur = mgr->_free; in resource_id_get()
36 mgr->_free = (void **)*mgr->_free; in resource_id_get()
37 rt_spin_unlock_irqrestore(&(mgr->spinlock), level); in resource_id_get()
38 return cur - mgr->_res; in resource_id_get()
40 else if (mgr->noused < mgr->size) in resource_id_get()
42 cur = &mgr->_res[mgr->noused++]; in resource_id_get()
43 rt_spin_unlock_irqrestore(&(mgr->spinlock), level); in resource_id_get()
44 return cur - mgr->_res; in resource_id_get()
50 void resource_id_put(resource_id_t *mgr, int no) in resource_id_put() argument
55 if (no >= 0 && no < mgr->size) in resource_id_put()
57 level = rt_spin_lock_irqsave(&(mgr->spinlock)); in resource_id_put()
58 cur = &mgr->_res[no]; in resource_id_put()
59 *cur = (void *)mgr->_free; in resource_id_put()
60 mgr->_free = cur; in resource_id_put()
61 rt_spin_unlock_irqrestore(&(mgr->spinlock), level); in resource_id_put()