Skip to content

Commit 50b65cc

Browse files
author
David S. Miller
committed
Merge master.kernel.org:/pub/scm/linux/kernel/git/holtmann/bluetooth-2.6
2 parents 2957862 + 5b7f990 commit 50b65cc

10 files changed

Lines changed: 195 additions & 142 deletions

File tree

‎drivers/bluetooth/hci_usb.c‎

Lines changed: 2 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ static void hci_usb_tx_complete(struct urb *urb);
199199
#define __pending_q(husb, type) (&husb->pending_q[type-1])
200200
#define __completed_q(husb, type) (&husb->completed_q[type-1])
201201
#define __transmit_q(husb, type) (&husb->transmit_q[type-1])
202-
#define __reassembly(husb, type) (husb->reassembly[type-1])
203202

204203
static inline struct _urb *__get_completed(struct hci_usb *husb, int type)
205204
{
@@ -429,12 +428,6 @@ static void hci_usb_unlink_urbs(struct hci_usb *husb)
429428
kfree(urb->transfer_buffer);
430429
_urb_free(_urb);
431430
}
432-
433-
/* Release reassembly buffers */
434-
if (husb->reassembly[i]) {
435-
kfree_skb(husb->reassembly[i]);
436-
husb->reassembly[i] = NULL;
437-
}
438431
}
439432
}
440433

@@ -671,83 +664,6 @@ static int hci_usb_send_frame(struct sk_buff *skb)
671664
return 0;
672665
}
673666

674-
static inline int __recv_frame(struct hci_usb *husb, int type, void *data, int count)
675-
{
676-
BT_DBG("%s type %d data %p count %d", husb->hdev->name, type, data, count);
677-
678-
husb->hdev->stat.byte_rx += count;
679-
680-
while (count) {
681-
struct sk_buff *skb = __reassembly(husb, type);
682-
struct { int expect; } *scb;
683-
int len = 0;
684-
685-
if (!skb) {
686-
/* Start of the frame */
687-
688-
switch (type) {
689-
case HCI_EVENT_PKT:
690-
if (count >= HCI_EVENT_HDR_SIZE) {
691-
struct hci_event_hdr *h = data;
692-
len = HCI_EVENT_HDR_SIZE + h->plen;
693-
} else
694-
return -EILSEQ;
695-
break;
696-
697-
case HCI_ACLDATA_PKT:
698-
if (count >= HCI_ACL_HDR_SIZE) {
699-
struct hci_acl_hdr *h = data;
700-
len = HCI_ACL_HDR_SIZE + __le16_to_cpu(h->dlen);
701-
} else
702-
return -EILSEQ;
703-
break;
704-
#ifdef CONFIG_BT_HCIUSB_SCO
705-
case HCI_SCODATA_PKT:
706-
if (count >= HCI_SCO_HDR_SIZE) {
707-
struct hci_sco_hdr *h = data;
708-
len = HCI_SCO_HDR_SIZE + h->dlen;
709-
} else
710-
return -EILSEQ;
711-
break;
712-
#endif
713-
}
714-
BT_DBG("new packet len %d", len);
715-
716-
skb = bt_skb_alloc(len, GFP_ATOMIC);
717-
if (!skb) {
718-
BT_ERR("%s no memory for the packet", husb->hdev->name);
719-
return -ENOMEM;
720-
}
721-
skb->dev = (void *) husb->hdev;
722-
bt_cb(skb)->pkt_type = type;
723-
724-
__reassembly(husb, type) = skb;
725-
726-
scb = (void *) skb->cb;
727-
scb->expect = len;
728-
} else {
729-
/* Continuation */
730-
scb = (void *) skb->cb;
731-
len = scb->expect;
732-
}
733-
734-
len = min(len, count);
735-
736-
memcpy(skb_put(skb, len), data, len);
737-
738-
scb->expect -= len;
739-
if (!scb->expect) {
740-
/* Complete frame */
741-
__reassembly(husb, type) = NULL;
742-
bt_cb(skb)->pkt_type = type;
743-
hci_recv_frame(skb);
744-
}
745-
746-
count -= len; data += len;
747-
}
748-
return 0;
749-
}
750-
751667
static void hci_usb_rx_complete(struct urb *urb)
752668
{
753669
struct _urb *_urb = container_of(urb, struct _urb, urb);
@@ -776,15 +692,15 @@ static void hci_usb_rx_complete(struct urb *urb)
776692
urb->iso_frame_desc[i].actual_length);
777693

