All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] telit: notify sim inserted when sim ready
@ 2012-07-26 13:36 Christopher Vogl
  2012-07-26 15:19 ` Andrea Galbusera
  0 siblings, 1 reply; 7+ messages in thread
From: Christopher Vogl @ 2012-07-26 13:36 UTC (permalink / raw)
  To: ofono

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

Use AT#QSS=2 instead of AT#QSS=1 to get an URC when the SIM is not only
inserted but ready to be used.

Remove sim_inserted_source and sim_inserted_timeout_cb which are not needed anymore as a
consequence. By the way the 1 second timeout was an ugly hack.
---
 plugins/telit.c |   32 ++------------------------------
 1 files changed, 2 insertions(+), 30 deletions(-)

diff --git a/plugins/telit.c b/plugins/telit.c
index 6ae7249..7fc2666 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -68,7 +68,6 @@ struct telit_data {
 	GAtChat *chat;
 	GAtChat *aux;
 	struct ofono_sim *sim;
-	guint sim_inserted_source;
 	struct ofono_modem *sap_modem;
 	GIOChannel *bt_io;
 	GIOChannel *hw_io;
@@ -211,20 +210,6 @@ static GAtChat *open_device(struct ofono_modem *modem,
 	return chat;
 }
 
-static gboolean sim_inserted_timeout_cb(gpointer user_data)
-{
-	struct ofono_modem *modem = user_data;
-	struct telit_data *data = ofono_modem_get_data(modem);
-
-	DBG("%p", modem);
-
-	data->sim_inserted_source = 0;
-
-	ofono_sim_inserted_notify(data->sim, TRUE);
-
-	return FALSE;
-}
-
 static void switch_sim_state_status(struct ofono_modem *modem, int status)
 {
 	struct telit_data *data = ofono_modem_get_data(modem);
@@ -238,16 +223,13 @@ static void switch_sim_state_status(struct ofono_modem *modem, int status)
 		break;
 	case 1:
 		DBG("SIM inserted");
-		/* We need to sleep a bit */
-		data->sim_inserted_source = g_timeout_add_seconds(1,
-							sim_inserted_timeout_cb,
-							modem);
 		break;
 	case 2:
 		DBG("SIM inserted and PIN unlocked");
 		break;
 	case 3:
 		DBG("SIM inserted and ready");
+		ofono_sim_inserted_notify(data->sim, TRUE);
 		break;
 	}
 }
@@ -308,7 +290,7 @@ static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	ofono_modem_set_powered(m, TRUE);
 
 	/* Enable sim state notification */
-	g_at_chat_send(data->chat, "AT#QSS=1", none_prefix, NULL, NULL, NULL);
+	g_at_chat_send(data->chat, "AT#QSS=2", none_prefix, NULL, NULL, NULL);
 
 	/* Follow sim state */
 	g_at_chat_register(data->chat, "#QSS:", telit_qss_notify,
@@ -397,9 +379,6 @@ static void cfun_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	g_at_chat_unref(data->chat);
 	data->chat = NULL;
 
-	if (data->sim_inserted_source > 0)
-		g_source_remove(data->sim_inserted_source);
-
 	if (ok)
 		ofono_modem_set_powered(modem, FALSE);
 
@@ -650,18 +629,11 @@ static int telit_probe(struct ofono_modem *modem)
 
 static void telit_remove(struct ofono_modem *modem)
 {
-	struct telit_data *data = ofono_modem_get_data(modem);
-
 	DBG("%p", modem);
 
 	bluetooth_sap_client_unregister(modem);
 
 	ofono_modem_set_data(modem, NULL);
-
-	if (data->sim_inserted_source > 0)
-		g_source_remove(data->sim_inserted_source);
-
-	g_free(data);
 }
 
 static struct ofono_modem_driver telit_driver = {
-- 
1.7.7.6


--
Scanned by MailScanner.


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

end of thread, other threads:[~2012-07-27 12:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-26 13:36 [PATCH] telit: notify sim inserted when sim ready Christopher Vogl
2012-07-26 15:19 ` Andrea Galbusera
2012-07-27  9:37   ` Christopher Vogl
2012-07-27  9:58     ` Andrea Galbusera
2012-07-27 10:54       ` Christopher Vogl
2012-07-27 11:52         ` Christopher Vogl
2012-07-27 12:39           ` Andrea Galbusera

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.