@@ -169,6 +169,10 @@ static inline int _impl_gpio_enable_callback(struct device *port,
169169 const struct gpio_driver_api * api =
170170 (const struct gpio_driver_api * )port -> driver_api ;
171171
172+ if (!api -> enable_callback ) {
173+ return - ENOTSUP ;
174+ }
175+
172176 return api -> enable_callback (port , access_op , pin );
173177}
174178
@@ -181,6 +185,10 @@ static inline int _impl_gpio_disable_callback(struct device *port,
181185 const struct gpio_driver_api * api =
182186 (const struct gpio_driver_api * )port -> driver_api ;
183187
188+ if (!api -> disable_callback ) {
189+ return - ENOTSUP ;
190+ }
191+
184192 return api -> disable_callback (port , access_op , pin );
185193}
186194/**
@@ -260,7 +268,9 @@ static inline int gpio_add_callback(struct device *port,
260268 const struct gpio_driver_api * api =
261269 (const struct gpio_driver_api * )port -> driver_api ;
262270
263- __ASSERT (callback , "Callback pointer should not be NULL" );
271+ if (!api -> manage_callback ) {
272+ return - ENOTSUP ;
273+ }
264274
265275 return api -> manage_callback (port , callback , true);
266276}
@@ -280,7 +290,9 @@ static inline int gpio_remove_callback(struct device *port,
280290 const struct gpio_driver_api * api =
281291 (const struct gpio_driver_api * )port -> driver_api ;
282292
283- __ASSERT (callback , "Callback pointer should not be NULL" );
293+ if (!api -> manage_callback ) {
294+ return - ENOTSUP ;
295+ }
284296
285297 return api -> manage_callback (port , callback , false);
286298}
@@ -405,9 +417,13 @@ __syscall int gpio_get_pending_int(struct device *dev);
405417 */
406418static inline int _impl_gpio_get_pending_int (struct device * dev )
407419{
408- struct gpio_driver_api * api ;
420+ const struct gpio_driver_api * api =
421+ (const struct gpio_driver_api * )dev -> driver_api ;
422+
423+ if (!api -> get_pending_int ) {
424+ return - ENOTSUP ;
425+ }
409426
410- api = (struct gpio_driver_api * )dev -> driver_api ;
411427 return api -> get_pending_int (dev );
412428}
413429
0 commit comments