diff options
author | Ulisses Furquim <ulisses@profusion.mobi> | 2011-12-21 07:11:33 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-12-22 11:07:29 -0500 |
commit | 686ebf283ba19f82abd8aaec023cd124749be9ec (patch) | |
tree | 9d10d8bc79779756dd8833a2c6ef8d5ad019ac81 /net/bluetooth/l2cap_core.c | |
parent | 68a8aea45973c8d0bc05f58389ce9e82e04bb5f6 (diff) |
Bluetooth: Make HCI call directly into SCO and L2CAP event functions
The struct hci_proto and all related register/unregister and dispatching
code was removed. HCI core code now call directly the SCO and L2CAP
event functions.
Signed-off-by: Ulisses Furquim <ulisses@profusion.mobi>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/l2cap_core.c')
-rw-r--r-- | net/bluetooth/l2cap_core.c | 51 |
1 files changed, 7 insertions, 44 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index a898285e3ea6..173218345a10 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -4413,14 +4413,11 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb) | |||
4413 | 4413 | ||
4414 | /* ---- L2CAP interface with lower layer (HCI) ---- */ | 4414 | /* ---- L2CAP interface with lower layer (HCI) ---- */ |
4415 | 4415 | ||
4416 | static int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) | 4416 | int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr) |
4417 | { | 4417 | { |
4418 | int exact = 0, lm1 = 0, lm2 = 0; | 4418 | int exact = 0, lm1 = 0, lm2 = 0; |
4419 | struct l2cap_chan *c; | 4419 | struct l2cap_chan *c; |
4420 | 4420 | ||
4421 | if (type != ACL_LINK) | ||
4422 | return -EINVAL; | ||
4423 | |||
4424 | BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr)); | 4421 | BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr)); |
4425 | 4422 | ||
4426 | /* Find listening sockets and check their link_mode */ | 4423 | /* Find listening sockets and check their link_mode */ |
@@ -4447,15 +4444,12 @@ static int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) | |||
4447 | return exact ? lm1 : lm2; | 4444 | return exact ? lm1 : lm2; |
4448 | } | 4445 | } |
4449 | 4446 | ||
4450 | static int l2cap_connect_cfm(struct hci_conn *hcon, u8 status) | 4447 | int l2cap_connect_cfm(struct hci_conn *hcon, u8 status) |
4451 | { | 4448 | { |
4452 | struct l2cap_conn *conn; | 4449 | struct l2cap_conn *conn; |
4453 | 4450 | ||
4454 | BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status); | 4451 | BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status); |
4455 | 4452 | ||
4456 | if (!(hcon->type == ACL_LINK || hcon->type == LE_LINK)) | ||
4457 | return -EINVAL; | ||
4458 | |||
4459 | if (!status) { | 4453 | if (!status) { |
4460 | conn = l2cap_conn_add(hcon, status); | 4454 | conn = l2cap_conn_add(hcon, status); |
4461 | if (conn) | 4455 | if (conn) |
@@ -4466,27 +4460,22 @@ static int l2cap_connect_cfm(struct hci_conn *hcon, u8 status) | |||
4466 | return 0; | 4460 | return 0; |
4467 | } | 4461 | } |
4468 | 4462 | ||
4469 | static int l2cap_disconn_ind(struct hci_conn *hcon) | 4463 | int l2cap_disconn_ind(struct hci_conn *hcon) |
4470 | { | 4464 | { |
4471 | struct l2cap_conn *conn = hcon->l2cap_data; | 4465 | struct l2cap_conn *conn = hcon->l2cap_data; |
4472 | 4466 | ||
4473 | BT_DBG("hcon %p", hcon); | 4467 | BT_DBG("hcon %p", hcon); |
4474 | 4468 | ||
4475 | if ((hcon->type != ACL_LINK && hcon->type != LE_LINK) || !conn) | 4469 | if (!conn) |
4476 | return HCI_ERROR_REMOTE_USER_TERM; | 4470 | return HCI_ERROR_REMOTE_USER_TERM; |
4477 | |||
4478 | return conn->disc_reason; | 4471 | return conn->disc_reason; |
4479 | } | 4472 | } |
4480 | 4473 | ||
4481 | static int l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason) | 4474 | int l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason) |
4482 | { | 4475 | { |
4483 | BT_DBG("hcon %p reason %d", hcon, reason); | 4476 | BT_DBG("hcon %p reason %d", hcon, reason); |
4484 | 4477 | ||
4485 | if (!(hcon->type == ACL_LINK || hcon->type == LE_LINK)) | ||
4486 | return -EINVAL; | ||
4487 | |||
4488 | l2cap_conn_del(hcon, bt_to_errno(reason)); | 4478 | l2cap_conn_del(hcon, bt_to_errno(reason)); |
4489 | |||
4490 | return 0; | 4479 | return 0; |
4491 | } | 4480 | } |
4492 | 4481 | ||
@@ -4507,7 +4496,7 @@ static inline void l2cap_check_encryption(struct l2cap_chan *chan, u8 encrypt) | |||
4507 | } | 4496 | } |
4508 | } | 4497 | } |
4509 | 4498 | ||
4510 | static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | 4499 | int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) |
4511 | { | 4500 | { |
4512 | struct l2cap_conn *conn = hcon->l2cap_data; | 4501 | struct l2cap_conn *conn = hcon->l2cap_data; |
4513 | struct l2cap_chan *chan; | 4502 | struct l2cap_chan *chan; |
@@ -4607,7 +4596,7 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
4607 | return 0; | 4596 | return 0; |
4608 | } | 4597 | } |
4609 | 4598 | ||
4610 | static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) | 4599 | int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) |
4611 | { | 4600 | { |
4612 | struct l2cap_conn *conn = hcon->l2cap_data; | 4601 | struct l2cap_conn *conn = hcon->l2cap_data; |
4613 | 4602 | ||
@@ -4754,17 +4743,6 @@ static const struct file_operations l2cap_debugfs_fops = { | |||
4754 | 4743 | ||
4755 | static struct dentry *l2cap_debugfs; | 4744 | static struct dentry *l2cap_debugfs; |
4756 | 4745 | ||
4757 | static struct hci_proto l2cap_hci_proto = { | ||
4758 | .name = "L2CAP", | ||
4759 | .id = HCI_PROTO_L2CAP, | ||
4760 | .connect_ind = l2cap_connect_ind, | ||
4761 | .connect_cfm = l2cap_connect_cfm, | ||
4762 | .disconn_ind = l2cap_disconn_ind, | ||
4763 | .disconn_cfm = l2cap_disconn_cfm, | ||
4764 | .security_cfm = l2cap_security_cfm, | ||
4765 | .recv_acldata = l2cap_recv_acldata | ||
4766 | }; | ||
4767 | |||
4768 | int __init l2cap_init(void) | 4746 | int __init l2cap_init(void) |
4769 | { | 4747 | { |
4770 | int err; | 4748 | int err; |
@@ -4773,13 +4751,6 @@ int __init l2cap_init(void) | |||
4773 | if (err < 0) | 4751 | if (err < 0) |
4774 | return err; | 4752 | return err; |
4775 | 4753 | ||
4776 | err = hci_register_proto(&l2cap_hci_proto); | ||
4777 | if (err < 0) { | ||
4778 | BT_ERR("L2CAP protocol registration failed"); | ||
4779 | bt_sock_unregister(BTPROTO_L2CAP); | ||
4780 | goto error; | ||
4781 | } | ||
4782 | |||
4783 | if (bt_debugfs) { | 4754 | if (bt_debugfs) { |
4784 | l2cap_debugfs = debugfs_create_file("l2cap", 0444, | 4755 | l2cap_debugfs = debugfs_create_file("l2cap", 0444, |
4785 | bt_debugfs, NULL, &l2cap_debugfs_fops); | 4756 | bt_debugfs, NULL, &l2cap_debugfs_fops); |
@@ -4788,19 +4759,11 @@ int __init l2cap_init(void) | |||
4788 | } | 4759 | } |
4789 | 4760 | ||
4790 | return 0; | 4761 | return 0; |
4791 | |||
4792 | error: | ||
4793 | l2cap_cleanup_sockets(); | ||
4794 | return err; | ||
4795 | } | 4762 | } |
4796 | 4763 | ||
4797 | void l2cap_exit(void) | 4764 | void l2cap_exit(void) |
4798 | { | 4765 | { |
4799 | debugfs_remove(l2cap_debugfs); | 4766 | debugfs_remove(l2cap_debugfs); |
4800 | |||
4801 | if (hci_unregister_proto(&l2cap_hci_proto) < 0) | ||
4802 | BT_ERR("L2CAP protocol unregistration failed"); | ||
4803 | |||
4804 | l2cap_cleanup_sockets(); | 4767 | l2cap_cleanup_sockets(); |
4805 | } | 4768 | } |
4806 | 4769 | ||