Skip to content

Commit

Permalink
Bluetooth: Merge L2CAP and SCO modules into bluetooth.ko
Browse files Browse the repository at this point in the history
Actually doesn't make sense have these modules built separately.
The L2CAP layer is needed by almost all Bluetooth protocols and profiles.
There isn't any real use case without having L2CAP loaded.
SCO is only essential for Audio transfers, but it is so small that we can
have it loaded always in bluetooth.ko without problems.
If you really doesn't want it you can disable SCO in the kernel config.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
  • Loading branch information
Gustavo F. Padovan committed Feb 14, 2011
1 parent c4c896e commit 6427451
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 41 deletions.
28 changes: 28 additions & 0 deletions include/net/bluetooth/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,32 @@ extern void bt_sysfs_cleanup(void);

extern struct dentry *bt_debugfs;

#ifdef CONFIG_BT_L2CAP
int l2cap_init(void);
void l2cap_exit(void);
#else
static inline int l2cap_init(void)
{
return 0;
}

static inline void l2cap_exit(void)
{
}
#endif

#ifdef CONFIG_BT_SCO
int sco_init(void);
void sco_exit(void);
#else
static inline int sco_init(void)
{
return 0;
}

static inline void sco_exit(void)
{
}
#endif

#endif /* __BLUETOOTH_H */
10 changes: 2 additions & 8 deletions net/bluetooth/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,21 @@ menuconfig BT
more information, see <http://www.bluez.org/>.

config BT_L2CAP
tristate "L2CAP protocol support"
bool "L2CAP protocol support"
depends on BT
select CRC16
help
L2CAP (Logical Link Control and Adaptation Protocol) provides
connection oriented and connection-less data transport. L2CAP
support is required for most Bluetooth applications.

Say Y here to compile L2CAP support into the kernel or say M to
compile it as module (l2cap).

config BT_SCO
tristate "SCO links support"
bool "SCO links support"
depends on BT
help
SCO link provides voice transport over Bluetooth. SCO support is
required for voice applications like Headset and Audio.

Say Y here to compile SCO support into the kernel or say M to
compile it as module (sco).

source "net/bluetooth/rfcomm/Kconfig"

source "net/bluetooth/bnep/Kconfig"
Expand Down
5 changes: 2 additions & 3 deletions net/bluetooth/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
#

obj-$(CONFIG_BT) += bluetooth.o
obj-$(CONFIG_BT_L2CAP) += l2cap.o
obj-$(CONFIG_BT_SCO) += sco.o
obj-$(CONFIG_BT_RFCOMM) += rfcomm/
obj-$(CONFIG_BT_BNEP) += bnep/
obj-$(CONFIG_BT_CMTP) += cmtp/
obj-$(CONFIG_BT_HIDP) += hidp/

bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o hci_sock.o hci_sysfs.o lib.o
l2cap-y := l2cap_core.o l2cap_sock.o
bluetooth-$(CONFIG_BT_L2CAP) += l2cap_core.o l2cap_sock.o
bluetooth-$(CONFIG_BT_SCO) += sco.o
32 changes: 30 additions & 2 deletions net/bluetooth/af_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

#include <net/bluetooth/bluetooth.h>

#define VERSION "2.15"
#define VERSION "2.16"

/* Bluetooth sockets */
#define BT_MAX_PROTO 8
Expand Down Expand Up @@ -545,13 +545,41 @@ static int __init bt_init(void)

BT_INFO("HCI device and connection manager initialized");

hci_sock_init();
err = hci_sock_init();
if (err < 0)
goto error;

err = l2cap_init();
if (err < 0) {
hci_sock_cleanup();
goto sock_err;
}

err = sco_init();
if (err < 0) {
l2cap_exit();
goto sock_err;
}

return 0;

sock_err:
hci_sock_cleanup();

error:
sock_unregister(PF_BLUETOOTH);
bt_sysfs_cleanup();

return err;
}

static void __exit bt_exit(void)
{

sco_exit();

l2cap_exit();

hci_sock_cleanup();

sock_unregister(PF_BLUETOOTH);
Expand Down
16 changes: 2 additions & 14 deletions net/bluetooth/l2cap_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/l2cap.h>

#define VERSION "2.15"

int disable_ertm;

static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN;
Expand Down Expand Up @@ -3806,7 +3804,7 @@ static struct hci_proto l2cap_hci_proto = {
.recv_acldata = l2cap_recv_acldata
};

static int __init l2cap_init(void)
int __init l2cap_init(void)
{
int err;

Expand Down Expand Up @@ -3834,7 +3832,6 @@ static int __init l2cap_init(void)
BT_ERR("Failed to create L2CAP debug file");
}

BT_INFO("L2CAP ver %s", VERSION);
BT_INFO("L2CAP socket layer initialized");

return 0;
Expand All @@ -3845,7 +3842,7 @@ static int __init l2cap_init(void)
return err;
}

static void __exit l2cap_exit(void)
void l2cap_exit(void)
{
debugfs_remove(l2cap_debugfs);

Expand All @@ -3866,14 +3863,5 @@ void l2cap_load(void)
}
EXPORT_SYMBOL(l2cap_load);

module_init(l2cap_init);
module_exit(l2cap_exit);

module_param(disable_ertm, bool, 0644);
MODULE_PARM_DESC(disable_ertm, "Disable enhanced retransmission mode");

MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION);
MODULE_VERSION(VERSION);
MODULE_LICENSE("GPL");
MODULE_ALIAS("bt-proto-0");
16 changes: 2 additions & 14 deletions net/bluetooth/sco.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/sco.h>

#define VERSION "0.6"

static int disable_esco;

static const struct proto_ops sco_sock_ops;
Expand Down Expand Up @@ -1024,7 +1022,7 @@ static struct hci_proto sco_hci_proto = {
.recv_scodata = sco_recv_scodata
};

static int __init sco_init(void)
int __init sco_init(void)
{
int err;

Expand Down Expand Up @@ -1052,7 +1050,6 @@ static int __init sco_init(void)
BT_ERR("Failed to create SCO debug file");
}

BT_INFO("SCO (Voice Link) ver %s", VERSION);
BT_INFO("SCO socket layer initialized");

return 0;
Expand All @@ -1062,7 +1059,7 @@ static int __init sco_init(void)
return err;
}

static void __exit sco_exit(void)
void __exit sco_exit(void)
{
debugfs_remove(sco_debugfs);

Expand All @@ -1075,14 +1072,5 @@ static void __exit sco_exit(void)
proto_unregister(&sco_proto);
}

module_init(sco_init);
module_exit(sco_exit);

module_param(disable_esco, bool, 0644);
MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation");

MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
MODULE_DESCRIPTION("Bluetooth SCO ver " VERSION);
MODULE_VERSION(VERSION);
MODULE_LICENSE("GPL");
MODULE_ALIAS("bt-proto-2");

0 comments on commit 6427451

Please sign in to comment.