summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/atmodem/atutil.c20
-rw-r--r--drivers/atmodem/atutil.h2
-rw-r--r--drivers/atmodem/voicecall.c24
3 files changed, 24 insertions, 22 deletions
diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
index 578522f6..26d0c259 100644
--- a/drivers/atmodem/atutil.c
+++ b/drivers/atmodem/atutil.c
@@ -81,3 +81,23 @@ gint at_util_call_compare(gconstpointer a, gconstpointer b)
return 0;
}
+unsigned int at_util_alloc_next_id(unsigned int *id_list)
+{
+ unsigned int i;
+
+ for (i = 1; i < sizeof(unsigned int) * 8; i++) {
+ if (*id_list & (1 << i))
+ continue;
+
+ *id_list |= (1 << i);
+ return i;
+ }
+
+ return 0;
+}
+
+void at_util_release_id(unsigned int *id_list, unsigned int id)
+{
+ *id_list &= ~(1 << id);
+}
+
diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
index ab9db053..0444561a 100644
--- a/drivers/atmodem/atutil.h
+++ b/drivers/atmodem/atutil.h
@@ -23,6 +23,8 @@ void decode_at_error(struct ofono_error *error, const char *final);
void dump_response(const char *func, gboolean ok, GAtResult *result);
gint at_util_call_compare_by_status(gconstpointer a, gconstpointer b);
gint at_util_call_compare(gconstpointer a, gconstpointer b);
+unsigned int at_util_alloc_next_id(unsigned int *id_list);
+void at_util_release_id(unsigned int *id_list, unsigned int id);
struct cb_data {
void *cb;
diff --git a/drivers/atmodem/voicecall.c b/drivers/atmodem/voicecall.c
index f0c8d93f..07336078 100644
--- a/drivers/atmodem/voicecall.c
+++ b/drivers/atmodem/voicecall.c
@@ -89,26 +89,6 @@ static int class_to_call_type(int cls)
}
}
-static unsigned int alloc_next_id(struct voicecall_data *d)
-{
- unsigned int i;
-
- for (i = 1; i < sizeof(d->id_list) * 8; i++) {
- if (d->id_list & (0x1 << i))
- continue;
-
- d->id_list |= (0x1 << i);
- return i;
- }
-
- return 0;
-}
-
-static void release_id(struct voicecall_data *d, unsigned int id)
-{
- d->id_list &= ~(0x1 << id);
-}
-
static struct ofono_call *create_call(struct voicecall_data *d, int type,
int direction, int status,
const char *num, int num_type, int clip)
@@ -121,7 +101,7 @@ static struct ofono_call *create_call(struct voicecall_data *d, int type,
if (!call)
return NULL;
- call->id = alloc_next_id(d);
+ call->id = at_util_alloc_next_id(&d->id_list);
call->type = type;
call->direction = direction;
call->status = status;
@@ -235,7 +215,7 @@ static void clcc_poll_cb(gboolean ok, GAtResult *result, gpointer user_data)
ofono_voicecall_disconnected(vc, oc->id,
reason, NULL);
- release_id(vd, oc->id);
+ at_util_release_id(&vd->id_list, oc->id);
o = o->next;
} else if (nc && (!oc || (nc->id < oc->id))) {