* @brief This function will alloc an id in an IDA object * * @param ida is the IDA object * * @return the id or -RT_EEMPTY */
| 61 | * @return the id or -RT_EEMPTY |
| 62 | */ |
| 63 | int rt_dm_ida_alloc(struct rt_dm_ida *ida) |
| 64 | { |
| 65 | int id; |
| 66 | RT_ASSERT(ida != RT_NULL); |
| 67 | |
| 68 | rt_spin_lock(&ida->lock); |
| 69 | |
| 70 | id = rt_bitmap_next_clear_bit(ida->map, 0, RT_DM_IDA_NUM); |
| 71 | |
| 72 | if (id != RT_DM_IDA_NUM) |
| 73 | { |
| 74 | rt_bitmap_set_bit(ida->map, id); |
| 75 | } |
| 76 | |
| 77 | rt_spin_unlock(&ida->lock); |
| 78 | |
| 79 | if (id != RT_DM_IDA_NUM) |
| 80 | { |
| 81 | return id; |
| 82 | } |
| 83 | |
| 84 | return -RT_EEMPTY; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * @brief This function will take (force) an id in an IDA object |
no test coverage detected