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

Function rt_mbox_request_by_index

components/drivers/mailbox/mailbox.c:227–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227struct rt_mbox_chan *rt_mbox_request_by_index(struct rt_mbox_client *client, int index)
228{
229 rt_err_t err;
230 struct rt_ofw_cell_args args;
231 struct rt_ofw_node *np, *ctrl_np;
232 struct rt_mbox_controller *ctrl;
233 struct rt_mbox_chan *chan = RT_NULL;
234
235 if (!client && index < 0)
236 {
237 return rt_err_ptr(-RT_EINVAL);
238 }
239
240 np = client->dev->ofw_node;
241
242 rt_spin_lock(&mbox_ops_lock);
243
244 err = rt_ofw_parse_phandle_cells(np, "mboxes", "#mbox-cells", index, &args);
245
246 if (err)
247 {
248 chan = rt_err_ptr(err);
249 goto _out_lock;
250 }
251
252 ctrl_np = args.data;
253
254 if (!rt_ofw_data(ctrl_np))
255 {
256 rt_spin_unlock(&mbox_ops_lock);
257
258 rt_platform_ofw_request(ctrl_np);
259
260 rt_spin_lock(&mbox_ops_lock);
261 }
262
263 ctrl = rt_ofw_data(ctrl_np);
264 rt_ofw_node_put(ctrl_np);
265
266 if (ctrl)
267 {
268 int index;
269
270 if (ctrl->ops->ofw_parse)
271 {
272 index = ctrl->ops->ofw_parse(ctrl, &args);
273 }
274 else
275 {
276 index = mbox_controller_ofw_parse_default(ctrl, &args);
277 }
278
279 if (index >= 0)
280 {
281 chan = &ctrl->chans[index];
282 }
283 else
284 {

Callers 1

rt_mbox_request_by_nameFunction · 0.85

Calls 9

rt_platform_ofw_requestFunction · 0.85
rt_ofw_node_putFunction · 0.85
rt_dm_dev_get_nameFunction · 0.85
rt_strerrorFunction · 0.85
rt_mbox_releaseFunction · 0.85
rt_spin_lockFunction · 0.50
rt_spin_unlockFunction · 0.50

Tested by

no test coverage detected