int ril_create(struct ofono_modem *modem, enum ofono_ril_vendor vendor) { ofono_bool_t lte_cap; struct ril_data *rd = g_try_new0(struct ril_data, 1); if (rd == NULL) { errno = ENOMEM; goto error; } DBG(""); rd->vendor = vendor; rd->ofono_online = FALSE; rd->radio_state = RADIO_STATE_OFF; lte_cap = getenv("OFONO_RIL_RAT_LTE") ? TRUE : FALSE; ofono_modem_set_boolean(modem, MODEM_PROP_LTE_CAPABLE, lte_cap); ofono_modem_set_data(modem, rd); return 0; error: g_free(rd); return -errno; }
static int mtk_probe(struct ofono_modem *modem) { struct mtk_data *md = g_try_new0(struct mtk_data, 1); if (md == NULL) { errno = ENOMEM; goto error; } md->ofono_online = FALSE; md->radio_state = RADIO_STATE_UNAVAILABLE; md->suspend_id = INVALID_SUSPEND_ID; md->slot = ofono_modem_get_integer(modem, "Slot"); if (md->slot == MULTISIM_SLOT_0) mtk_data_0 = md; else mtk_data_1 = md; DBG("slot %d", md->slot); md->modem = modem; ofono_modem_set_data(modem, md); return 0; error: g_free(md); return -errno; }
static void phonesim_remove(struct ofono_modem *modem) { struct phonesim_data *data = ofono_modem_get_data(modem); DBG("%p", modem); g_free(data); ofono_modem_set_data(modem, NULL); }
static void localhfp_remove(struct ofono_modem *modem) { struct hfp_slc_info *info = ofono_modem_get_data(modem); DBG("%p", modem); g_free(info); ofono_modem_set_data(modem, NULL); }
static int cinterion_enable(struct ofono_modem *modem) { GAtChat *chat; GIOChannel *channel; GAtSyntax *syntax; GHashTable *options; const char *device; DBG("%p", modem); options = g_hash_table_new(g_str_hash, g_str_equal); if (options == NULL) return -ENOMEM; device = ofono_modem_get_string(modem, "Device"); if (device == NULL) return -EINVAL; g_hash_table_insert(options, "Baud", "115200"); g_hash_table_insert(options, "StopBits", "1"); g_hash_table_insert(options, "DataBits", "8"); g_hash_table_insert(options, "Parity", "none"); g_hash_table_insert(options, "XonXoff", "off"); g_hash_table_insert(options, "RtsCts", "on"); g_hash_table_insert(options, "Local", "on"); g_hash_table_insert(options, "Read", "on"); channel = g_at_tty_open(device, options); g_hash_table_destroy(options); if (channel == NULL) return -EIO; /* * (Cinterion plugin is based on tc65 plugin. Comment left in but may * not be applicable in the general case) * * TC65 works almost as the 27.007 says. But for example after * AT+CRSM the modem replies with the data in the queried EF and * writes three pairs of <CR><LF> after the data and before OK. */ syntax = g_at_syntax_new_gsm_permissive(); chat = g_at_chat_new(channel, syntax); g_at_syntax_unref(syntax); g_io_channel_unref(channel); if (chat == NULL) return -ENOMEM; if (getenv("OFONO_AT_DEBUG")) g_at_chat_set_debug(chat, cinterion_debug, ""); ofono_modem_set_data(modem, chat); return 0; }
static int hfp_probe(struct ofono_modem *modem) { struct hfp *hfp; DBG("modem: %p", modem); hfp = g_new0(struct hfp, 1); ofono_modem_set_data(modem, hfp); return 0; }
static int atgen_disable(struct ofono_modem *modem) { GAtChat *chat = ofono_modem_get_data(modem); DBG("%p", modem); ofono_modem_set_data(modem, NULL); g_at_chat_unref(chat); return 0; }
static void sap_remove(struct ofono_modem *modem) { struct sap_data *data = ofono_modem_get_data(modem); DBG("%p", modem); if (data->call != NULL) dbus_pending_call_cancel(data->call); g_free(data); ofono_modem_set_data(modem, NULL); }
static void telit_remove(struct ofono_modem *modem) { struct telit_data *data = ofono_modem_get_data(modem); DBG("%p", modem); ofono_modem_set_data(modem, NULL); if (data->sim_inserted_source > 0) g_source_remove(data->sim_inserted_source); g_free(data); }
void ril_remove(struct ofono_modem *modem) { struct ril_data *rd = ofono_modem_get_data(modem); ofono_modem_set_data(modem, NULL); if (!rd) return; g_ril_unref(rd->ril); g_free(rd); }
static void mtk_remove(struct ofono_modem *modem) { struct mtk_data *md = ofono_modem_get_data(modem); ofono_modem_set_data(modem, NULL); if (!md) return; g_ril_unref(md->ril); g_free(md); }
static void sierra_remove(struct ofono_modem *modem) { struct sierra_data *data = ofono_modem_get_data(modem); DBG("%p", modem); ofono_modem_set_data(modem, NULL); /* Cleanup after hot-unplug */ g_at_chat_unref(data->modem); g_free(data); }
static void ril_remove(struct ofono_modem *modem) { struct ril_data *ril = ofono_modem_get_data(modem); ofono_modem_set_data(modem, NULL); if (!ril) return; g_ril_unref(ril->modem); g_free(ril); }
static int tc65_disable(struct ofono_modem *modem) { GAtChat *chat = ofono_modem_get_data(modem); DBG("%p", modem); ofono_modem_set_data(modem, NULL); g_at_chat_send(chat, "AT+CFUN=7", NULL, NULL, NULL, NULL); g_at_chat_unref(chat); return 0; }
static int hfp_hf_probe(const char *device, const char *dev_addr, const char *adapter_addr, const char *alias) { struct ofono_modem *modem; struct hfp_data *data; char buf[256]; /* We already have this device in our hash, ignore */ if (g_hash_table_lookup(modem_hash, device) != NULL) return -EALREADY; ofono_info("Using device: %s, devaddr: %s, adapter: %s", device, dev_addr, adapter_addr); strcpy(buf, "hfp/"); bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4); modem = ofono_modem_create(buf, "hfp"); if (modem == NULL) return -ENOMEM; data = g_try_new0(struct hfp_data, 1); if (data == NULL) goto free; data->handsfree_path = g_strdup(device); if (data->handsfree_path == NULL) goto free; data->handsfree_address = g_strdup(dev_addr); if (data->handsfree_address == NULL) goto free; ofono_modem_set_data(modem, data); ofono_modem_set_name(modem, alias); ofono_modem_register(modem); g_hash_table_insert(modem_hash, g_strdup(device), modem); return 0; free: if (data != NULL) g_free(data->handsfree_path); g_free(data); ofono_modem_remove(modem); return -ENOMEM; }
static void u8500_remove(struct ofono_modem *modem) { struct isi_data *isi = ofono_modem_get_data(modem); ofono_modem_set_data(modem, NULL); if (isi == NULL) return; g_isi_pn_netlink_stop(isi->link); g_isi_client_destroy(isi->client); g_isi_modem_destroy(isi->modem); g_free(isi); }
static int localhfp_probe(struct ofono_modem *modem) { struct hfp_slc_info *info; DBG("%p", modem); info = g_try_new(struct hfp_slc_info, 1); if (info == NULL) return -ENOMEM; ofono_modem_set_data(modem, info); return 0; }
static int phonesim_probe(struct ofono_modem *modem) { struct phonesim_data *data; DBG("%p", modem); data = g_try_new0(struct phonesim_data, 1); if (data == NULL) return -ENOMEM; ofono_modem_set_data(modem, data); return 0; }
static int telit_probe(struct ofono_modem *modem) { struct telit_data *data; DBG("%p", modem); data = g_try_new0(struct telit_data, 1); if (data == NULL) return -ENOMEM; ofono_modem_set_data(modem, data); bluetooth_sap_client_register(&sap_driver, modem); return 0; }
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); /* Cleanup after hot-unplug */ g_at_chat_unref(data->chat); g_at_chat_unref(data->modem); g_free(data); }
static void hfp_remove(struct ofono_modem *modem) { struct hfp *hfp = ofono_modem_get_data(modem); struct hfp_slc_info *info = &hfp->info; DBG("modem: %p", modem); if (hfp->msg) dbus_message_unref(hfp->msg); g_at_chat_unref(info->chat); g_free(hfp); ofono_modem_set_data(modem, NULL); }
static int ril_probe(struct ofono_modem *modem) { struct ril_data *rd; ofono_bool_t lte_cap; DBG(""); rd = g_new0(struct ril_data, 1); lte_cap = getenv("OFONO_RIL_RAT_LTE") ? TRUE : FALSE; ofono_modem_set_boolean(modem, MODEM_PROP_LTE_CAPABLE, lte_cap); ofono_modem_set_data(modem, rd); return 0; }
static void ril_remove(struct ofono_modem *modem) { DBusConnection *conn = ofono_dbus_get_connection(); struct ril_data *rd = ofono_modem_get_data(modem); const char *path = ofono_modem_get_path(modem); if (g_dbus_unregister_interface(conn, path, THERMAL_MANAGEMENT_INTERFACE)) ofono_modem_remove_interface(modem, THERMAL_MANAGEMENT_INTERFACE); ofono_modem_set_data(modem, NULL); g_ril_unref(rd->ril); g_free(rd); }
static int ifx_probe(struct ofono_modem *modem) { struct ifx_data *data; DBG("%p", modem); data = g_try_new0(struct ifx_data, 1); if (data == NULL) return -ENOMEM; data->mux_ldisc = -1; data->saved_ldisc = -1; ofono_modem_set_data(modem, data); return 0; }
static void hfp_remove(struct ofono_modem *modem) { struct hfp_data *data = ofono_modem_get_data(modem); const char *obj_path = ofono_modem_get_path(modem); if (data->call != NULL) dbus_pending_call_cancel(data->call); if (g_dbus_unregister_interface(connection, obj_path, HFP_AGENT_INTERFACE)) hfp_unregister_ofono_handsfree(modem); g_free(data->handsfree_address); g_free(data->handsfree_path); g_free(data); ofono_modem_set_data(modem, NULL); }
static void ril_remove(struct ofono_modem *modem) { struct ril_data *ril = ofono_modem_get_data(modem); DBG("modem: %p ril: %p", modem, ril); ofono_modem_set_data(modem, NULL); if (!ril) return; if (ril->timer_id > 0) g_source_remove(ril->timer_id); g_ril_unref(ril->modem); g_free(ril); g_dbus_remove_watch(connection, mce_daemon_watch); if (signal_watch > 0) g_dbus_remove_watch(connection, signal_watch); }
static int ril_probe(struct ofono_modem *modem) { DBG("modem: %p", modem); struct ril_data *ril = NULL; ril = g_try_new0(struct ril_data, 1); if (ril == NULL) { errno = ENOMEM; goto error; } ril->modem = NULL; ofono_modem_set_data(modem, ril); return 0; error: g_free(ril); return -errno; }
static int ril_probe(struct ofono_modem *modem) { struct ril_data *ril = g_try_new0(struct ril_data, 1); if (ril == NULL) { errno = ENOMEM; goto error; } DBG(""); ril->have_sim = FALSE; ril->ofono_online = FALSE; ril->radio_state = RADIO_STATE_OFF; ofono_modem_set_data(modem, ril); return 0; error: g_free(ril); return -errno; }
static int atgen_enable(struct ofono_modem *modem) { GAtChat *chat; GIOChannel *channel; GAtSyntax *syntax; const char *device; const char *value; GHashTable *options; int i; DBG("%p", modem); device = ofono_modem_get_string(modem, "Device"); if (!device) return -EINVAL; options = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); if (!options) return -ENOMEM; for (i = 0; tty_opts[i]; i++) { value = ofono_modem_get_string(modem, tty_opts[i]); if (value == NULL) continue; g_hash_table_insert(options, g_strdup(tty_opts[i]), g_strdup(value)); } channel = g_at_tty_open(device, options); g_hash_table_destroy(options); if (!channel) { return -EIO; } value = ofono_modem_get_string(modem, "GsmSyntax"); if (value) { if (g_str_equal(value, "V1")) syntax = g_at_syntax_new_gsmv1(); else if (g_str_equal(value, "Permissive")) syntax = g_at_syntax_new_gsm_permissive(); else return -EINVAL; } else { syntax = g_at_syntax_new_gsmv1(); } chat = g_at_chat_new(channel, syntax); g_at_syntax_unref(syntax); g_io_channel_unref(channel); if (!chat) return -ENOMEM; if (getenv("OFONO_AT_DEBUG")) g_at_chat_set_debug(chat, atgen_debug, NULL); ofono_modem_set_data(modem, chat); return 0; }
static int u8500_probe(struct ofono_modem *modem) { const char *ifname = ofono_modem_get_string(modem, "Interface"); unsigned address = ofono_modem_get_integer(modem, "Address"); GIsiModem *isimodem; GIsiClient *client = NULL; GIsiPhonetNetlink *link = NULL; struct isi_data *isi = NULL; if (ifname == NULL) return -EINVAL; DBG("(%p) with %s", modem, ifname); isimodem = g_isi_modem_create_by_name(ifname); if (isimodem == NULL) { DBG("Interface=%s: %s", ifname, strerror(errno)); return -errno; } g_isi_modem_set_userdata(isimodem, modem); if (getenv("OFONO_ISI_DEBUG")) g_isi_modem_set_debug(isimodem, ofono_debug); if (getenv("OFONO_ISI_TRACE")) g_isi_modem_set_trace(isimodem, isi_trace); if (g_isi_pn_netlink_by_modem(isimodem)) { DBG("%s: %s", ifname, strerror(EBUSY)); errno = EBUSY; goto error; } link = g_isi_pn_netlink_start(isimodem, phonet_status_cb, modem); if (link == NULL) { DBG("%s: %s", ifname, strerror(errno)); goto error; } if (address) { int error = g_isi_pn_netlink_set_address(isimodem, address); if (error && error != -EEXIST) { DBG("g_isi_pn_netlink_set_address(): %s\n", strerror(-error)); errno = -error; goto error; } } isi = g_try_new0(struct isi_data, 1); if (isi == NULL) { errno = ENOMEM; goto error; } client = g_isi_client_create(isimodem, PN_MODEM_MCE); if (!client) goto error; g_isi_modem_set_device(isimodem, PN_DEV_MODEM); isi->modem = isimodem; isi->ifname = ifname; isi->link = link; isi->reported = -1; isi->client = client; ofono_modem_set_data(modem, isi); return 0; error: g_isi_pn_netlink_stop(link); g_isi_client_destroy(client); g_isi_modem_destroy(isimodem); g_free(isi); return -errno; }