MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_dm_ida_alloc

Function rt_dm_ida_alloc

components/drivers/core/dm.c:63–85  ·  view source on GitHub ↗

* @brief This function will alloc an id in an IDA object * * @param ida is the IDA object * * @return the id or -RT_EEMPTY */

Source from the content-addressed store, hash-verified

61 * @return the id or -RT_EEMPTY
62 */
63int 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

Callers 6

scsi_sd_probeFunction · 0.85
scsi_cdrom_probeFunction · 0.85
rt_led_registerFunction · 0.85
blk.cFile · 0.85
disk_add_blk_devFunction · 0.85

Calls 4

rt_bitmap_next_clear_bitFunction · 0.85
rt_bitmap_set_bitFunction · 0.85
rt_spin_lockFunction · 0.50
rt_spin_unlockFunction · 0.50

Tested by

no test coverage detected