Hi Pekka, * [email protected] <[email protected]> [2010-12-16 20:36:39 +0200]:
> From: Pekka Pessi <[email protected]> > > Ensure that SIM is ready before calling ofono_sim_inserted_notify(). > --- > plugins/zte.c | 57 > ++++++++++++++++++++++++++++++++++++++++++++++++++++----- > 1 files changed, 52 insertions(+), 5 deletions(-) > > diff --git a/plugins/zte.c b/plugins/zte.c > index 82f322a..50f6280 100644 > --- a/plugins/zte.c > +++ b/plugins/zte.c > @@ -55,6 +55,9 @@ struct zte_data { > GAtChat *aux; > struct ofono_gprs *gprs; > struct ofono_gprs_context *gc; > + struct ofono_sim *sim; > + guint poll_source; > + guint poll_count; > }; > > static int zte_probe(struct ofono_modem *modem) > @@ -221,6 +224,13 @@ static int zte_disable(struct ofono_modem *modem) > if (data->aux == NULL) > return 0; > > + data->sim = NULL; > + > + if (data->poll_source) { > + g_source_remove(data->poll_source); > + data->poll_source = 0; > + } > + > g_at_chat_cancel_all(data->aux); > g_at_chat_unregister_all(data->aux); > g_at_chat_send(data->aux, "AT+CFUN=0", none_prefix, > @@ -262,19 +272,56 @@ error: > CALLBACK_WITH_FAILURE(cb, cbd->data); > } > > +static gboolean poll_sim(gpointer user_data); Why not moving the whole function to here instead adding a its declaration here. > + > +static void sim_poll_result(gboolean ok, GAtResult *result, gpointer > user_data) > +{ > + struct ofono_modem *modem = user_data; > + struct zte_data *data = ofono_modem_get_data(modem); > + > + DBG("%p", modem); > + > + if (ok) { > + ofono_sim_inserted_notify(data->sim, ok); > + return; > + } > + > + if (++data->poll_count > 5) > + /* Give up after 5 seconds - there is probably no SIM */ s/seconds/times/ ? -- Gustavo F. Padovan http://profusion.mobi _______________________________________________ ofono mailing list [email protected] http://lists.ofono.org/listinfo/ofono
