Skip to content

Commit

Permalink
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/bluetooth/bluetooth-next

Johan Hedberg says:

====================
pull request: bluetooth-next 2015-01-16

Here are some more bluetooth & ieee802154 patches intended for 3.20:

 - Refactoring & cleanups of ieee802154 & 6lowpan code
 - Various fixes to the btmrvl driver
 - Fixes for Bluetooth Low Energy Privacy feature handling
 - Added build-time sanity checks for sockaddr sizes
 - Fixes for Security Manager registration on LE-only controllers
 - Refactoring of broken inquiry mode handling to a generic quirk

Please let me know if there are any issues pulling. Thanks.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jan 18, 2015
2 parents 3aeb661 + 0026b65 commit e445dd5
Show file tree
Hide file tree
Showing 39 changed files with 2,461 additions and 2,397 deletions.
5 changes: 3 additions & 2 deletions drivers/bluetooth/btmrvl_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
#define BTM_UPLD_SIZE 2312

/* Time to wait until Host Sleep state change in millisecond */
#define WAIT_UNTIL_HS_STATE_CHANGED 5000
#define WAIT_UNTIL_HS_STATE_CHANGED msecs_to_jiffies(5000)
/* Time to wait for command response in millisecond */
#define WAIT_UNTIL_CMD_RESP 5000
#define WAIT_UNTIL_CMD_RESP msecs_to_jiffies(5000)

enum rdwr_status {
RDWR_STATUS_SUCCESS = 0,
Expand Down Expand Up @@ -104,6 +104,7 @@ struct btmrvl_private {
#ifdef CONFIG_DEBUG_FS
void *debugfs_data;
#endif
bool surprise_removed;
};

#define MRVL_VENDOR_PKT 0xFE
Expand Down
32 changes: 25 additions & 7 deletions drivers/bluetooth/btmrvl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ static int btmrvl_send_sync_cmd(struct btmrvl_private *priv, u16 opcode,
struct sk_buff *skb;
struct hci_command_hdr *hdr;

if (priv->surprise_removed) {
BT_ERR("Card is removed");
return -EFAULT;
}

skb = bt_skb_alloc(HCI_COMMAND_HDR_SIZE + len, GFP_ATOMIC);
if (skb == NULL) {
BT_ERR("No free skb");
Expand All @@ -202,10 +207,14 @@ static int btmrvl_send_sync_cmd(struct btmrvl_private *priv, u16 opcode,
wake_up_interruptible(&priv->main_thread.wait_q);

if (!wait_event_interruptible_timeout(priv->adapter->cmd_wait_q,
priv->adapter->cmd_complete,
msecs_to_jiffies(WAIT_UNTIL_CMD_RESP)))
priv->adapter->cmd_complete ||
priv->surprise_removed,
WAIT_UNTIL_CMD_RESP))
return -ETIMEDOUT;

if (priv->surprise_removed)
return -EFAULT;

return 0;
}

Expand Down Expand Up @@ -287,9 +296,10 @@ int btmrvl_enable_hs(struct btmrvl_private *priv)
}

ret = wait_event_interruptible_timeout(adapter->event_hs_wait_q,
adapter->hs_state,
msecs_to_jiffies(WAIT_UNTIL_HS_STATE_CHANGED));
if (ret < 0) {
adapter->hs_state ||
priv->surprise_removed,
WAIT_UNTIL_HS_STATE_CHANGED);
if (ret < 0 || priv->surprise_removed) {
BT_ERR("event_hs_wait_q terminated (%d): %d,%d,%d",
ret, adapter->hs_state, adapter->ps_state,
adapter->wakeup_tries);
Expand Down Expand Up @@ -538,8 +548,11 @@ static int btmrvl_check_device_tree(struct btmrvl_private *priv)
static int btmrvl_setup(struct hci_dev *hdev)
{
struct btmrvl_private *priv = hci_get_drvdata(hdev);
int ret;

btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);
ret = btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);
if (ret)
return ret;

priv->btmrvl_dev.gpio_gap = 0xffff;

Expand Down Expand Up @@ -597,7 +610,7 @@ static int btmrvl_service_main_thread(void *data)
add_wait_queue(&thread->wait_q, &wait);

