Skip to content

Commit

Permalink
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/…
Browse files Browse the repository at this point in the history
…padovan/bluetooth-next-2.6

Conflicts:
	net/bluetooth/l2cap_core.c
  • Loading branch information
John W. Linville committed Jul 11, 2011
2 parents d859898 + e2fd318 commit 4b42c54
Show file tree
Hide file tree
Showing 16 changed files with 690 additions and 270 deletions.
5 changes: 5 additions & 0 deletions drivers/bluetooth/ath3k.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@ static int ath3k_probe(struct usb_interface *intf,

/* load patch and sysconfig files for AR3012 */
if (id->driver_info & BTUSB_ATH3012) {

/* New firmware with patch and sysconfig files already loaded */
if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x0001)
return -ENODEV;

ret = ath3k_load_patch(udev);
if (ret < 0) {
BT_ERR("Loading patch file failed");
Expand Down
12 changes: 11 additions & 1 deletion drivers/bluetooth/btusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ static struct usb_driver btusb_driver;
#define BTUSB_BCM92035 0x10
#define BTUSB_BROKEN_ISOC 0x20
#define BTUSB_WRONG_SCO_MTU 0x40
#define BTUSB_ATH3012 0x80

static struct usb_device_id btusb_table[] = {
/* Generic Bluetooth USB device */
Expand Down Expand Up @@ -110,7 +111,7 @@ static struct usb_device_id blacklist_table[] = {
{ USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },

/* Atheros 3012 with sflash firmware */
{ USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_IGNORE },
{ USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },

/* Atheros AR5BBU12 with sflash firmware */
{ USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
Expand Down Expand Up @@ -914,6 +915,15 @@ static int btusb_probe(struct usb_interface *intf,
if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER)
return -ENODEV;

if (id->driver_info & BTUSB_ATH3012) {
struct usb_device *udev = interface_to_usbdev(intf);

/* Old firmware would otherwise let ath3k driver load
* patch and sysconfig files */
if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001)
return -ENODEV;
}

data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
Expand Down
12 changes: 8 additions & 4 deletions include/net/bluetooth/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#define BT_SECURITY 4
struct bt_security {
__u8 level;
__u8 key_size;
};
#define BT_SECURITY_SDP 0
#define BT_SECURITY_LOW 1
Expand All @@ -76,9 +77,12 @@ struct bt_power {
#define BT_POWER_FORCE_ACTIVE_OFF 0
#define BT_POWER_FORCE_ACTIVE_ON 1

#define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg)
#define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg)
#define BT_DBG(fmt, arg...) pr_debug("%s: " fmt "\n" , __func__ , ## arg)
__attribute__((format (printf, 2, 3)))
int bt_printk(const char *level, const char *fmt, ...);

#define BT_INFO(fmt, arg...) bt_printk(KERN_INFO, pr_fmt(fmt), ##arg)
#define BT_ERR(fmt, arg...) bt_printk(KERN_ERR, pr_fmt(fmt), ##arg)
#define BT_DBG(fmt, arg...) pr_debug(fmt "\n", ##arg)

/* Connection and socket states */
enum {
Expand Down Expand Up @@ -204,7 +208,7 @@ static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk,
return NULL;
}

int bt_err(__u16 code);
int bt_to_errno(__u16 code);

extern int hci_sock_init(void);
extern void hci_sock_cleanup(void);
Expand Down
18 changes: 18 additions & 0 deletions include/net/bluetooth/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,16 @@ enum {
#define LMP_EDR_3S_ESCO 0x80

#define LMP_EXT_INQ 0x01
#define LMP_SIMUL_LE_BR 0x02
#define LMP_SIMPLE_PAIR 0x08
#define LMP_NO_FLUSH 0x40

#define LMP_LSTO 0x01
#define LMP_INQ_TX_PWR 0x02
#define LMP_EXTFEATURES 0x80

/* Extended LMP features */
#define LMP_HOST_LE 0x02

/* Connection modes */
#define HCI_CM_ACTIVE 0x0000
Expand Down Expand Up @@ -254,6 +259,10 @@ enum {
#define HCI_LK_UNAUTH_COMBINATION 0x04
#define HCI_LK_AUTH_COMBINATION 0x05
#define HCI_LK_CHANGED_COMBINATION 0x06
/* The spec doesn't define types for SMP keys */
#define HCI_LK_SMP_LTK 0x81
#define HCI_LK_SMP_IRK 0x82
#define HCI_LK_SMP_CSRK 0x83

/* ----- HCI Commands ---- */
#define HCI_OP_NOP 0x0000
Expand Down Expand Up @@ -653,6 +662,12 @@ struct hci_rp_read_local_oob_data {

#define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58

#define HCI_OP_WRITE_LE_HOST_SUPPORTED 0x0c6d
struct hci_cp_write_le_host_supported {
__u8 le;
__u8 simul;
} __packed;

#define HCI_OP_READ_LOCAL_VERSION 0x1001
struct hci_rp_read_local_version {
__u8 status;
Expand All @@ -676,6 +691,9 @@ struct hci_rp_read_local_features {
} __packed;

#define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004
struct hci_cp_read_local_ext_features {
__u8 page;
} __packed;
struct hci_rp_read_local_ext_features {
__u8 status;
__u8 page;
Expand Down
29 changes: 26 additions & 3 deletions include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,28 @@ struct bt_uuid {
u8 svc_hint;
};

struct key_master_id {
__le16 ediv;
u8 rand[8];
} __packed;

struct link_key_data {
bdaddr_t bdaddr;
u8 type;
u8 val[16];
u8 pin_len;
u8 dlen;
u8 data[0];
} __packed;

struct link_key {
struct list_head list;
bdaddr_t bdaddr;
u8 type;
u8 val[16];
u8 pin_len;
u8 dlen;
u8 data[0];
};

struct oob_data {
Expand Down Expand Up @@ -113,6 +129,7 @@ struct hci_dev {
__u8 major_class;
__u8 minor_class;
__u8 features[8];
__u8 extfeatures[8];
__u8 commands[64];
__u8 ssp_mode;
__u8 hci_ver;
Expand Down Expand Up @@ -223,7 +240,6 @@ struct hci_conn {
struct list_head list;

atomic_t refcnt;
spinlock_t lock;

bdaddr_t dst;
__u8 dst_type;
Expand All @@ -245,11 +261,11 @@ struct hci_conn {
__u8 sec_level;
__u8 pending_sec_level;
__u8 pin_length;
__u8 enc_key_size;
__u8 io_capability;
__u8 power_save;
__u16 disc_timeout;
unsigned long pend;
__u8 ltk[16];

__u8 remote_cap;
__u8 remote_oob;
Expand All @@ -272,7 +288,6 @@ struct hci_conn {
struct hci_dev *hdev;
void *l2cap_data;
void *sco_data;
void *priv;

struct hci_conn *link;

Expand Down Expand Up @@ -538,6 +553,11 @@ int hci_link_keys_clear(struct hci_dev *hdev);
struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len);
struct link_key *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]);
struct link_key *hci_find_link_key_type(struct hci_dev *hdev,
bdaddr_t *bdaddr, u8 type);
int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr,
u8 key_size, __le16 ediv, u8 rand[8], u8 ltk[16]);
int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);

int hci_remote_oob_data_clear(struct hci_dev *hdev);
Expand Down Expand Up @@ -579,6 +599,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
#define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH)
#define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE)

/* ----- Extended LMP capabilities ----- */
#define lmp_host_le_capable(dev) ((dev)->extfeatures[0] & LMP_HOST_LE)

/* ----- HCI protocols ----- */
struct hci_proto {
char *name;
Expand Down
25 changes: 20 additions & 5 deletions include/net/bluetooth/l2cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */
#define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */
#define L2CAP_DEFAULT_ACK_TO 200
#define L2CAP_LOCAL_BUSY_TRIES 12
#define L2CAP_LE_DEFAULT_MTU 23

#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */
Expand Down Expand Up @@ -130,6 +129,12 @@ struct l2cap_conninfo {
#define L2CAP_SDU_END 0x8000
#define L2CAP_SDU_CONTINUE 0xC000

/* L2CAP Command rej. reasons */
#define L2CAP_REJ_NOT_UNDERSTOOD 0x0000
#define L2CAP_REJ_MTU_EXCEEDED 0x0001
#define L2CAP_REJ_INVALID_CID 0x0002


/* L2CAP structures */
struct l2cap_hdr {
__le16 len;
Expand All @@ -144,8 +149,19 @@ struct l2cap_cmd_hdr {
} __packed;
#define L2CAP_CMD_HDR_SIZE 4

struct l2cap_cmd_rej {
struct l2cap_cmd_rej_unk {
__le16 reason;
} __packed;

struct l2cap_cmd_rej_mtu {
__le16 reason;
__le16 max_mtu;
} __packed;

struct l2cap_cmd_rej_cid {
__le16 reason;
__le16 scid;
__le16 dcid;
} __packed;

struct l2cap_conn_req {
Expand Down Expand Up @@ -352,8 +368,6 @@ struct l2cap_chan {
struct sk_buff *tx_send_head;
struct sk_buff_head tx_q;
struct sk_buff_head srej_q;
struct sk_buff_head busy_q;
struct work_struct busy_work;
struct list_head srej_l;

struct list_head list;
Expand Down Expand Up @@ -422,6 +436,7 @@ struct l2cap_conn {
struct l2cap_pinfo {
struct bt_sock bt;
struct l2cap_chan *chan;
struct sk_buff *rx_busy_skb;
};

enum {
Expand Down Expand Up @@ -449,7 +464,6 @@ enum {
CONN_REJ_ACT,
CONN_SEND_FBIT,
CONN_RNR_SENT,
CONN_SAR_RETRY,
};

#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t))
Expand Down Expand Up @@ -498,5 +512,6 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason);
void l2cap_chan_destroy(struct l2cap_chan *chan);
int l2cap_chan_connect(struct l2cap_chan *chan);
int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
void l2cap_chan_busy(struct l2cap_chan *chan, int busy);

#endif /* __L2CAP_H */
2 changes: 2 additions & 0 deletions include/net/bluetooth/mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ struct mgmt_key_info {
u8 type;
u8 val[16];
u8 pin_len;
u8 dlen;
u8 data[0];
} __packed;

#define MGMT_OP_LOAD_KEYS 0x000D
Expand Down
1 change: 1 addition & 0 deletions include/net/bluetooth/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,6 @@ struct smp_cmd_security_req {
/* SMP Commands */
int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level);
int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb);
int smp_distribute_keys(struct l2cap_conn *conn, __u8 force);

#endif /* __SMP_H */
Loading

0 comments on commit 4b42c54

Please sign in to comment.