* rtlink device register */
| 360 | * rtlink device register |
| 361 | */ |
| 362 | rt_err_t rt_link_dev_register(struct rt_link_device *rtlink, |
| 363 | const char *name, |
| 364 | rt_uint32_t flag, |
| 365 | void *data) |
| 366 | { |
| 367 | rt_err_t ret; |
| 368 | struct rt_device *device; |
| 369 | RT_ASSERT(rtlink != RT_NULL); |
| 370 | |
| 371 | device = (struct rt_device *)rtlink; |
| 372 | device->type = RT_Device_Class_Char; |
| 373 | device->rx_indicate = RT_NULL; |
| 374 | device->tx_complete = RT_NULL; |
| 375 | |
| 376 | #ifdef RT_USING_DEVICE_OPS |
| 377 | device->ops = &rtlink_ops; |
| 378 | #else |
| 379 | device->init = rt_link_dev_init; |
| 380 | device->open = rt_link_dev_open; |
| 381 | device->close = rt_link_dev_close; |
| 382 | device->read = rt_link_dev_read; |
| 383 | device->write = rt_link_dev_write; |
| 384 | device->control = rt_link_dev_control; |
| 385 | #endif |
| 386 | device->user_data = data; |
| 387 | |
| 388 | /* register a character device */ |
| 389 | ret = rt_device_register(device, name, flag); |
| 390 | |
| 391 | #ifdef RT_USING_POSIX_DEVIO |
| 392 | /* set fops */ |
| 393 | device->fops = &_rtlink_fops; |
| 394 | #endif |
| 395 | |
| 396 | rt_event_init(&recv_event, "rtlink_dev", RT_IPC_FLAG_FIFO); |
| 397 | return ret; |
| 398 | } |
no test coverage detected