set_current_state(TASK_INTERRUPTIBLE);
if (kthread_should_stop()) {
if (kthread_should_stop() || priv->surprise_removed) {
BT_DBG("main_thread: break from main thread");
break;
}
Expand All @@ -616,6 +629,11 @@ static int btmrvl_service_main_thread(void *data)

BT_DBG("main_thread woke up");

if (kthread_should_stop() || priv->surprise_removed) {
BT_DBG("main_thread: break from main thread");
break;
}

spin_lock_irqsave(&priv->driver_lock, flags);
if (adapter->int_count) {
adapter->int_count = 0;
Expand Down
6 changes: 5 additions & 1 deletion drivers/bluetooth/btmrvl_sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
offset += txlen;
} while (true);

BT_DBG("FW download over, size %d bytes", offset);
BT_INFO("FW download over, size %d bytes", offset);

ret = 0;

Expand Down Expand Up @@ -798,6 +798,9 @@ static void btmrvl_sdio_interrupt(struct sdio_func *func)

priv = card->priv;

if (priv->surprise_removed)
return;

if (card->reg->int_read_to_clear)
ret = btmrvl_sdio_read_to_clear(card, &ireg);
else
Expand Down Expand Up @@ -1466,6 +1469,7 @@ static void btmrvl_sdio_remove(struct sdio_func *func)
btmrvl_sdio_disable_host_int(card);
}
BT_DBG("unregester dev");
card->priv->surprise_removed = true;
btmrvl_sdio_unregister_dev(card);
btmrvl_remove_card(card->priv);
}
Expand Down
15 changes: 11 additions & 4 deletions drivers/bluetooth/btusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static struct usb_driver btusb_driver;
#define BTUSB_INTEL_BOOT 0x200
#define BTUSB_BCM_PATCHRAM 0x400
#define BTUSB_MARVELL 0x800
#define BTUSB_AVM 0x1000
#define BTUSB_SWAVE 0x1000

