Diff between a0d52c9ad0abe3d7b4f99ea855c8d7664bb3c3fd and 5dd93fc16a76b57e1a5fd93f89b47268ceaf0599

Changed Files

File Additions Deletions Status
attrib/client.c +4 -6 modified
attrib/gattrib.c +3 -6 modified
attrib/interactive.c +1 -2 modified
attrib/utils.c +2 -2 modified
audio/avctp.c +4 -4 modified
audio/avdtp.c +6 -7 modified
audio/gateway.c +2 -2 modified
audio/headset.c +2 -2 modified
audio/main.c +2 -2 modified
audio/manager.c +5 -5 modified
profiles/gatt/gas.c +1 -1 modified
profiles/health/hdp.c +1 -1 modified
profiles/health/mcap.c +9 -15 modified
profiles/input/device.c +4 -4 modified
profiles/input/server.c +5 -5 modified
profiles/network/connection.c +1 -1 modified
profiles/network/server.c +2 -2 modified
profiles/sap/server.c +2 -2 modified
src/attrib-server.c +5 -8 modified
src/device.c +4 -4 modified
test/btiotest.c +44 -63 modified

Full Patch

diff --git a/attrib/client.c b/attrib/client.c
index c438d7c..bb6adf8 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -706,14 +706,12 @@ static void update_char_desc(guint8 status, const guint8 *pdu, guint16 len,
 		GIOChannel *io = g_attrib_get_channel(gatt->attrib);
 		BtIOSecLevel level = BT_IO_SEC_HIGH;
 
-		bt_io_get(io, BT_IO_L2CAP, NULL,
-				BT_IO_OPT_SEC_LEVEL, &level,
-				BT_IO_OPT_INVALID);
-
+		bt_io_get(io, NULL, BT_IO_OPT_SEC_LEVEL, &level,
+							BT_IO_OPT_INVALID);
 		if (level < BT_IO_SEC_HIGH)
 			level++;
 
-		if (bt_io_set(io, BT_IO_L2CAP, NULL,
+		if (bt_io_set(io, NULL,
 				BT_IO_OPT_SEC_LEVEL, level,
 				BT_IO_OPT_INVALID)) {
 			gatt_read_char(gatt->attrib, current->handle, 0,
@@ -764,7 +762,7 @@ static void update_char_value(guint8 status, const guint8 *pdu,
 	else if (status == ATT_ECODE_INSUFF_ENC) {
 		GIOChannel *io = g_attrib_get_channel(gatt->attrib);
 
-		if (bt_io_set(io, BT_IO_L2CAP, NULL,
+		if (bt_io_set(io, NULL,
 				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_HIGH,
 				BT_IO_OPT_INVALID)) {
 			gatt_read_char(gatt->attrib, chr->handle, 0,
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index c91f5e9..108d1d3 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -444,11 +444,8 @@ GAttrib *g_attrib_new(GIOChannel *io)
 	g_io_channel_set_encoding(io, NULL, NULL);
 	g_io_channel_set_buffered(io, FALSE);
 
-	bt_io_get(io, BT_IO_L2CAP, &gerr,
-			BT_IO_OPT_IMTU, &imtu,
-			BT_IO_OPT_CID, &cid,
-			BT_IO_OPT_INVALID);
-
+	bt_io_get(io, &gerr, BT_IO_OPT_IMTU, &imtu,
+				BT_IO_OPT_CID, &cid, BT_IO_OPT_INVALID);
 	if (gerr) {
 		error("%s", gerr->message);
 		g_error_free(gerr);
@@ -673,7 +670,7 @@ gboolean g_attrib_is_encrypted(GAttrib *attrib)
 {
 	BtIOSecLevel sec_level;
 
-	if (!bt_io_get(attrib->io, BT_IO_L2CAP, NULL,
+	if (!bt_io_get(attrib->io, NULL,
 			BT_IO_OPT_SEC_LEVEL, &sec_level,
 			BT_IO_OPT_INVALID))
 		return FALSE;
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 3e8a0d9..c96df3e 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -665,10 +665,9 @@ static void cmd_sec_level(int argcp, char **argvp)
 		return;
 	}
 
-	bt_io_set(iochannel, BT_IO_L2CAP, &gerr,
+	bt_io_set(iochannel, &gerr,
 			BT_IO_OPT_SEC_LEVEL, sec_level,
 			BT_IO_OPT_INVALID);
-
 	if (gerr) {
 		printf("Error: %s\n", gerr->message);
 		g_error_free(gerr);
diff --git a/attrib/utils.c b/attrib/utils.c
index d856fe2..b5ade9a 100644
--- a/attrib/utils.c
+++ b/attrib/utils.c
@@ -76,7 +76,7 @@ GIOChannel *gatt_connect(const gchar *src, const gchar *dst,
 		sec = BT_IO_SEC_LOW;
 
 	if (psm == 0)
-		chan = bt_io_connect(BT_IO_L2CAP, connect_cb, NULL, NULL, &err,
+		chan = bt_io_connect(connect_cb, NULL, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &sba,
 				BT_IO_OPT_DEST_BDADDR, &dba,
 				BT_IO_OPT_DEST_TYPE, dest_type,
@@ -84,7 +84,7 @@ GIOChannel *gatt_connect(const gchar *src, const gchar *dst,
 				BT_IO_OPT_SEC_LEVEL, sec,
 				BT_IO_OPT_INVALID);
 	else
-		chan = bt_io_connect(BT_IO_L2CAP, connect_cb, NULL, NULL, &err,
+		chan = bt_io_connect(connect_cb, NULL, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &sba,
 				BT_IO_OPT_DEST_BDADDR, &dba,
 				BT_IO_OPT_PSM, psm,
diff --git a/audio/avctp.c b/audio/avctp.c
index 074eabd..2970986 100644
--- a/audio/avctp.c
+++ b/audio/avctp.c
@@ -626,7 +626,7 @@ static void avctp_connect_cb(GIOChannel *chan, GError *err, gpointer data)
 		return;
 	}
 
-	bt_io_get(chan, BT_IO_L2CAP, &gerr,
+	bt_io_get(chan, &gerr,
 			BT_IO_OPT_DEST, &address,
 			BT_IO_OPT_IMTU, &imtu,
 			BT_IO_OPT_INVALID);
@@ -737,7 +737,7 @@ static void avctp_confirm_cb(GIOChannel *chan, gpointer data)
 	bdaddr_t src, dst;
 	GError *err = NULL;
 
-	bt_io_get(chan, BT_IO_L2CAP, &err,
+	bt_io_get(chan, &err,
 			BT_IO_OPT_SOURCE_BDADDR, &src,
 			BT_IO_OPT_DEST_BDADDR, &dst,
 			BT_IO_OPT_DEST, address,
@@ -799,7 +799,7 @@ static GIOChannel *avctp_server_socket(const bdaddr_t *src, gboolean master)
 	GError *err = NULL;
 	GIOChannel *io;
 
-	io = bt_io_listen(BT_IO_L2CAP, NULL, avctp_confirm_cb, NULL,
+	io = bt_io_listen(NULL, avctp_confirm_cb, NULL,
 				NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, src,
 				BT_IO_OPT_PSM, AVCTP_PSM,
@@ -1087,7 +1087,7 @@ struct avctp *avctp_connect(const bdaddr_t *src, const bdaddr_t *dst)
 
 	avctp_set_state(session, AVCTP_STATE_CONNECTING);
 
-	io = bt_io_connect(BT_IO_L2CAP, avctp_connect_cb, session, NULL, &err,
+	io = bt_io_connect(avctp_connect_cb, session, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &session->server->src,
 				BT_IO_OPT_DEST_BDADDR, &session->dst,
 				BT_IO_OPT_PSM, AVCTP_PSM,
diff --git a/audio/avdtp.c b/audio/avdtp.c
index abd384b..eafafc0 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
@@ -893,9 +893,8 @@ static void handle_transport_connect(struct avdtp *session, GIOChannel *io,
 	if (sep->info.type != AVDTP_SEP_TYPE_SOURCE)
 		goto proceed;
 
-	bt_io_set(stream->io, BT_IO_L2CAP, &err,
-					BT_IO_OPT_FLUSHABLE, TRUE,
-					BT_IO_OPT_INVALID);
+	bt_io_set(stream->io, &err, BT_IO_OPT_FLUSHABLE, TRUE,
+							BT_IO_OPT_INVALID);
 	if (err != NULL) {
 		error("Enabling flushable packets failed: %s", err->message);
 		g_error_free(err);
@@ -2414,7 +2413,7 @@ static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	if (!session->io)
 		session->io = g_io_channel_ref(chan);
 
-	bt_io_get(chan, BT_IO_L2CAP, &gerr,
+	bt_io_get(chan, &gerr,
 			BT_IO_OPT_OMTU, &session->omtu,
 			BT_IO_OPT_IMTU, &session->imtu,
 			BT_IO_OPT_INVALID);
@@ -2510,7 +2509,7 @@ static void avdtp_confirm_cb(GIOChannel *chan, gpointer data)
 	int perr;
 	GError *err = NULL;
 
-	bt_io_get(chan, BT_IO_L2CAP, &err,
+	bt_io_get(chan, &err,
 			BT_IO_OPT_SOURCE_BDADDR, &src,
 			BT_IO_OPT_DEST_BDADDR, &dst,
 			BT_IO_OPT_DEST, address,
@@ -2587,7 +2586,7 @@ static GIOChannel *l2cap_connect(struct avdtp *session)
 	GError *err = NULL;
 	GIOChannel *io;
 
-	io = bt_io_connect(BT_IO_L2CAP, avdtp_connect_cb, session,
+	io = bt_io_connect(avdtp_connect_cb, session,
 				NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &session->server->src,
 				BT_IO_OPT_DEST_BDADDR, &session->dst,
@@ -3855,7 +3854,7 @@ static GIOChannel *avdtp_server_socket(const bdaddr_t *src, gboolean master)
 	GError *err = NULL;
 	GIOChannel *io;
 
-	io = bt_io_listen(BT_IO_L2CAP, NULL, avdtp_confirm_cb,
+	io = bt_io_listen(NULL, avdtp_confirm_cb,
 				NULL, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, src,
 				BT_IO_OPT_PSM, AVDTP_PSM,
diff --git a/audio/gateway.c b/audio/gateway.c
index 6162948..c0159a4 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -496,7 +496,7 @@ static void get_record_cb(sdp_list_t *recs, int err, gpointer user_data)
 		goto fail;
 	}
 
-	io = bt_io_connect(BT_IO_RFCOMM, rfcomm_connect_cb, dev, NULL, &gerr,
+	io = bt_io_connect(rfcomm_connect_cb, dev, NULL, &gerr,
 				BT_IO_OPT_SOURCE_BDADDR, &dev->src,
 				BT_IO_OPT_DEST_BDADDR, &dev->dst,
 				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
@@ -842,7 +842,7 @@ unsigned int gateway_request_stream(struct audio_device *dev,
 	if (!gw->rfcomm)
 		get_records(dev);
 	else if (!gw->sco) {
-		io = bt_io_connect(BT_IO_SCO, sco_connect_cb, dev, NULL, &err,
+		io = bt_io_connect(sco_connect_cb, dev, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &dev->src,
 				BT_IO_OPT_DEST_BDADDR, &dev->dst,
 				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
diff --git a/audio/headset.c b/audio/headset.c
index 1014c59..0ddd134 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -621,7 +621,7 @@ static int sco_connect(struct audio_device *dev, headset_stream_cb_t cb,
 	if (hs->state != HEADSET_STATE_CONNECTED)
 		return -EINVAL;
 
-	io = bt_io_connect(BT_IO_SCO, sco_connect_cb, dev, NULL, &err,
+	io = bt_io_connect(sco_connect_cb, dev, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &dev->src,
 				BT_IO_OPT_DEST_BDADDR, &dev->dst,
 				BT_IO_OPT_INVALID);
@@ -1621,7 +1621,7 @@ static int rfcomm_connect(struct audio_device *dev, headset_stream_cb_t cb,
 	DBG("%s: Connecting to %s channel %d", dev->path, address,
 		hs->rfcomm_ch);
 
-	hs->tmp_rfcomm = bt_io_connect(BT_IO_RFCOMM, headset_connect_cb, dev,
+	hs->tmp_rfcomm = bt_io_connect(headset_connect_cb, dev,
 					NULL, &err,
 					BT_IO_OPT_SOURCE_BDADDR, &dev->src,
 					BT_IO_OPT_DEST_BDADDR, &dev->dst,
diff --git a/audio/main.c b/audio/main.c
index a48c8b8..a88f163 100644
--- a/audio/main.c
+++ b/audio/main.c
@@ -79,7 +79,7 @@ static void sco_server_cb(GIOChannel *chan, GError *err, gpointer data)
 		return;
 	}
 
-	bt_io_get(chan, BT_IO_SCO, &err,
+	bt_io_get(chan, &err,
 			BT_IO_OPT_SOURCE_BDADDR, &src,
 			BT_IO_OPT_DEST_BDADDR, &dst,
 			BT_IO_OPT_DEST, addr,
@@ -161,7 +161,7 @@ static int audio_init(void)
 	if (!enable_sco)
 		return 0;
 
-	sco_server = bt_io_listen(BT_IO_SCO, sco_server_cb, NULL, NULL,
+	sco_server = bt_io_listen(sco_server_cb, NULL, NULL,
 					NULL, NULL,
 					BT_IO_OPT_INVALID);
 	if (!sco_server) {
diff --git a/audio/manager.c b/audio/manager.c
index 999124d..7406a1f 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -462,7 +462,7 @@ static void ag_confirm(GIOChannel *chan, gpointer data)
 	GError *err = NULL;
 	uint8_t ch;
 
-	bt_io_get(chan, BT_IO_RFCOMM, &err,
+	bt_io_get(chan, &err,
 			BT_IO_OPT_SOURCE_BDADDR, &src,
 			BT_IO_OPT_DEST_BDADDR, &dst,
 			BT_IO_OPT_CHANNEL, &ch,
@@ -560,7 +560,7 @@ static void hf_io_cb(GIOChannel *chan, gpointer data)
 	struct audio_device *device;
 	int perr;
 
-	bt_io_get(chan, BT_IO_RFCOMM, &err,
+	bt_io_get(chan, &err,
 			BT_IO_OPT_SOURCE_BDADDR, &src,
 			BT_IO_OPT_DEST_BDADDR, &dst,
 			BT_IO_OPT_CHANNEL, &ch,
@@ -632,7 +632,7 @@ static int headset_server_init(struct audio_adapter *adapter)
 
 	adapter_get_address(adapter->btd_adapter, &src);
 
-	io =  bt_io_listen(BT_IO_RFCOMM, NULL, ag_confirm, adapter, NULL, &err,
+	io =  bt_io_listen(NULL, ag_confirm, adapter, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &src,
 				BT_IO_OPT_CHANNEL, chan,
 				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
@@ -663,7 +663,7 @@ static int headset_server_init(struct audio_adapter *adapter)
 
 	chan = DEFAULT_HF_AG_CHANNEL;
 
-	io = bt_io_listen(BT_IO_RFCOMM, NULL, ag_confirm, adapter, NULL, &err,
+	io = bt_io_listen(NULL, ag_confirm, adapter, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &src,
 				BT_IO_OPT_CHANNEL, chan,
 				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
@@ -733,7 +733,7 @@ static int gateway_server_init(struct audio_adapter *adapter)
 
 	adapter_get_address(adapter->btd_adapter, &src);
 
-	io = bt_io_listen(BT_IO_RFCOMM, NULL, hf_io_cb, adapter, NULL, &err,
+	io = bt_io_listen(NULL, hf_io_cb, adapter, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &src,
 				BT_IO_OPT_CHANNEL, chan,
 				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index e82513b..67cc5ae 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -286,7 +286,7 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 	gas->attrib = g_attrib_ref(attrib);
 	io = g_attrib_get_channel(attrib);
 
-	if (bt_io_get(io, BT_IO_L2CAP, &gerr, BT_IO_OPT_IMTU, &imtu,
+	if (bt_io_get(io, &gerr, BT_IO_OPT_IMTU, &imtu,
 				BT_IO_OPT_CID, &cid, BT_IO_OPT_INVALID)) {
 		gatt_exchange_mtu(gas->attrib, imtu, exchange_mtu_cb, gas);
 		gas->mtu = imtu;
diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
index 2316204..b54733b 100644
--- a/profiles/health/hdp.c
+++ b/profiles/health/hdp.c
@@ -887,7 +887,7 @@ static gboolean check_channel_conf(struct hdp_channel *chan)
 		return FALSE;
 	io = g_io_channel_unix_new(fd);
 
-	if (!bt_io_get(io, BT_IO_L2CAP, &err,
+	if (!bt_io_get(io, &err,
 			BT_IO_OPT_MODE, &mode,
 			BT_IO_OPT_IMTU, &imtu,
 			BT_IO_OPT_OMTU, &omtu,
diff --git a/profiles/health/mcap.c b/profiles/health/mcap.c
index b76d88a..86f0575 100644
--- a/profiles/health/mcap.c
+++ b/profiles/health/mcap.c
@@ -1674,7 +1674,7 @@ gboolean mcap_connect_mdl(struct mcap_mdl *mdl, uint8_t mode,
 	con->destroy = destroy;
 	con->user_data = user_data;
 
-	mdl->dc = bt_io_connect(BT_IO_L2CAP, mcap_connect_mdl_cb, con,
+	mdl->dc = bt_io_connect(mcap_connect_mdl_cb, con,
 				(GDestroyNotify) free_mcap_mdl_op, err,
 				BT_IO_OPT_SOURCE_BDADDR, &mdl->mcl->mi->src,
 				BT_IO_OPT_DEST_BDADDR, &mdl->mcl->addr,
@@ -1847,7 +1847,7 @@ gboolean mcap_create_mcl(struct mcap_instance *mi,
 	con->destroy = destroy;
 	con->user_data = user_data;
 
-	mcl->cc = bt_io_connect(BT_IO_L2CAP, mcap_connect_mcl_cb, con,
+	mcl->cc = bt_io_connect(mcap_connect_mcl_cb, con,
 				mcl_io_destroy, err,
 				BT_IO_OPT_SOURCE_BDADDR, &mi->src,
 				BT_IO_OPT_DEST_BDADDR, addr,
@@ -1883,9 +1883,7 @@ static void connect_dc_event_cb(GIOChannel *chan, GError *gerr,
 	if (gerr)
 		return;
 
-	bt_io_get(chan, BT_IO_L2CAP, &err,
-			BT_IO_OPT_DEST_BDADDR, &dst,
-			BT_IO_OPT_INVALID);
+	bt_io_get(chan, &err, BT_IO_OPT_DEST_BDADDR, &dst, BT_IO_OPT_INVALID);
 	if (err) {
 		error("%s", err->message);
 		g_error_free(err);
@@ -1952,7 +1950,7 @@ static void connect_mcl_event_cb(GIOChannel *chan, GError *gerr,
 	if (gerr)
 		return;
 
-	bt_io_get(chan, BT_IO_L2CAP, &err,
+	bt_io_get(chan, &err,
 			BT_IO_OPT_DEST_BDADDR, &dst,
 			BT_IO_OPT_DEST, address,
 			BT_IO_OPT_INVALID);
@@ -2028,7 +2026,7 @@ struct mcap_instance *mcap_create_instance(bdaddr_t *src,
 	mi->csp_enabled = FALSE;
 
 	/* Listen incoming connections in control channel */
-	mi->ccio = bt_io_listen(BT_IO_L2CAP, connect_mcl_event_cb, NULL, mi,
+	mi->ccio = bt_io_listen(connect_mcl_event_cb, NULL, mi,
 				NULL, gerr,
 				BT_IO_OPT_SOURCE_BDADDR, &mi->src,
 				BT_IO_OPT_PSM, ccpsm,
@@ -2043,7 +2041,7 @@ struct mcap_instance *mcap_create_instance(bdaddr_t *src,
 	}
 
 	/* Listen incoming connections in data channels */
-	mi->dcio = bt_io_listen(BT_IO_L2CAP, connect_dc_event_cb, NULL, mi,
+	mi->dcio = bt_io_listen(connect_dc_event_cb, NULL, mi,
 				NULL, gerr,
 				BT_IO_OPT_SOURCE_BDADDR, &mi->src,
 				BT_IO_OPT_PSM, dcpsm,
@@ -2133,9 +2131,7 @@ uint16_t mcap_get_ctrl_psm(struct mcap_instance *mi, GError **err)
 		return 0;
 	}
 
-	if (!bt_io_get(mi->ccio, BT_IO_L2CAP, err,
-			BT_IO_OPT_PSM, &lpsm,
-			BT_IO_OPT_INVALID))
+	if (!bt_io_get(mi->ccio, err, BT_IO_OPT_PSM, &lpsm, BT_IO_OPT_INVALID))
 		return 0;
 
 	return lpsm;
@@ -2151,9 +2147,7 @@ uint16_t mcap_get_data_psm(struct mcap_instance *mi, GError **err)
 		return 0;
 	}
 
-	if (!bt_io_get(mi->dcio, BT_IO_L2CAP, err,
-			BT_IO_OPT_PSM, &lpsm,
-			BT_IO_OPT_INVALID))
+	if (!bt_io_get(mi->dcio, err, BT_IO_OPT_PSM, &lpsm, BT_IO_OPT_INVALID))
 		return 0;
 
 	return lpsm;
@@ -2168,7 +2162,7 @@ gboolean mcap_set_data_chan_mode(struct mcap_instance *mi, uint8_t mode,
 		return FALSE;
 	}
 
-	return bt_io_set(mi->dcio, BT_IO_L2CAP, err, BT_IO_OPT_MODE, mode,
+	return bt_io_set(mi->dcio, err, BT_IO_OPT_MODE, mode,
 							BT_IO_OPT_INVALID);
 }
 
diff --git a/profiles/input/device.c b/profiles/input/device.c
index 48d397a..e3f9dac 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -363,7 +363,7 @@ static gboolean rfcomm_connect(struct input_conn *iconn, GError **err)
 	struct input_device *idev = iconn->idev;
 	GIOChannel *io;
 
-	io = bt_io_connect(BT_IO_RFCOMM, rfcomm_connect_cb, iconn,
+	io = bt_io_connect(rfcomm_connect_cb, iconn,
 				NULL, err,
 				BT_IO_OPT_SOURCE_BDADDR, &idev->src,
 				BT_IO_OPT_DEST_BDADDR, &idev->dst,
@@ -651,7 +651,7 @@ static int hidp_add_connection(const struct input_device *idev,
 
 	/* Encryption is mandatory for keyboards */
 	if (req->subclass & 0x40) {
-		if (!bt_io_set(iconn->intr_io, BT_IO_L2CAP, &gerr,
+		if (!bt_io_set(iconn->intr_io, &gerr,
 					BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
 					BT_IO_OPT_INVALID)) {
 			error("btio: %s", gerr->message);
@@ -885,7 +885,7 @@ static void control_connect_cb(GIOChannel *chan, GError *conn_err,
 	}
 
 	/* Connect to the HID interrupt channel */
-	io = bt_io_connect(BT_IO_L2CAP, interrupt_connect_cb, iconn,
+	io = bt_io_connect(interrupt_connect_cb, iconn,
 				NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &idev->src,
 				BT_IO_OPT_DEST_BDADDR, &idev->dst,
@@ -972,7 +972,7 @@ static DBusMessage *input_device_connect(DBusConnection *conn,
 		if (idev->disable_sdp)
 			bt_clear_cached_session(&idev->src, &idev->dst);
 
-		io = bt_io_connect(BT_IO_L2CAP, control_connect_cb, iconn,
+		io = bt_io_connect(control_connect_cb, iconn,
 					NULL, &err,
 					BT_IO_OPT_SOURCE_BDADDR, &idev->src,
 					BT_IO_OPT_DEST_BDADDR, &idev->dst,
diff --git a/profiles/input/server.c b/profiles/input/server.c
index 8965c4e..0464c4a 100644
--- a/profiles/input/server.c
+++ b/profiles/input/server.c
@@ -72,7 +72,7 @@ static void connect_event_cb(GIOChannel *chan, GError *err, gpointer data)
 		return;
 	}
 
-	bt_io_get(chan, BT_IO_L2CAP, &gerr,
+	bt_io_get(chan, &gerr,
 			BT_IO_OPT_SOURCE_BDADDR, &src,
 			BT_IO_OPT_DEST_BDADDR, &dst,
 			BT_IO_OPT_PSM, &psm,
@@ -110,7 +110,7 @@ static void auth_callback(DBusError *derr, void *user_data)
 	bdaddr_t src, dst;
 	GError *err = NULL;
 
-	bt_io_get(server->confirm, BT_IO_L2CAP, &err,
+	bt_io_get(server->confirm, &err,
 			BT_IO_OPT_SOURCE_BDADDR, &src,
 			BT_IO_OPT_DEST_BDADDR, &dst,
 			BT_IO_OPT_INVALID);
@@ -152,7 +152,7 @@ static void confirm_event_cb(GIOChannel *chan, gpointer user_data)
 	char addr[18];
 	int ret;
 
-	bt_io_get(chan, BT_IO_L2CAP, &err,
+	bt_io_get(chan, &err,
 			BT_IO_OPT_SOURCE_BDADDR, &src,
 			BT_IO_OPT_DEST_BDADDR, &dst,
 			BT_IO_OPT_INVALID);
@@ -198,7 +198,7 @@ int server_start(const bdaddr_t *src)
 	server = g_new0(struct input_server, 1);
 	bacpy(&server->src, src);
 
-	server->ctrl = bt_io_listen(BT_IO_L2CAP, connect_event_cb, NULL,
+	server->ctrl = bt_io_listen(connect_event_cb, NULL,
 				server, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, src,
 				BT_IO_OPT_PSM, L2CAP_PSM_HIDP_CTRL,
@@ -211,7 +211,7 @@ int server_start(const bdaddr_t *src)
 		return -1;
 	}
 
-	server->intr = bt_io_listen(BT_IO_L2CAP, NULL, confirm_event_cb,
+	server->intr = bt_io_listen(NULL, confirm_event_cb,
 				server, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, src,
 				BT_IO_OPT_PSM, L2CAP_PSM_HIDP_INTR,
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index e8ac643..40b360f 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -412,7 +412,7 @@ static DBusMessage *connection_connect(DBusConnection *conn,
 	if (nc->state != DISCONNECTED)
 		return btd_error_already_connected(msg);
 
-	nc->io = bt_io_connect(BT_IO_L2CAP, connect_cb, nc,
+	nc->io = bt_io_connect(connect_cb, nc,
 				NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &peer->src,
 				BT_IO_OPT_DEST_BDADDR, &peer->dst,
diff --git a/profiles/network/server.c b/profiles/network/server.c
index cfad893..ae8bd36 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -504,7 +504,7 @@ static void confirm_event(GIOChannel *chan, gpointer user_data)
 	char address[18];
 	GError *err = NULL;
 
-	bt_io_get(chan, BT_IO_L2CAP, &err,
+	bt_io_get(chan, &err,
 			BT_IO_OPT_SOURCE_BDADDR, &src,
 			BT_IO_OPT_DEST_BDADDR, &dst,
 			BT_IO_OPT_DEST, address,
@@ -752,7 +752,7 @@ static struct network_adapter *create_adapter(struct btd_adapter *adapter)
 
 	adapter_get_address(adapter, &src);
 
-	na->io = bt_io_listen(BT_IO_L2CAP, NULL, confirm_event, na,
+	na->io = bt_io_listen(NULL, confirm_event, na,
 				NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &src,
 				BT_IO_OPT_PSM, BNEP_PSM,
diff --git a/profiles/sap/server.c b/profiles/sap/server.c
index ee2624d..3adbb1a 100644
--- a/profiles/sap/server.c
+++ b/profiles/sap/server.c
@@ -1245,7 +1245,7 @@ static void connect_confirm_cb(GIOChannel *io, gpointer data)
 	conn->io = g_io_channel_ref(io);
 	conn->state = SAP_STATE_DISCONNECTED;
 
-	bt_io_get(io, BT_IO_RFCOMM, &gerr,
+	bt_io_get(io, &gerr,
 			BT_IO_OPT_SOURCE_BDADDR, &src,
 			BT_IO_OPT_DEST_BDADDR, &dst,
 			BT_IO_OPT_INVALID);
@@ -1399,7 +1399,7 @@ int sap_server_register(const char *path, bdaddr_t *src)
 	server->path = g_strdup(path);
 	server->record_id = record->handle;
 
-	io = bt_io_listen(BT_IO_RFCOMM, NULL, connect_confirm_cb, server,
+	io = bt_io_listen(NULL, connect_confirm_cb, server,
 			NULL, &gerr,
 			BT_IO_OPT_SOURCE_BDADDR, src,
 			BT_IO_OPT_CHANNEL, SAP_SERVER_CHANNEL,
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 145fada..5cb1383 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -879,9 +879,7 @@ static uint16_t mtu_exchange(struct gatt_channel *channel, uint16_t mtu,
 
 	io = g_attrib_get_channel(channel->attrib);
 
-	bt_io_get(io, BT_IO_L2CAP, &gerr,
-			BT_IO_OPT_IMTU, &imtu,
-			BT_IO_OPT_INVALID);
+	bt_io_get(io, &gerr, BT_IO_OPT_IMTU, &imtu, BT_IO_OPT_INVALID);
 
 	if (gerr)
 		return enc_error_resp(ATT_OP_MTU_REQ, 0,
@@ -1051,7 +1049,7 @@ guint attrib_channel_attach(GAttrib *attrib)
 
 	channel = g_new0(struct gatt_channel, 1);
 
-	bt_io_get(io, BT_IO_L2CAP, &gerr,
+	bt_io_get(io, &gerr,
 			BT_IO_OPT_SOURCE_BDADDR, &channel->src,
 			BT_IO_OPT_DEST_BDADDR, &channel->dst,
 			BT_IO_OPT_CID, &cid,
@@ -1123,8 +1121,7 @@ gboolean attrib_channel_detach(GAttrib *attrib, guint id)
 
 	io = g_attrib_get_channel(attrib);
 
-	bt_io_get(io, BT_IO_L2CAP, &gerr, BT_IO_OPT_SOURCE_BDADDR, &src,
-							BT_IO_OPT_INVALID);
+	bt_io_get(io, &gerr, BT_IO_OPT_SOURCE_BDADDR, &src, BT_IO_OPT_INVALID);
 
 	if (gerr != NULL) {
 		error("bt_io_get: %s", gerr->message);
@@ -1253,7 +1250,7 @@ int btd_adapter_gatt_server_start(struct btd_adapter *adapter)
 	adapter_get_address(server->adapter, &addr);
 
 	/* BR/EDR socket */
-	server->l2cap_io = bt_io_listen(BT_IO_L2CAP, NULL, confirm_event,
+	server->l2cap_io = bt_io_listen(NULL, confirm_event,
 					NULL, NULL, &gerr,
 					BT_IO_OPT_SOURCE_BDADDR, &addr,
 					BT_IO_OPT_PSM, ATT_PSM,
@@ -1273,7 +1270,7 @@ int btd_adapter_gatt_server_start(struct btd_adapter *adapter)
 	}
 
 	/* LE socket */
-	server->le_io = bt_io_listen(BT_IO_L2CAP, NULL, confirm_event,
+	server->le_io = bt_io_listen(NULL, confirm_event,
 					&server->le_io, NULL, &gerr,
 					BT_IO_OPT_SOURCE_BDADDR, &addr,
 					BT_IO_OPT_CID, ATT_CID,
diff --git a/src/device.c b/src/device.c
index 7b44e27..3b44d9b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2002,7 +2002,7 @@ static gboolean att_connect(gpointer user_data)
 	attcb->user_data = device;
 
 	if (device_is_bredr(device)) {
-		io = bt_io_connect(BT_IO_L2CAP, att_connect_cb,
+		io = bt_io_connect(att_connect_cb,
 					attcb, NULL, &gerr,
 					BT_IO_OPT_SOURCE_BDADDR, &sba,
 					BT_IO_OPT_DEST_BDADDR, &device->bdaddr,
@@ -2010,7 +2010,7 @@ static gboolean att_connect(gpointer user_data)
 					BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
 					BT_IO_OPT_INVALID);
 	} else {
-		io = bt_io_connect(BT_IO_L2CAP, att_connect_cb,
+		io = bt_io_connect(att_connect_cb,
 				attcb, NULL, &gerr,
 				BT_IO_OPT_SOURCE_BDADDR, &sba,
 				BT_IO_OPT_DEST_BDADDR, &device->bdaddr,
@@ -2088,7 +2088,7 @@ int device_browse_primary(struct btd_device *device, DBusConnection *conn,
 	attcb->success = att_browse_cb;
 	attcb->user_data = device;
 
-	device->att_io = bt_io_connect(BT_IO_L2CAP, att_connect_cb,
+	device->att_io = bt_io_connect(att_connect_cb,
 				attcb, NULL, NULL,
 				BT_IO_OPT_SOURCE_BDADDR, &src,
 				BT_IO_OPT_DEST_BDADDR, &device->bdaddr,
@@ -2474,7 +2474,7 @@ DBusMessage *device_create_bonding(struct btd_device *device,
 		attcb = g_new0(struct att_callbacks, 1);
 		attcb->user_data = device;
 
-		device->att_io = bt_io_connect(BT_IO_L2CAP, att_connect_cb,
+		device->att_io = bt_io_connect(att_connect_cb,
 				attcb, NULL, &gerr,
 				BT_IO_OPT_SOURCE_BDADDR, &sba,
 				BT_IO_OPT_DEST_BDADDR, &device->bdaddr,
diff --git a/test/btiotest.c b/test/btiotest.c
index 66a7dd2..f090dd9 100644
--- a/test/btiotest.c
+++ b/test/btiotest.c
@@ -38,7 +38,6 @@ static gint opt_update_sec = 0;
 struct io_data {
 	guint ref;
 	GIOChannel *io;
-	BtIOType type;
 	gint reject;
 	gint disconn;
 	gint accept;
@@ -63,14 +62,13 @@ static struct io_data *io_data_ref(struct io_data *data)
 	return data;
 }
 
-static struct io_data *io_data_new(GIOChannel *io, BtIOType type, gint reject,
-						gint disconn, gint accept)
+static struct io_data *io_data_new(GIOChannel *io, int reject, gint disconn,
+								gint accept)
 {
 	struct io_data *data;
 
 	data = g_new0(struct io_data, 1);
 	data->io = io;
-	data->type = type;
 	data->reject = reject;
 	data->disconn = disconn;
 	data->accept = accept;
@@ -100,9 +98,8 @@ static void update_sec_level(struct io_data *data)
 	GError *err = NULL;
 	int sec_level;
 
-	if (!bt_io_get(data->io, data->type, &err,
-					BT_IO_OPT_SEC_LEVEL, &sec_level,
-					BT_IO_OPT_INVALID)) {
+	if (!bt_io_get(data->io, &err, BT_IO_OPT_SEC_LEVEL, &sec_level,
+							BT_IO_OPT_INVALID)) {
 		printf("bt_io_get(OPT_SEC_LEVEL): %s\n", err->message);
 		g_clear_error(&err);
 		return;
@@ -113,9 +110,8 @@ static void update_sec_level(struct io_data *data)
 	if (opt_update_sec == sec_level)
 		return;
 
-	if (!bt_io_set(data->io, data->type, &err,
-					BT_IO_OPT_SEC_LEVEL, opt_update_sec,
-					BT_IO_OPT_INVALID)) {
+	if (!bt_io_set(data->io, &err, BT_IO_OPT_SEC_LEVEL, opt_update_sec,
+							BT_IO_OPT_INVALID)) {
 		printf("bt_io_set(OPT_SEC_LEVEL): %s\n", err->message);
 		g_clear_error(&err);
 	}
@@ -126,15 +122,15 @@ static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
 	struct io_data *data = user_data;
 	GIOCondition cond;
 	char addr[18];
-	uint16_t handle;
-	uint8_t cls[3];
+	uint16_t handle, omtu, imtu;
+	uint8_t cls[3], key_size;
 
 	if (err) {
 		printf("Connecting failed: %s\n", err->message);
 		return;
 	}
 
-	if (!bt_io_get(io, data->type, &err,
+	if (!bt_io_get(io, &err,
 			BT_IO_OPT_DEST, addr,
 			BT_IO_OPT_HANDLE, &handle,
 			BT_IO_OPT_CLASS, cls,
@@ -148,32 +144,20 @@ static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
 	printf("Successfully connected to %s. handle=%u, class=%02x%02x%02x\n",
 			addr, handle, cls[0], cls[1], cls[2]);
 
-	if (data->type == BT_IO_L2CAP || data->type == BT_IO_SCO) {
-		uint16_t omtu, imtu;
-
-		if (!bt_io_get(io, data->type, &err,
-					BT_IO_OPT_OMTU, &omtu,
+	if (!bt_io_get(io, &err, BT_IO_OPT_OMTU, &omtu,
 					BT_IO_OPT_IMTU, &imtu,
 					BT_IO_OPT_INVALID)) {
-			printf("Unable to get L2CAP MTU sizes: %s\n",
-								err->message);
-			g_clear_error(&err);
-		} else
-			printf("imtu=%u, omtu=%u\n", imtu, omtu);
-	}
-
-	if (data->type == BT_IO_L2CAP) {
-		uint8_t key_size;
+		printf("Unable to get MTU sizes: %s\n", err->message);
+		g_clear_error(&err);
+	} else
+		printf("imtu=%u, omtu=%u\n", imtu, omtu);
 
-		if (!bt_io_get(io, data->type, &err,
-					BT_IO_OPT_KEY_SIZE, &key_size,
-					BT_IO_OPT_INVALID)) {
-			printf("Unable to get L2CAP Key size: %s\n",
-								err->message);
-			g_clear_error(&err);
-		} else
-			printf("key_size=%u\n", key_size);
-	}
+	if (!bt_io_get(io, &err, BT_IO_OPT_KEY_SIZE, &key_size,
+							BT_IO_OPT_INVALID)) {
+		printf("Unable to get Key size: %s\n", err->message);
+		g_clear_error(&err);
+	} else
+		printf("key_size=%u\n", key_size);
 
 	if (data->disconn == 0) {
 		g_io_channel_shutdown(io, TRUE, NULL);
@@ -234,8 +218,7 @@ static void confirm_cb(GIOChannel *io, gpointer user_data)
 	struct io_data *data = user_data;
 	GError *err = NULL;
 
-	if (!bt_io_get(io, data->type, &err, BT_IO_OPT_DEST, addr,
-							BT_IO_OPT_INVALID)) {
+	if (!bt_io_get(io, &err, BT_IO_OPT_DEST, addr, BT_IO_OPT_INVALID)) {
 		printf("bt_io_get(OPT_DEST): %s\n", err->message);
 		g_clear_error(&err);
 	} else
@@ -280,10 +263,10 @@ static void l2cap_connect(const char *src, const char *dst, uint16_t psm,
 
 	printf("Connecting to %s L2CAP PSM %u\n", dst, psm);
 
-	data = io_data_new(NULL, BT_IO_L2CAP, -1, disconn, -1);
+	data = io_data_new(NULL, -1, disconn, -1);
 
 	if (src)
-		data->io = bt_io_connect(BT_IO_L2CAP, connect_cb, data,
+		data->io = bt_io_connect(connect_cb, data,
 						(GDestroyNotify) io_data_unref,
 						&err,
 						BT_IO_OPT_SOURCE, src,
@@ -294,7 +277,7 @@ static void l2cap_connect(const char *src, const char *dst, uint16_t psm,
 						BT_IO_OPT_PRIORITY, prio,
 						BT_IO_OPT_INVALID);
 	else
-		data->io = bt_io_connect(BT_IO_L2CAP, connect_cb, data,
+		data->io = bt_io_connect(connect_cb, data,
 						(GDestroyNotify) io_data_unref,
 						&err,
 						BT_IO_OPT_DEST, dst,
@@ -331,11 +314,11 @@ static void l2cap_listen(const char *src, uint16_t psm, gint defer,
 
 	printf("Listening on L2CAP PSM %u\n", psm);
 
-	data = io_data_new(NULL, BT_IO_L2CAP, reject, disconn, accept);
+	data = io_data_new(NULL, reject, disconn, accept);
 
 	if (src)
-		l2_srv = bt_io_listen(BT_IO_L2CAP, conn, cfm,
-					data, (GDestroyNotify) io_data_unref,
+		l2_srv = bt_io_listen(conn, cfm, data,
+					(GDestroyNotify) io_data_unref,
 					&err,
 					BT_IO_OPT_SOURCE, src,
 					BT_IO_OPT_PSM, psm,
@@ -343,8 +326,8 @@ static void l2cap_listen(const char *src, uint16_t psm, gint defer,
 					BT_IO_OPT_MASTER, master,
 					BT_IO_OPT_INVALID);
 	else
-		l2_srv = bt_io_listen(BT_IO_L2CAP, conn, cfm,
-					data, (GDestroyNotify) io_data_unref,
+		l2_srv = bt_io_listen(conn, cfm, data,
+					(GDestroyNotify) io_data_unref,
 					&err,
 					BT_IO_OPT_PSM, psm,
 					BT_IO_OPT_SEC_LEVEL, sec,
@@ -368,10 +351,10 @@ static void rfcomm_connect(const char *src, const char *dst, uint8_t ch,
 
 	printf("Connecting to %s RFCOMM channel %u\n", dst, ch);
 
-	data = io_data_new(NULL, BT_IO_RFCOMM, -1, disconn, -1);
+	data = io_data_new(NULL, -1, disconn, -1);
 
 	if (src)
-		data->io = bt_io_connect(BT_IO_RFCOMM, connect_cb, data,
+		data->io = bt_io_connect(connect_cb, data,
 						(GDestroyNotify) io_data_unref,
 						&err,
 						BT_IO_OPT_SOURCE, src,
@@ -380,7 +363,7 @@ static void rfcomm_connect(const char *src, const char *dst, uint8_t ch,
 						BT_IO_OPT_SEC_LEVEL, sec,
 						BT_IO_OPT_INVALID);
 	else
-		data->io = bt_io_connect(BT_IO_RFCOMM, connect_cb, data,
+		data->io = bt_io_connect(connect_cb, data,
 						(GDestroyNotify) io_data_unref,
 						&err,
 						BT_IO_OPT_DEST, dst,
@@ -413,10 +396,10 @@ static void rfcomm_listen(const char *src, uint8_t ch, gboolean defer,
 		cfm = NULL;
 	}
 
-	data = io_data_new(NULL, BT_IO_RFCOMM, reject, disconn, accept);
+	data = io_data_new(NULL, reject, disconn, accept);
 
 	if (src)
-		rc_srv = bt_io_listen(BT_IO_RFCOMM, conn, cfm,
+		rc_srv = bt_io_listen(conn, cfm,
 					data, (GDestroyNotify) io_data_unref,
 					&err,
 					BT_IO_OPT_SOURCE, src,
@@ -425,7 +408,7 @@ static void rfcomm_listen(const char *src, uint8_t ch, gboolean defer,
 					BT_IO_OPT_MASTER, master,
 					BT_IO_OPT_INVALID);
 	else
-		rc_srv = bt_io_listen(BT_IO_RFCOMM, conn, cfm,
+		rc_srv = bt_io_listen(conn, cfm,
 					data, (GDestroyNotify) io_data_unref,
 					&err,
 					BT_IO_OPT_CHANNEL, ch,
@@ -439,9 +422,7 @@ static void rfcomm_listen(const char *src, uint8_t ch, gboolean defer,
 		exit(EXIT_FAILURE);
 	}
 
-	bt_io_get(rc_srv, BT_IO_RFCOMM, &err,
-			BT_IO_OPT_CHANNEL, &ch,
-			BT_IO_OPT_INVALID);
+	bt_io_get(rc_srv, &err, BT_IO_OPT_CHANNEL, &ch, BT_IO_OPT_INVALID);
 
 	printf("Listening on RFCOMM channel %u\n", ch);
 
@@ -455,17 +436,17 @@ static void sco_connect(const char *src, const char *dst, gint disconn)
 
 	printf("Connecting SCO to %s\n", dst);
 
-	data = io_data_new(NULL, BT_IO_SCO, -1, disconn, -1);
+	data = io_data_new(NULL, -1, disconn, -1);
 
 	if (src)
-		data->io = bt_io_connect(BT_IO_SCO, connect_cb, data,
+		data->io = bt_io_connect(connect_cb, data,
 						(GDestroyNotify) io_data_unref,
 						&err,
 						BT_IO_OPT_SOURCE, src,
 						BT_IO_OPT_DEST, dst,
 						BT_IO_OPT_INVALID);
 	else
-		data->io = bt_io_connect(BT_IO_SCO, connect_cb, data,
+		data->io = bt_io_connect(connect_cb, data,
 						(GDestroyNotify) io_data_unref,
 						&err,
 						BT_IO_OPT_DEST, dst,
@@ -486,17 +467,17 @@ static void sco_listen(const char *src, gint disconn)
 
 	printf("Listening for SCO connections\n");
 
-	data = io_data_new(NULL, BT_IO_SCO, -1, disconn, -1);
+	data = io_data_new(NULL, -1, disconn, -1);
 
 	if (src)
-		sco_srv = bt_io_listen(BT_IO_SCO, connect_cb, NULL,
-					data, (GDestroyNotify) io_data_unref,
+		sco_srv = bt_io_listen(connect_cb, NULL, data,
+					(GDestroyNotify) io_data_unref,
 					&err,
 					BT_IO_OPT_SOURCE, src,
 					BT_IO_OPT_INVALID);
 	else
-		sco_srv = bt_io_listen(BT_IO_SCO, connect_cb, NULL,
-					data, (GDestroyNotify) io_data_unref,
+		sco_srv = bt_io_listen(connect_cb, NULL, data,
+					(GDestroyNotify) io_data_unref,
 					&err, BT_IO_OPT_INVALID);
 
 	if (!sco_srv) {