/* * gpio-aggregator-avm-wrapper.h * * Created on: Mar 2, 2021 * Author: cmimidis */ #ifndef DRIVERS_GPIO_GPIO_AGGREGATOR_AVM_WRAPPER_H_ #define DRIVERS_GPIO_GPIO_AGGREGATOR_AVM_WRAPPER_H_ /* * slab.h is needed by the gpio-aggregator and not explicitly included by it. * This ist done here. */ #include /* * idr_remove * idr_remove is expected to return a void pointer to a struct gpio_aggregator. * This behavior is introduced with commit d3e709e63e97e5 * A cherry pick is not easily possible since the idr subsystem is also used by * many other modules. So a change here can introduce problems outside the gpio * subsystem. * That's why the following wrapper is implemented. * Note: The next stable kernel after 4.9 (4.14) contain the updated ida_remove * function. If the kernel is updated, this wrapper and its references can be * removed safely. **/ static void *idr_remove_wrapper(struct idr *idp, int id) { void *data = idr_find(idp, id); /* * first check data as if idr_find wouldn't succeed idr_remove wouldn't * succeed either with the given id! idr_find only fails with an invalid * id or NULL given. **/ if (!data) return NULL; idr_remove(idp, id); return data; } #endif /* DRIVERS_GPIO_GPIO_AGGREGATOR_AVM_WRAPPER_H_ */