Skip to content

Commit 6427451

Browse files
author
Gustavo F. Padovan
committed
Bluetooth: Merge L2CAP and SCO modules into bluetooth.ko
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 <[email protected]>
1 parent c4c896e commit 6427451

File tree

6 files changed

+66
-41
lines changed

6 files changed

+66
-41
lines changed

include/net/bluetooth/bluetooth.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,32 @@ extern void bt_sysfs_cleanup(void);
205205

206206
extern struct dentry *bt_debugfs;
207207

208+
#ifdef CONFIG_BT_L2CAP
209+
int l2cap_init(void);
210+
void l2cap_exit(void);
211+
#else
212+
static inline int l2cap_init(void)
213+
{
214+
return 0;
215+
}
216+
217+
static inline void l2cap_exit(void)
218+
{
219+
}
220+
#endif
221+
222+
#ifdef CONFIG_BT_SCO
223+
int sco_init(void);
224+
void sco_exit(void);
225+
#else
226+
static inline int sco_init(void)
227+
{
228+
return 0;
229+
}
230+
231+
static inline void sco_exit(void)
232+
{
233+
}
234+
#endif
235+
208236
#endif /* __BLUETOOTH_H */

net/bluetooth/Kconfig

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,21 @@ menuconfig BT
3232
more information, see <http://www.bluez.org/>.
3333

3434
config BT_L2CAP
35-
tristate "L2CAP protocol support"
35+
bool "L2CAP protocol support"
3636
depends on BT
3737
select CRC16
3838
help
3939
L2CAP (Logical Link Control and Adaptation Protocol) provides
4040
connection oriented and connection-less data transport. L2CAP
4141
support is required for most Bluetooth applications.
4242

43-
Say Y here to compile L2CAP support into the kernel or say M to
44-
compile it as module (l2cap).
45-
4643
config BT_SCO
47-
tristate "SCO links support"
44+
bool "SCO links support"
4845
depends on BT
4946
help
5047
SCO link provides voice transport over Bluetooth. SCO support is
5148
required for voice applications like Headset and Audio.
5249

53-
Say Y here to compile SCO support into the kernel or say M to
54-
compile it as module (sco).
55-
5650
source "net/bluetooth/rfcomm/Kconfig"
5751

5852
source "net/bluetooth/bnep/Kconfig"

net/bluetooth/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
#
44

55
obj-$(CONFIG_BT) += bluetooth.o
6-
obj-$(CONFIG_BT_L2CAP) += l2cap.o
7-
obj-$(CONFIG_BT_SCO) += sco.o
86
obj-$(CONFIG_BT_RFCOMM) += rfcomm/
97
obj-$(CONFIG_BT_BNEP) += bnep/
108
obj-$(CONFIG_BT_CMTP) += cmtp/
119
obj-$(CONFIG_BT_HIDP) += hidp/
1210

1311
bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o hci_sock.o hci_sysfs.o lib.o
14-
l2cap-y := l2cap_core.o l2cap_sock.o
12+
bluetooth-$(CONFIG_BT_L2CAP) += l2cap_core.o l2cap_sock.o
13+
bluetooth-$(CONFIG_BT_SCO) += sco.o

net/bluetooth/af_bluetooth.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
#include <net/bluetooth/bluetooth.h>
4242

43-
#define VERSION "2.15"
43+
#define VERSION "2.16"
4444

4545
/* Bluetooth sockets */
4646
#define BT_MAX_PROTO 8
@@ -545,13 +545,41 @@ static int __init bt_init(void)
545545

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

548-
hci_sock_init();
548+
err = hci_sock_init();
549+
if (err < 0)
550+
goto error;
551+
552+
err = l2cap_init();
553+
if (err < 0) {
554+
hci_sock_cleanup();
555+
goto sock_err;
556+
}
557+
558+
err = sco_init();
559+
if (err < 0) {
560+
l2cap_exit();
561+
goto sock_err;
562+
}
549563

