diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2020-04-03 15:47:37 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2020-04-08 16:35:09 +0200 |
commit | 0f708daf0b9bfa26193d0efbd2591bcc81ef1d44 (patch) | |
tree | bddccaec9aa07596ada387500f8a463a3d00bd1f | |
parent | fd1464cff04017f283ee296f81acb18f0c2ae7ab (diff) |
modem-helpers: port supported modes filtering to use object logging
24 files changed, 40 insertions, 27 deletions
diff --git a/plugins/cinterion/mm-broadband-modem-cinterion.c b/plugins/cinterion/mm-broadband-modem-cinterion.c index 97c4bcbc..c517288f 100644 --- a/plugins/cinterion/mm-broadband-modem-cinterion.c +++ b/plugins/cinterion/mm-broadband-modem-cinterion.c @@ -1019,7 +1019,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self, } /* Filter out those unsupported modes */ - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/plugins/linktop/mm-broadband-modem-linktop.c b/plugins/linktop/mm-broadband-modem-linktop.c index 9c3ecb79..42818920 100644 --- a/plugins/linktop/mm-broadband-modem-linktop.c +++ b/plugins/linktop/mm-broadband-modem-linktop.c @@ -88,7 +88,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self, g_array_append_val (combinations, mode); /* Filter out those unsupported modes */ - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/plugins/longcheer/mm-broadband-modem-longcheer.c b/plugins/longcheer/mm-broadband-modem-longcheer.c index 7dc6d372..8e07bdf8 100644 --- a/plugins/longcheer/mm-broadband-modem-longcheer.c +++ b/plugins/longcheer/mm-broadband-modem-longcheer.c @@ -88,7 +88,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self, g_array_append_val (combinations, mode); /* Filter out those unsupported modes */ - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/plugins/novatel/mm-broadband-modem-novatel.c b/plugins/novatel/mm-broadband-modem-novatel.c index 2675a7e0..3a07b555 100644 --- a/plugins/novatel/mm-broadband-modem-novatel.c +++ b/plugins/novatel/mm-broadband-modem-novatel.c @@ -104,7 +104,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self, g_array_append_val (combinations, mode); /* Filter out those unsupported modes */ - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/plugins/option/mm-broadband-modem-option.c b/plugins/option/mm-broadband-modem-option.c index eaf5a00c..46a70aa0 100644 --- a/plugins/option/mm-broadband-modem-option.c +++ b/plugins/option/mm-broadband-modem-option.c @@ -111,7 +111,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self, g_array_append_val (combinations, mode); /* Filter out those unsupported modes */ - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/plugins/sierra/mm-broadband-modem-sierra.c b/plugins/sierra/mm-broadband-modem-sierra.c index c1ac89ab..80db350f 100644 --- a/plugins/sierra/mm-broadband-modem-sierra.c +++ b/plugins/sierra/mm-broadband-modem-sierra.c @@ -589,7 +589,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self, } /* Filter out those unsupported modes */ - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/plugins/simtech/mm-broadband-modem-simtech.c b/plugins/simtech/mm-broadband-modem-simtech.c index f967479e..c8011862 100644 --- a/plugins/simtech/mm-broadband-modem-simtech.c +++ b/plugins/simtech/mm-broadband-modem-simtech.c @@ -850,7 +850,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self, g_array_append_val (combinations, mode); /* Filter out those unsupported modes */ - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/plugins/telit/mm-broadband-modem-mbim-telit.c b/plugins/telit/mm-broadband-modem-mbim-telit.c index 43bce7fa..248461b5 100644 --- a/plugins/telit/mm-broadband-modem-mbim-telit.c +++ b/plugins/telit/mm-broadband-modem-mbim-telit.c @@ -102,7 +102,7 @@ load_supported_modes_ready (MMIfaceModem *self, /* Filter out those unsupported modes */ combinations = mm_telit_build_modes_list(); - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/plugins/telit/mm-broadband-modem-telit.c b/plugins/telit/mm-broadband-modem-telit.c index dde60a9b..a240bb1c 100644 --- a/plugins/telit/mm-broadband-modem-telit.c +++ b/plugins/telit/mm-broadband-modem-telit.c @@ -1241,7 +1241,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self, /* Filter out those unsupported modes */ combinations = mm_telit_build_modes_list(); - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/plugins/ublox/mm-broadband-modem-ublox.c b/plugins/ublox/mm-broadband-modem-ublox.c index d5ce452a..67474d2b 100644 --- a/plugins/ublox/mm-broadband-modem-ublox.c +++ b/plugins/ublox/mm-broadband-modem-ublox.c @@ -690,7 +690,7 @@ load_supported_modes_finish (MMIfaceModem *self, if (!(combinations = mm_ublox_parse_urat_test_response (response, error))) return FALSE; - if (!(combinations = mm_ublox_filter_supported_modes (mm_iface_modem_get_model (self), combinations, error))) + if (!(combinations = mm_ublox_filter_supported_modes (mm_iface_modem_get_model (self), combinations, self, error))) return FALSE; /* Decide and store which combination to apply when ANY requested */ diff --git a/plugins/ublox/mm-modem-helpers-ublox.c b/plugins/ublox/mm-modem-helpers-ublox.c index df6b6a26..fde9c962 100644 --- a/plugins/ublox/mm-modem-helpers-ublox.c +++ b/plugins/ublox/mm-modem-helpers-ublox.c @@ -980,6 +980,7 @@ supported_modes_per_model (const gchar *model) GArray * mm_ublox_filter_supported_modes (const gchar *model, GArray *combinations, + gpointer logger, GError **error) { MMModemModeCombination mode; @@ -1002,7 +1003,7 @@ mm_ublox_filter_supported_modes (const gchar *model, all = g_array_sized_new (FALSE, FALSE, sizeof (MMModemModeCombination), 1); g_array_append_val (all, mode); - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, logger); g_array_unref (all); g_array_unref (combinations); diff --git a/plugins/ublox/mm-modem-helpers-ublox.h b/plugins/ublox/mm-modem-helpers-ublox.h index 121a9839..0b01b3df 100644 --- a/plugins/ublox/mm-modem-helpers-ublox.h +++ b/plugins/ublox/mm-modem-helpers-ublox.h @@ -115,6 +115,7 @@ gboolean mm_ublox_get_support_config (const gchar *model, GArray *mm_ublox_filter_supported_modes (const gchar *model, GArray *combinations, + gpointer logger, GError **error); /*****************************************************************************/ diff --git a/plugins/ublox/tests/test-modem-helpers-ublox.c b/plugins/ublox/tests/test-modem-helpers-ublox.c index 8f2f3664..0aa20f2b 100644 --- a/plugins/ublox/tests/test-modem-helpers-ublox.c +++ b/plugins/ublox/tests/test-modem-helpers-ublox.c @@ -294,7 +294,7 @@ compare_combinations (const gchar *response, g_assert_no_error (error); g_assert (combinations); - combinations = mm_ublox_filter_supported_modes (model, combinations, &error); + combinations = mm_ublox_filter_supported_modes (model, combinations, NULL, &error); g_assert_no_error (error); g_assert (combinations); diff --git a/plugins/wavecom/mm-broadband-modem-wavecom.c b/plugins/wavecom/mm-broadband-modem-wavecom.c index 47980d86..500d8895 100644 --- a/plugins/wavecom/mm-broadband-modem-wavecom.c +++ b/plugins/wavecom/mm-broadband-modem-wavecom.c @@ -176,7 +176,7 @@ supported_ms_classes_query_ready (MMBaseModem *self, g_array_append_val (combinations, mode); /* Filter out those unsupported modes */ - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/plugins/x22x/mm-broadband-modem-x22x.c b/plugins/x22x/mm-broadband-modem-x22x.c index 0d7794ad..a86b7a57 100644 --- a/plugins/x22x/mm-broadband-modem-x22x.c +++ b/plugins/x22x/mm-broadband-modem-x22x.c @@ -90,7 +90,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self, g_array_append_val (combinations, mode); /* Filter out those unsupported modes */ - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/plugins/xmm/mm-modem-helpers-xmm.c b/plugins/xmm/mm-modem-helpers-xmm.c index 4ccbc745..2e52d162 100644 --- a/plugins/xmm/mm-modem-helpers-xmm.c +++ b/plugins/xmm/mm-modem-helpers-xmm.c @@ -172,6 +172,7 @@ static const MMModemMode xmm_modes[] = { gboolean mm_xmm_parse_xact_test_response (const gchar *response, + gpointer logger, GArray **modes_out, GArray **bands_out, GError **error) @@ -318,7 +319,7 @@ mm_xmm_parse_xact_test_response (const gchar *response, all_modes = g_array_sized_new (FALSE, FALSE, sizeof (MMModemModeCombination), 1); g_array_append_val (all_modes, all); - filtered = mm_filter_supported_modes (all_modes, modes); + filtered = mm_filter_supported_modes (all_modes, modes, logger); if (!filtered || filtered->len == 0) { inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Empty supported mode list after frequency band filtering"); diff --git a/plugins/xmm/mm-modem-helpers-xmm.h b/plugins/xmm/mm-modem-helpers-xmm.h index f70fc346..79676cfa 100644 --- a/plugins/xmm/mm-modem-helpers-xmm.h +++ b/plugins/xmm/mm-modem-helpers-xmm.h @@ -21,6 +21,7 @@ /* AT+XACT=? response parser */ gboolean mm_xmm_parse_xact_test_response (const gchar *response, + gpointer logger, GArray **modes_out, GArray **bands_out, GError **error); diff --git a/plugins/xmm/mm-shared-xmm.c b/plugins/xmm/mm-shared-xmm.c index 2f40d787..8dfa135f 100644 --- a/plugins/xmm/mm-shared-xmm.c +++ b/plugins/xmm/mm-shared-xmm.c @@ -154,6 +154,7 @@ xact_test_ready (MMBaseModem *self, response = mm_base_modem_at_command_finish (self, res, &error); if (!response || !mm_xmm_parse_xact_test_response (response, + self, &priv->supported_modes, &priv->supported_bands, &error)) diff --git a/plugins/xmm/tests/test-modem-helpers-xmm.c b/plugins/xmm/tests/test-modem-helpers-xmm.c index 0e65c7cc..c6a3f33d 100644 --- a/plugins/xmm/tests/test-modem-helpers-xmm.c +++ b/plugins/xmm/tests/test-modem-helpers-xmm.c @@ -45,7 +45,7 @@ validate_xact_test_response (const gchar *response, gboolean ret; guint i; - ret = mm_xmm_parse_xact_test_response (response, &modes, &bands, &error); + ret = mm_xmm_parse_xact_test_response (response, NULL, &modes, &bands, &error); g_assert_no_error (error); g_assert (ret); diff --git a/plugins/zte/mm-broadband-modem-zte.c b/plugins/zte/mm-broadband-modem-zte.c index a1b24bc3..a3c81a66 100644 --- a/plugins/zte/mm-broadband-modem-zte.c +++ b/plugins/zte/mm-broadband-modem-zte.c @@ -303,7 +303,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self, } /* Filter out those unsupported modes */ - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index ac9802a4..e73bff11 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -418,7 +418,8 @@ mm_new_iso8601_time (guint year, GArray * mm_filter_supported_modes (const GArray *all, - const GArray *supported_combinations) + const GArray *supported_combinations, + gpointer log_object) { MMModemModeCombination all_item; guint i; @@ -429,6 +430,9 @@ mm_filter_supported_modes (const GArray *all, g_return_val_if_fail (all->len == 1, NULL); g_return_val_if_fail (supported_combinations != NULL, NULL); + mm_obj_dbg (log_object, "filtering %u supported mode combinations with %u modes", + supported_combinations->len, all->len); + all_item = g_array_index (all, MMModemModeCombination, 0); g_return_val_if_fail (all_item.allowed != MM_MODEM_MODE_NONE, NULL); @@ -450,14 +454,17 @@ mm_filter_supported_modes (const GArray *all, } if (filtered_combinations->len == 0) - mm_warn ("All supported mode combinations were filtered out."); + mm_obj_warn (log_object, "all supported mode combinations were filtered out"); /* Add default entry with the generic mask including all items */ if (!all_item_added) { - mm_dbg ("Adding an explicit item with all supported modes allowed"); + mm_obj_dbg (log_object, "adding an explicit item with all supported modes allowed"); g_array_append_val (filtered_combinations, all_item); } + mm_obj_dbg (log_object, "device supports %u different mode combinations", + filtered_combinations->len); + return filtered_combinations; } diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h index f22b880c..87c39b08 100644 --- a/src/mm-modem-helpers.h +++ b/src/mm-modem-helpers.h @@ -84,7 +84,8 @@ gchar *mm_new_iso8601_time (guint year, gint offset_minutes); GArray *mm_filter_supported_modes (const GArray *all, - const GArray *supported_combinations); + const GArray *supported_combinations, + gpointer log_object); GArray *mm_filter_supported_capabilities (MMModemCapability all, const GArray *supported_combinations); diff --git a/src/mm-shared-qmi.c b/src/mm-shared-qmi.c index 13b873f2..95b270a3 100644 --- a/src/mm-shared-qmi.c +++ b/src/mm-shared-qmi.c @@ -1624,7 +1624,7 @@ mm_shared_qmi_load_supported_modes (MMIfaceModem *self, } /* Filter out unsupported modes */ - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, self); g_array_unref (all); g_array_unref (combinations); diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c index 33f53b9e..f2233dc4 100644 --- a/src/tests/test-modem-helpers.c +++ b/src/tests/test-modem-helpers.c @@ -3423,7 +3423,7 @@ test_supported_mode_filter (void *f, gpointer d) /* Only 2G supported */ all = build_mode_all (MM_MODEM_MODE_2G); - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, NULL); g_assert_cmpuint (filtered->len, ==, 1); g_assert (find_mode_combination (filtered, MM_MODEM_MODE_2G, MM_MODEM_MODE_NONE)); g_array_unref (filtered); @@ -3431,7 +3431,7 @@ test_supported_mode_filter (void *f, gpointer d) /* Only 3G supported */ all = build_mode_all (MM_MODEM_MODE_3G); - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, NULL); g_assert_cmpuint (filtered->len, ==, 1); g_assert (find_mode_combination (filtered, MM_MODEM_MODE_3G, MM_MODEM_MODE_NONE)); g_array_unref (filtered); @@ -3439,7 +3439,7 @@ test_supported_mode_filter (void *f, gpointer d) /* 2G and 3G supported */ all = build_mode_all (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G); - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, NULL); g_assert_cmpuint (filtered->len, ==, 3); g_assert (find_mode_combination (filtered, MM_MODEM_MODE_2G, MM_MODEM_MODE_NONE)); g_assert (find_mode_combination (filtered, MM_MODEM_MODE_3G, MM_MODEM_MODE_NONE)); @@ -3449,7 +3449,7 @@ test_supported_mode_filter (void *f, gpointer d) /* 3G and 4G supported */ all = build_mode_all (MM_MODEM_MODE_3G | MM_MODEM_MODE_4G); - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, NULL); g_assert_cmpuint (filtered->len, ==, 3); g_assert (find_mode_combination (filtered, MM_MODEM_MODE_3G, MM_MODEM_MODE_NONE)); g_assert (find_mode_combination (filtered, MM_MODEM_MODE_4G, MM_MODEM_MODE_NONE)); @@ -3459,7 +3459,7 @@ test_supported_mode_filter (void *f, gpointer d) /* 2G, 3G and 4G supported */ all = build_mode_all (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G | MM_MODEM_MODE_4G); - filtered = mm_filter_supported_modes (all, combinations); + filtered = mm_filter_supported_modes (all, combinations, NULL); g_assert_cmpuint (filtered->len, ==, 6); g_assert (find_mode_combination (filtered, MM_MODEM_MODE_2G, MM_MODEM_MODE_NONE)); g_assert (find_mode_combination (filtered, MM_MODEM_MODE_3G, MM_MODEM_MODE_NONE)); |