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 /include/net | |
| 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 'include/net')
| -rw-r--r-- | include/net/bluetooth/hci_core.h | 138 |
1 files changed, 59 insertions, 79 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 25c161ab6803..5ce73dbaf604 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
| @@ -28,10 +28,6 @@ | |||
| 28 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
| 29 | #include <net/bluetooth/hci.h> | 29 | #include <net/bluetooth/hci.h> |
| 30 | 30 | ||
| 31 | /* HCI upper protocols */ | ||
| 32 | #define HCI_PROTO_L2CAP 0 | ||
| 33 | #define HCI_PROTO_SCO 1 | ||
| 34 | |||
| 35 | /* HCI priority */ | 31 | /* HCI priority */ |
| 36 | #define HCI_PRIO_MAX 7 | 32 | #define HCI_PRIO_MAX 7 |
| 37 | 33 | ||
| @@ -330,12 +326,24 @@ struct hci_chan { | |||
| 330 | unsigned int sent; | 326 | unsigned int sent; |
| 331 | }; | 327 | }; |
| 332 | 328 | ||
| 333 | extern struct hci_proto *hci_proto[]; | ||
| 334 | extern struct list_head hci_dev_list; | 329 | extern struct list_head hci_dev_list; |
| 335 | extern struct list_head hci_cb_list; | 330 | extern struct list_head hci_cb_list; |
| 336 | extern rwlock_t hci_dev_list_lock; | 331 | extern rwlock_t hci_dev_list_lock; |
| 337 | extern rwlock_t hci_cb_list_lock; | 332 | extern rwlock_t hci_cb_list_lock; |
| 338 | 333 | ||
| 334 | /* ----- HCI interface to upper protocols ----- */ | ||
| 335 | extern int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
| 336 | extern int l2cap_connect_cfm(struct hci_conn *hcon, u8 status); | ||
| 337 | extern int l2cap_disconn_ind(struct hci_conn *hcon); | ||
| 338 | extern int l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason); | ||
| 339 | extern int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt); | ||
| 340 | extern int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags); | ||
| 341 | |||
| 342 | extern int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
| 343 | extern int sco_connect_cfm(struct hci_conn *hcon, __u8 status); | ||
| 344 | extern int sco_disconn_cfm(struct hci_conn *hcon, __u8 reason); | ||
| 345 | extern int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb); | ||
| 346 | |||
| 339 | /* ----- Inquiry cache ----- */ | 347 | /* ----- Inquiry cache ----- */ |
| 340 | #define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */ | 348 | #define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */ |
| 341 | #define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */ | 349 | #define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */ |
| @@ -677,53 +685,40 @@ void hci_conn_del_sysfs(struct hci_conn *conn); | |||
| 677 | #define lmp_host_le_capable(dev) ((dev)->extfeatures[0] & LMP_HOST_LE) | 685 | #define lmp_host_le_capable(dev) ((dev)->extfeatures[0] & LMP_HOST_LE) |
| 678 | 686 | ||
| 679 | /* ----- HCI protocols ----- */ | 687 | /* ----- HCI protocols ----- */ |
| 680 | struct hci_proto { | ||
| 681 | char *name; | ||
| 682 | unsigned int id; | ||
| 683 | unsigned long flags; | ||
| 684 | |||
| 685 | void *priv; | ||
| 686 | |||
| 687 | int (*connect_ind) (struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
| 688 | __u8 type); | ||
| 689 | int (*connect_cfm) (struct hci_conn *conn, __u8 status); | ||
| 690 | int (*disconn_ind) (struct hci_conn *conn); | ||
| 691 | int (*disconn_cfm) (struct hci_conn *conn, __u8 reason); | ||
| 692 | int (*recv_acldata) (struct hci_conn *conn, struct sk_buff *skb, | ||
| 693 | __u16 flags); | ||
| 694 | int (*recv_scodata) (struct hci_conn *conn, struct sk_buff *skb); | ||
| 695 | int (*security_cfm) (struct hci_conn *conn, __u8 status, | ||
| 696 | __u8 encrypt); | ||
| 697 | }; | ||
| 698 | |||
| 699 | static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, | 688 | static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 700 | __u8 type) | 689 | __u8 type) |
| 701 | { | 690 | { |
| 702 | register struct hci_proto *hp; | 691 | switch (type) { |
| 703 | int mask = 0; | 692 | case ACL_LINK: |
| 704 | 693 | return l2cap_connect_ind(hdev, bdaddr); | |
| 705 | hp = hci_proto[HCI_PROTO_L2CAP]; | ||
| 706 | if (hp && hp->connect_ind) | ||
| 707 | mask |= hp->connect_ind(hdev, bdaddr, type); | ||
| 708 | 694 | ||
| 709 | hp = hci_proto[HCI_PROTO_SCO]; | 695 | case SCO_LINK: |
| 710 | if (hp && hp->connect_ind) | 696 | case ESCO_LINK: |
| 711 | mask |= hp->connect_ind(hdev, bdaddr, type); | 697 | return sco_connect_ind(hdev, bdaddr); |
| 712 | 698 | ||
| 713 | return mask; | 699 | default: |
| 700 | BT_ERR("unknown link type %d", type); | ||
| 701 | return -EINVAL; | ||
| 702 | } | ||
| 714 | } | 703 | } |
| 715 | 704 | ||
| 716 | static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) | 705 | static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) |
| 717 | { | 706 | { |
| 718 | register struct hci_proto *hp; | 707 | switch (conn->type) { |
| 708 | case ACL_LINK: | ||
| 709 | case LE_LINK: | ||
| 710 | l2cap_connect_cfm(conn, status); | ||
| 711 | break; | ||
| 719 | 712 | ||
| 720 | hp = hci_proto[HCI_PROTO_L2CAP]; | 713 | case SCO_LINK: |
| 721 | if (hp && hp->connect_cfm) | 714 | case ESCO_LINK: |
| 722 | hp->connect_cfm(conn, status); | 715 | sco_connect_cfm(conn, status); |
| 716 | break; | ||
| 723 | 717 | ||
| 724 | hp = hci_proto[HCI_PROTO_SCO]; | 718 | default: |
| 725 | if (hp && hp->connect_cfm) | 719 | BT_ERR("unknown link type %d", conn->type); |
| 726 | hp->connect_cfm(conn, status); | 720 | break; |
| 721 | } | ||
| 727 | 722 | ||
| 728 | if (conn->connect_cfm_cb) | 723 | if (conn->connect_cfm_cb) |
| 729 | conn->connect_cfm_cb(conn, status); | 724 | conn->connect_cfm_cb(conn, status); |
| @@ -731,31 +726,29 @@ static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) | |||
| 731 | 726 | ||
| 732 | static inline int hci_proto_disconn_ind(struct hci_conn *conn) | 727 | static inline int hci_proto_disconn_ind(struct hci_conn *conn) |
| 733 | { | 728 | { |
| 734 | register struct hci_proto *hp; | 729 | if (conn->type != ACL_LINK && conn->type != LE_LINK) |
| 735 | int reason = HCI_ERROR_REMOTE_USER_TERM; | 730 | return HCI_ERROR_REMOTE_USER_TERM; |
| 736 | 731 | ||
| 737 | hp = hci_proto[HCI_PROTO_L2CAP]; | 732 | return l2cap_disconn_ind(conn); |
| 738 | if (hp && hp->disconn_ind) | ||
| 739 | reason = hp->disconn_ind(conn); | ||
| 740 | |||
| 741 | hp = hci_proto[HCI_PROTO_SCO]; | ||
| 742 | if (hp && hp->disconn_ind) | ||
| 743 | reason = hp->disconn_ind(conn); | ||
| 744 | |||
| 745 | return reason; | ||
| 746 | } | 733 | } |
| 747 | 734 | ||
| 748 | static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) | 735 | static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) |
| 749 | { | 736 | { |
| 750 | register struct hci_proto *hp; | 737 | switch (conn->type) { |
| 738 | case ACL_LINK: | ||
| 739 | case LE_LINK: | ||
| 740 | l2cap_disconn_cfm(conn, reason); | ||
| 741 | break; | ||
| 751 | 742 | ||
| 752 | hp = hci_proto[HCI_PROTO_L2CAP]; | 743 | case SCO_LINK: |
| 753 | if (hp && hp->disconn_cfm) | 744 | case ESCO_LINK: |
| 754 | hp->disconn_cfm(conn, reason); | 745 | sco_disconn_cfm(conn, reason); |
| 746 | break; | ||
| 755 | 747 | ||
| 756 | hp = hci_proto[HCI_PROTO_SCO]; | 748 | default: |
| 757 | if (hp && hp->disconn_cfm) | 749 | BT_ERR("unknown link type %d", conn->type); |
| 758 | hp->disconn_cfm(conn, reason); | 750 | break; |
| 751 | } | ||
| 759 | 752 | ||
| 760 | if (conn->disconn_cfm_cb) | 753 | if (conn->disconn_cfm_cb) |
| 761 | conn->disconn_cfm_cb(conn, reason); | 754 | conn->disconn_cfm_cb(conn, reason); |
| @@ -763,21 +756,16 @@ static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) | |||
| 763 | 756 | ||
| 764 | static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) | 757 | static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) |
| 765 | { | 758 | { |
| 766 | register struct hci_proto *hp; | ||
| 767 | __u8 encrypt; | 759 | __u8 encrypt; |
| 768 | 760 | ||
