@@ -216,7 +216,7 @@ static void create_voice_cb(struct qmi_service *service, void *user_data)
return;
}
- bd->voice = qmi_service_ref(service);
+ bd->voice = service;
ofono_call_barring_register(barr);
}
@@ -248,7 +248,7 @@ static void qmi_call_barring_remove(struct ofono_call_barring *barr)
ofono_call_barring_set_data(barr, NULL);
if (bd->voice)
- qmi_service_unref(bd->voice);
+ qmi_service_free(bd->voice);
l_free(bd);
}
@@ -302,7 +302,7 @@ static void create_voice_cb(struct qmi_service *service, void *user_data)
return;
}
- cfd->voice = qmi_service_ref(service);
+ cfd->voice = service;
ofono_call_forwarding_register(cf);
}
@@ -334,7 +334,7 @@ static void qmi_call_forwarding_remove(struct ofono_call_forwarding *cf)
ofono_call_forwarding_set_data(cf, NULL);
if (cfd->voice)
- qmi_service_unref(cfd->voice);
+ qmi_service_free(cfd->voice);
l_free(cfd);
}
@@ -288,7 +288,7 @@ static void create_voice_cb(struct qmi_service *service, void *user_data)
return;
}
- csd->voice = qmi_service_ref(service);
+ csd->voice = service;
csd->sups_ind_id = qmi_service_register(csd->voice, QMI_VOICE_SUPS_IND,
sups_ind, cs, NULL);
@@ -324,7 +324,7 @@ static void qmi_call_settings_remove(struct ofono_call_settings *cs)
if (csd->voice) {
qmi_service_unregister(csd->voice, csd->sups_ind_id);
- qmi_service_unref(csd->voice);
+ qmi_service_free(csd->voice);
}
l_free(csd);
@@ -232,7 +232,7 @@ static void create_dms_cb(struct qmi_service *service, void *user_data)
return;
}
- data->dms = qmi_service_ref(service);
+ data->dms = service;
data->device_is_3gpp = false;
qmi_query_caps(devinfo);
@@ -264,7 +264,7 @@ static void qmi_devinfo_remove(struct ofono_devinfo *devinfo)
ofono_devinfo_set_data(devinfo, NULL);
- qmi_service_unref(data->dms);
+ qmi_service_free(data->dms);
l_free(data);
}
@@ -467,7 +467,7 @@ static void create_wds_cb(struct qmi_service *service, void *user_data)
return;
}
- data->wds = qmi_service_ref(service);
+ data->wds = service;
qmi_service_register(data->wds, QMI_WDS_PACKET_SERVICE_STATUS,
pkt_status_notify, gc, NULL);
@@ -504,7 +504,7 @@ static void qmi_gprs_context_remove(struct ofono_gprs_context *gc)
ofono_gprs_context_set_data(gc, NULL);
if (data->wds)
- qmi_service_unref(data->wds);
+ qmi_service_free(data->wds);
l_free(data);
}
@@ -350,7 +350,7 @@ static void create_wds_cb(struct qmi_service *service, void *user_data)
return;
}
- data->wds = qmi_service_ref(service);
+ data->wds = service;
/*
* First get the SS info - the modem may already be connected,
@@ -382,7 +382,7 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)
return;
}
- data->nas = qmi_service_ref(service);
+ data->nas = service;
qmi_service_create_shared(data->dev, QMI_SERVICE_WDS,
create_wds_cb, gprs, NULL);
@@ -416,7 +416,7 @@ static void qmi_gprs_remove(struct ofono_gprs *gprs)
ofono_gprs_set_data(gprs, NULL);
- qmi_service_unref(data->wds);
+ qmi_service_free(data->wds);
if (data->serving_system_indication_id) {
qmi_service_unregister(data->nas,
@@ -424,7 +424,7 @@ static void qmi_gprs_remove(struct ofono_gprs *gprs)
data->serving_system_indication_id = 0;
}
- qmi_service_unref(data->nas);
+ qmi_service_free(data->nas);
l_free(data);
}
@@ -208,7 +208,7 @@ static void create_pds_cb(struct qmi_service *service, void *user_data)
return;
}
- data->pds = qmi_service_ref(service);
+ data->pds = service;
qmi_service_register(data->pds, QMI_PDS_EVENT,
event_notify, lr, NULL);
@@ -257,7 +257,7 @@ static void qmi_location_reporting_remove(struct ofono_location_reporting *lr)
ofono_location_reporting_set_data(lr, NULL);
- qmi_service_unref(data->pds);
+ qmi_service_free(data->pds);
l_free(data);
}
@@ -183,7 +183,7 @@ static void create_wds_cb(struct qmi_service *service, void *user_data)
return;
}
- ldd->wds = qmi_service_ref(service);
+ ldd->wds = service;
/* Query the default profile */
param = qmi_param_new();
@@ -228,7 +228,7 @@ static void qmimodem_lte_remove(struct ofono_lte *lte)
ofono_lte_set_data(lte, NULL);
- qmi_service_unref(ldd->wds);
+ qmi_service_free(ldd->wds);
l_free(ldd);
}
@@ -222,7 +222,7 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)
return;
}
- nmd->nas = qmi_service_ref(service);
+ nmd->nas = service;
ofono_netmon_register(netmon);
}
@@ -253,7 +253,7 @@ static void qmi_netmon_remove(struct ofono_netmon *netmon)
ofono_netmon_set_data(netmon, NULL);
- qmi_service_unref(nmd->nas);
+ qmi_service_free(nmd->nas);
l_free(nmd);
}
@@ -657,7 +657,7 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)
goto error;
}
- data->nas = qmi_service_ref(service);
+ data->nas = service;
param = qmi_param_new();
@@ -733,7 +733,7 @@ static void qmi_netreg_remove(struct ofono_netreg *netreg)
data->signal_info_indication_id = 0;
}
- qmi_service_unref(data->nas);
+ qmi_service_free(data->nas);
l_free(data);
}
@@ -133,7 +133,6 @@ struct service_family {
};
struct qmi_service {
- int ref_count;
unsigned int handle; /* Uniquely identifies this client's reqs */
struct service_family *family;
};
@@ -1510,7 +1509,6 @@ static struct qmi_service *service_create(struct service_family *family)
device->next_service_handle = 1;
service = l_new(struct qmi_service, 1);
- service->ref_count = 1;
service->handle = device->next_service_handle++;
service->family = service_family_ref(family);
@@ -1531,7 +1529,6 @@ static void service_create_shared_reply(struct l_idle *idle, void *user_data)
service = service_create(data->family);
DISCOVERY_DONE(data, service, data->user_data);
- qmi_service_unref(service);
}
static void service_create_shared_pending_reply(struct qmi_device *device,
@@ -1844,7 +1841,6 @@ done:
service_create_shared_pending_reply(device, data->type, family);
DISCOVERY_DONE(data, service, data->user_data);
- qmi_service_unref(service);
}
static int qmi_device_qmux_client_create(struct qmi_device *device,
@@ -2724,22 +2720,11 @@ bool qmi_service_create(struct qmi_device *device,
user_data, destroy);
}
-struct qmi_service *qmi_service_ref(struct qmi_service *service)
-{
- if (service)
- service->ref_count++;
-
- return service;
-}
-
-void qmi_service_unref(struct qmi_service *service)
+void qmi_service_free(struct qmi_service *service)
{
if (!service)
return;
- if (--service->ref_count)
- return;
-
qmi_service_cancel_all(service);
qmi_service_unregister_all(service);
@@ -156,9 +156,7 @@ bool qmi_service_create(struct qmi_device *device,
bool qmi_service_create_shared(struct qmi_device *device,
uint16_t type, qmi_create_func_t func,
void *user_data, qmi_destroy_func_t destroy);
-
-struct qmi_service *qmi_service_ref(struct qmi_service *service);
-void qmi_service_unref(struct qmi_service *service);
+void qmi_service_free(struct qmi_service *service);
const char *qmi_service_get_identifier(struct qmi_service *service);
bool qmi_service_get_version(struct qmi_service *service,
@@ -222,7 +222,7 @@ static void create_dms_cb(struct qmi_service *service, void *user_data)
if (!service)
return;
- data->dms = qmi_service_ref(service);
+ data->dms = service;
}
static void create_nas_cb(struct qmi_service *service, void *user_data)
@@ -244,7 +244,7 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)
return;
}
- data->nas = qmi_service_ref(service);
+ data->nas = service;
ofono_radio_settings_register(rs);
}
@@ -277,8 +277,8 @@ static void qmi_radio_settings_remove(struct ofono_radio_settings *rs)
ofono_radio_settings_set_data(rs, NULL);
- qmi_service_unref(data->dms);
- qmi_service_unref(data->nas);
+ qmi_service_free(data->dms);
+ qmi_service_free(data->nas);
l_free(data);
}
@@ -323,7 +323,7 @@ static void create_dms_cb(struct qmi_service *service, void *user_data)
return;
}
- data->dms = qmi_service_ref(service);
+ data->dms = service;
data->event_indication_id =
qmi_service_register(data->dms, QMI_DMS_EVENT,
@@ -379,7 +379,7 @@ static void qmi_sim_remove(struct ofono_sim *sim)
data->event_indication_id = 0;
}
- qmi_service_unref(data->dms);
+ qmi_service_free(data->dms);
l_free(data);
}
@@ -869,7 +869,7 @@ static void create_uim_cb(struct qmi_service *service, void *user_data)
goto error;
}
- data->uim = qmi_service_ref(service);
+ data->uim = service;
param = qmi_param_new_uint32(QMI_UIM_PARAM_EVENT_MASK, mask);
@@ -894,7 +894,7 @@ static void create_dms_cb(struct qmi_service *service, void *user_data)
return;
}
- data->dms = qmi_service_ref(service);
+ data->dms = service;
qmi_service_create(data->qmi_dev, QMI_SERVICE_UIM, create_uim_cb, sim,
NULL);
@@ -938,12 +938,12 @@ static void qmi_sim_remove(struct ofono_sim *sim)
data->card_status_indication_id = 0;
}
- qmi_service_unref(data->uim);
+ qmi_service_free(data->uim);
data->uim = NULL;
}
if (data->dms) {
- qmi_service_unref(data->dms);
+ qmi_service_free(data->dms);
data->dms = NULL;
}
@@ -759,7 +759,7 @@ static void create_wms_cb(struct qmi_service *service, void *user_data)
return;
}
- data->wms = qmi_service_ref(service);
+ data->wms = service;
memset(&data->rd_msg_id, 0, sizeof(data->rd_msg_id));
data->msg_mode = QMI_WMS_MESSAGE_MODE_GSMWCDMA;
@@ -801,7 +801,7 @@ static void qmi_sms_remove(struct ofono_sms *sms)
ofono_sms_set_data(sms, NULL);
- qmi_service_unref(data->wms);
+ qmi_service_free(data->wms);
if (data->msg_list)
l_free(data->msg_list);
@@ -178,7 +178,7 @@ static void create_voice_cb(struct qmi_service *service, void *user_data)
return;
}
- data->voice = qmi_service_ref(service);
+ data->voice = service;
qmi_service_register(data->voice, QMI_VOICE_USSD_IND,
async_ind, ussd, NULL);
@@ -215,7 +215,7 @@ static void qmi_ussd_remove(struct ofono_ussd *ussd)
ofono_ussd_set_data(ussd, NULL);
- qmi_service_unref(data->voice);
+ qmi_service_free(data->voice);
l_free(data);
}
@@ -618,7 +618,7 @@ static void create_voice_cb(struct qmi_service *service, void *user_data)
return;
}
- data->voice = qmi_service_ref(service);
+ data->voice = service;
qmi_service_register(data->voice, QMI_VOICE_ALL_CALL_STATUS_IND,
all_call_status_ind, vc, NULL);
@@ -653,7 +653,7 @@ static void qmi_voicecall_remove(struct ofono_voicecall *vc)
ofono_voicecall_set_data(vc, NULL);
- qmi_service_unref(data->voice);
+ qmi_service_free(data->voice);
l_queue_destroy(data->call_list, l_free);
l_free(data);
@@ -124,10 +124,10 @@ static int gobi_probe(struct ofono_modem *modem)
static void cleanup_services(struct gobi_data *data)
{
- qmi_service_unref(data->dms);
+ qmi_service_free(data->dms);
data->dms = NULL;
- qmi_service_unref(data->wda);
+ qmi_service_free(data->wda);
data->wda = NULL;
}
@@ -330,7 +330,7 @@ static void create_wda_cb(struct qmi_service *service, void *user_data)
goto error;
}
- data->wda = qmi_service_ref(service);
+ data->wda = service;
if (qmi_service_send(data->wda, QMI_WDA_GET_DATA_FORMAT, NULL,
get_data_format_cb, modem, NULL) > 0)
@@ -354,7 +354,7 @@ static void create_dms_cb(struct qmi_service *service, void *user_data)
if (!service)
goto error;
- data->dms = qmi_service_ref(service);
+ data->dms = service;
if (qmi_service_create(data->device, QMI_SERVICE_WDA,
create_wda_cb, modem, NULL))
@@ -173,7 +173,7 @@ static void test_cleanup(struct test_info *info)
l_free(info->received);
l_timeout_remove(info->timeout);
l_queue_destroy(info->services,
- (l_queue_destroy_func_t) qmi_service_unref);
+ (l_queue_destroy_func_t) qmi_service_free);
qmi_device_free(info->device);
/* The qrtr services will be destroyed automatically. */
@@ -220,7 +220,6 @@ static void create_service_cb(struct qmi_service *service, void *user_data)
{
struct test_info *info = user_data;
- service = qmi_service_ref(service);
l_queue_push_tail(info->services, service);
}
@@ -259,7 +258,7 @@ static void test_create_services(const void *data)
assert(major == unique_service_version(i));
assert(minor == 0);
- qmi_service_unref(service);
+ qmi_service_free(service);
}
/*
@@ -286,7 +285,7 @@ static void test_create_services(const void *data)
}
for (i = 0; i < L_ARRAY_SIZE(services); i++)
- qmi_service_unref(services[i]);
+ qmi_service_free(services[i]);
test_cleanup(info);
}
@@ -470,7 +469,7 @@ static void test_send_data(const void *data)
send_response_to_client(info, io);
l_io_destroy(io);
- qmi_service_unref(service);
+ qmi_service_free(service);
test_cleanup(info);
}
@@ -528,7 +527,7 @@ static void test_notifications(const void *data)
while (!info->notify_callback_called)
l_main_iterate(-1);
- qmi_service_unref(service);
+ qmi_service_free(service);
/* Confirm no notifications received after the service is destroyed */
info->notify_callback_called = false;
@@ -583,7 +582,7 @@ static void test_service_notification_independence(const void *data)
info_clear_received(info);
}
- qmi_service_unref(services[0]);
+ qmi_service_free(services[0]);
send_message_to_client(&info->sender, io, QMI_MESSAGE_TYPE_IND, 0,
TEST_IND_MESSAGE_ID,
@@ -593,7 +592,7 @@ static void test_service_notification_independence(const void *data)
l_main_iterate(-1);
for (i = 1; i < L_ARRAY_SIZE(services); i++)
- qmi_service_unref(services[i]);
+ qmi_service_free(services[i]);
l_io_destroy(io);
test_cleanup(info);