@@ -874,9 +874,7 @@ __syscall int can_get_core_clock(const struct device *dev, uint32_t *rate);
874874
875875static inline int z_impl_can_get_core_clock (const struct device * dev , uint32_t * rate )
876876{
877- const struct can_driver_api * api = (const struct can_driver_api * )dev -> api ;
878-
879- return api -> get_core_clock (dev , rate );
877+ return DEVICE_API_GET (can , dev )-> get_core_clock (dev , rate );
880878}
881879
882880/**
@@ -940,9 +938,7 @@ __syscall const struct can_timing *can_get_timing_min(const struct device *dev);
940938
941939static inline const struct can_timing * z_impl_can_get_timing_min (const struct device * dev )
942940{
943- const struct can_driver_api * api = (const struct can_driver_api * )dev -> api ;
944-
945- return & api -> timing_min ;
941+ return & DEVICE_API_GET (can , dev )-> timing_min ;
946942}
947943
948944/**
@@ -956,9 +952,7 @@ __syscall const struct can_timing *can_get_timing_max(const struct device *dev);
956952
957953static inline const struct can_timing * z_impl_can_get_timing_max (const struct device * dev )
958954{
959- const struct can_driver_api * api = (const struct can_driver_api * )dev -> api ;
960-
961- return & api -> timing_max ;
955+ return & DEVICE_API_GET (can , dev )-> timing_max ;
962956}
963957
964958/**
@@ -1008,9 +1002,7 @@ __syscall const struct can_timing *can_get_timing_data_min(const struct device *
10081002#ifdef CONFIG_CAN_FD_MODE
10091003static inline const struct can_timing * z_impl_can_get_timing_data_min (const struct device * dev )
10101004{
1011- const struct can_driver_api * api = (const struct can_driver_api * )dev -> api ;
1012-
1013- return & api -> timing_data_min ;
1005+ return & DEVICE_API_GET (can , dev )-> timing_data_min ;
10141006}
10151007#endif /* CONFIG_CAN_FD_MODE */
10161008
@@ -1032,9 +1024,7 @@ __syscall const struct can_timing *can_get_timing_data_max(const struct device *
10321024#ifdef CONFIG_CAN_FD_MODE
10331025static inline const struct can_timing * z_impl_can_get_timing_data_max (const struct device * dev )
10341026{
1035- const struct can_driver_api * api = (const struct can_driver_api * )dev -> api ;
1036-
1037- return & api -> timing_data_max ;
1027+ return & DEVICE_API_GET (can , dev )-> timing_data_max ;
10381028}
10391029#endif /* CONFIG_CAN_FD_MODE */
10401030
@@ -1144,9 +1134,7 @@ __syscall int can_get_capabilities(const struct device *dev, can_mode_t *cap);
11441134
11451135static inline int z_impl_can_get_capabilities (const struct device * dev , can_mode_t * cap )
11461136{
1147- const struct can_driver_api * api = (const struct can_driver_api * )dev -> api ;
1148-
1149- return api -> get_capabilities (dev , cap );
1137+ return DEVICE_API_GET (can , dev )-> get_capabilities (dev , cap );
11501138}
11511139
11521140/**
@@ -1188,9 +1176,7 @@ __syscall int can_start(const struct device *dev);
11881176
11891177static inline int z_impl_can_start (const struct device * dev )
11901178{
1191- const struct can_driver_api * api = (const struct can_driver_api * )dev -> api ;
1192-
1193- return api -> start (dev );
1179+ return DEVICE_API_GET (can , dev )-> start (dev );
11941180}
11951181
11961182/**
@@ -1212,9 +1198,7 @@ __syscall int can_stop(const struct device *dev);
12121198
12131199static inline int z_impl_can_stop (const struct device * dev )
12141200{
1215- const struct can_driver_api * api = (const struct can_driver_api * )dev -> api ;
1216-
1217- return api -> stop (dev );
1201+ return DEVICE_API_GET (can , dev )-> stop (dev );
12181202}
12191203
12201204/**
@@ -1231,9 +1215,7 @@ __syscall int can_set_mode(const struct device *dev, can_mode_t mode);
12311215
12321216static inline int z_impl_can_set_mode (const struct device * dev , can_mode_t mode )
12331217{
1234- const struct can_driver_api * api = (const struct can_driver_api * )dev -> api ;
1235-
1236- return api -> set_mode (dev , mode );
1218+ return DEVICE_API_GET (can , dev )-> set_mode (dev , mode );
12371219}
12381220
12391221/**
@@ -1427,9 +1409,7 @@ __syscall void can_remove_rx_filter(const struct device *dev, int filter_id);
14271409
14281410static inline void z_impl_can_remove_rx_filter (const struct device * dev , int filter_id )
14291411{
1430- const struct can_driver_api * api = (const struct can_driver_api * )dev -> api ;
1431-
1432- api -> remove_rx_filter (dev , filter_id );
1412+ DEVICE_API_GET (can , dev )-> remove_rx_filter (dev , filter_id );
14331413}
14341414
14351415/**
@@ -1449,7 +1429,7 @@ __syscall int can_get_max_filters(const struct device *dev, bool ide);
14491429
14501430static inline int z_impl_can_get_max_filters (const struct device * dev , bool ide )
14511431{
1452- const struct can_driver_api * api = ( const struct can_driver_api * ) dev -> api ;
1432+ const struct can_driver_api * api = DEVICE_API_GET ( can , dev ) ;
14531433
14541434 if (api -> get_max_filters == NULL ) {
14551435 return - ENOSYS ;
@@ -1485,9 +1465,7 @@ __syscall int can_get_state(const struct device *dev, enum can_state *state,
14851465static inline int z_impl_can_get_state (const struct device * dev , enum can_state * state ,
14861466 struct can_bus_err_cnt * err_cnt )
14871467{
1488- const struct can_driver_api * api = (const struct can_driver_api * )dev -> api ;
1489-
1490- return api -> get_state (dev , state , err_cnt );
1468+ return DEVICE_API_GET (can , dev )-> get_state (dev , state , err_cnt );
14911469}
14921470
14931471/**
@@ -1513,7 +1491,7 @@ __syscall int can_recover(const struct device *dev, k_timeout_t timeout);
15131491#ifdef CONFIG_CAN_MANUAL_RECOVERY_MODE
15141492static inline int z_impl_can_recover (const struct device * dev , k_timeout_t timeout )
15151493{
1516- const struct can_driver_api * api = ( const struct can_driver_api * ) dev -> api ;
1494+ const struct can_driver_api * api = DEVICE_API_GET ( can , dev ) ;
15171495
15181496 if (api -> recover == NULL ) {
15191497 return - ENOSYS ;
@@ -1540,9 +1518,7 @@ static inline void can_set_state_change_callback(const struct device *dev,
15401518 can_state_change_callback_t callback ,
15411519 void * user_data )
15421520{
1543- const struct can_driver_api * api = (const struct can_driver_api * )dev -> api ;
1544-
1545- api -> set_state_change_callback (dev , callback , user_data );
1521+ DEVICE_API_GET (can , dev )-> set_state_change_callback (dev , callback , user_data );
15461522}
15471523
15481524/** @} */
0 commit comments