diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2012-10-05 10:16:58 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-10-05 11:27:45 +0300 |
commit | ed6a8af4a31d00bd8a3b5aeb6f22b929f8637d6c (patch) | |
tree | a5cb07a0a27f3fef3926b2a33b08d6d829eb5aba /profiles | |
parent | 4c34fcd00be61a1b9a659358eb5f6318f0fe2150 (diff) | |
download | bluez-ed6a8af4a31d00bd8a3b5aeb6f22b929f8637d6c.tar.gz |
device: Convert device_get_address into simple getter
This allow to remove number of local variables used only to get device
address and pass it as pointer later on.
bdaddr_type parameter is also removed as there is device_get_addr_type
already present which can be used to get it if needed.
Diffstat (limited to 'profiles')
-rw-r--r-- | profiles/gatt/gas.c | 20 | ||||
-rw-r--r-- | profiles/health/hdp.c | 4 | ||||
-rw-r--r-- | profiles/health/hdp_util.c | 27 | ||||
-rw-r--r-- | profiles/input/device.c | 6 | ||||
-rw-r--r-- | profiles/network/manager.c | 10 | ||||
-rw-r--r-- | profiles/proximity/monitor.c | 11 |
6 files changed, 33 insertions, 45 deletions
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c index 03bdd5a15..82c2ef0f7 100644 --- a/profiles/gatt/gas.c +++ b/profiles/gatt/gas.c @@ -170,8 +170,6 @@ static void ccc_written_cb(guint8 status, const guint8 *pdu, guint16 plen, gpointer user_data) { struct gas *gas = user_data; - bdaddr_t dba; - uint8_t bdaddr_type; if (status) { error("Write Service Changed CCC failed: %s", @@ -181,11 +179,11 @@ static void ccc_written_cb(guint8 status, const guint8 *pdu, guint16 plen, DBG("Service Changed indications enabled"); - device_get_address(gas->device, &dba, &bdaddr_type); - write_ctp_handle(adapter_get_address(device_get_adapter(gas->device)), - &dba, bdaddr_type, GATT_CHARAC_SERVICE_CHANGED, - gas->changed_handle); + device_get_address(gas->device), + device_get_addr_type(gas->device), + GATT_CHARAC_SERVICE_CHANGED, + gas->changed_handle); } static void write_ccc(GAttrib *attrib, uint16_t handle, gpointer user_data) @@ -379,8 +377,6 @@ int gas_register(struct btd_device *device, struct att_range *gap, struct att_range *gatt) { struct gas *gas; - bdaddr_t dba; - uint8_t bdaddr_type; gas = g_new0(struct gas, 1); gas->gap.start = gap->start; @@ -396,11 +392,11 @@ int gas_register(struct btd_device *device, struct att_range *gap, attio_connected_cb, attio_disconnected_cb, gas); - device_get_address(gas->device, &dba, &bdaddr_type); - read_ctp_handle(adapter_get_address(device_get_adapter(gas->device)), - &dba, bdaddr_type, GATT_CHARAC_SERVICE_CHANGED, - &gas->changed_handle); + device_get_address(gas->device), + device_get_addr_type(gas->device), + GATT_CHARAC_SERVICE_CHANGED, + &gas->changed_handle); return 0; } diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c index d07462ac4..fd21a234d 100644 --- a/profiles/health/hdp.c +++ b/profiles/health/hdp.c @@ -210,10 +210,8 @@ static int cmp_device(gconstpointer a, gconstpointer b) static gint cmp_dev_addr(gconstpointer a, gconstpointer dst) { const struct hdp_device *device = a; - bdaddr_t addr; - device_get_address(device->dev, &addr, NULL); - return bacmp(&addr, dst); + return bacmp(device_get_address(device->dev), dst); } static gint cmp_dev_mcl(gconstpointer a, gconstpointer mcl) diff --git a/profiles/health/hdp_util.c b/profiles/health/hdp_util.c index 1d9419ec8..1fd33e59f 100644 --- a/profiles/health/hdp_util.c +++ b/profiles/health/hdp_util.c @@ -857,12 +857,12 @@ gboolean hdp_get_mdep(struct hdp_device *device, struct hdp_application *app, GDestroyNotify destroy, GError **err) { struct get_mdep_data *mdep_data; - bdaddr_t dst; const bdaddr_t *src; + const bdaddr_t *dst; uuid_t uuid; - device_get_address(device->dev, &dst, NULL); src = adapter_get_address(device_get_adapter(device->dev)); + dst = device_get_address(device->dev); mdep_data = g_new0(struct get_mdep_data, 1); mdep_data->app = hdp_application_ref(app); @@ -871,7 +871,7 @@ gboolean hdp_get_mdep(struct hdp_device *device, struct hdp_application *app, mdep_data->destroy = destroy; bt_string2uuid(&uuid, HDP_UUID); - if (bt_search_service(src, &dst, &uuid, get_mdep_cb, mdep_data, + if (bt_search_service(src, dst, &uuid, get_mdep_cb, mdep_data, free_mdep_data) < 0) { g_set_error(err, HDP_ERROR, HDP_CONNECTION_ERROR, "Can't get remote SDP record"); @@ -1044,7 +1044,6 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data) { struct conn_mcl_data *conn_data = user_data; GError *gerr = NULL; - bdaddr_t dst; uint16_t ccpsm; if (conn_data->dev->hdp_adapter->mi == NULL) { @@ -1067,10 +1066,10 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data) conn_data = con_mcl_data_ref(conn_data); - device_get_address(conn_data->dev->dev, &dst, NULL); - if (!mcap_create_mcl(conn_data->dev->hdp_adapter->mi, &dst, ccpsm, - create_mcl_cb, conn_data, - destroy_con_mcl_data, &gerr)) { + if (!mcap_create_mcl(conn_data->dev->hdp_adapter->mi, + device_get_address(conn_data->dev->dev), + ccpsm, create_mcl_cb, conn_data, + destroy_con_mcl_data, &gerr)) { con_mcl_data_unref(conn_data); goto fail; } @@ -1087,12 +1086,12 @@ gboolean hdp_establish_mcl(struct hdp_device *device, GError **err) { struct conn_mcl_data *conn_data; - bdaddr_t dst; const bdaddr_t *src; + const bdaddr_t *dst; uuid_t uuid; - device_get_address(device->dev, &dst, NULL); src = adapter_get_address(device_get_adapter(device->dev)); + dst = device_get_address(device->dev); conn_data = g_new0(struct conn_mcl_data, 1); conn_data->refs = 1; @@ -1102,7 +1101,7 @@ gboolean hdp_establish_mcl(struct hdp_device *device, conn_data->dev = health_device_ref(device); bt_string2uuid(&uuid, HDP_UUID); - if (bt_search_service(src, &dst, &uuid, search_cb, conn_data, + if (bt_search_service(src, dst, &uuid, search_cb, conn_data, destroy_con_mcl_data) < 0) { g_set_error(err, HDP_ERROR, HDP_CONNECTION_ERROR, "Can't get remote SDP record"); @@ -1158,12 +1157,12 @@ gboolean hdp_get_dcpsm(struct hdp_device *device, hdp_continue_dcpsm_f func, GError **err) { struct get_dcpsm_data *dcpsm_data; - bdaddr_t dst; const bdaddr_t *src; + const bdaddr_t *dst; uuid_t uuid; - device_get_address(device->dev, &dst, NULL); src = adapter_get_address(device_get_adapter(device->dev)); + dst = device_get_address(device->dev); dcpsm_data = g_new0(struct get_dcpsm_data, 1); dcpsm_data->func = func; @@ -1171,7 +1170,7 @@ gboolean hdp_get_dcpsm(struct hdp_device *device, hdp_continue_dcpsm_f func, dcpsm_data->destroy = destroy; bt_string2uuid(&uuid, HDP_UUID); - if (bt_search_service(src, &dst, &uuid, get_dcpsm_cb, dcpsm_data, + if (bt_search_service(src, dst, &uuid, get_dcpsm_cb, dcpsm_data, free_dcpsm_data) < 0) { g_set_error(err, HDP_ERROR, HDP_CONNECTION_ERROR, "Can't get remote SDP record"); diff --git a/profiles/input/device.c b/profiles/input/device.c index ed50e3b0f..92e1fa919 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -782,11 +782,10 @@ static struct input_device *input_device_new(struct btd_device *device, struct btd_adapter *adapter = device_get_adapter(device); struct input_device *idev; char name[249], src_addr[18], dst_addr[18]; - uint8_t dst_type; idev = g_new0(struct input_device, 1); bacpy(&idev->src, adapter_get_address(adapter)); - device_get_address(device, &idev->dst, &dst_type); + bacpy(&idev->dst, device_get_address(device)); idev->device = btd_device_ref(device); idev->path = g_strdup(path); idev->handle = handle; @@ -795,7 +794,8 @@ static struct input_device *input_device_new(struct btd_device *device, ba2str(&idev->src, src_addr); ba2str(&idev->dst, dst_addr); - if (read_device_name(src_addr, dst_addr, dst_type, name) == 0) + if (read_device_name(src_addr, dst_addr, device_get_addr_type(device), + name) == 0) idev->name = g_strdup(name); if (g_dbus_register_interface(btd_get_dbus_connection(), diff --git a/profiles/network/manager.c b/profiles/network/manager.c index 42b521436..049fbc739 100644 --- a/profiles/network/manager.c +++ b/profiles/network/manager.c @@ -79,19 +79,19 @@ static int network_probe(struct btd_profile *p, struct btd_device *device, struct btd_adapter *adapter = device_get_adapter(device); const gchar *path = device_get_path(device); const bdaddr_t *src; - bdaddr_t dst; + const bdaddr_t *dst; DBG("path %s", path); src = adapter_get_address(adapter); - device_get_address(device, &dst, NULL); + dst = device_get_address(device); if (g_slist_find_custom(uuids, PANU_UUID, bt_uuid_strcmp)) - connection_register(device, path, src, &dst, BNEP_SVC_PANU); + connection_register(device, path, src, dst, BNEP_SVC_PANU); if (g_slist_find_custom(uuids, GN_UUID, bt_uuid_strcmp)) - connection_register(device, path, src, &dst, BNEP_SVC_GN); + connection_register(device, path, src, dst, BNEP_SVC_GN); if (g_slist_find_custom(uuids, NAP_UUID, bt_uuid_strcmp)) - connection_register(device, path, src, &dst, BNEP_SVC_NAP); + connection_register(device, path, src, dst, BNEP_SVC_NAP); return 0; } diff --git a/profiles/proximity/monitor.c b/profiles/proximity/monitor.c index 03df0e20d..1a142651e 100644 --- a/profiles/proximity/monitor.c +++ b/profiles/proximity/monitor.c @@ -407,7 +407,6 @@ static DBusMessage *set_link_loss_alert(DBusConnection *conn, DBusMessage *msg, { struct monitor *monitor = data; struct btd_device *device = monitor->device; - bdaddr_t dba; if (!level_is_valid(level)) return btd_error_invalid_args(msg); @@ -418,10 +417,9 @@ static DBusMessage *set_link_loss_alert(DBusConnection *conn, DBusMessage *msg, g_free(monitor->linklosslevel); monitor->linklosslevel = g_strdup(level); - device_get_address(device, &dba, NULL); - write_proximity_config(adapter_get_address(device_get_adapter(device)), - &dba, "LinkLossAlertLevel", level); + device_get_address(device), + "LinkLossAlertLevel", level); if (monitor->attrib) write_alert_level(monitor); @@ -593,14 +591,11 @@ int monitor_register(struct btd_device *device, { const char *path = device_get_path(device); struct monitor *monitor; - bdaddr_t dba; char *level; - device_get_address(device, &dba, NULL); - level = read_proximity_config( adapter_get_address(device_get_adapter(device)), - &dba, "LinkLossAlertLevel"); + device_get_address(device), "LinkLossAlertLevel"); monitor = g_new0(struct monitor, 1); monitor->device = btd_device_ref(device); |