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

Function rt_dma_controller_register

components/drivers/dma/dma.c:22–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20static RT_DEFINE_SPINLOCK(dmac_nodes_lock);
21
22rt_err_t rt_dma_controller_register(struct rt_dma_controller *ctrl)
23{
24 const char *dev_name;
25 char dma_name[RT_NAME_MAX];
26
27 if (!ctrl || !ctrl->dev || !ctrl->ops)
28 {
29 return -RT_EINVAL;
30 }
31
32 dev_name = rt_dm_dev_get_name(ctrl->dev);
33
34 if (rt_bitmap_next_set_bit(ctrl->dir_cap, 0, RT_DMA_DIR_MAX) == RT_DMA_DIR_MAX)
35 {
36 LOG_E("%s: Not direction capability", dev_name);
37
38 return -RT_EINVAL;
39 }
40
41 rt_snprintf(dma_name, sizeof(dma_name), "%s-dmac", dev_name);
42
43 rt_list_init(&ctrl->list);
44
45 rt_spin_lock(&dmac_nodes_lock);
46 rt_list_insert_before(&dmac_nodes, &ctrl->list);
47 rt_spin_unlock(&dmac_nodes_lock);
48
49 rt_list_init(&ctrl->channels_nodes);
50 rt_mutex_init(&ctrl->mutex, dma_name, RT_IPC_FLAG_PRIO);
51
52 if (ctrl->dev->ofw_node)
53 {
54 rt_dm_dev_bind_fwdata(ctrl->dev, RT_NULL, ctrl);
55 }
56
57 return RT_EOK;
58}
59
60rt_err_t rt_dma_controller_unregister(struct rt_dma_controller *ctrl)
61{

Callers

nothing calls this directly

Calls 9

rt_dm_dev_get_nameFunction · 0.85
rt_bitmap_next_set_bitFunction · 0.85
rt_snprintfFunction · 0.85
rt_list_initFunction · 0.85
rt_list_insert_beforeFunction · 0.85
rt_mutex_initFunction · 0.85
rt_dm_dev_bind_fwdataFunction · 0.85
rt_spin_lockFunction · 0.50
rt_spin_unlockFunction · 0.50

Tested by

no test coverage detected