diff options
author | Denis Kenzior <denkenz@gmail.com> | 2017-10-04 11:14:25 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2017-10-05 11:08:38 -0500 |
commit | cc90b1f71e76f3136ac81da7125049a950f1ceee (patch) | |
tree | 86486d5385132d3649d096a4fe6dcad39fcf8fbd /drivers/mbimmodem/mbim.c | |
parent | db42e75a9cbada6f3249bb473c99b9059a178fee (diff) | |
download | ofono-cc90b1f71e76f3136ac81da7125049a950f1ceee.tar.gz |
mbim: Add mbim_device_cancel_group
Diffstat (limited to 'drivers/mbimmodem/mbim.c')
-rw-r--r-- | drivers/mbimmodem/mbim.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/mbimmodem/mbim.c b/drivers/mbimmodem/mbim.c index db0528c0..4eef713f 100644 --- a/drivers/mbimmodem/mbim.c +++ b/drivers/mbimmodem/mbim.c @@ -267,6 +267,29 @@ static void pending_command_free(void *pending) l_free(pending); } +static void pending_command_cancel_by_gid(void *data, void *user_data) +{ + struct pending_command *pending = data; + uint32_t gid = L_PTR_TO_UINT(user_data); + + if (pending->gid != gid) + return; + + pending_command_cancel(pending); +} + +static bool pending_command_free_by_gid(void *data, void *user_data) +{ + struct pending_command *pending = data; + uint32_t gid = L_PTR_TO_UINT(user_data); + + if (pending->gid != gid) + return false; + + pending_command_free(pending); + return true; +} + static inline uint32_t _mbim_device_get_next_tid(struct mbim_device *device) { uint32_t tid = device->next_tid; @@ -915,3 +938,19 @@ bool mbim_device_cancel(struct mbim_device *device, uint32_t tid) pending_command_cancel(pending); return true; } + +bool mbim_device_cancel_group(struct mbim_device *device, uint32_t gid) +{ + if (unlikely(!device)) + return false; + + l_queue_foreach_remove(device->pending_commands, + pending_command_free_by_gid, + L_UINT_TO_PTR(gid)); + + l_queue_foreach(device->sent_commands, + pending_command_cancel_by_gid, + L_UINT_TO_PTR(gid)); + + return true; +} |