summaryrefslogtreecommitdiff
path: root/components/drivers/serial
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2018-06-10 17:59:17 +0800
committerBernard Xiong <[email protected]>2018-06-10 17:59:17 +0800
commit884fb70fe9973eaf01a7df04941cbcb0475ba8d5 (patch)
tree7c8e3f42629e46b3d7ecb0c8507f67934d9fae47 /components/drivers/serial
parentbca65f30a90857287dc1371ddbc8d5f165691c7f (diff)
[Kernel] Add device ops feature.
Diffstat (limited to 'components/drivers/serial')
-rw-r--r--components/drivers/serial/serial.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c
index 645d083283..1de1331344 100644
--- a/components/drivers/serial/serial.c
+++ b/components/drivers/serial/serial.c
@@ -1072,6 +1072,18 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
return ret;
}
+#ifdef RT_USING_DEVICE_OPS
+const static struct rt_device_ops serial_ops =
+{
+ rt_serial_init,
+ rt_serial_open,
+ rt_serial_close,
+ rt_serial_read,
+ rt_serial_write,
+ rt_serial_control
+};
+#endif
+
/*
* serial register
*/
@@ -1090,12 +1102,16 @@ rt_err_t rt_hw_serial_register(struct rt_serial_device *serial,
device->rx_indicate = RT_NULL;
device->tx_complete = RT_NULL;
+#ifdef RT_USING_DEVICE_OPS
+ device->ops = &serial_ops;
+#else
device->init = rt_serial_init;
device->open = rt_serial_open;
device->close = rt_serial_close;
device->read = rt_serial_read;
device->write = rt_serial_write;
device->control = rt_serial_control;
+#endif
device->user_data = data;
/* register a character device */