Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50b65cc6 authored by David S. Miller's avatar David S. Miller
Browse files

Merge master.kernel.org:/pub/scm/linux/kernel/git/holtmann/bluetooth-2.6

parents 29578624 5b7f9909
Loading
Loading
Loading
Loading
+2 −86
Original line number Diff line number Diff line
@@ -199,7 +199,6 @@ static void hci_usb_tx_complete(struct urb *urb);
#define __pending_q(husb, type)   (&husb->pending_q[type-1])
#define __completed_q(husb, type) (&husb->completed_q[type-1])
#define __transmit_q(husb, type)  (&husb->transmit_q[type-1])
#define __reassembly(husb, type)  (husb->reassembly[type-1])

static inline struct _urb *__get_completed(struct hci_usb *husb, int type)
{
@@ -429,12 +428,6 @@ static void hci_usb_unlink_urbs(struct hci_usb *husb)
			kfree(urb->transfer_buffer);
			_urb_free(_urb);
		}

		/* Release reassembly buffers */
		if (husb->reassembly[i]) {
			kfree_skb(husb->reassembly[i]);
			husb->reassembly[i] = NULL;
		}
	}
}

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

static inline int __recv_frame(struct hci_usb *husb, int type, void *data, int count)
{
	BT_DBG("%s type %d data %p count %d", husb->hdev->name, type, data, count);

	husb->hdev->stat.byte_rx += count;

	while (count) {
		struct sk_buff *skb = __reassembly(husb, type);
		struct { int expect; } *scb;
		int len = 0;
	
		if (!skb) {
			/* Start of the frame */

			switch (type) {
			case HCI_EVENT_PKT:
				if (count >= HCI_EVENT_HDR_SIZE) {
					struct hci_event_hdr *h = data;
					len = HCI_EVENT_HDR_SIZE + h->plen;
				} else
					return -EILSEQ;
				break;

			case HCI_ACLDATA_PKT:
				if (count >= HCI_ACL_HDR_SIZE) {
					struct hci_acl_hdr *h = data;
					len = HCI_ACL_HDR_SIZE + __le16_to_cpu(h->dlen);
				} else
					return -EILSEQ;
				break;
#ifdef CONFIG_BT_HCIUSB_SCO
			case HCI_SCODATA_PKT:
				if (count >= HCI_SCO_HDR_SIZE) {
					struct hci_sco_hdr *h = data;
					len = HCI_SCO_HDR_SIZE + h->dlen;
				} else
					return -EILSEQ;
				break;
#endif
			}
			BT_DBG("new packet len %d", len);

			skb = bt_skb_alloc(len, GFP_ATOMIC);
			if (!skb) {
				BT_ERR("%s no memory for the packet", husb->hdev->name);
				return -ENOMEM;
			}
			skb->dev = (void *) husb->hdev;
			bt_cb(skb)->pkt_type = type;
	
			__reassembly(husb, type) = skb;

			scb = (void *) skb->cb;
			scb->expect = len;
		} else {
			/* Continuation */
			scb = (void *) skb->cb;
			len = scb->expect;
		}

		len = min(len, count);
		
		memcpy(skb_put(skb, len), data, len);

		scb->expect -= len;
		if (!scb->expect) {
			/* Complete frame */
			__reassembly(husb, type) = NULL;
			bt_cb(skb)->pkt_type = type;
			hci_recv_frame(skb);
		}

		count -= len; data += len;
	}
	return 0;
}

static void hci_usb_rx_complete(struct urb *urb)
{
	struct _urb *_urb = container_of(urb, struct _urb, urb);
@@ -776,7 +692,7 @@ static void hci_usb_rx_complete(struct urb *urb)
					urb->iso_frame_desc[i].actual_length);
	
			if (!urb->iso_frame_desc[i].status)
				__recv_frame(husb, _urb->type, 
				hci_recv_fragment(husb->hdev, _urb->type, 
					urb->transfer_buffer + urb->iso_frame_desc[i].offset,
					urb->iso_frame_desc[i].actual_length);
		}
@@ -784,7 +700,7 @@ static void hci_usb_rx_complete(struct urb *urb)
		;
#endif
	} else {
		err = __recv_frame(husb, _urb->type, urb->transfer_buffer, count);
		err = hci_recv_fragment(husb->hdev, _urb->type, urb->transfer_buffer, count);
		if (err < 0) { 
			BT_ERR("%s corrupted packet: type %d count %d",
					husb->hdev->name, _urb->type, count);
+2 −3
Original line number Diff line number Diff line
@@ -116,7 +116,6 @@ struct hci_usb {
	__u8			ctrl_req;

	struct sk_buff_head	transmit_q[4];
	struct sk_buff		*reassembly[4];		/* Reassembly buffers */

	rwlock_t		completion_lock;

+0 −6
Original line number Diff line number Diff line
@@ -180,11 +180,6 @@ static inline ssize_t vhci_put_user(struct vhci_data *data,
	return total;
}

static loff_t vhci_llseek(struct file *file, loff_t offset, int origin)
{
	return -ESPIPE;
}

static ssize_t vhci_read(struct file *file,
				char __user *buf, size_t count, loff_t *pos)
{
@@ -334,7 +329,6 @@ static int vhci_fasync(int fd, struct file *file, int on)

static const struct file_operations vhci_fops = {
	.owner		= THIS_MODULE,
	.llseek		= vhci_llseek,
	.read		= vhci_read,
	.write		= vhci_write,
	.poll		= vhci_poll,
+16 −2
Original line number Diff line number Diff line
@@ -107,14 +107,14 @@ enum {
#define HCI_IDLE_TIMEOUT	(6000)	/* 6 seconds */
#define HCI_INIT_TIMEOUT	(10000)	/* 10 seconds */

/* HCI Packet types */
/* HCI data types */
#define HCI_COMMAND_PKT		0x01
#define HCI_ACLDATA_PKT		0x02
#define HCI_SCODATA_PKT		0x03
#define HCI_EVENT_PKT		0x04
#define HCI_VENDOR_PKT		0xff

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

/* eSCO packet types */
#define ESCO_HV1	0x0001
#define ESCO_HV2	0x0002
#define ESCO_HV3	0x0004
#define ESCO_EV3	0x0008
#define ESCO_EV4	0x0010
#define ESCO_EV5	0x0020

/* ACL flags */
#define ACL_CONT		0x01
#define ACL_START		0x02
@@ -138,6 +146,7 @@ enum {
/* Baseband links */
#define SCO_LINK	0x00
#define ACL_LINK	0x01
#define ESCO_LINK	0x02

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

#define LMP_ESCO	0x80

#define LMP_EV4		0x01
#define LMP_EV5		0x02

#define LMP_SNIFF_SUBR	0x02

/* Connection modes */
+5 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ struct hci_dev {
	__u16		voice_setting;

	__u16		pkt_type;
	__u16		esco_type;
	__u16		link_policy;
	__u16		link_mode;

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

	struct sk_buff		*sent_cmd;
	struct sk_buff		*reassembly[3];

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

int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count);

int hci_register_sysfs(struct hci_dev *hdev);
void hci_unregister_sysfs(struct hci_dev *hdev);
void hci_conn_add_sysfs(struct hci_conn *conn);
@@ -449,6 +453,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
#define lmp_encrypt_capable(dev)   ((dev)->features[0] & LMP_ENCRYPT)
#define lmp_sniff_capable(dev)     ((dev)->features[0] & LMP_SNIFF)
#define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR)
#define lmp_esco_capable(dev)      ((dev)->features[3] & LMP_ESCO)

/* ----- HCI protocols ----- */
struct hci_proto {
Loading