Diff between 24998ea93418daafa83e86275c664b2fdd1b0f4a and 766efe9e0d996284f4dcc7c5d9fe2f51b38730f5

Changed Files

File Additions Deletions Status
profiles/cyclingspeed/cyclingspeed.c +2 -16 modified
profiles/deviceinfo/deviceinfo.c +2 -16 modified
profiles/gatt/manager.c +3 -19 modified
profiles/heartrate/heartrate.c +4 -15 modified
profiles/proximity/manager.c +3 -20 modified
profiles/scanparam/scan.c +4 -15 modified
profiles/thermometer/thermometer.c +2 -16 modified

Full Patch

diff --git a/profiles/cyclingspeed/cyclingspeed.c b/profiles/cyclingspeed/cyclingspeed.c
index e0ba4d2..3fcf492 100644
--- a/profiles/cyclingspeed/cyclingspeed.c
+++ b/profiles/cyclingspeed/cyclingspeed.c
@@ -1172,14 +1172,6 @@ static const GDBusMethodTable cyclingspeed_device_methods[] = {
 	{ }
 };
 
-static gint cmp_primary_uuid(gconstpointer a, gconstpointer b)
-{
-	const struct gatt_primary *prim = a;
-	const char *uuid = b;
-
-	return g_strcmp0(prim->uuid, uuid);
-}
-
 static int csc_device_probe(struct btd_profile *p,
 				struct btd_device *device, GSList *uuids)
 {
@@ -1187,17 +1179,11 @@ static int csc_device_probe(struct btd_profile *p,
 	struct csc_adapter *cadapter;
 	struct csc *csc;
 	struct gatt_primary *prim;
-	GSList *primaries;
-	GSList *l;
-
-	primaries = btd_device_get_primaries(device);
 
-	l = g_slist_find_custom(primaries, CYCLING_SC_UUID, cmp_primary_uuid);
-	if (l == NULL)
+	prim = btd_device_get_primary(device, CYCLING_SC_UUID);
+	if (prim == NULL)
 		return -EINVAL;
 
-	prim = l->data;
-
 	adapter = device_get_adapter(device);
 
 	cadapter = find_csc_adapter(adapter);
diff --git a/profiles/deviceinfo/deviceinfo.c b/profiles/deviceinfo/deviceinfo.c
index d7891f5..7a97ecc 100644
--- a/profiles/deviceinfo/deviceinfo.c
+++ b/profiles/deviceinfo/deviceinfo.c
@@ -198,30 +198,16 @@ static void deviceinfo_unregister(struct btd_device *device)
 	deviceinfo_free(d);
 }
 
-static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
-{
-	const struct gatt_primary *prim = a;
-	const char *uuid = b;
-
-	return g_strcmp0(prim->uuid, uuid);
-}
-
 static int deviceinfo_driver_probe(struct btd_profile *p,
 					struct btd_device *device,
 					GSList *uuids)
 {
 	struct gatt_primary *prim;
-	GSList *primaries, *l;
 
-	primaries = btd_device_get_primaries(device);
-
-	l = g_slist_find_custom(primaries, DEVICE_INFORMATION_UUID,
-							primary_uuid_cmp);
-	if (l == NULL)
+	prim = btd_device_get_primary(device, DEVICE_INFORMATION_UUID);
+	if (prim == NULL)
 		return -EINVAL;
 
-	prim = l->data;
-
 	return deviceinfo_register(device, prim);
 }
 
diff --git a/profiles/gatt/manager.c b/profiles/gatt/manager.c
index 3d8051e..ce0ed91 100644
--- a/profiles/gatt/manager.c
+++ b/profiles/gatt/manager.c
@@ -35,29 +35,13 @@
 #include "log.h"
 #include "manager.h"
 
-static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
-{
-	const struct gatt_primary *prim = a;
-	const char *uuid = b;
-
-	return g_strcmp0(prim->uuid, uuid);
-}
-
 static int gatt_driver_probe(struct btd_profile *p, struct btd_device *device,
 								GSList *uuids)
 {
-	GSList *primaries, *l;
-	struct gatt_primary *gap = NULL, *gatt = NULL;
-
-	primaries = btd_device_get_primaries(device);
-
-	l = g_slist_find_custom(primaries, GAP_UUID, primary_uuid_cmp);
-	if (l)
-		gap = l->data;
+	struct gatt_primary *gap, *gatt;
 
-	l = g_slist_find_custom(primaries, GATT_UUID, primary_uuid_cmp);
-	if (l)
-		gatt = l->data;
+	gap = btd_device_get_primary(device, GAP_UUID);
+	gatt = btd_device_get_primary(device, GATT_UUID);
 
 	if (gap == NULL || gatt == NULL) {
 		error("GAP and GATT are mandatory");
diff --git a/profiles/heartrate/heartrate.c b/profiles/heartrate/heartrate.c
index d76295e..7ee9325 100644
--- a/profiles/heartrate/heartrate.c
+++ b/profiles/heartrate/heartrate.c
@@ -829,14 +829,6 @@ static void heartrate_device_unregister(struct btd_device *device)
 				device_get_path(device), HEART_RATE_INTERFACE);
 }
 
-static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
-{
-	const struct gatt_primary *prim = a;
-	const char *uuid = b;
-
-	return g_strcmp0(prim->uuid, uuid);
-}
-
 static int heartrate_adapter_probe(struct btd_profile *p,
 						struct btd_adapter *adapter)
 {
@@ -852,16 +844,13 @@ static void heartrate_adapter_remove(struct btd_profile *p,
 static int heartrate_device_probe(struct btd_profile *p,
 				struct btd_device *device, GSList *uuids)
 {
-	GSList *primaries;
-	GSList *l;
-
-	primaries = btd_device_get_primaries(device);
+	struct gatt_primary *prim;
 
-	l = g_slist_find_custom(primaries, HEART_RATE_UUID, primary_uuid_cmp);
-	if (l == NULL)
+	prim = btd_device_get_primary(device, HEART_RATE_UUID);
+	if (prim == NULL)
 		return -EINVAL;
 
-	return heartrate_device_register(device, l->data);
+	return heartrate_device_register(device, prim);
 }
 
 static void heartrate_device_remove(struct btd_profile *p,
diff --git a/profiles/proximity/manager.c b/profiles/proximity/manager.c
index b93a609..c3d0933 100644
--- a/profiles/proximity/manager.c
+++ b/profiles/proximity/manager.c
@@ -48,31 +48,14 @@ static struct enabled enabled  = {
 	.findme = TRUE,
 };
 
-static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
-{
-	const struct gatt_primary *prim = a;
-	const char *uuid = b;
-
-	return g_strcmp0(prim->uuid, uuid);
-}
-
 static int monitor_device_probe(struct btd_profile *p,
 				struct btd_device *device, GSList *uuids)
 {
 	struct gatt_primary *linkloss, *txpower, *immediate;
-	GSList *l, *primaries;
-
-	primaries = btd_device_get_primaries(device);
-
-	l = g_slist_find_custom(primaries, IMMEDIATE_ALERT_UUID,
-			primary_uuid_cmp);
-	immediate = (l ? l->data : NULL);
-
-	l = g_slist_find_custom(primaries, TX_POWER_UUID, primary_uuid_cmp);
-	txpower = (l ? l->data : NULL);
 
-	l = g_slist_find_custom(primaries, LINK_LOSS_UUID, primary_uuid_cmp);
-	linkloss = (l ? l->data : NULL);
+	immediate = btd_device_get_primary(device, IMMEDIATE_ALERT_UUID);
+	txpower = btd_device_get_primary(device, TX_POWER_UUID);
+	linkloss = btd_device_get_primary(device, LINK_LOSS_UUID);
 
 	return monitor_register(device, linkloss, txpower, immediate, &enabled);
 }
diff --git a/profiles/scanparam/scan.c b/profiles/scanparam/scan.c
index d46b79f..7c21ac3 100644
--- a/profiles/scanparam/scan.c
+++ b/profiles/scanparam/scan.c
@@ -266,29 +266,18 @@ static void scan_unregister(struct btd_device *device)
 	g_free(scan);
 }
 
-static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
-{
-	const struct gatt_primary *prim = a;
-	const char *uuid = b;
-
-	return g_strcmp0(prim->uuid, uuid);
-}
-
 static int scan_param_probe(struct btd_profile *p, struct btd_device *device,
 								GSList *uuids)
 {
-	GSList *primaries, *l;
+	struct gatt_primary *prim;
 
 	DBG("Probing Scan Parameters");
 
-	primaries = btd_device_get_primaries(device);
-
-	l = g_slist_find_custom(primaries, SCAN_PARAMETERS_UUID,
-							primary_uuid_cmp);
-	if (!l)
+	prim = btd_device_get_primary(device, SCAN_PARAMETERS_UUID);
+	if (!prim)
 		return -EINVAL;
 
-	return scan_register(device, l->data);
+	return scan_register(device, prim);
 }
 
 static void scan_param_remove(struct btd_profile *p, struct btd_device *device)
diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c
index 3bd39f2..3ce0ff3 100644
--- a/profiles/thermometer/thermometer.c
+++ b/profiles/thermometer/thermometer.c
@@ -1275,30 +1275,16 @@ static void thermometer_adapter_unregister(struct btd_adapter *adapter)
 					THERMOMETER_MANAGER_INTERFACE);
 }
 
-static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
-{
-	const struct gatt_primary *prim = a;
-	const char *uuid = b;
-
-	return g_strcmp0(prim->uuid, uuid);
-}
-
 static int thermometer_device_probe(struct btd_profile *p,
 					struct btd_device *device,
 					GSList *uuids)
 {
 	struct gatt_primary *tattr;
-	GSList *primaries, *l;
 
-	primaries = btd_device_get_primaries(device);
-
-	l = g_slist_find_custom(primaries, HEALTH_THERMOMETER_UUID,
-							primary_uuid_cmp);
-	if (l == NULL)
+	tattr = btd_device_get_primary(device, HEALTH_THERMOMETER_UUID);
+	if (tattr == NULL)
 		return -EINVAL;
 
-	tattr = l->data;
-
 	return thermometer_register(device, tattr);
 }