| 225 | } |
| 226 | |
| 227 | struct 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 | { |
no test coverage detected