550564
return 0;
565+
566+
sock_err:
567+
hci_sock_cleanup();
568+
569+
error:
570+
sock_unregister(PF_BLUETOOTH);
571+
bt_sysfs_cleanup();
572+
573+
return err;
551574
}
552575

553576
static void __exit bt_exit(void)
554577
{
578+
579+
sco_exit();
580+
581+
l2cap_exit();
582+
555583
hci_sock_cleanup();
556584

557585
sock_unregister(PF_BLUETOOTH);

net/bluetooth/l2cap_core.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@
5555
#include <net/bluetooth/hci_core.h>
5656
#include <net/bluetooth/l2cap.h>
5757

58-
#define VERSION "2.15"
59-
6058
int disable_ertm;
6159

6260
static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN;
@@ -3806,7 +3804,7 @@ static struct hci_proto l2cap_hci_proto = {
38063804
.recv_acldata = l2cap_recv_acldata
38073805
};
38083806

3809-
static int __init l2cap_init(void)
3807+
int __init l2cap_init(void)
38103808
{
38113809
int err;
38123810

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

3837-
BT_INFO("L2CAP ver %s", VERSION);
38383835
BT_INFO("L2CAP socket layer initialized");
38393836

38403837
return 0;
@@ -3845,7 +3842,7 @@ static int __init l2cap_init(void)
38453842
return err;
38463843
}
38473844

3848-
static void __exit l2cap_exit(void)
3845+
void l2cap_exit(void)
38493846
{
38503847
debugfs_remove(l2cap_debugfs);
38513848

@@ -3866,14 +3863,5 @@ void l2cap_load(void)
38663863
}
38673864
EXPORT_SYMBOL(l2cap_load);
38683865

3869-
module_init(l2cap_init);
3870-
module_exit(l2cap_exit);
3871-
38723866
module_param(disable_ertm, bool, 0644);
38733867
MODULE_PARM_DESC(disable_ertm, "Disable enhanced retransmission mode");
3874-
3875-
MODULE_AUTHOR("Marcel Holtmann <[email protected]>");
3876-
MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION);
3877-
MODULE_VERSION(VERSION);
3878-
MODULE_LICENSE("GPL");
3879-
MODULE_ALIAS("bt-proto-0");

net/bluetooth/sco.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050
#include <net/bluetooth/hci_core.h>
5151
#include <net/bluetooth/sco.h>
5252

53-
#define VERSION "0.6"
54-
5553
static int disable_esco;
5654

5755
static const struct proto_ops sco_sock_ops;
@@ -1024,7 +1022,7 @@ static struct hci_proto sco_hci_proto = {
10241022
.recv_scodata = sco_recv_scodata
10251023
};
10261024

1027-
static int __init sco_init(void)
1025+
int __init sco_init(void)
10281026
{
10291027
int err;
10301028

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

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

10581055
return 0;
@@ -1062,7 +1059,7 @@ static int __init sco_init(void)
10621059
return err;
10631060
}
10641061

1065-
static void __exit sco_exit(void)
1062+
void __exit sco_exit(void)
10661063
{
10671064
debugfs_remove(sco_debugfs);
10681065

@@ -1075,14 +1072,5 @@ static void __exit sco_exit(void)
10751072
proto_unregister(&sco_proto);
10761073
}
10771074

1078-
module_init(sco_init);
1079-
module_exit(sco_exit);
1080-
10811075
module_param(disable_esco, bool, 0644);
10821076
MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation");
1083-
1084-
MODULE_AUTHOR("Marcel Holtmann <[email protected]>");
1085-
MODULE_DESCRIPTION("Bluetooth SCO ver " VERSION);
1086-
MODULE_VERSION(VERSION);
1087-
MODULE_LICENSE("GPL");
1088-
MODULE_ALIAS("bt-proto-2");

0 commit comments

Comments
 (0)