3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-23 06:02:37 +01:00

watchlist: Add WATCHLIST_NOTIFY_MATCHES

This can be used to selectively notify watchlist items.  The match
function is called for each watchlist_item and match_data is passed
along.  If the match function returns true, then the watch_item is
notified.  The match function signature and semantics are identical
to l_queue_match_func_t.
This commit is contained in:
Denis Kenzior 2017-08-31 17:58:36 -05:00
parent 70079912ad
commit fa7fab196e

View File

@ -73,3 +73,22 @@ void __watchlist_prune_stale(struct watchlist *watchlist);
__watchlist_prune_stale(watchlist); \
} while (false) \
#define WATCHLIST_NOTIFY_MATCHES(watchlist, match, match_data, type, args...) \
do { \
const struct l_queue_entry *entry = \
l_queue_get_entries((watchlist)->items);\
\
(watchlist)->in_notify = true; \
for (; entry; entry = entry->next) { \
struct watchlist_item *item = entry->data; \
type t = item->notify; \
\
if (!match(item->notify_data, match_data)) \
continue; \
\
t(args, item->notify_data); \
} \
(watchlist)->in_notify = false; \
if ((watchlist)->stale_items) \
__watchlist_prune_stale(watchlist); \
} while (false)