summaryrefslogtreecommitdiffstats
path: root/plugins/telit.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2011-09-29 10:48:23 -0500
committerDenis Kenzior <denkenz@gmail.com>2011-09-29 10:48:23 -0500
commit019f0c92653a6547c9b07fecddab0ce87ed9736f (patch)
tree9cd5152551744d09adc7a9e21149ce2352039b1d /plugins/telit.c
parentc035b1af4824ca7e2d2e115cf104a367f7d3140b (diff)
downloadofono-019f0c92653a6547c9b07fecddab0ce87ed9736f.tar.bz2
telit: Reflow sap_enable logic
To cover some conditions where we do not clean up properly
Diffstat (limited to 'plugins/telit.c')
-rw-r--r--plugins/telit.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/plugins/telit.c b/plugins/telit.c
index cb34ae60..d2f6c5af 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -279,10 +279,6 @@ static int telit_sap_enable(struct ofono_modem *modem,
DBG("%p", modem);
- data->aux = open_device(modem, "Data", "Aux: ");
- if (data->aux == NULL)
- return -EINVAL;
-
fd = telit_sap_open();
if (fd < 0)
return fd;
@@ -297,25 +293,26 @@ static int telit_sap_enable(struct ofono_modem *modem,
g_io_channel_set_buffered(data->hw_io, FALSE);
g_io_channel_set_close_on_unref(data->hw_io, TRUE);
- data->hw_watch = g_io_add_watch_full(data->hw_io, G_PRIORITY_DEFAULT,
- G_IO_HUP | G_IO_ERR | G_IO_NVAL | G_IO_IN,
- hw_event_cb, modem, hw_watch_remove);
+ data->aux = open_device(modem, "Data", "Aux: ");
+ if (data->aux == NULL)
+ goto error;
data->bt_io = g_io_channel_unix_new(bt_fd);
- if (data->bt_io == NULL) {
- sap_close_io(modem);
- return -ENOMEM;
- }
+ if (data->bt_io == NULL)
+ goto error;
g_io_channel_set_encoding(data->bt_io, NULL, NULL);
g_io_channel_set_buffered(data->bt_io, FALSE);
g_io_channel_set_close_on_unref(data->bt_io, TRUE);
+ data->hw_watch = g_io_add_watch_full(data->hw_io, G_PRIORITY_DEFAULT,
+ G_IO_HUP | G_IO_ERR | G_IO_NVAL | G_IO_IN,
+ hw_event_cb, modem, hw_watch_remove);
+
data->bt_watch = g_io_add_watch_full(data->bt_io, G_PRIORITY_DEFAULT,
G_IO_HUP | G_IO_ERR | G_IO_NVAL | G_IO_IN,
bt_event_cb, modem, bt_watch_remove);
-
data->sap_modem = sap_modem;
g_at_chat_register(data->aux, "#RSEN:", telit_rsen_notify,
@@ -328,6 +325,10 @@ static int telit_sap_enable(struct ofono_modem *modem,
rsen_enable_cb, modem, NULL);
return -EINPROGRESS;
+
+error:
+ sap_close_io(modem);
+ return -EINVAL;
}
static struct bluetooth_sap_driver sap_driver = {