OSDN Git Service

core: Make device_connect LE return int instead of GIOChannel
authorJohan Hedberg <johan.hedberg@intel.com>
Fri, 25 Jan 2013 09:48:53 +0000 (11:48 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 25 Jan 2013 09:49:48 +0000 (11:49 +0200)
The IO channel doesn't need external tracking so just return a simple
int instead.

src/device.c
src/device.h

index 4113811..ea316b7 100644 (file)
@@ -3116,7 +3116,7 @@ static void att_success_cb(gpointer user_data)
        g_slist_foreach(device->attios, attio_connected, device->attrib);
 }
 
-GIOChannel *device_connect_le(struct btd_device *dev)
+int device_connect_le(struct btd_device *dev)
 {
        struct btd_adapter *adapter = dev->adapter;
        struct att_callbacks *attcb;
@@ -3127,7 +3127,7 @@ GIOChannel *device_connect_le(struct btd_device *dev)
 
        /* There is one connection attempt going on */
        if (dev->att_io)
-               return NULL;
+               return -EALREADY;
 
        ba2str(&dev->bdaddr, addr);
 
@@ -3168,13 +3168,13 @@ GIOChannel *device_connect_le(struct btd_device *dev)
                error("ATT bt_io_connect(%s): %s", addr, gerr->message);
                g_error_free(gerr);
                g_free(attcb);
-               return NULL;
+               return -EIO;
        }
 
        /* Keep this, so we can cancel the connection */
-       dev->att_io = g_io_channel_ref(io);
+       dev->att_io = io;
 
-       return io;
+       return 0;
 }
 
 static void att_browse_error_cb(const GError *gerr, gpointer user_data)
index 696632c..102f21f 100644 (file)
@@ -109,7 +109,7 @@ int device_unblock(struct btd_device *device, gboolean silent,
 void btd_device_set_pnpid(struct btd_device *device, uint16_t source,
                        uint16_t vendor, uint16_t product, uint16_t version);
 
-GIOChannel *device_connect_le(struct btd_device *dev);
+int device_connect_le(struct btd_device *dev);
 
 struct btd_profile;