aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-04-28 12:36:25 +0200
committerAleksander Morgado <aleksander@lanedo.com>2011-04-29 12:31:09 +0200
commita0c902bdb5f03fc4d4b58ffbfb8bb36c06bfa55f (patch)
tree307739d984a5f48b77ce1ff6fc1042a76d90fad2
parent466b6edbf72e95bdc5b563ab2ea90df79f3796ea (diff)
huawei: enable getting and setting more than one band
-rw-r--r--plugins/mm-modem-huawei-gsm.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/plugins/mm-modem-huawei-gsm.c b/plugins/mm-modem-huawei-gsm.c
index c9a8a3f8..df58d535 100644
--- a/plugins/mm-modem-huawei-gsm.c
+++ b/plugins/mm-modem-huawei-gsm.c
@@ -85,9 +85,7 @@ static BandTable bands[] = {
/* 2G second */
{ MM_MODEM_GSM_BAND_DCS, 0x00000080 },
{ MM_MODEM_GSM_BAND_EGSM, 0x00000300 }, /* 0x100 = Extended GSM, 0x200 = Primary GSM */
- { MM_MODEM_GSM_BAND_PCS, 0x00200000 },
- /* And ANY last since it's most inclusive */
- { MM_MODEM_GSM_BAND_ANY, 0x3FFFFFFF },
+ { MM_MODEM_GSM_BAND_PCS, 0x00200000 }
};
static gboolean
@@ -95,13 +93,19 @@ band_mm_to_huawei (MMModemGsmBand band, guint32 *out_huawei)
{
int i;
- for (i = 0; i < sizeof (bands) / sizeof (BandTable); i++) {
- if (bands[i].mm == band) {
- *out_huawei = bands[i].huawei;
- return TRUE;
+ /* Treat ANY as a special case: All huawei flags enabled */
+ if (band == MM_MODEM_GSM_BAND_ANY) {
+ *out_huawei = 0x3FFFFFFF;
+ return TRUE;
+ }
+
+ *out_huawei = 0;
+ for (i = 0; i < G_N_ELEMENTS (bands); i++) {
+ if (bands[i].mm & band) {
+ *out_huawei |= bands[i].huawei;
}
}
- return FALSE;
+ return (*out_huawei > 0 ? TRUE : FALSE);
}
static gboolean
@@ -109,16 +113,13 @@ band_huawei_to_mm (guint32 huawei, MMModemGsmBand *out_mm)
{
int i;
- for (i = 0; i < sizeof (bands) / sizeof (BandTable); i++) {
- /* The dongle returns a bitfield, but since we don't support that
- * yet in MM, take the "best" band and return it.
- */
+ *out_mm = 0;
+ for (i = 0; i < G_N_ELEMENTS (bands); i++) {
if (bands[i].huawei & huawei) {
- *out_mm = bands[i].mm;
- return TRUE;
+ *out_mm |= bands[i].mm;
}
}
- return FALSE;
+ return (*out_mm > 0 ? TRUE : FALSE);
}
/*****************************************************************************/