drivers/gpio: Manage callback addition/removal properly

It needs to verify if the callback was not already installed, and if so:
if is was in controller's list.
It should return an error in case the node is not found though it was
requested to be removed.
If already inserted, it will be silently removed but added again, to
avoid circular list as stated in the bug.

Fixes #11394

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2018-11-15 09:45:54 +01:00 committed by Anas Nashif
commit 064f5f0cef
20 changed files with 37 additions and 59 deletions

View file

@ -174,9 +174,7 @@ static int gpio_mcux_manage_callback(struct device *dev,
{
struct gpio_mcux_data *data = dev->driver_data;
_gpio_manage_callback(&data->callbacks, callback, set);
return 0;
return _gpio_manage_callback(&data->callbacks, callback, set);
}
static int gpio_mcux_enable_callback(struct device *dev,
@ -412,4 +410,3 @@ static int gpio_mcux_porte_init(struct device *dev)
#endif
}
#endif /* CONFIG_GPIO_MCUX_PORTE */