Diff between 5ad45a4b57d0aa6f2629196921b06bcf1539729d and 4c527e87cafc2d66c7b4c12643102e978a63ba2d

Changed Files

File Additions Deletions Status
src/device.c +35 -27 modified

Full Patch

diff --git a/src/device.c b/src/device.c
index a7e363b..1258109 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1342,44 +1342,52 @@ static GSList *device_match_profile(struct btd_device *device,
 	return match_uuids;
 }
 
-void device_probe_profiles(struct btd_device *device, GSList *uuids)
-{
+struct probe_data {
+	struct btd_device *dev;
+	GSList *uuids;
 	char addr[18];
-	GSList *l;
+};
 
-	ba2str(&device->bdaddr, addr);
+static void dev_probe(struct btd_profile *p, void *user_data)
+{
+	struct probe_data *d = user_data;
+	GSList *probe_uuids;
+	int err;
 
-	if (device->blocked) {
-		DBG("Skipping profiles for blocked device %s", addr);
-		goto add_uuids;
-	}
+	if (p->device_probe == NULL)
+		return;
 
-	DBG("Probing profiles for device %s", addr);
+	probe_uuids = device_match_profile(d->dev, p, d->uuids);
+	if (!probe_uuids)
+		return;
 
-	for (l = btd_get_profiles(); l != NULL; l = g_slist_next(l)) {
-		struct btd_profile *profile = l->data;
-		GSList *probe_uuids;
-		int err;
+	err = p->device_probe(d->dev, probe_uuids);
+	if (err < 0) {
+		error("%s profile probe failed for %s", p->name, d->addr);
+		g_slist_free(probe_uuids);
+		return;
+	}
 
-		if (profile->device_probe == NULL)
-			continue;
+	d->dev->profiles = g_slist_append(d->dev->profiles, p);
+	g_slist_free(probe_uuids);
+}
 
-		probe_uuids = device_match_profile(device, profile, uuids);
-		if (!probe_uuids)
-			continue;
+void device_probe_profiles(struct btd_device *device, GSList *uuids)
+{
+	struct probe_data d = { device, uuids };
+	GSList *l;
 
-		err = profile->device_probe(device, probe_uuids);
-		if (err < 0) {
-			error("%s profile probe failed for device %s",
-							profile->name, addr);
-			g_slist_free(probe_uuids);
-			continue;
-		}
+	ba2str(&device->bdaddr, d.addr);
 
-		device->profiles = g_slist_append(device->profiles, profile);
-		g_slist_free(probe_uuids);
+	if (device->blocked) {
+		DBG("Skipping profiles for blocked device %s", d.addr);
+		goto add_uuids;
 	}
 
+	DBG("Probing profiles for device %s", d.addr);
+
+	btd_profile_foreach(dev_probe, &d);
+
 add_uuids:
 	for (l = uuids; l != NULL; l = g_slist_next(l)) {
 		GSList *match = g_slist_find_custom(device->uuids, l->data,