xref: /DragonOS/kernel/src/driver/rtc/utils.rs (revision da152319797436368304cbc3f85a3b9ec049134b)
1 use alloc::sync::Arc;
2 use intertrait::cast::CastArc;
3 
4 use crate::driver::base::kobject::KObject;
5 
6 use super::{sysfs::RtcGeneralDevice, RtcDevice};
7 
8 #[inline]
kobj2rtc_device(kobj: Arc<dyn KObject>) -> Option<Arc<dyn RtcDevice>>9 pub fn kobj2rtc_device(kobj: Arc<dyn KObject>) -> Option<Arc<dyn RtcDevice>> {
10     kobj.arc_any().cast::<dyn RtcDevice>().ok()
11 }
12 
13 #[inline]
kobj2rtc_general_device(kobj: Arc<dyn KObject>) -> Option<Arc<RtcGeneralDevice>>14 pub fn kobj2rtc_general_device(kobj: Arc<dyn KObject>) -> Option<Arc<RtcGeneralDevice>> {
15     kobj.arc_any().downcast().ok()
16 }
17