diff options
| author | Bernard Xiong <[email protected]> | 2018-06-10 17:59:17 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2018-06-10 17:59:17 +0800 |
| commit | 884fb70fe9973eaf01a7df04941cbcb0475ba8d5 (patch) | |
| tree | 7c8e3f42629e46b3d7ecb0c8507f67934d9fae47 /components/drivers/can | |
| parent | bca65f30a90857287dc1371ddbc8d5f165691c7f (diff) | |
[Kernel] Add device ops feature.
Diffstat (limited to 'components/drivers/can')
| -rw-r--r-- | components/drivers/can/can.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/components/drivers/can/can.c b/components/drivers/can/can.c index 000745514c..98d76cd5b3 100644 --- a/components/drivers/can/can.c +++ b/components/drivers/can/can.c @@ -687,6 +687,18 @@ static void cantimeout(void *arg) } } +#ifdef RT_USING_DEVICE_OPS +const static struct rt_device_ops can_device_ops = +{ + rt_can_init, + rt_can_open, + rt_can_close, + rt_can_read, + rt_can_write, + rt_can_control +}; +#endif + /* * can register */ @@ -712,12 +724,17 @@ rt_err_t rt_hw_can_register(struct rt_can_device *can, #ifdef RT_CAN_USING_BUS_HOOK can->bus_hook = RT_NULL; #endif /*RT_CAN_USING_BUS_HOOK*/ + +#ifdef RT_USING_DEVICE_OPS + device->ops = &can_device_ops; +#else device->init = rt_can_init; device->open = rt_can_open; device->close = rt_can_close; device->read = rt_can_read; device->write = rt_can_write; device->control = rt_can_control; +#endif can->ops = ops; can->status_indicate.ind = RT_NULL; |
