summaryrefslogtreecommitdiffstats
path: root/drivers/atmodem/devinfo.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-12-07 14:53:18 -0600
committerDenis Kenzior <denkenz@gmail.com>2009-12-07 17:14:41 -0600
commite50efac7cc1e545551903e0d1d75cc397991708c (patch)
treeefe7779417dca2653210adcc2f080c0a0e1446cd /drivers/atmodem/devinfo.c
parentddad4d80676f27788a3cac9ecb24021706d9b7ed (diff)
downloadofono-e50efac7cc1e545551903e0d1d75cc397991708c.tar.bz2
Fix: Sometimes Option modems don't return info
When querying CGMI the Option modems sometimes just return OK, with no manufacturer information given.
Diffstat (limited to 'drivers/atmodem/devinfo.c')
-rw-r--r--drivers/atmodem/devinfo.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/drivers/atmodem/devinfo.c b/drivers/atmodem/devinfo.c
index e03389ec..06417122 100644
--- a/drivers/atmodem/devinfo.c
+++ b/drivers/atmodem/devinfo.c
@@ -54,31 +54,37 @@ static void attr_cb(gboolean ok, GAtResult *result, gpointer user_data)
ofono_devinfo_query_cb_t cb = cbd->cb;
const char *prefix = cbd->user;
struct ofono_error error;
+ int numlines = g_at_result_num_response_lines(result);
+ GAtResultIter iter;
+ const char *line;
+ int i;
decode_at_error(&error, g_at_result_final_response(result));
-
dump_response("attr_cb", ok, result);
- if (ok) {
- GAtResultIter iter;
- const char *line;
- int i;
+ if (!ok) {
+ cb(&error, NULL, cbd->data);
+ return;
+ }
+
+ if (numlines == 0) {
+ CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
+ return;
+ }
- g_at_result_iter_init(&iter, result);
+ g_at_result_iter_init(&iter, result);
- /* We have to be careful here, sometimes a stray unsolicited
- * notification will appear as part of the response and we
- * cannot rely on having a prefix to recognize the actual
- * response line. So use the last line only as the response
- */
- for (i = 0; i < g_at_result_num_response_lines(result); i++)
- g_at_result_iter_next(&iter, NULL);
+ /* We have to be careful here, sometimes a stray unsolicited
+ * notification will appear as part of the response and we
+ * cannot rely on having a prefix to recognize the actual
+ * response line. So use the last line only as the response
+ */
+ for (i = 0; i < numlines; i++)
+ g_at_result_iter_next(&iter, NULL);
- line = g_at_result_iter_raw_line(&iter);
+ line = g_at_result_iter_raw_line(&iter);
- cb(&error, fixup_return(line, prefix), cbd->data);
- } else
- cb(&error, "", cbd->data);
+ cb(&error, fixup_return(line, prefix), cbd->data);
}
static void at_query_manufacturer(struct ofono_devinfo *info,