linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/8] audio: Move btd_device unref after last use in device_free
@ 2012-10-16 10:12 Szymon Janc
  2012-10-16 10:12 ` [PATCH 2/8] mgmt: Make mgmt_update_powered return void Szymon Janc
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Szymon Janc @ 2012-10-16 10:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

btd_device should not be used after local reference was dropped.

---
 audio/device.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/audio/device.c b/audio/device.c
index 175e3c0..be63031 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -98,8 +98,6 @@ static void device_free(struct audio_device *dev)
 {
 	struct dev_priv *priv = dev->priv;
 
-	btd_device_unref(dev->btd_dev);
-
 	if (priv) {
 		if (priv->control_timer)
 			g_source_remove(priv->control_timer);
@@ -117,6 +115,8 @@ static void device_free(struct audio_device *dev)
 		g_free(priv);
 	}
 
+	btd_device_unref(dev->btd_dev);
+
 	g_free(dev->path);
 	g_free(dev);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/8] mgmt: Make mgmt_update_powered return void
  2012-10-16 10:12 [PATCH 1/8] audio: Move btd_device unref after last use in device_free Szymon Janc
@ 2012-10-16 10:12 ` Szymon Janc
  2012-10-16 10:12 ` [PATCH 3/8] audio: Remove path from struct audio_device Szymon Janc
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Szymon Janc @ 2012-10-16 10:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

mgmt_update_powered always returned 0 and this was never checked by
caller.

---
 src/mgmt.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/mgmt.c b/src/mgmt.c
index 2a66be2..8caabe8 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -352,7 +352,7 @@ static void update_settings(struct btd_adapter *adapter, uint32_t settings)
 		mgmt_set_low_energy(index, TRUE);
 }
 
-static int mgmt_update_powered(struct btd_adapter *adapter,
+static void mgmt_update_powered(struct btd_adapter *adapter,
 						struct controller_info *info,
 						uint32_t settings)
 {
@@ -363,14 +363,12 @@ static int mgmt_update_powered(struct btd_adapter *adapter,
 		info->pending_uuid = FALSE;
 		info->pending_class = FALSE;
 		info->pending_cod_change = FALSE;
-		return 0;
+		return;
 	}
 
 	btd_adapter_start(adapter);
 
 	update_settings(adapter, settings);
-
-	return 0;
 }
 
 static int mode_changed(uint32_t s1, uint32_t s2)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/8] audio: Remove path from struct audio_device
  2012-10-16 10:12 [PATCH 1/8] audio: Move btd_device unref after last use in device_free Szymon Janc
  2012-10-16 10:12 ` [PATCH 2/8] mgmt: Make mgmt_update_powered return void Szymon Janc
@ 2012-10-16 10:12 ` Szymon Janc
  2012-10-16 10:12 ` [PATCH 4/8] network: Remove redundant struct network_peer members Szymon Janc
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Szymon Janc @ 2012-10-16 10:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

struct audio_device is holding a reference to btd_device and path can
be easily taken from it when needed.

---
NOTE:
src and dst can also be removed but this require a bit more work and is not
included in this patch

 audio/control.c   |   23 +++++++++++--------
 audio/device.c    |   26 +++++++++------------
 audio/device.h    |    5 ++--
 audio/gateway.c   |   16 +++++++++----
 audio/headset.c   |   66 ++++++++++++++++++++++++++++++-----------------------
 audio/manager.c   |   10 ++++----
 audio/sink.c      |   17 +++++++-------
 audio/source.c    |   13 ++++++-----
 audio/transport.c |    9 +++++---
 9 files changed, 102 insertions(+), 83 deletions(-)

diff --git a/audio/control.c b/audio/control.c
index 8bb085a..37b027b 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -46,6 +46,9 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
+#include "../src/adapter.h"
+#include "../src/device.h"
+
 #include "log.h"
 #include "error.h"
 #include "device.h"
