From 884fb70fe9973eaf01a7df04941cbcb0475ba8d5 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Sun, 10 Jun 2018 17:59:17 +0800 Subject: [Kernel] Add device ops feature. --- components/drivers/rtc/soft_rtc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'components/drivers/rtc') diff --git a/components/drivers/rtc/soft_rtc.c b/components/drivers/rtc/soft_rtc.c index 6db2136ad4..c828e43ebc 100644 --- a/components/drivers/rtc/soft_rtc.c +++ b/components/drivers/rtc/soft_rtc.c @@ -68,6 +68,18 @@ static rt_err_t soft_rtc_control(rt_device_t dev, int cmd, void *args) return RT_EOK; } +#ifdef RT_USING_DEVICE_OPS +const static struct rt_device_ops soft_rtc_ops = +{ + RT_NULL, + RT_NULL, + RT_NULL, + RT_NULL, + RT_NULL, + soft_rtc_control +}; +#endif + int rt_soft_rtc_init(void) { static rt_bool_t init_ok = RT_FALSE; @@ -86,12 +98,16 @@ int rt_soft_rtc_init(void) soft_rtc_dev.type = RT_Device_Class_RTC; /* register rtc device */ +#ifdef RT_USING_DEVICE_OPS + soft_rtc_dev.ops = &soft_rtc_ops; +#else soft_rtc_dev.init = RT_NULL; soft_rtc_dev.open = RT_NULL; soft_rtc_dev.close = RT_NULL; soft_rtc_dev.read = RT_NULL; soft_rtc_dev.write = RT_NULL; soft_rtc_dev.control = soft_rtc_control; +#endif /* no private */ soft_rtc_dev.user_data = RT_NULL; -- cgit v1.3.1