~phablet-team/ofono/ubuntu

« back to all changes in this revision

Viewing changes to plugins/mtk.c

  • Committer: CI bot
  • Author(s): Tony Espy
  • Date: 2014-07-21 18:59:07 UTC
  • mfrom: (6869.1.3 ofono-ubuntu-bzr)
  • Revision ID: ps-jenkins@lists.canonical.com-20140721185907-3ukx18fb7vpws498
  * drivers/rilmodem/sim.c: notify on SIM removal (LP: #1332306)
  * unit/rilmodem/test-sim-online: fix serial number check (LP: #1334867)
  * plugins/mtk.c: fix race condition when onlining modem
  * build, drivers/infeonmodem, drivers/rilmodem, gril,
    plugins/infeon.c, plugins/ril.*, unit: add Infeon OEM hooks
  * build, plugins/ubuntu-provision.c, ubuntu-apndb.*: re-named
    provisioning plugin code from android-* to ubuntu-*.  Also removed
    code that queries mobile-broadband-provider-info's db, and finally
    implemented a /custom hook for custom apn dbs (LP: #1315509).
 Fixes: 1315509, 1332306, 1334867
Approved by: Alfonso Sanchez-Beato, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
        int slot;
93
93
        struct ril_sim_data sim_data;
94
94
        struct ofono_devinfo *devinfo;
 
95
        struct cb_data *pending_online_cbd;
 
96
        ofono_bool_t pending_online;
95
97
};
96
98
 
97
99
/*
106
108
static void send_get_sim_status(struct ofono_modem *modem);
107
109
static int create_gril(struct ofono_modem *modem);
108
110
static gboolean mtk_connected(gpointer user_data);
 
111
static void mtk_set_online(struct ofono_modem *modem, ofono_bool_t online,
 
112
                                ofono_modem_online_cb_t callback, void *data);
109
113
 
110
114
static void mtk_debug(const char *str, void *user_data)
111
115
{
372
376
        send_get_sim_status(modem);
373
377
}
374
378
 
 
379
static struct mtk_data *ril_complement(struct mtk_data *ril)
 
380
{
 
381
        if (ril->slot == MULTISIM_SLOT_0)
 
382
                return mtk_1;
 
383
        else
 
384
                return mtk_0;
 
385
}
 
386
 
375
387
static void mtk_sim_mode_cb(struct ril_msg *message, gpointer user_data)
376
388
{
377
389
        struct cb_data *cbd = user_data;
378
390
        ofono_modem_online_cb_t cb = cbd->cb;
379
391
        struct ofono_modem *modem = cbd->user;
380
392
        struct mtk_data *ril = ofono_modem_get_data(modem);
 
393
        struct mtk_data *ril_c;
381
394
 
382
 
        ril->pending_cb = NULL;
 
395
        mtk_0->pending_cb = NULL;
383
396
 
384
397
        if (message->error == RIL_E_SUCCESS) {
385
398
                g_ril_print_response_no_args(ril->modem, message);
390
403
                                ril_error_to_string(message->error));
391
404
                CALLBACK_WITH_FAILURE(cb, cbd->data);
392
405
        }
 
406
 
 
407
        /* Execute possible pending operation on the other modem */
 
408
 
 
409
        ril_c = ril_complement(ril);
 
410
 
 
411
        if (ril_c->pending_online_cbd) {
 
412
                struct cb_data *pending_cbd = ril_c->pending_online_cbd;
 
413
                ofono_modem_online_cb_t pending_cb = pending_cbd->cb;
 
414
 
 
415
                mtk_set_online(pending_cbd->user, ril_c->pending_online,
 
416
                                pending_cb, pending_cbd->data);
 
417
 
 
418
                g_free(ril_c->pending_online_cbd);
 
419
                ril_c->pending_online_cbd = NULL;
 
420
        }
393
421
}
394
422
 
395
423
static int sim_state()
484
512
        ofono_modem_online_cb_t cb = cbd->cb;
485
513
        int current_state, next_state;
486
514
 
 
515
        /*
 
516
         * Serialize online requests to avoid incoherent states. When changing
 
517
         * the online state of *one* of the modems, we need to send a
 
518
         * DUAL_SIM_MODE_SWITCH request, which affects *both* modems. Also, when
 
519
         * we want to online one modem and at that time both modems are
 
520
         * offline a RADIO_POWERON needs to be sent before DUAL_SIM_MODE_SWITCH,
 
521
         * with the additional complexity of being disconnected from the rild
 
522
         * socket while doing the sequence. This can take some time, and we
 
523
         * cannot change the state of the other modem while the sequence is
 
524
         * happenig, as DUAL_SIM_MODE_SWITCH affects both states. Therefore, we
 
525
         * need to do this serialization, which is different from the one done
 
526
         * per modem by ofono core.
 
527
         */
 
528
        if (mtk_0->pending_cb != NULL) {
 
529
                ril->pending_online_cbd = cbd;
 
530
                ril->pending_online = online;
 
531
                return;
 
532
        }
 
533
 
487
534
        current_state = sim_state();
488
535
 
489
536
        ril->ofono_online = online;