@@ -70,6 +73,7 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 {
 	DBusConnection *conn = btd_get_dbus_connection();
 	struct control *control = dev->control;
+	const char *path = device_get_path(dev->btd_dev);
 
 	switch (new_state) {
 	case AVCTP_STATE_DISCONNECTED:
@@ -94,10 +98,9 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 		if (old_state != AVCTP_STATE_CONNECTED)
 			break;
 
-		g_dbus_emit_signal(conn, dev->path,
-					AUDIO_CONTROL_INTERFACE,
+		g_dbus_emit_signal(conn, path, AUDIO_CONTROL_INTERFACE,
 					"Disconnected", DBUS_TYPE_INVALID);
-		g_dbus_emit_property_changed(conn, dev->path,
+		g_dbus_emit_property_changed(conn, path,
 					AUDIO_CONTROL_INTERFACE, "Connected");
 
 		break;
@@ -116,10 +119,10 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 			control->connect = NULL;
 		}
 
-		g_dbus_emit_signal(conn, dev->path,
+		g_dbus_emit_signal(conn, path,
 				AUDIO_CONTROL_INTERFACE, "Connected",
 				DBUS_TYPE_INVALID);
-		g_dbus_emit_property_changed(conn, dev->path,
+		g_dbus_emit_property_changed(conn, path,
 					AUDIO_CONTROL_INTERFACE, "Connected");
 		break;
 	default:
@@ -298,7 +301,7 @@ static void path_unregister(void *data)
 	struct control *control = dev->control;
 
 	DBG("Unregistered interface %s on path %s",
-		AUDIO_CONTROL_INTERFACE, dev->path);
+		AUDIO_CONTROL_INTERFACE, device_get_path(dev->btd_dev));
 
 	if (control->session)
 		avctp_disconnect(control->session);
@@ -315,7 +318,8 @@ static void path_unregister(void *data)
 
 void control_unregister(struct audio_device *dev)
 {
-	g_dbus_unregister_interface(btd_get_dbus_connection(), dev->path,
+	g_dbus_unregister_interface(btd_get_dbus_connection(),
+						device_get_path(dev->btd_dev),
 						AUDIO_CONTROL_INTERFACE);
 }
 
@@ -329,7 +333,8 @@ struct control *control_init(struct audio_device *dev, GSList *uuids)
 {
 	struct control *control;
 
-	if (!g_dbus_register_interface(btd_get_dbus_connection(), dev->path,
+	if (!g_dbus_register_interface(btd_get_dbus_connection(),
+					device_get_path(dev->btd_dev),
 					AUDIO_CONTROL_INTERFACE,
 					control_methods, control_signals,
 					control_properties, dev,
@@ -337,7 +342,7 @@ struct control *control_init(struct audio_device *dev, GSList *uuids)
 		return NULL;
 
 	DBG("Registered interface %s on path %s",
-		AUDIO_CONTROL_INTERFACE, dev->path);
+		AUDIO_CONTROL_INTERFACE, device_get_path(dev->btd_dev));
 
 	control = g_new0(struct control, 1);
 
diff --git a/audio/device.c b/audio/device.c
index be63031..aee4161 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -117,7 +117,6 @@ static void device_free(struct audio_device *dev)
 
 	btd_device_unref(dev->btd_dev);
 
-	g_free(dev->path);
 	g_free(dev);
 }
 
@@ -266,7 +265,7 @@ static void device_set_state(struct audio_device *dev, audio_state_t new_state)
 		g_dbus_send_message(conn, reply);
 	}
 
-	emit_property_changed(dev->path,
+	emit_property_changed(device_get_path(dev->btd_dev),
 				AUDIO_INTERFACE, "State",
 				DBUS_TYPE_STRING, &state_str);
 }
@@ -619,35 +618,31 @@ static const GDBusSignalTable dev_signals[] = {
 };
 
 struct audio_device *audio_device_register(struct btd_device *device,
-					const char *path, const bdaddr_t *src,
-					const bdaddr_t *dst)
+							const bdaddr_t *src,
+							const bdaddr_t *dst)
 {
 	struct audio_device *dev;
 
-	if (!path)
-		return NULL;
-
 	dev = g_new0(struct audio_device, 1);
 
 	dev->btd_dev = btd_device_ref(device);
-	dev->path = g_strdup(path);
 	bacpy(&dev->dst, dst);
 	bacpy(&dev->src, src);
 	dev->priv = g_new0(struct dev_priv, 1);
 	dev->priv->state = AUDIO_STATE_DISCONNECTED;
 
 	if (!g_dbus_register_interface(btd_get_dbus_connection(),
-					dev->path, AUDIO_INTERFACE,
-					dev_methods, dev_signals, NULL,
-					dev, NULL)) {
+					device_get_path(dev->btd_dev),
+					AUDIO_INTERFACE, dev_methods,
+					dev_signals, NULL, dev, NULL)) {
 		error("Unable to register %s on %s", AUDIO_INTERFACE,
-								dev->path);
+						device_get_path(dev->btd_dev));
 		device_free(dev);
 		return NULL;
 	}
 
 	DBG("Registered interface %s on path %s", AUDIO_INTERFACE,
-								dev->path);
+						device_get_path(dev->btd_dev));
 
 	if (sink_callback_id == 0)
 		sink_callback_id = sink_add_state_cb(device_sink_cb, NULL);
@@ -714,8 +709,9 @@ void audio_device_unregister(struct audio_device *device)
 	if (device->control)
 		control_unregister(device);
 
-	g_dbus_unregister_interface(btd_get_dbus_connection(), device->path,
-						AUDIO_INTERFACE);
+	g_dbus_unregister_interface(btd_get_dbus_connection(),
+					device_get_path(device->btd_dev),
+					AUDIO_INTERFACE);
 
 	device_free(device);
 }
diff --git a/audio/device.h b/audio/device.h
index 2b92528..1e2cac1 100644
--- a/audio/device.h
+++ b/audio/device.h
@@ -33,7 +33,6 @@ struct dev_priv;
 struct audio_device {
 	struct btd_device *btd_dev;
 
-	char *path;
 	bdaddr_t src;
 	bdaddr_t dst;
 
@@ -53,8 +52,8 @@ struct audio_device {
 };
 
 struct audio_device *audio_device_register(struct btd_device *device,
-					const char *path, const bdaddr_t *src,
-					const bdaddr_t *dst);
+							const bdaddr_t *src,
+							const bdaddr_t *dst);
 
 void audio_device_unregister(struct audio_device *device);
 
diff --git a/audio/gateway.c b/audio/gateway.c
index b4d96f0..2d5b4aa 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -42,6 +42,9 @@
 #include <bluetooth/sdp.h>
 #include <bluetooth/sdp_lib.h>
 
+#include "../src/adapter.h"
+#include "../src/device.h"
+
 #include "sdp-client.h"
 #include "device.h"
 #include "gateway.h"
@@ -135,7 +138,7 @@ static void change_state(struct audio_device *dev, gateway_state_t new_state)
 	old_state = gw->state;
 	gw->state = new_state;
 
-	emit_property_changed(dev->path,
+	emit_property_changed(device_get_path(dev->btd_dev),
 				AUDIO_GATEWAY_INTERFACE, "State",
 				DBUS_TYPE_STRING, &val);
 
@@ -649,7 +652,8 @@ static DBusMessage *ag_disconnect(DBusConnection *conn, DBusMessage *msg,
 
 	gateway_close(device);
 	ba2str(&device->dst, gw_addr);
-	DBG("Disconnected from %s, %s", gw_addr, device->path);
+	DBG("Disconnected from %s, %s", gw_addr,
+					device_get_path(device->btd_dev));
 
 	return reply;
 }
@@ -779,7 +783,7 @@ static void path_unregister(void *data)
 	struct audio_device *dev = data;
 
 	DBG("Unregistered interface %s on path %s",
-		AUDIO_GATEWAY_INTERFACE, dev->path);
+		AUDIO_GATEWAY_INTERFACE, device_get_path(dev->btd_dev));
 
 	gateway_close(dev);
 
@@ -792,13 +796,15 @@ void gateway_unregister(struct audio_device *dev)
 	if (dev->gateway->agent)
 		agent_disconnect(dev, dev->gateway->agent);
 
-	g_dbus_unregister_interface(btd_get_dbus_connection(), dev->path,
+	g_dbus_unregister_interface(btd_get_dbus_connection(),
+						device_get_path(dev->btd_dev),
 						AUDIO_GATEWAY_INTERFACE);
 }
 
 struct gateway *gateway_init(struct audio_device *dev)
 {
-	if (!g_dbus_register_interface(btd_get_dbus_connection(), dev->path,
+	if (!g_dbus_register_interface(btd_get_dbus_connection(),
+					device_get_path(dev->btd_dev),
 					AUDIO_GATEWAY_INTERFACE,
 					gateway_methods, gateway_signals,
 					NULL, dev, path_unregister))
diff --git a/audio/headset.c b/audio/headset.c
index c822e35..5e42a61 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -582,7 +582,7 @@ static void sco_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 		return;
 	}
 
-	DBG("SCO socket opened for headset %s", dev->path);
+	DBG("SCO socket opened for headset %s", device_get_path(dev->btd_dev));
 
 	sk = g_io_channel_unix_get_fd(chan);
 
@@ -802,7 +802,8 @@ static int key_press(struct audio_device *device, const char *buf)
 	if (strlen(buf) < 9)
 		return -EINVAL;
 
-	g_dbus_emit_signal(btd_get_dbus_connection(), device->path,
+	g_dbus_emit_signal(btd_get_dbus_connection(),
+			device_get_path(device->btd_dev),
 			AUDIO_HEADSET_INTERFACE, "AnswerRequested",
 			DBUS_TYPE_INVALID);
 
@@ -847,7 +848,8 @@ int telephony_terminate_call_rsp(void *telephony_device,
 	if (err != CME_ERROR_NONE)
 		return telephony_generic_rsp(telephony_device, err);
 
-	g_dbus_emit_signal(btd_get_dbus_connection(), device->path,
+	g_dbus_emit_signal(btd_get_dbus_connection(),
+			device_get_path(device->btd_dev),
 			AUDIO_HEADSET_INTERFACE, "CallTerminated",
 			DBUS_TYPE_INVALID);
 
@@ -982,12 +984,13 @@ static int headset_set_gain(struct audio_device *device, uint16_t gain, char typ
 		return -EINVAL;
 	}
 
-	g_dbus_emit_signal(btd_get_dbus_connection(), device->path,
+	g_dbus_emit_signal(btd_get_dbus_connection(),
+				device_get_path(device->btd_dev),
 				AUDIO_HEADSET_INTERFACE, name,
 				DBUS_TYPE_UINT16, &gain,
 				DBUS_TYPE_INVALID);
 
-	emit_property_changed(device->path,
+	emit_property_changed(device_get_path(device->btd_dev),
 				AUDIO_HEADSET_INTERFACE, property,
 				DBUS_TYPE_UINT16, &gain);
 
@@ -1401,7 +1404,7 @@ void headset_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	g_io_add_watch(chan, G_IO_IN | G_IO_ERR | G_IO_HUP| G_IO_NVAL,
 			(GIOFunc) rfcomm_io_cb, dev);
 
-	DBG("%s: Connected to %s", dev->path, hs_address);
+	DBG("%s: Connected to %s", device_get_path(dev->btd_dev), hs_address);
 
 	hs->slc = g_new0(struct headset_slc, 1);
 	hs->slc->sp_gain = 15;
@@ -1619,8 +1622,8 @@ static int rfcomm_connect(struct audio_device *dev, headset_stream_cb_t cb,
 
 	ba2str(&dev->dst, address);
 
-	DBG("%s: Connecting to %s channel %d", dev->path, address,
-		hs->rfcomm_ch);
+	DBG("%s: Connecting to %s channel %d", device_get_path(dev->btd_dev),
+						address, hs->rfcomm_ch);
 
 	hs->tmp_rfcomm = bt_io_connect(headset_connect_cb, dev,
 					NULL, &err,
@@ -1686,7 +1689,8 @@ static DBusMessage *hs_disconnect(DBusConnection *conn, DBusMessage *msg,
 
 	headset_shutdown(device);
 	ba2str(&device->dst, hs_address);
-	info("Disconnected from %s, %s", hs_address, device->path);
+	info("Disconnected from %s, %s", hs_address,
+					device_get_path(device->btd_dev));
 
 	return dbus_message_new_method_return(msg);
 
@@ -2024,15 +2028,16 @@ static void path_unregister(void *data)
 	}
 
 	DBG("Unregistered interface %s on path %s",
-		AUDIO_HEADSET_INTERFACE, dev->path);
+		AUDIO_HEADSET_INTERFACE, device_get_path(dev->btd_dev));
 
 	headset_free(dev);
 }
 
 void headset_unregister(struct audio_device *dev)
 {
-	g_dbus_unregister_interface(btd_get_dbus_connection(), dev->path,
-		AUDIO_HEADSET_INTERFACE);
+	g_dbus_unregister_interface(btd_get_dbus_connection(),
+						device_get_path(dev->btd_dev),
+						AUDIO_HEADSET_INTERFACE);
 }
 
 struct headset *headset_init(struct audio_device *dev, GSList *uuids,
@@ -2046,7 +2051,8 @@ struct headset *headset_init(struct audio_device *dev, GSList *uuids,
 
 	headset_update(dev, hs, uuids);
 
-	if (!g_dbus_register_interface(btd_get_dbus_connection(), dev->path,
+	if (!g_dbus_register_interface(btd_get_dbus_connection(),
+					device_get_path(dev->btd_dev),
 					AUDIO_HEADSET_INTERFACE,
 					headset_methods, headset_signals, NULL,
 					dev, path_unregister)) {
@@ -2055,7 +2061,7 @@ struct headset *headset_init(struct audio_device *dev, GSList *uuids,
 	}
 
 	DBG("Registered interface %s on path %s", AUDIO_HEADSET_INTERFACE,
-								dev->path);
+						device_get_path(dev->btd_dev));
 
 	return hs;
 }
@@ -2341,15 +2347,16 @@ void headset_set_state(struct audio_device *dev, headset_state_t state)
 		value = FALSE;
 		close_sco(dev);
 		headset_close_rfcomm(dev);
-		emit_property_changed(dev->path,
+		emit_property_changed(device_get_path(dev->btd_dev),
 					AUDIO_HEADSET_INTERFACE, "State",
 					DBUS_TYPE_STRING, &state_str);
-		g_dbus_emit_signal(btd_get_dbus_connection(), dev->path,
+		g_dbus_emit_signal(btd_get_dbus_connection(),
+					device_get_path(dev->btd_dev),
 					AUDIO_HEADSET_INTERFACE,
 					"Disconnected",
 					DBUS_TYPE_INVALID);
 		if (hs->state > HEADSET_STATE_CONNECTING) {
-			emit_property_changed(dev->path,
+			emit_property_changed(device_get_path(dev->btd_dev),
 					AUDIO_HEADSET_INTERFACE, "Connected",
 					DBUS_TYPE_BOOLEAN, &value);
 			telephony_device_disconnected(dev);
@@ -2357,14 +2364,14 @@ void headset_set_state(struct audio_device *dev, headset_state_t state)
 		active_devices = g_slist_remove(active_devices, dev);
 		break;
 	case HEADSET_STATE_CONNECTING:
-		emit_property_changed(dev->path,
+		emit_property_changed(device_get_path(dev->btd_dev),
 					AUDIO_HEADSET_INTERFACE, "State",
 					DBUS_TYPE_STRING, &state_str);
 		break;
 	case HEADSET_STATE_CONNECTED:
 		close_sco(dev);
 		if (hs->state != HEADSET_STATE_PLAY_IN_PROGRESS)
-			emit_property_changed(dev->path,
+			emit_property_changed(device_get_path(dev->btd_dev),
 					AUDIO_HEADSET_INTERFACE, "State",
 					DBUS_TYPE_STRING, &state_str);
 		if (hs->state < state) {
@@ -2372,12 +2379,13 @@ void headset_set_state(struct audio_device *dev, headset_state_t state)
 				slc->inband_ring = TRUE;
 			else
 				slc->inband_ring = FALSE;
-			g_dbus_emit_signal(btd_get_dbus_connection(), dev->path,
+			g_dbus_emit_signal(btd_get_dbus_connection(),
+						device_get_path(dev->btd_dev),
 						AUDIO_HEADSET_INTERFACE,
 						"Connected",
 						DBUS_TYPE_INVALID);
 			value = TRUE;
-			emit_property_changed(dev->path,
+			emit_property_changed(device_get_path(dev->btd_dev),
 						AUDIO_HEADSET_INTERFACE,
 						"Connected",
 						DBUS_TYPE_BOOLEAN, &value);
@@ -2385,11 +2393,12 @@ void headset_set_state(struct audio_device *dev, headset_state_t state)
 			telephony_device_connected(dev);
 		} else if (hs->state == HEADSET_STATE_PLAYING) {
 			value = FALSE;
-			g_dbus_emit_signal(btd_get_dbus_connection(), dev->path,
+			g_dbus_emit_signal(btd_get_dbus_connection(),
+						device_get_path(dev->btd_dev),
 						AUDIO_HEADSET_INTERFACE,
 						"Stopped",
 						DBUS_TYPE_INVALID);
-			emit_property_changed(dev->path,
+			emit_property_changed(device_get_path(dev->btd_dev),
 						AUDIO_HEADSET_INTERFACE,
 						"Playing",
 						DBUS_TYPE_BOOLEAN, &value);
@@ -2399,7 +2408,7 @@ void headset_set_state(struct audio_device *dev, headset_state_t state)
 		break;
 	case HEADSET_STATE_PLAYING:
 		value = TRUE;
-		emit_property_changed(dev->path,
+		emit_property_changed(device_get_path(dev->btd_dev),
 					AUDIO_HEADSET_INTERFACE, "State",
 					DBUS_TYPE_STRING, &state_str);
 
@@ -2409,10 +2418,11 @@ void headset_set_state(struct audio_device *dev, headset_state_t state)
 					G_IO_ERR | G_IO_NVAL,
 					(GIOFunc) sco_cb, dev);
 
-		g_dbus_emit_signal(btd_get_dbus_connection(), dev->path,
+		g_dbus_emit_signal(btd_get_dbus_connection(),
+					device_get_path(dev->btd_dev),
 					AUDIO_HEADSET_INTERFACE, "Playing",
 					DBUS_TYPE_INVALID);
-		emit_property_changed(dev->path,
+		emit_property_changed(device_get_path(dev->btd_dev),
 					AUDIO_HEADSET_INTERFACE, "Playing",
 					DBUS_TYPE_BOOLEAN, &value);
 
@@ -2425,8 +2435,8 @@ void headset_set_state(struct audio_device *dev, headset_state_t state)
 
 	hs->state = state;
 
-	DBG("State changed %s: %s -> %s", dev->path, str_state[old_state],
-		str_state[state]);
+	DBG("State changed %s: %s -> %s", device_get_path(dev->btd_dev),
+				str_state[old_state], str_state[state]);
 
 	for (l = headset_callbacks; l != NULL; l = l->next) {
 		struct headset_state_callback *cb = l->data;
diff --git a/audio/manager.c b/audio/manager.c
index b052009..4ea61bf 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -435,7 +435,7 @@ static void gateway_auth_cb(DBusError *derr, void *user_data)
 
 		ba2str(&device->dst, ag_address);
 		DBG("Accepted AG connection from %s for %s",
-			ag_address, device->path);
+			ag_address, device_get_path(device->btd_dev));
 
 		gateway_start_service(device);
 	}
@@ -1240,7 +1240,8 @@ GSList *manager_find_devices(const char *path,
 	for (l = devices; l != NULL; l = l->next) {
 		struct audio_device *dev = l->data;
 
-		if ((path && (strcmp(path, "")) && strcmp(dev->path, path)))
+		if ((path && (strcmp(path, "")) &&
+				strcmp(device_get_path(dev->btd_dev), path)))
 			continue;
 
 		if ((src && bacmp(src, BDADDR_ANY)) && bacmp(&dev->src, src))
@@ -1304,7 +1305,6 @@ struct audio_device *manager_get_device(const bdaddr_t *src,
 	struct btd_adapter *adapter;
 	struct btd_device *device;
 	char addr[18];
-	const char *path;
 
 	dev = manager_find_device(NULL, src, dst, NULL, FALSE);
 	if (dev)
@@ -1330,9 +1330,7 @@ struct audio_device *manager_get_device(const bdaddr_t *src,
 		return NULL;
 	}
 
-	path = device_get_path(device);
-
-	dev = audio_device_register(device, path, src, dst);
+	dev = audio_device_register(device, src, dst);
 	if (!dev)
 		return NULL;
 
diff --git a/audio/sink.c b/audio/sink.c
index d45185c..2e63579 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -114,12 +114,12 @@ static void sink_set_state(struct audio_device *dev, sink_state_t new_state)
 
 	state_str = state2str(new_state);
 	if (state_str)
-		emit_property_changed(dev->path,
+		emit_property_changed(device_get_path(dev->btd_dev),
 					AUDIO_SINK_INTERFACE, "State",
 					DBUS_TYPE_STRING, &state_str);
 
-	DBG("State changed %s: %s -> %s", dev->path, str_state[old_state],
-		str_state[new_state]);
+	DBG("State changed %s: %s -> %s", device_get_path(dev->btd_dev),
+				str_state[old_state], str_state[new_state]);
 
 	for (l = sink_callbacks; l != NULL; l = l->next) {
 		struct sink_state_callback *cb = l->data;
@@ -532,29 +532,30 @@ static void path_unregister(void *data)
 	struct audio_device *dev = data;
 
 	DBG("Unregistered interface %s on path %s",
-		AUDIO_SINK_INTERFACE, dev->path);
+			AUDIO_SINK_INTERFACE, device_get_path(dev->btd_dev));
 
 	sink_free(dev);
 }
 
 void sink_unregister(struct audio_device *dev)
 {
-	g_dbus_unregister_interface(btd_get_dbus_connection(), dev->path,
-		AUDIO_SINK_INTERFACE);
+	g_dbus_unregister_interface(btd_get_dbus_connection(),
+			device_get_path(dev->btd_dev), AUDIO_SINK_INTERFACE);
 }
 
 struct sink *sink_init(struct audio_device *dev)
 {
 	struct sink *sink;
 
-	if (!g_dbus_register_interface(btd_get_dbus_connection(), dev->path,
+	if (!g_dbus_register_interface(btd_get_dbus_connection(),
+					device_get_path(dev->btd_dev),
 					AUDIO_SINK_INTERFACE,
 					sink_methods, sink_signals, NULL,
 					dev, path_unregister))
 		return NULL;
 
 	DBG("Registered interface %s on path %s",
-		AUDIO_SINK_INTERFACE, dev->path);
+			AUDIO_SINK_INTERFACE, device_get_path(dev->btd_dev));
 
 	if (avdtp_callback_id == 0)
 		avdtp_callback_id = avdtp_add_state_cb(avdtp_state_callback,
diff --git a/audio/source.c b/audio/source.c
index e111954..1d0c74a 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -108,7 +108,7 @@ static void source_set_state(struct audio_device *dev, source_state_t new_state)
 
 	state_str = state2str(new_state);
 	if (state_str)
-		emit_property_changed(dev->path,
+		emit_property_changed(device_get_path(dev->btd_dev),
 					AUDIO_SOURCE_INTERFACE, "State",
 					DBUS_TYPE_STRING, &state_str);
 
@@ -521,29 +521,30 @@ static void path_unregister(void *data)
 	struct audio_device *dev = data;
 
 	DBG("Unregistered interface %s on path %s",
-		AUDIO_SOURCE_INTERFACE, dev->path);
+			AUDIO_SOURCE_INTERFACE, device_get_path(dev->btd_dev));
 
 	source_free(dev);
 }
 
 void source_unregister(struct audio_device *dev)
 {
-	g_dbus_unregister_interface(btd_get_dbus_connection(), dev->path,
-						AUDIO_SOURCE_INTERFACE);
+	g_dbus_unregister_interface(btd_get_dbus_connection(),
+			device_get_path(dev->btd_dev), AUDIO_SOURCE_INTERFACE);
 }
 
 struct source *source_init(struct audio_device *dev)
 {
 	struct source *source;
 
-	if (!g_dbus_register_interface(btd_get_dbus_connection(), dev->path,
+	if (!g_dbus_register_interface(btd_get_dbus_connection(),
+					device_get_path(dev->btd_dev),
 					AUDIO_SOURCE_INTERFACE,
 					source_methods, source_signals, NULL,
 					dev, path_unregister))
 		return NULL;
 
 	DBG("Registered interface %s on path %s",
-					AUDIO_SOURCE_INTERFACE, dev->path);
+			AUDIO_SOURCE_INTERFACE, device_get_path(dev->btd_dev));
 
 	if (avdtp_callback_id == 0)
 		avdtp_callback_id = avdtp_add_state_cb(avdtp_state_callback,
diff --git a/audio/transport.c b/audio/transport.c
index daafff8..46ab0a7 100644
--- a/audio/transport.c
+++ b/audio/transport.c
@@ -34,6 +34,7 @@
 #include <gdbus.h>
 
 #include "../src/adapter.h"
+#include "../src/device.h"
 #include "../src/dbus-common.h"
 
 #include "log.h"
@@ -1040,6 +1041,7 @@ void transport_get_properties(struct media_transport *transport,
 	const char *uuid;
 	uint8_t codec;
 	const char *state;
+	const char *path;
 
 	dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
 			DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
@@ -1047,8 +1049,8 @@ void transport_get_properties(struct media_transport *transport,
 			DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
 
 	/* Device */
-	dict_append_entry(&dict, "Device", DBUS_TYPE_OBJECT_PATH,
-						&transport->device->path);
+	path = device_get_path(transport->device->btd_dev);
+	dict_append_entry(&dict, "Device", DBUS_TYPE_OBJECT_PATH, &path);
 
 	uuid = media_endpoint_get_uuid(transport->endpoint);
 	dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, &uuid);
@@ -1265,7 +1267,8 @@ struct media_transport *media_transport_create(struct media_endpoint *endpoint,
 	transport->configuration = g_new(uint8_t, size);
 	memcpy(transport->configuration, configuration, size);
 	transport->size = size;
-	transport->path = g_strdup_printf("%s/fd%d", device->path, fd++);
+	transport->path = g_strdup_printf("%s/fd%d",
+				device_get_path(device->btd_dev), fd++);
 	transport->fd = -1;
 
 	uuid = media_endpoint_get_uuid(endpoint);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/8] network: Remove redundant struct network_peer members
  2012-10-16 10:12 [PATCH 1/8] audio: Move btd_device unref after last use in device_free Szymon Janc
  2012-10-16 10:12 ` [PATCH 2/8] mgmt: Make mgmt_update_powered return void Szymon Janc
  2012-10-16 10:12 ` [PATCH 3/8] audio: Remove path from struct audio_device Szymon Janc
@ 2012-10-16 10:12 ` Szymon Janc
  2012-10-16 10:12 ` [PATCH 5/8] input: Remove not needed adapters list in manager Szymon Janc
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Szymon Janc @ 2012-10-16 10:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

struct network_peer holds reference to btd_device so path, src and dst
can be accessed from it.

---
 profiles/network/common.c     |    2 +-
 profiles/network/common.h     |    2 +-
 profiles/network/connection.c |   66 ++++++++++++++++++++---------------------
 profiles/network/connection.h |    5 ++--
 profiles/network/manager.c    |   22 ++++----------
 5 files changed, 43 insertions(+), 54 deletions(-)

diff --git a/profiles/network/common.c b/profiles/network/common.c
index da493c1..34ab788 100644
--- a/profiles/network/common.c
+++ b/profiles/network/common.c
@@ -124,7 +124,7 @@ int bnep_cleanup(void)
 	return 0;
 }
 
-int bnep_kill_connection(bdaddr_t *dst)
+int bnep_kill_connection(const bdaddr_t *dst)
 {
 	struct bnep_conndel_req req;
 
diff --git a/profiles/network/common.h b/profiles/network/common.h
index 62f2f59..0a8c4fe 100644
--- a/profiles/network/common.h
+++ b/profiles/network/common.h
@@ -28,7 +28,7 @@ uint16_t bnep_service_id(const char *svc);
 const char *bnep_uuid(uint16_t id);
 const char *bnep_name(uint16_t id);
 
-int bnep_kill_connection(bdaddr_t *dst);
+int bnep_kill_connection(const bdaddr_t *dst);
 int bnep_kill_all_connections(void);
 
 int bnep_connadd(int sk, uint16_t role, char *dev);
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index 9646e5a..8564bca 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -59,9 +59,6 @@ typedef enum {
 } conn_state;
 
 struct network_peer {
-	bdaddr_t	src;
-	bdaddr_t	dst;
-	char		*path;		/* D-Bus path */
 	struct btd_device *device;
 	GSList		*connections;
 };
@@ -86,12 +83,12 @@ struct __service_16 {
 
 static GSList *peers = NULL;
 
-static struct network_peer *find_peer(GSList *list, const char *path)
+static struct network_peer *find_peer(GSList *list, struct btd_device *device)
 {
 	for (; list; list = list->next) {
 		struct network_peer *peer = list->data;
 
-		if (!strcmp(peer->path, path))
+		if (peer->device == device)
 			return peer;
 	}
 
@@ -116,14 +113,15 @@ static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
 	struct network_conn *nc = data;
 	gboolean connected = FALSE;
 	const char *property = "";
+	const char *path = device_get_path(nc->peer->device);
 
-	emit_property_changed(nc->peer->path,
+	emit_property_changed(path,
 				NETWORK_PEER_INTERFACE, "Connected",
 				DBUS_TYPE_BOOLEAN, &connected);
-	emit_property_changed(nc->peer->path,
+	emit_property_changed(path,
 				NETWORK_PEER_INTERFACE, "Interface",
 				DBUS_TYPE_STRING, &property);
-	emit_property_changed(nc->peer->path,
+	emit_property_changed(path,
 				NETWORK_PEER_INTERFACE, "UUID",
 				DBUS_TYPE_STRING, &property);
 	device_remove_disconnect_watch(nc->peer->device, nc->dc_id);
@@ -180,7 +178,7 @@ static void connection_destroy(DBusConnection *conn, void *user_data)
 
 	if (nc->state == CONNECTED) {
 		bnep_if_down(nc->dev);
-		bnep_kill_connection(&nc->peer->dst);
+		bnep_kill_connection(device_get_address(nc->peer->device));
 	} else if (nc->io)
 		cancel_connection(nc, NULL);
 }
@@ -190,7 +188,7 @@ static void disconnect_cb(struct btd_device *device, gboolean removal,
 {
 	struct network_conn *nc = user_data;
 
-	info("Network: disconnect %s", nc->peer->path);
+	info("Network: disconnect %s", device_get_path(nc->peer->device));
 
 	connection_destroy(NULL, user_data);
 }
@@ -206,6 +204,7 @@ static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
 	int sk;
 	const char *pdev, *uuid;
 	gboolean connected;
+	const char *path;
 
 	if (cond & G_IO_NVAL)
 		return FALSE;
@@ -277,14 +276,16 @@ static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
 	dbus_message_unref(nc->msg);
 	nc->msg = NULL;
 
+	path = device_get_path(nc->peer->device);
+
 	connected = TRUE;
-	emit_property_changed(nc->peer->path,
+	emit_property_changed(path,
 				NETWORK_PEER_INTERFACE, "Connected",
 				DBUS_TYPE_BOOLEAN, &connected);
-	emit_property_changed(nc->peer->path,
+	emit_property_changed(path,
 				NETWORK_PEER_INTERFACE, "Interface",
 				DBUS_TYPE_STRING, &pdev);
-	emit_property_changed(nc->peer->path,
+	emit_property_changed(path,
 				NETWORK_PEER_INTERFACE, "UUID",
 				DBUS_TYPE_STRING, &uuid);
 
@@ -404,6 +405,8 @@ static DBusMessage *connection_connect(DBusConnection *conn,
 	const char *svc;
 	uint16_t id;
 	GError *err = NULL;
+	const bdaddr_t *src;
+	const bdaddr_t *dst;
 
 	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &svc,
 						DBUS_TYPE_INVALID) == FALSE)
@@ -417,10 +420,13 @@ static DBusMessage *connection_connect(DBusConnection *conn,
 	if (nc->state != DISCONNECTED)
 		return btd_error_already_connected(msg);
 
+	src = adapter_get_address(device_get_adapter(peer->device));
+	dst = device_get_address(peer->device);
+
 	nc->io = bt_io_connect(connect_cb, nc,
 				NULL, &err,
-				BT_IO_OPT_SOURCE_BDADDR, &peer->src,
-				BT_IO_OPT_DEST_BDADDR, &peer->dst,
+				BT_IO_OPT_SOURCE_BDADDR, src,
+				BT_IO_OPT_DEST_BDADDR, dst,
 				BT_IO_OPT_PSM, BNEP_PSM,
 				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
 				BT_IO_OPT_OMTU, BNEP_MTU,
@@ -544,7 +550,6 @@ static void peer_free(struct network_peer *peer)
 {
 	g_slist_free_full(peer->connections, connection_free);
 	btd_device_unref(peer->device);
-	g_free(peer->path);
 	g_free(peer);
 }
 
@@ -553,7 +558,7 @@ static void path_unregister(void *data)
 	struct network_peer *peer = data;
 
 	DBG("Unregistered interface %s on path %s",
-		NETWORK_PEER_INTERFACE, peer->path);
+		NETWORK_PEER_INTERFACE, device_get_path(peer->device));
 
 	peers = g_slist_remove(peers, peer);
 	peer_free(peer);
@@ -578,11 +583,11 @@ static const GDBusSignalTable connection_signals[] = {
 	{ }
 };
 
-void connection_unregister(const char *path)
+void connection_unregister(struct btd_device *device)
 {
 	struct network_peer *peer;
 
-	peer = find_peer(peers, path);
+	peer = find_peer(peers, device);
 	if (!peer)
 		return;
 
@@ -590,20 +595,19 @@ void connection_unregister(const char *path)
 	peer->connections = NULL;
 
 	g_dbus_unregister_interface(btd_get_dbus_connection(),
-						path, NETWORK_PEER_INTERFACE);
+						device_get_path(device),
+						NETWORK_PEER_INTERFACE);
 }
 
-static struct network_peer *create_peer(struct btd_device *device,
-					const char *path, const bdaddr_t *src,
-					const bdaddr_t *dst)
+static struct network_peer *create_peer(struct btd_device *device)
 {
 	struct network_peer *peer;
+	const char *path;
 
 	peer = g_new0(struct network_peer, 1);
 	peer->device = btd_device_ref(device);
-	peer->path = g_strdup(path);
-	bacpy(&peer->src, src);
-	bacpy(&peer->dst, dst);
+
+	path = device_get_path(device);
 
 	if (g_dbus_register_interface(btd_get_dbus_connection(), path,
 					NETWORK_PEER_INTERFACE,
@@ -622,18 +626,14 @@ static struct network_peer *create_peer(struct btd_device *device,
 	return peer;
 }
 
-int connection_register(struct btd_device *device, const char *path,
-			const bdaddr_t *src, const bdaddr_t *dst, uint16_t id)
+int connection_register(struct btd_device *device, uint16_t id)
 {
 	struct network_peer *peer;
 	struct network_conn *nc;
 
-	if (!path)
-		return -EINVAL;
-
-	peer = find_peer(peers, path);
+	peer = find_peer(peers, device);
 	if (!peer) {
-		peer = create_peer(device, path, src, dst);
+		peer = create_peer(device);
 		if (!peer)
 			return -1;
 		peers = g_slist_append(peers, peer);
diff --git a/profiles/network/connection.h b/profiles/network/connection.h
index efc4ccb..50c0774 100644
--- a/profiles/network/connection.h
+++ b/profiles/network/connection.h
@@ -21,6 +21,5 @@
  *
  */
 
-int connection_register(struct btd_device *device, const char *path,
-			const bdaddr_t *src, const bdaddr_t *dst, uint16_t id);
-void connection_unregister(const char *path);
+int connection_register(struct btd_device *device, uint16_t id);
+void connection_unregister(struct btd_device *device);
diff --git a/profiles/network/manager.c b/profiles/network/manager.c
index 049fbc7..aa564bd 100644
--- a/profiles/network/manager.c
+++ b/profiles/network/manager.c
@@ -76,33 +76,23 @@ done:
 static int network_probe(struct btd_profile *p, struct btd_device *device,
 								GSList *uuids)
 {
-	struct btd_adapter *adapter = device_get_adapter(device);
-	const gchar *path = device_get_path(device);
-	const bdaddr_t *src;
-	const bdaddr_t *dst;
-
-	DBG("path %s", path);
-
-	src = adapter_get_address(adapter);
-	dst = device_get_address(device);
+	DBG("path %s", device_get_path(device));
 
 	if (g_slist_find_custom(uuids, PANU_UUID, bt_uuid_strcmp))
-		connection_register(device, path, src, dst, BNEP_SVC_PANU);
+		connection_register(device, 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, 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, BNEP_SVC_NAP);
 
 	return 0;
 }
 
 static void network_remove(struct btd_profile *p, struct btd_device *device)
 {
-	const gchar *path = device_get_path(device);
-
-	DBG("path %s", path);
+	DBG("path %s", device_get_path(device));
 
-	connection_unregister(path);
+	connection_unregister(device);
 }
 
 static int network_server_probe(struct btd_profile *p,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 5/8] input: Remove not needed adapters list in manager
  2012-10-16 10:12 [PATCH 1/8] audio: Move btd_device unref after last use in device_free Szymon Janc
                   ` (2 preceding siblings ...)
  2012-10-16 10:12 ` [PATCH 4/8] network: Remove redundant struct network_peer members Szymon Janc
@ 2012-10-16 10:12 ` Szymon Janc
  2012-10-16 10:12 ` [PATCH 6/8] mgmt: Remove not used members from controller_info Szymon Janc
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Szymon Janc @ 2012-10-16 10:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

adapters list is not used for anything usefull.

---
 profiles/input/manager.c |   15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/profiles/input/manager.c b/profiles/input/manager.c
index 3f68620..a2690b5 100644
--- a/profiles/input/manager.c
+++ b/profiles/input/manager.c
@@ -44,8 +44,6 @@
 
 static int idle_timeout = 0;
 
-static GSList *adapters = NULL;
-
 static void input_remove(struct btd_device *device, const char *uuid)
 {
 	const gchar *path = device_get_path(device);
@@ -77,24 +75,13 @@ static void hid_device_remove(struct btd_profile *p, struct btd_device *device)
 
 static int hid_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
 {
-	int ret;
-
-	ret = server_start(adapter_get_address(adapter));
-	if (ret < 0)
-		return ret;
-
-	adapters = g_slist_append(adapters, btd_adapter_ref(adapter));
-
-	return 0;
+	return server_start(adapter_get_address(adapter));
 }
 
 static void hid_server_remove(struct btd_profile *p,
 						struct btd_adapter *adapter)
 {
 	server_stop(adapter_get_address(adapter));
-
-	adapters = g_slist_remove(adapters, adapter);
-	btd_adapter_unref(adapter);
 }
 
 static struct btd_profile input_profile = {
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 6/8] mgmt: Remove not used members from controller_info
  2012-10-16 10:12 [PATCH 1/8] audio: Move btd_device unref after last use in device_free Szymon Janc
                   ` (3 preceding siblings ...)
  2012-10-16 10:12 ` [PATCH 5/8] input: Remove not needed adapters list in manager Szymon Janc
@ 2012-10-16 10:12 ` Szymon Janc
  2012-10-16 10:12 ` [PATCH 7/8] Simplify str2ba function Szymon Janc
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Szymon Janc @ 2012-10-16 10:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

notified, version, manufacturer and dev_class were not used for
anything usefull. For debug print reply can be used directly.

---
 src/mgmt.c |   12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/mgmt.c b/src/mgmt.c
index 8caabe8..627fb4b 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -61,13 +61,9 @@ struct pending_uuid {
 static int max_index = -1;
 static struct controller_info {
 	gboolean valid;
-	gboolean notified;
 	bdaddr_t bdaddr;
-	uint8_t version;
-	uint16_t manufacturer;
 	uint32_t supported_settings;
 	uint32_t current_settings;
-	uint8_t dev_class[3];
 	GSList *connections;
 	uint8_t discov_type;
 
@@ -1075,20 +1071,16 @@ static void read_info_complete(int sk, uint16_t index, void *buf, size_t len)
 	info = &controllers[index];
 
 	bacpy(&info->bdaddr, &rp->bdaddr);
-	info->version = rp->version;
-	info->manufacturer = bt_get_le16(&rp->manufacturer);
 
 	memcpy(&info->supported_settings, &rp->supported_settings,
 					sizeof(info->supported_settings));
 	memcpy(&info->current_settings, &rp->current_settings,
 					sizeof(info->current_settings));
 
-	memcpy(info->dev_class, rp->dev_class, sizeof(info->dev_class));
-
 	ba2str(&info->bdaddr, addr);
 	DBG("hci%u addr %s version %u manufacturer %u class 0x%02x%02x%02x\n",
-		index, addr, info->version, info->manufacturer,
-		info->dev_class[2], info->dev_class[1], info->dev_class[0]);
+		index, addr, rp->version, bt_get_le16(&rp->manufacturer),
+		rp->dev_class[2], rp->dev_class[1], rp->dev_class[0]);
 	DBG("hci%u settings", index);
 	DBG("hci%u name %s", index, (char *) rp->name);
 	DBG("hci%u short name %s", index, (char *) rp->short_name);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 7/8] Simplify str2ba function
  2012-10-16 10:12 [PATCH 1/8] audio: Move btd_device unref after last use in device_free Szymon Janc
                   ` (4 preceding siblings ...)
  2012-10-16 10:12 ` [PATCH 6/8] mgmt: Remove not used members from controller_info Szymon Janc
@ 2012-10-16 10:12 ` Szymon Janc
  2012-10-16 10:12 ` [PATCH 8/8] adapter: Remove not used defines Szymon Janc
  2012-10-16 10:37 ` [PATCH 1/8] audio: Move btd_device unref after last use in device_free Johan Hedberg
  7 siblings, 0 replies; 9+ messages in thread
From: Szymon Janc @ 2012-10-16 10:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Reverse loop iteration so that baswap call is not needed.

---
 lib/bluetooth.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index d092d01..d9360dc 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
@@ -82,7 +82,6 @@ int ba2str(const bdaddr_t *ba, char *str)
 
 int str2ba(const char *str, bdaddr_t *ba)
 {
-	bdaddr_t b;
 	int i;
 
 	if (bachk(str) < 0) {
@@ -90,10 +89,8 @@ int str2ba(const char *str, bdaddr_t *ba)
 		return -1;
 	}
 
-	for (i = 0; i < 6; i++, str += 3)
-		b.b[i] = strtol(str, NULL, 16);
-
-	baswap(ba, &b);
+	for (i = 5; i >= 0; i--, str += 3)
+		ba->b[i] = strtol(str, NULL, 16);
 
 	return 0;
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 8/8] adapter: Remove not used defines
  2012-10-16 10:12 [PATCH 1/8] audio: Move btd_device unref after last use in device_free Szymon Janc
                   ` (5 preceding siblings ...)
  2012-10-16 10:12 ` [PATCH 7/8] Simplify str2ba function Szymon Janc
@ 2012-10-16 10:12 ` Szymon Janc
  2012-10-16 10:37 ` [PATCH 1/8] audio: Move btd_device unref after last use in device_free Johan Hedberg
  7 siblings, 0 replies; 9+ messages in thread
From: Szymon Janc @ 2012-10-16 10:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

check_address and OFF_TIMER are not used anymore.

---
 src/adapter.c |    4 ----
 1 file changed, 4 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 86a2124..7c2aec0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -80,10 +80,6 @@
 #define IO_CAPABILITY_KEYBOARDDISPLAY	0x04
 #define IO_CAPABILITY_INVALID		0xFF
 
-#define check_address(address) bachk(address)
-
-#define OFF_TIMER 3
-
 #define REMOVE_TEMP_TIMEOUT (3 * 60)
 #define PENDING_FOUND_MAX 5
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/8] audio: Move btd_device unref after last use in device_free
  2012-10-16 10:12 [PATCH 1/8] audio: Move btd_device unref after last use in device_free Szymon Janc
                   ` (6 preceding siblings ...)
  2012-10-16 10:12 ` [PATCH 8/8] adapter: Remove not used defines Szymon Janc
@ 2012-10-16 10:37 ` Johan Hedberg
  7 siblings, 0 replies; 9+ messages in thread
From: Johan Hedberg @ 2012-10-16 10:37 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth

Hi Szymon,

On Tue, Oct 16, 2012, Szymon Janc wrote:
> btd_device should not be used after local reference was dropped.
> 
> ---
>  audio/device.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

All patches in this set have been applied. Thanks.

As a note for future commit messages please prefix lib/* changes with
"lib: ..". I fixed it manually this time.

Johan

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-10-16 10:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-16 10:12 [PATCH 1/8] audio: Move btd_device unref after last use in device_free Szymon Janc
2012-10-16 10:12 ` [PATCH 2/8] mgmt: Make mgmt_update_powered return void Szymon Janc
2012-10-16 10:12 ` [PATCH 3/8] audio: Remove path from struct audio_device Szymon Janc
2012-10-16 10:12 ` [PATCH 4/8] network: Remove redundant struct network_peer members Szymon Janc
2012-10-16 10:12 ` [PATCH 5/8] input: Remove not needed adapters list in manager Szymon Janc
2012-10-16 10:12 ` [PATCH 6/8] mgmt: Remove not used members from controller_info Szymon Janc
2012-10-16 10:12 ` [PATCH 7/8] Simplify str2ba function Szymon Janc
2012-10-16 10:12 ` [PATCH 8/8] adapter: Remove not used defines Szymon Janc
2012-10-16 10:37 ` [PATCH 1/8] audio: Move btd_device unref after last use in device_free Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).