diff options
author | Ben Chan <benchan@chromium.org> | 2012-08-19 23:27:19 -0700 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-08-20 09:17:00 +0200 |
commit | 2b5fb682c6315d27723137d8c7a7982e198a538a (patch) | |
tree | ce245d3d4e9c5b2149719d984aa5913ec233cd9c | |
parent | 3955aab25bfc5ad68678ee27ee29867c805ce57d (diff) |
icera: fix modem_load_current_bands and modem_set_bands
This patch modifies MMBroadbandModemIcera as follows:
- Change modem_load_current_bands to report only bands that are
currently enabled
- Change modem_set_bands to handle setting ANY band in a way that no
forbidden bands are activated.
-rw-r--r-- | plugins/icera/mm-broadband-modem-icera.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/plugins/icera/mm-broadband-modem-icera.c b/plugins/icera/mm-broadband-modem-icera.c index 60777c72..715758a8 100644 --- a/plugins/icera/mm-broadband-modem-icera.c +++ b/plugins/icera/mm-broadband-modem-icera.c @@ -946,6 +946,8 @@ static const Band modem_bands[] = { { MM_MODEM_BAND_ANY, "ANY", FALSE }, }; +static const guint modem_band_any_bit = 1 << (G_N_ELEMENTS (modem_bands) - 1); + static MMModemBand icera_band_to_mm (const char *icera) { @@ -1200,7 +1202,8 @@ load_current_bands_ready (MMIfaceModem *self, for (iter = parsed; iter; iter = g_slist_next (iter)) { Band *b = iter->data; - g_array_append_val (bands, b->band); + if (b->enabled) + g_array_append_val (bands, b->band); } g_slist_free_full (parsed, (GDestroyNotify) band_free); @@ -1387,15 +1390,14 @@ modem_set_bands (MMIfaceModem *self, ctx->bandbits = band_array_to_bandbits (bands_array); /* - * For the sake of efficiency, convert "ANY" to the actual set of - * bands; this matches what we get from load_current_bands and - * minimizes the number of changes we need to make. - * - * This requires that ANY is last in modem_bands and that all the - * other bits are valid. - */ - if (ctx->bandbits == (1 << (G_N_ELEMENTS (modem_bands) - 1))) - ctx->bandbits--; /* clear the top bit, set all lower bits */ + * If ANY is requested, simply enable ANY to activate all bands except for + * those forbidden. */ + if (ctx->bandbits & modem_band_any_bit) { + ctx->enablebits = modem_band_any_bit; + ctx->disablebits = 0; + set_one_band (self, ctx); + return; + } modem_load_current_bands (self, (GAsyncReadyCallback)set_bands_got_current_bands, |