778694
if (!urb->iso_frame_desc[i].status)
779-
__recv_frame(husb, _urb->type,
695+
hci_recv_fragment(husb->hdev, _urb->type,
780696
urb->transfer_buffer + urb->iso_frame_desc[i].offset,
781697
urb->iso_frame_desc[i].actual_length);
782698
}
783699
#else
784700
;
785701
#endif
786702
} else {
787-
err = __recv_frame(husb, _urb->type, urb->transfer_buffer, count);
703+
err = hci_recv_fragment(husb->hdev, _urb->type, urb->transfer_buffer, count);
788704
if (err < 0) {
789705
BT_ERR("%s corrupted packet: type %d count %d",
790706
husb->hdev->name, _urb->type, count);

‎drivers/bluetooth/hci_usb.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ struct hci_usb {
102102
struct hci_dev *hdev;
103103

104104
unsigned long state;
105-
105+
106106
struct usb_device *udev;
107-
107+
108108
struct usb_host_endpoint *bulk_in_ep;
109109
struct usb_host_endpoint *bulk_out_ep;
110110
struct usb_host_endpoint *intr_in_ep;
@@ -116,7 +116,6 @@ struct hci_usb {
116116
__u8 ctrl_req;
117117

118118
struct sk_buff_head transmit_q[4];
119-
struct sk_buff *reassembly[4]; /* Reassembly buffers */
120119

121120
rwlock_t completion_lock;
122121

‎drivers/bluetooth/hci_vhci.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,6 @@ static inline ssize_t vhci_put_user(struct vhci_data *data,
180180
return total;
181181
}
182182

183-
static loff_t vhci_llseek(struct file *file, loff_t offset, int origin)
184-
{
185-
return -ESPIPE;
186-
}
187-
188183
static ssize_t vhci_read(struct file *file,
189184
char __user *buf, size_t count, loff_t *pos)
190185
{
@@ -334,7 +329,6 @@ static int vhci_fasync(int fd, struct file *file, int on)
334329

335330
static const struct file_operations vhci_fops = {
336331
.owner = THIS_MODULE,
337-
.llseek = vhci_llseek,
338332
.read = vhci_read,
339333
.write = vhci_write,
340334
.poll = vhci_poll,

‎include/net/bluetooth/hci.h‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ enum {
107107
#define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */
108108
#define HCI_INIT_TIMEOUT (10000) /* 10 seconds */
109109

110-
/* HCI Packet types */
110+
/* HCI data types */
111111
#define HCI_COMMAND_PKT 0x01
112112
#define HCI_ACLDATA_PKT 0x02
113113
#define HCI_SCODATA_PKT 0x03
114114
#define HCI_EVENT_PKT 0x04
115115
#define HCI_VENDOR_PKT 0xff
116116

117-
/* HCI Packet types */
117+
/* HCI packet types */
118118
#define HCI_DM1 0x0008
119119
#define HCI_DM3 0x0400
120120
#define HCI_DM5 0x4000
@@ -129,6 +129,14 @@ enum {
129129
#define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
130130
#define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
131131

132+
/* eSCO packet types */
133+
#define ESCO_HV1 0x0001
134+
#define ESCO_HV2 0x0002
135+
#define ESCO_HV3 0x0004
136+
#define ESCO_EV3 0x0008
137+
#define ESCO_EV4 0x0010
138+
#define ESCO_EV5 0x0020
139+
132140
/* ACL flags */
133141
#define ACL_CONT 0x01
134142
#define ACL_START 0x02
@@ -138,6 +146,7 @@ enum {
138146
/* Baseband links */
139147
#define SCO_LINK 0x00
140148
#define ACL_LINK 0x01
149+
#define ESCO_LINK 0x02
141150

142151
/* LMP features */
143152
#define LMP_3SLOT 0x01
@@ -162,6 +171,11 @@ enum {
162171
#define LMP_PSCHEME 0x02
163172
#define LMP_PCONTROL 0x04
164173

174+
#define LMP_ESCO 0x80
175+
176+
#define LMP_EV4 0x01
177+
#define LMP_EV5 0x02
178+
165179
#define LMP_SNIFF_SUBR 0x02
166180

167181
/* Connection modes */

‎include/net/bluetooth/hci_core.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct hci_dev {
7878
__u16 voice_setting;
7979

8080
__u16 pkt_type;
81+
__u16 esco_type;
8182
__u16 link_policy;
8283
__u16 link_mode;
8384

@@ -109,6 +110,7 @@ struct hci_dev {
109110
struct sk_buff_head cmd_q;
110111

111112
struct sk_buff *sent_cmd;
113+
struct sk_buff *reassembly[3];
112114

113115
struct semaphore req_lock;
114116
wait_queue_head_t req_wait_q;
@@ -437,6 +439,8 @@ static inline int hci_recv_frame(struct sk_buff *skb)
437439
return 0;
438440
}
439441

442+
int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count);
443+
440444
int hci_register_sysfs(struct hci_dev *hdev);
441445
void hci_unregister_sysfs(struct hci_dev *hdev);
442446
void hci_conn_add_sysfs(struct hci_conn *conn);
@@ -449,6 +453,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
449453
#define lmp_encrypt_capable(dev) ((dev)->features[0] & LMP_ENCRYPT)
450454
#define lmp_sniff_capable(dev) ((dev)->features[0] & LMP_SNIFF)
451455
#define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR)
456+
#define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO)
452457

453458
/* ----- HCI protocols ----- */
454459
struct hci_proto {

‎include/net/bluetooth/rfcomm.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc
323323
#define RFCOMM_RELEASE_ONHUP 1
324324
#define RFCOMM_HANGUP_NOW 2
325325
#define RFCOMM_TTY_ATTACHED 3
326+
#define RFCOMM_TTY_RELEASED 4
326327

327328
struct rfcomm_dev_req {
328329
s16 dev_id;

‎net/bluetooth/hci_conn.c‎

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ void hci_add_sco(struct hci_conn *conn, __u16 handle)
123123
conn->state = BT_CONNECT;
124124
conn->out = 1;
125125

126-
cp.pkt_type = cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK);
127126
cp.handle = cpu_to_le16(handle);
127+
cp.pkt_type = cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK);
128128

129129
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_ADD_SCO, sizeof(cp), &cp);
130130
}
@@ -220,19 +220,19 @@ int hci_conn_del(struct hci_conn *conn)
220220

221221
del_timer(&conn->disc_timer);
222222

223-
if (conn->type == SCO_LINK) {
224-
struct hci_conn *acl = conn->link;
225-
if (acl) {
226-
acl->link = NULL;
227-
hci_conn_put(acl);
228-
}
229-
} else {
223+
if (conn->type == ACL_LINK) {
230224
struct hci_conn *sco = conn->link;
231225
if (sco)
232226
sco->link = NULL;
233227

234228
/* Unacked frames */
235229
hdev->acl_cnt += conn->sent;
230+
} else {
231+
struct hci_conn *acl = conn->link;
232+
if (acl) {
233+
acl->link = NULL;
234+
hci_conn_put(acl);
235+
}
236236
}
237237

238238
tasklet_disable(&hdev->tx_task);
@@ -297,9 +297,10 @@ EXPORT_SYMBOL(hci_get_route);
297297

298298
/* Create SCO or ACL connection.
299299
* Device _must_ be locked */
300-
struct hci_conn * hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst)
300+
struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst)
301301
{
302302
struct hci_conn *acl;
303+
struct hci_conn *sco;
303304

304305
BT_DBG("%s dst %s", hdev->name, batostr(dst));
305306

@@ -313,28 +314,26 @@ struct hci_conn * hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst)
313314
if (acl->state == BT_OPEN || acl->state == BT_CLOSED)
314315
hci_acl_connect(acl);
315316

316-
if (type == SCO_LINK) {
317-
struct hci_conn *sco;
317+
if (type == ACL_LINK)
318+
return acl;
318319

319-
if (!(sco = hci_conn_hash_lookup_ba(hdev, SCO_LINK, dst))) {
320-
if (!(sco = hci_conn_add(hdev, SCO_LINK, dst))) {
321-
hci_conn_put(acl);
322-
return NULL;
323-
}
320+
if (!(sco = hci_conn_hash_lookup_ba(hdev, type, dst))) {
321+
if (!(sco = hci_conn_add(hdev, type, dst))) {
322+
hci_conn_put(acl);
323+
return NULL;
324324
}
325-
acl->link = sco;
326-
sco->link = acl;
325+
}
327326

328-
hci_conn_hold(sco);
327+
acl->link = sco;
328+
sco->link = acl;
329329

330-
if (acl->state == BT_CONNECTED &&
331-
(sco->state == BT_OPEN || sco->state == BT_CLOSED))
332-
hci_add_sco(sco, acl->handle);
330+
hci_conn_hold(sco);
333331

334-
return sco;
335-
} else {
336-
return acl;
337-
}
332+
if (acl->state == BT_CONNECTED &&
333+
(sco->state == BT_OPEN || sco->state == BT_CLOSED))
334+
hci_add_sco(sco, acl->handle);
335+
336+
return sco;
338337
}
339338
EXPORT_SYMBOL(hci_connect);
340339

0 commit comments

Comments
 (0)