All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH_v2 1/6] android/pan: Rename pan_device_free to destroy_pan_device
@ 2013-12-16 22:05 Ravi kumar Veeramally
  2013-12-16 22:05 ` [PATCH_v2 2/6] android/pan: Rename connect_cb to bt_io_connect_cb Ravi kumar Veeramally
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Ravi kumar Veeramally @ 2013-12-16 22:05 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

Renaming function name because it does more than freeing memory.
Also moving disconnect notification call to destory_pan_device
reduce redundancy.
---
 android/pan.c | 51 +++++++++++++++++++++++----------------------------
 1 file changed, 23 insertions(+), 28 deletions(-)

diff --git a/android/pan.c b/android/pan.c
index e410f54..ec589cf 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -65,24 +65,6 @@ static int device_cmp(gconstpointer s, gconstpointer user_data)
 	return bacmp(&dev->dst, dst);
 }
 
-static void pan_device_free(struct pan_device *dev)
-{
-	local_role = HAL_PAN_ROLE_NONE;
-
-	if (dev->watch > 0) {
-		g_source_remove(dev->watch);
-		dev->watch = 0;
-	}
-
-	if (dev->io) {
-		g_io_channel_unref(dev->io);
-		dev->io = NULL;
-	}
-
-	devices = g_slist_remove(devices, dev);
-	g_free(dev);
-}
-
 static void bt_pan_notify_conn_state(struct pan_device *dev, uint8_t state)
 {
 	struct hal_ev_pan_conn_state ev;
@@ -121,6 +103,25 @@ static void bt_pan_notify_ctrl_state(struct pan_device *dev, uint8_t state)
 									&ev);
 }
 
+static void destroy_pan_device(struct pan_device *dev)
+{
+	local_role = HAL_PAN_ROLE_NONE;
+
+	if (dev->watch > 0) {
+		g_source_remove(dev->watch);
+		dev->watch = 0;
+	}
+
+	if (dev->io) {
+		g_io_channel_unref(dev->io);
+		dev->io = NULL;
+	}
+
+	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
+	devices = g_slist_remove(devices, dev);
+	g_free(dev);
+}
+
 static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
 								gpointer data)
 {
@@ -130,8 +131,7 @@ static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
 
 	bnep_if_down(dev->iface);
 	bnep_conndel(&dev->dst);
-	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
-	pan_device_free(dev);
+	destroy_pan_device(dev);
 
 	return FALSE;
 }
@@ -145,8 +145,7 @@ static void bnep_conn_cb(GIOChannel *chan, char *iface, int err, void *data)
 	if (err < 0) {
 		error("bnep connect req failed: %s", strerror(-err));
 		bnep_conndel(&dev->dst);
-		bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
-		pan_device_free(dev);
+		destroy_pan_device(dev);
 		return;
 	}
 
@@ -189,8 +188,7 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer data)
 	return;
 
 fail:
-	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
-	pan_device_free(dev);
+	destroy_pan_device(dev);
 }
 
 static void bt_pan_connect(const void *buf, uint16_t len)
@@ -292,10 +290,7 @@ static void bt_pan_disconnect(const void *buf, uint16_t len)
 
 	bnep_if_down(dev->iface);
 	bnep_conndel(&dst);
-
-	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
-	pan_device_free(dev);
-
+	destroy_pan_device(dev);
 	status = HAL_STATUS_SUCCESS;
 
 failed:
-- 
1.8.3.2


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

end of thread, other threads:[~2013-12-17  9:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-16 22:05 [PATCH_v2 1/6] android/pan: Rename pan_device_free to destroy_pan_device Ravi kumar Veeramally
2013-12-16 22:05 ` [PATCH_v2 2/6] android/pan: Rename connect_cb to bt_io_connect_cb Ravi kumar Veeramally
2013-12-17  9:27   ` Johan Hedberg
2013-12-17  9:38     ` Ravi kumar Veeramally
2013-12-16 22:05 ` [PATCH_v2 3/6] bnep: Add bnep_new and bnep_free api's Ravi kumar Veeramally
2013-12-17  9:19   ` Luiz Augusto von Dentz
2013-12-17  9:42     ` Ravi kumar Veeramally
2013-12-16 22:05 ` [PATCH_v2 4/6] bnep: Refactored bnep connect and disconnect calls Ravi kumar Veeramally
2013-12-16 22:05 ` [PATCH_v2 5/6] bnep: Refactored bnep server apis for bridge addition and deletion Ravi kumar Veeramally
2013-12-16 22:05 ` [PATCH_v2 6/6] bnep: Refactor bnep setup response validation functionality Ravi kumar Veeramally
2013-12-17  9:09 ` [PATCH_v2 1/6] android/pan: Rename pan_device_free to destroy_pan_device Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.