@@ -71,16 +71,17 @@ __subsystem struct syscon_driver_api {
71
71
*
72
72
* @param dev The device to get the register size for.
73
73
* @param addr Where to write the base address.
74
- * @return 0 When addr was written to.
74
+ * @return 0 When @a addr was written to.
75
+ * @return -ENOSYS If the API or function isn't implemented.
75
76
*/
76
77
__syscall int syscon_get_base (const struct device * dev , uintptr_t * addr );
77
78
78
79
static inline int z_impl_syscon_get_base (const struct device * dev , uintptr_t * addr )
79
80
{
80
81
const struct syscon_driver_api * api = (const struct syscon_driver_api * )dev -> api ;
81
82
82
- if (api == NULL ) {
83
- return - ENOTSUP ;
83
+ if (( api == NULL ) || ( api -> get_base == NULL ) ) {
84
+ return - ENOSYS ;
84
85
}
85
86
86
87
return api -> get_base (dev , addr );
@@ -96,16 +97,17 @@ static inline int z_impl_syscon_get_base(const struct device *dev, uintptr_t *ad
96
97
* @param reg The register offset
97
98
* @param val The returned value read from the syscon register
98
99
*
99
- * @return 0 on success, negative on error
100
+ * @return 0 on success.
101
+ * @return -ENOSYS If the API or function isn't implemented.
100
102
*/
101
103
__syscall int syscon_read_reg (const struct device * dev , uint16_t reg , uint32_t * val );
102
104
103
105
static inline int z_impl_syscon_read_reg (const struct device * dev , uint16_t reg , uint32_t * val )
104
106
{
105
107
const struct syscon_driver_api * api = (const struct syscon_driver_api * )dev -> api ;
106
108
107
- if (api == NULL ) {
108
- return - ENOTSUP ;
109
+ if (( api == NULL ) || ( api -> read == NULL ) ) {
110
+ return - ENOSYS ;
109
111
}
110
112
111
113
return api -> read (dev , reg , val );
@@ -121,16 +123,17 @@ static inline int z_impl_syscon_read_reg(const struct device *dev, uint16_t reg,
121
123
* @param reg The register offset
122
124
* @param val The value to be written in the register
123
125
*
124
- * @return 0 on success, negative on error
126
+ * @return 0 on success.
127
+ * @return -ENOSYS If the API or function isn't implemented.
125
128
*/
126
129
__syscall int syscon_write_reg (const struct device * dev , uint16_t reg , uint32_t val );
127
130
128
131
static inline int z_impl_syscon_write_reg (const struct device * dev , uint16_t reg , uint32_t val )
129
132
{
130
133
const struct syscon_driver_api * api = (const struct syscon_driver_api * )dev -> api ;
131
134
132
- if (api == NULL ) {
133
- return - ENOTSUP ;
135
+ if (( api == NULL ) || ( api -> write == NULL ) ) {
136
+ return - ENOSYS ;
134
137
}
135
138
136
139
return api -> write (dev , reg , val );
@@ -142,13 +145,18 @@ static inline int z_impl_syscon_write_reg(const struct device *dev, uint16_t reg
142
145
* @param dev The device to get the register size for.
143
146
* @param size Pointer to write the size to.
144
147
* @return 0 for success.
148
+ * @return -ENOSYS If the API or function isn't implemented.
145
149
*/
146
150
__syscall int syscon_get_size (const struct device * dev , size_t * size );
147
151
148
152
static inline int z_impl_syscon_get_size (const struct device * dev , size_t * size )
149
153
{
150
154
const struct syscon_driver_api * api = (const struct syscon_driver_api * )dev -> api ;
151
155
156
+ if ((api == NULL ) || (api -> get_size == NULL )) {
157
+ return - ENOSYS ;
158
+ }
159
+
152
160
return api -> get_size (dev , size );
153
161
}
154
162
0 commit comments