gpio: Improve the public API to handle multi callbacks

Many sub-systems might require to set a callback on different pins.
Thus enabling it via changing the API.

It is also possible to retrieve private-data in the callback handler
using CONTAINER_OF() macro (include/misc/util.h).

Former API is still available, and is emulated through the new one.
Using both should not be a problem as it's using new API calls.
However, it's now better to start using the new API.

Change-Id: Id16594202905976cc524775d1cd3592b54a84514
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Tomasz Bursztyka 2016-03-23 12:01:06 +01:00 committed by Anas Nashif
commit fea1c49ba2
22 changed files with 537 additions and 224 deletions

View file

@ -515,11 +515,13 @@ done:
return ret;
}
static int gpio_pcal9535a_set_callback(struct device *dev,
gpio_callback_t callback)
static int gpio_pcal9535a_manage_callback(struct device *dev,
struct gpio_callback *callback,
bool set)
{
ARG_UNUSED(dev);
ARG_UNUSED(callback);
ARG_UNUSED(set);
return -ENOTSUP;
}
@ -548,7 +550,7 @@ static struct gpio_driver_api gpio_pcal9535a_drv_api_funcs = {
.config = gpio_pcal9535a_config,
.write = gpio_pcal9535a_write,
.read = gpio_pcal9535a_read,
.set_callback = gpio_pcal9535a_set_callback,
.manage_callback = gpio_pcal9535a_manage_callback,
.enable_callback = gpio_pcal9535a_enable_callback,
.disable_callback = gpio_pcal9535a_disable_callback,
};