From 9726e50d82e292e2be68d65d63d1e955055480a1 Mon Sep 17 00:00:00 2001 From: Mikel Astiz Date: Mon, 21 Jan 2013 16:30:22 +0100 Subject: hfpmodem: Refactor voicecall notify with foreach Define a helper function in order to use foreach statements when ofono_voicecall_notify() needs to be called. --- drivers/hfpmodem/voicecall.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'drivers/hfpmodem/voicecall.c') diff --git a/drivers/hfpmodem/voicecall.c b/drivers/hfpmodem/voicecall.c index 505601cb..97700596 100644 --- a/drivers/hfpmodem/voicecall.c +++ b/drivers/hfpmodem/voicecall.c @@ -91,6 +91,14 @@ static GSList *find_dialing(GSList *calls) return c; } +static void voicecall_notify(gpointer value, gpointer user) +{ + struct ofono_call *call = value; + struct ofono_voicecall *vc = user; + + ofono_voicecall_notify(vc, call); +} + static struct ofono_call *create_call(struct ofono_voicecall *vc, int type, int direction, int status, const char *num, int num_type, int clip) @@ -1029,15 +1037,13 @@ static void hfp_clcc_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_voicecall *vc = user_data; struct voicecall_data *vd = ofono_voicecall_get_data(vc); - GSList *l; if (!ok) return; vd->calls = at_util_parse_clcc(result); - for (l = vd->calls; l; l = l->next) - ofono_voicecall_notify(vc, l->data); + g_slist_foreach(vd->calls, voicecall_notify, vc); } static void hfp_voicecall_initialized(gboolean ok, GAtResult *result, -- cgit v1.2.3