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

Function rt_clk_register

components/drivers/clk/clk.c:214–269  ·  view source on GitHub ↗

* @brief Register clock node into clock list * * @param clk_np point to child node that will be registered node. * @param parent_np point to parent rt_clk. If it is RT_NULL, clock node will be linked to init node. * * @retval RT_EOK * @retval -RT_ENOMEM */

Source from the content-addressed store, hash-verified

212 * @retval -RT_ENOMEM
213 */
214rt_err_t rt_clk_register(struct rt_clk_node *clk_np, struct rt_clk_node *parent_np)
215{
216 rt_err_t err = RT_EOK;
217 struct rt_clk *clk = RT_NULL;
218
219 if (clk_np)
220 {
221 clk_np->clk = clk;
222
223 if (!clk_np->ops)
224 {
225 clk_np->ops = &unused_clk_ops;
226 }
227
228 #if RT_NAME_MAX > 0
229 rt_strncpy(clk_np->rt_parent.name, RT_CLK_NODE_OBJ_NAME, RT_NAME_MAX);
230 #else
231 clk_np->rt_parent.name = RT_CLK_NODE_OBJ_NAME;
232 #endif
233
234 rt_ref_init(&clk_np->ref);
235 rt_list_init(&clk_np->list);
236 rt_list_init(&clk_np->children_nodes);
237 clk_np->multi_clk = 0;
238
239 if (parent_np)
240 {
241 clk_np->clk = clk_alloc(clk_np, RT_NULL, RT_NULL, RT_NULL);
242
243 if (clk_np->clk)
244 {
245 clk_set_parent(clk_np, parent_np);
246 }
247 else
248 {
249 err = -RT_ENOMEM;
250 }
251 }
252 else
253 {
254 clk_np->parent = RT_NULL;
255
256 rt_hw_spin_lock(&_clk_lock.lock);
257
258 rt_list_insert_after(&_clk_nodes, &clk_np->list);
259
260 rt_hw_spin_unlock(&_clk_lock.lock);
261 }
262 }
263 else
264 {
265 err = -RT_ENOMEM;
266 }
267
268 return err;
269}
270
271/**

Callers 3

fixed_clk_probeFunction · 0.85
clk_rk3568_probeFunction · 0.85
clk_rk3588_probeFunction · 0.85

Calls 8

rt_strncpyFunction · 0.85
rt_ref_initFunction · 0.85
rt_list_initFunction · 0.85
clk_allocFunction · 0.85
rt_list_insert_afterFunction · 0.85
clk_set_parentFunction · 0.70
rt_hw_spin_lockFunction · 0.50
rt_hw_spin_unlockFunction · 0.50

Tested by

no test coverage detected