static const struct usb_device_id btusb_table[] = {
/* Generic Bluetooth USB device */
Expand Down Expand Up @@ -86,7 +86,7 @@ static const struct usb_device_id btusb_table[] = {
{ USB_DEVICE(0x05ac, 0x8281) },

/* AVM BlueFRITZ! USB v2.0 */
{ USB_DEVICE(0x057c, 0x3800), .driver_info = BTUSB_AVM },
{ USB_DEVICE(0x057c, 0x3800), .driver_info = BTUSB_SWAVE },

/* Bluetooth Ultraport Module from IBM */
{ USB_DEVICE(0x04bf, 0x030a) },
Expand Down Expand Up @@ -238,6 +238,9 @@ static const struct usb_device_id blacklist_table[] = {
/* CONWISE Technology based adapters with buggy SCO support */
{ USB_DEVICE(0x0e5e, 0x6622), .driver_info = BTUSB_BROKEN_ISOC },

/* Roper Class 1 Bluetooth Dongle (Silicon Wave based) */
{ USB_DEVICE(0x1300, 0x0001), .driver_info = BTUSB_SWAVE },

/* Digianswer devices */
{ USB_DEVICE(0x08fd, 0x0001), .driver_info = BTUSB_DIGIANSWER },
{ USB_DEVICE(0x08fd, 0x0002), .driver_info = BTUSB_IGNORE },
Expand Down Expand Up @@ -306,6 +309,7 @@ struct btusb_data {
int isoc_altsetting;
int suspend_count;

int (*recv_event)(struct hci_dev *hdev, struct sk_buff *skb);
int (*recv_bulk)(struct btusb_data *data, void *buffer, int count);
};

Expand Down Expand Up @@ -371,7 +375,7 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)

if (bt_cb(skb)->expect == 0) {
/* Complete frame */
hci_recv_frame(data->hdev, skb);
data->recv_event(data->hdev, skb);
skb = NULL;
}
}
Expand Down Expand Up @@ -2045,6 +2049,7 @@ static int btusb_probe(struct usb_interface *intf,
init_usb_anchor(&data->isoc_anchor);
spin_lock_init(&data->rxlock);

data->recv_event = hci_recv_frame;
data->recv_bulk = btusb_recv_bulk;

hdev = hci_alloc_dev();
Expand Down Expand Up @@ -2081,8 +2086,10 @@ static int btusb_probe(struct usb_interface *intf,
if (id->driver_info & BTUSB_MARVELL)
hdev->set_bdaddr = btusb_set_bdaddr_marvell;

if (id->driver_info & BTUSB_AVM)
if (id->driver_info & BTUSB_SWAVE) {
set_bit(HCI_QUIRK_FIXUP_INQUIRY_MODE, &hdev->quirks);
set_bit(HCI_QUIRK_BROKEN_LOCAL_COMMANDS, &hdev->quirks);
}

if (id->driver_info & BTUSB_INTEL_BOOT)
set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
Expand Down
2 changes: 1 addition & 1 deletion include/net/bluetooth/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ struct l2cap_ctrl {

struct hci_dev;

typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status);
typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);

struct hci_req_ctrl {
bool start;
Expand Down
30 changes: 28 additions & 2 deletions include/net/bluetooth/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ enum {
*/
HCI_QUIRK_FIXUP_BUFFER_SIZE,

/* When this quirk is set, then a controller that does not
* indicate support for Inquiry Result with RSSI is assumed to
* support it anyway. Some early Bluetooth 1.2 controllers had
* wrongly configured local features that will require forcing
* them to enable this mode. Getting RSSI information with the
* inquiry responses is preferred since it allows for a better
* user expierence.
*
* This quirk must be set before hci_register_dev is called.
*/
HCI_QUIRK_FIXUP_INQUIRY_MODE,

/* When this quirk is set, then the HCI Read Local Supported
* Commands command is not supported. In general Bluetooth 1.2
* and later controllers should support this command. However
Expand Down Expand Up @@ -172,8 +184,7 @@ enum {
*/
enum {
HCI_DUT_MODE,
HCI_FORCE_SC,
HCI_FORCE_LESC,
HCI_FORCE_BREDR_SMP,
HCI_FORCE_STATIC_ADDR,
};

Expand Down Expand Up @@ -844,11 +855,26 @@ struct hci_cp_set_event_flt {
#define HCI_CONN_SETUP_AUTO_OFF 0x01
#define HCI_CONN_SETUP_AUTO_ON 0x02

#define HCI_OP_READ_STORED_LINK_KEY 0x0c0d
struct hci_cp_read_stored_link_key {
bdaddr_t bdaddr;
__u8 read_all;
} __packed;
struct hci_rp_read_stored_link_key {
__u8 status;
__u8 max_keys;
__u8 num_keys;
} __packed;

#define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
struct hci_cp_delete_stored_link_key {
bdaddr_t bdaddr;
__u8 delete_all;
} __packed;
struct hci_rp_delete_stored_link_key {
__u8 status;
__u8 num_keys;
} __packed;

#define HCI_MAX_NAME_LENGTH 248

Expand Down
6 changes: 3 additions & 3 deletions include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ struct hci_dev {
__u16 lmp_subver;
__u16 voice_setting;
__u8 num_iac;
__u8 stored_max_keys;
__u8 stored_num_keys;
__u8 io_capability;
__s8 inq_tx_power;
__u16 page_scan_interval;
Expand Down Expand Up @@ -779,7 +781,6 @@ int hci_conn_check_link_mode(struct hci_conn *conn);
int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level);
int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type,
bool initiator);
int hci_conn_change_link_key(struct hci_conn *conn);
int hci_conn_switch_role(struct hci_conn *conn, __u8 role);

void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active);
Expand Down Expand Up @@ -1017,8 +1018,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);

#define hdev_is_powered(hdev) (test_bit(HCI_UP, &hdev->flags) && \
!test_bit(HCI_AUTO_OFF, &hdev->dev_flags))
#define bredr_sc_enabled(dev) ((lmp_sc_capable(dev) || \
test_bit(HCI_FORCE_SC, &(dev)->dbg_flags)) && \
#define bredr_sc_enabled(dev) (lmp_sc_capable(dev) && \
test_bit(HCI_SC_ENABLED, &(dev)->dev_flags))

/* ----- HCI protocols ----- */
Expand Down
Loading

0 comments on commit e445dd5

Please sign in to comment.