diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-08-08 14:05:29 +0200 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2018-08-21 17:02:39 +0000 |
commit | 6262e844f5a8cde8554f12292611118ff85cc145 (patch) | |
tree | 44b6515649623c72c48fc27e4fb947b9ec5eb49c /plugins | |
parent | d6b1c321ef75bc4dfda065231f04cfb2b2e932ed (diff) |
xmm: new helper to get 'any' allowed mode combination
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/xmm/mm-modem-helpers-xmm.c | 31 | ||||
-rw-r--r-- | plugins/xmm/mm-modem-helpers-xmm.h | 3 |
2 files changed, 34 insertions, 0 deletions
diff --git a/plugins/xmm/mm-modem-helpers-xmm.c b/plugins/xmm/mm-modem-helpers-xmm.c index 0dc48f00..a8ede4cf 100644 --- a/plugins/xmm/mm-modem-helpers-xmm.c +++ b/plugins/xmm/mm-modem-helpers-xmm.c @@ -560,3 +560,34 @@ mm_xmm_build_xact_set_command (const MMModemModeCombination *mode, return g_string_free (command, FALSE); } + +/*****************************************************************************/ +/* Get mode to apply when ANY */ + +MMModemMode +mm_xmm_get_modem_mode_any (const GArray *combinations) +{ + guint i; + MMModemMode any = MM_MODEM_MODE_NONE; + guint any_bits_set = 0; + + for (i = 0; i < combinations->len; i++) { + MMModemModeCombination *combination; + guint bits_set; + + combination = &g_array_index (combinations, MMModemModeCombination, i); + if (combination->preferred != MM_MODEM_MODE_NONE) + continue; + bits_set = mm_count_bits_set (combination->allowed); + if (bits_set > any_bits_set) { + any_bits_set = bits_set; + any = combination->allowed; + } + } + + /* If combinations were processed via mm_xmm_parse_uact_test_response(), + * we're sure that there will be at least one combination with preferred + * 'none', so there must be some valid combination as result */ + g_assert (any != MM_MODEM_MODE_NONE); + return any; +} diff --git a/plugins/xmm/mm-modem-helpers-xmm.h b/plugins/xmm/mm-modem-helpers-xmm.h index 11c95483..abe11905 100644 --- a/plugins/xmm/mm-modem-helpers-xmm.h +++ b/plugins/xmm/mm-modem-helpers-xmm.h @@ -36,4 +36,7 @@ gchar *mm_xmm_build_xact_set_command (const MMModemModeCombination *mode, const GArray *bands, GError **error); +/* Mode to apply when ANY */ +MMModemMode mm_xmm_get_modem_mode_any (const GArray *combinations); + #endif /* MM_MODEM_HELPERS_XMM_H */ |