ac74d8b652
Replace the existing Apache 2.0 boilerplate header with an SPDX tag throughout the zephyr code tree. This patch was generated via a script run over the master branch. Also updated doc/porting/application.rst that had a dependency on line numbers in a literal include. Manually updated subsys/logging/sys_log.c that had a malformed header in the original file. Also cleanup several cases that already had a SPDX tag and we either got a duplicate or missed updating. Jira: ZEP-1457 Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c Signed-off-by: David B. Kinder <david.b.kinder@intel.com> Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
61 lines
1.5 KiB
C
61 lines
1.5 KiB
C
/*
|
|
* Copyright (c) 2016 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @file Header where utility code can be found for GPIO drivers
|
|
*/
|
|
|
|
#ifndef __GPIO_UTILS_H__
|
|
#define __GPIO_UTILS_H__
|
|
|
|
|
|
/**
|
|
* @brief Generic function to insert or remove a callback from a callback list
|
|
*
|
|
* @param callbacks A pointer to the original list of callbacks (can be NULL)
|
|
* @param callback A pointer of the callback to insert or remove from the list
|
|
* @param set A boolean indicating insertion or removal of the callback
|
|
*/
|
|
static inline void _gpio_manage_callback(sys_slist_t *callbacks,
|
|
struct gpio_callback *callback,
|
|
bool set)
|
|
{
|
|
__ASSERT(callback, "No callback!");
|
|
__ASSERT(callback->handler, "No callback handler!");
|
|
|
|
if (set) {
|
|
sys_slist_prepend(callbacks, &callback->node);
|
|
} else {
|
|
sys_slist_find_and_remove(callbacks, &callback->node);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief Generic function to go through and fire callback from a callback list
|
|
*
|
|
* @param list A pointer on the gpio callback list
|
|
* @param port A pointer on the gpio driver instance
|
|
* @param pins The actual pin mask that triggered the interrupt
|
|
*/
|
|
static inline void _gpio_fire_callbacks(sys_slist_t *list,
|
|
struct device *port,
|
|
uint32_t pins)
|
|
{
|
|
struct gpio_callback *cb;
|
|
sys_snode_t *node;
|
|
|
|
SYS_SLIST_FOR_EACH_NODE(list, node) {
|
|
cb = (struct gpio_callback *)node;
|
|
|
|
if (cb->pin_mask & pins) {
|
|
__ASSERT(cb->handler, "No callback handler!");
|
|
cb->handler(port, cb, pins);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif /* __GPIO_UTILS_H__ */
|