All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] he910: set modem unpowered after IO disconnect
@ 2014-05-02 14:15 Jonas Bonn
  2014-05-06 13:38 ` Denis Kenzior
  0 siblings, 1 reply; 8+ messages in thread
From: Jonas Bonn @ 2014-05-02 14:15 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1660 bytes --]

This patch address an issue with SIM hotplug.  If the SIM card is removed
while there is an active connection then the io_disconnect function
of gatchat.c pulls the rug out from under us by cleaning up the modem
chat that we hold a reference to.

This patch addresses this by hooking into the notification from
io_disconnect and setting the modem to 'unpowered' state in order to force
a reinitialization when the SIM is reinserted.

The modem is not actually powered off as that would turn off SIM detection
as well.

With this patch, SIM hotplug works reliably.
---
 plugins/he910.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/plugins/he910.c b/plugins/he910.c
index 38dbfac..999889f 100644
--- a/plugins/he910.c
+++ b/plugins/he910.c
@@ -76,6 +76,22 @@ static void he910_debug(const char *str, void *user_data)
 	ofono_info("%s%s", prefix, str);
 }
 
+static void he910_disconnected_cb(gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct he910_data *data = ofono_modem_get_data(modem);
+
+	DBG("HE910 disconnected");
+
+	ofono_modem_set_powered(modem, FALSE);
+
+	g_at_chat_unref(data->chat);
+	data->chat = NULL;
+
+	g_at_chat_unref(data->modem);
+	data->modem = NULL;
+}
+
 static GAtChat *open_device(struct ofono_modem *modem,
 				const char *key, char *debug)
 {
@@ -110,6 +126,8 @@ static GAtChat *open_device(struct ofono_modem *modem,
 	if (chat == NULL)
 		return NULL;
 
+	g_at_chat_set_disconnect_function(chat, he910_disconnected_cb, modem);
+
 	if (getenv("OFONO_AT_DEBUG"))
 		g_at_chat_set_debug(chat, he910_debug, debug);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-05-08 14:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-02 14:15 [PATCH 1/1] he910: set modem unpowered after IO disconnect Jonas Bonn
2014-05-06 13:38 ` Denis Kenzior
2014-05-07  6:29   ` Jonas Bonn
2014-05-07 16:03     ` Denis Kenzior
2014-05-07 12:14   ` [PATCH v2 1/1] he910: reset modem " Jonas Bonn
2014-05-07 16:28     ` Denis Kenzior
2014-05-08  6:41       ` Jonas Bonn
2014-05-08 14:06         ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.