Hi Kalle, On 08/10/2010 04:57 AM, Kalle Valo wrote: > On my Huawei E1552 with PIN locked SIM sim_state is 0 when calling > huawei_post_sim() and gprs context is not registered. This is because > ^SIMST notification is received only after huawei_post_sim() is called: > > Aug 10 12:38:33 tukki ofonod[6565]: plugins/huawei.c:huawei_post_sim() 0x6cdb50 > [...] > Aug 10 12:38:34 tukki ofonod[6565]: Pcui:< \r\n^SIMST:1\r\n\r\n^SRVST:2\r\n > Aug 10 12:38:34 tukki ofonod[6565]: plugins/huawei.c:notify_sim_state() 1 > > Add a test to wait for sim_state to be ready and also a call to > notify_sim_state() to call huawei_post_sim() whenever needed. So this problem affects multiple modem families and I think we should solve it a bit better. What I'm proposing is to introduce a new function to include/sim.h. Something like: void ofono_sim_ready_notify(struct ofono_sim *sim); The way it should work is as follows: When oFono determines the SIM PIN is READY, it checks whether ofono_sim_ready_notify has been called. If it hasn't, then it stalls the initialization procedure (and calling post_sim) until ofono_sim_ready_notify is called. This way if the SIM is not PIN locked, the driver can call sim_inserted and sim_ready at once. If the PIN is locked, the driver can notify sim_ready later. Regards, -Denis