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

Function ofw_get_reset_control

components/drivers/reset/reset.c:267–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267static struct rt_reset_control *ofw_get_reset_control(struct rt_ofw_node *np, int index,
268 const char *name, rt_bool_t is_array)
269{
270 rt_err_t err = RT_EOK;
271 struct rt_reset_control *rstc;
272 struct rt_ofw_cell_args reset_args = {};
273 struct rt_reset_controller *rstcer = RT_NULL;
274
275 if (is_array)
276 {
277 rt_size_t rstc_nr;
278 struct reset_control_array *rstc_arr;
279
280 rstc_nr = rt_ofw_count_phandle_cells(np, "resets", "#reset-cells");
281
282 if (!rstc_nr)
283 {
284 return RT_NULL;
285 }
286
287 rstc_arr = rt_calloc(1, sizeof(*rstc_arr) + sizeof(struct rt_reset_control *) * rstc_nr);
288
289 if (!rstc_arr)
290 {
291 LOG_E("No memory to create %s[%d] reset control",
292 rt_ofw_node_full_name(np), index);
293
294 return rt_err_ptr(-RT_ENOMEM);
295 }
296
297 rstc_arr->count = rstc_nr - 1;
298
299 for (int i = 0; i < rstc_arr->count; ++i)
300 {
301 rstc_arr->rstcs[i] = ofw_get_reset_control(np, i + 1, RT_NULL, RT_FALSE);
302
303 if (rt_is_err(rstc_arr->rstcs[i]))
304 {
305 err = rt_ptr_err(rstc_arr->rstcs[i]);
306
307 while (i --> 0)
308 {
309 rt_reset_control_put(rstc_arr->rstcs[i]);
310 }
311
312 rt_free(rstc_arr);
313
314 return rt_err_ptr(err);
315 }
316 }
317
318 rstc = &rstc_arr->captain;
319 rstc->is_array = RT_TRUE;
320 }
321 else
322 {
323 rstc = rt_calloc(1, sizeof(*rstc));
324

Calls 15

rt_callocFunction · 0.85
rt_ofw_node_full_nameFunction · 0.85
rt_reset_control_putFunction · 0.85
rt_freeFunction · 0.85
rt_platform_ofw_requestFunction · 0.85
rt_ofw_parse_objectFunction · 0.85
rt_ofw_node_putFunction · 0.85
rt_ofw_prop_read_boolFunction · 0.85
rt_strerrorFunction · 0.85

Tested by

no test coverage detected