mirror of git://git.sysmocom.de/ofono
G1: move chat handling into enable callback
This updates the g1 code to create the GAtChat object in the enable() callback, and to unref it in the disable() callback. This is more in line with what the other plugins do, and as a bonus fixes a segfault when powering down the G1 modem.. Signed-off-by: Andres Salomon <dilinger@collabora.co.uk>
This commit is contained in:
parent
128d129ef5
commit
4decda3f7f
56
plugins/g1.c
56
plugins/g1.c
|
@ -56,6 +56,29 @@ static void g1_debug(const char *str, void *data)
|
|||
|
||||
/* Detect hardware, and initialize if found */
|
||||
static int g1_probe(struct ofono_modem *modem)
|
||||
{
|
||||
DBG("");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void g1_remove(struct ofono_modem *modem)
|
||||
{
|
||||
DBG("");
|
||||
}
|
||||
|
||||
static void cfun_set_on_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct ofono_modem *modem = user_data;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (ok)
|
||||
ofono_modem_set_powered(modem, TRUE);
|
||||
}
|
||||
|
||||
/* power up hardware */
|
||||
static int g1_enable(struct ofono_modem *modem)
|
||||
{
|
||||
GAtSyntax *syntax;
|
||||
GAtChat *chat;
|
||||
|
@ -79,36 +102,6 @@ static int g1_probe(struct ofono_modem *modem)
|
|||
|
||||
ofono_modem_set_data(modem, chat);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void g1_remove(struct ofono_modem *modem)
|
||||
{
|
||||
GAtChat *chat = ofono_modem_get_data(modem);
|
||||
|
||||
DBG("");
|
||||
|
||||
ofono_modem_set_data(modem, NULL);
|
||||
g_at_chat_unref(chat);
|
||||
}
|
||||
|
||||
static void cfun_set_on_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct ofono_modem *modem = user_data;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (ok)
|
||||
ofono_modem_set_powered(modem, TRUE);
|
||||
}
|
||||
|
||||
/* power up hardware */
|
||||
static int g1_enable(struct ofono_modem *modem)
|
||||
{
|
||||
GAtChat *chat = ofono_modem_get_data(modem);
|
||||
|
||||
DBG("");
|
||||
|
||||
/* ensure modem is in a known state; verbose on, echo/quiet off */
|
||||
g_at_chat_send(chat, "ATE0Q0V1", NULL, NULL, NULL, NULL);
|
||||
|
||||
|
@ -137,6 +130,9 @@ static int g1_disable(struct ofono_modem *modem)
|
|||
/* power down modem */
|
||||
g_at_chat_send(chat, "AT+CFUN=0", NULL, cfun_set_off_cb, modem, NULL);
|
||||
|
||||
g_at_chat_unref(chat);
|
||||
ofono_modem_set_data(modem, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue