---
drivers/atmodem/atutil.c | 56 ++
drivers/atmodem/atutil.h |2 +
drivers/atmodem/devinfo.c | 59 +++-
3 files changed, 62 insertions(+), 55 deletions(-)
diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
index 427b098..7d7fa1b 100644
--- a/drivers/atmodem/atutil.c
+++ b/drivers/atmodem/atutil.c
@@ -438,3 +438,59 @@ gboolean at_util_parse_cscs_query(GAtResult *result,
return FALSE;
}
+
+typedef void (*at_util_attr_cb_t)(const struct ofono_error *error,
+ const char *attribute, void *data);
+
+const char *at_util_fixup_return(const char *line, const char *prefix)
+{
+ if (g_str_has_prefix(line, prefix) == FALSE)
+ return line;
+
+ line += strlen(prefix);
+
+ while (line[0] == ' ')
+ line++;
+
+ return line;
+}
+
+void at_util_attr_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ at_util_attr_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));
+
+ 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);
+
+ /*
+* 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);
+
+ cb(&error, at_util_fixup_return(line, prefix), cbd->data);
+}
+
diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
index 3901801..cab9340 100644
--- a/drivers/atmodem/atutil.h
+++ b/drivers/atmodem/atutil.h
@@ -70,6 +70,8 @@ gboolean at_util_parse_sms_index_delivery(GAtResult *result,
const char *prefix,
gboolean at_util_parse_cscs_supported(GAtResult *result, int *supported);
gboolean at_util_parse_cscs_query(GAtResult *result,
enum at_util_charset *charset);
+const char *at_util_fixup_return(const char *line, const char *prefix);
+void at_util_attr_cb(gboolean ok, GAtResult *result, gpointer user_data);
struct cb_data {
void *cb;
diff --git a/drivers/atmodem/devinfo.c b/drivers/atmodem/devinfo.c
index 84ff898..b3ae9ad 100644
--- a/drivers/atmodem/devinfo.c
+++ b/drivers/atmodem/devinfo.c
@@ -35,57 +35,6 @@
#include "atmodem.h"
-static const char *fixup_return(const char *line, const char *prefix)
-{
- if (g_str_has_prefix(line, prefix) == FALSE)
- return line;
-
- line = line + strlen(prefix);
-
- while (line[0] == ' ')
- line++;
-
- return line;
-}
-
-static void attr_cb(gboolean ok, GAtResult *result, gpointer user_data)
-{
- struct cb_data *cbd = 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));
-
- 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);
-
- /* 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);
-
- cb(&error, fixup_return(line, prefix), cbd->data);
-}
-
static void at_query_manufacturer(struct ofono_devinfo *info,
ofono_devinfo_query_cb_t cb, void *data)
{
@@ -98,7 +47,7 @@ static void at_query_manufacturer(struct ofono_devinfo *info,
cbd->user = "+CGMI:";
if (g_at_chat_send(chat, "AT+CGMI", NULL,
- attr_cb, cbd, g_free) > 0)
+ at_util_attr_cb, cbd, g_free) > 0)
return;
error:
@@ -119,7 +68,7 @@ static void at_query_model(struct ofon