Commit 59c1cecc authored by David S. Miller's avatar David S. Miller

Merge branch 'for-upstream' of...

Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next

Johan Hedberg says:

====================
pull request: bluetooth-next 2017-11-01

Here's one more bluetooth-next pull request for the 4.15 kernel.

 - New NFA344A device entry for btusb drvier
 - Fix race conditions in hci_ldisc
 - Fix for isochronous interface assignments in btusb driver
 - A few other smaller fixes & improvements

Please let me know if there are any issues pulling. Thanks.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 1969db47 0338b1b3
...@@ -117,7 +117,7 @@ static void bpa10x_rx_complete(struct urb *urb) ...@@ -117,7 +117,7 @@ static void bpa10x_rx_complete(struct urb *urb)
bpa10x_recv_pkts, bpa10x_recv_pkts,
ARRAY_SIZE(bpa10x_recv_pkts)); ARRAY_SIZE(bpa10x_recv_pkts));
if (IS_ERR(data->rx_skb[idx])) { if (IS_ERR(data->rx_skb[idx])) {
BT_ERR("%s corrupted event packet", hdev->name); bt_dev_err(hdev, "corrupted event packet");
hdev->stat.err_rx++; hdev->stat.err_rx++;
data->rx_skb[idx] = NULL; data->rx_skb[idx] = NULL;
} }
...@@ -127,8 +127,7 @@ static void bpa10x_rx_complete(struct urb *urb) ...@@ -127,8 +127,7 @@ static void bpa10x_rx_complete(struct urb *urb)
err = usb_submit_urb(urb, GFP_ATOMIC); err = usb_submit_urb(urb, GFP_ATOMIC);
if (err < 0) { if (err < 0) {
BT_ERR("%s urb %p failed to resubmit (%d)", bt_dev_err(hdev, "urb %p failed to resubmit (%d)", urb, -err);
hdev->name, urb, -err);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} }
} }
...@@ -164,8 +163,7 @@ static inline int bpa10x_submit_intr_urb(struct hci_dev *hdev) ...@@ -164,8 +163,7 @@ static inline int bpa10x_submit_intr_urb(struct hci_dev *hdev)
err = usb_submit_urb(urb, GFP_KERNEL); err = usb_submit_urb(urb, GFP_KERNEL);
if (err < 0) { if (err < 0) {
BT_ERR("%s urb %p submission failed (%d)", bt_dev_err(hdev, "urb %p submission failed (%d)", urb, -err);
hdev->name, urb, -err);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} }
...@@ -205,8 +203,7 @@ static inline int bpa10x_submit_bulk_urb(struct hci_dev *hdev) ...@@ -205,8 +203,7 @@ static inline int bpa10x_submit_bulk_urb(struct hci_dev *hdev)
err = usb_submit_urb(urb, GFP_KERNEL); err = usb_submit_urb(urb, GFP_KERNEL);
if (err < 0) { if (err < 0) {
BT_ERR("%s urb %p submission failed (%d)", bt_dev_err(hdev, "urb %p submission failed (%d)", urb, -err);
hdev->name, urb, -err);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} }
...@@ -272,7 +269,7 @@ static int bpa10x_setup(struct hci_dev *hdev) ...@@ -272,7 +269,7 @@ static int bpa10x_setup(struct hci_dev *hdev)
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
BT_INFO("%s: %s", hdev->name, (char *)(skb->data + 1)); bt_dev_info(hdev, "%s", (char *)(skb->data + 1));
hci_set_fw_info(hdev, "%s", skb->data + 1); hci_set_fw_info(hdev, "%s", skb->data + 1);
...@@ -348,7 +345,7 @@ static int bpa10x_send_frame(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -348,7 +345,7 @@ static int bpa10x_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
err = usb_submit_urb(urb, GFP_ATOMIC); err = usb_submit_urb(urb, GFP_ATOMIC);
if (err < 0) { if (err < 0) {
BT_ERR("%s urb %p submission failed", hdev->name, urb); bt_dev_err(hdev, "urb %p submission failed", urb);
kfree(urb->setup_packet); kfree(urb->setup_packet);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} }
......
...@@ -355,7 +355,7 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst) ...@@ -355,7 +355,7 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst)
} else if ((stat & 0xff) != 0xff) { } else if ((stat & 0xff) != 0xff) {
if (stat & 0x0020) { if (stat & 0x0020) {
int status = bt3c_read(iobase, 0x7002) & 0x10; int status = bt3c_read(iobase, 0x7002) & 0x10;
BT_INFO("%s: Antenna %s", info->hdev->name, bt_dev_info(info->hdev, "Antenna %s",
status ? "out" : "in"); status ? "out" : "in");
} }
if (stat & 0x0001) if (stat & 0x0001)
......
...@@ -45,13 +45,12 @@ int btbcm_check_bdaddr(struct hci_dev *hdev) ...@@ -45,13 +45,12 @@ int btbcm_check_bdaddr(struct hci_dev *hdev)
HCI_INIT_TIMEOUT); HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
int err = PTR_ERR(skb); int err = PTR_ERR(skb);
BT_ERR("%s: BCM: Reading device address failed (%d)", bt_dev_err(hdev, "BCM: Reading device address failed (%d)", err);
hdev->name, err);
return err; return err;
} }
if (skb->len != sizeof(*bda)) { if (skb->len != sizeof(*bda)) {
BT_ERR("%s: BCM: Device address length mismatch", hdev->name); bt_dev_err(hdev, "BCM: Device address length mismatch");
kfree_skb(skb); kfree_skb(skb);
return -EIO; return -EIO;
} }
...@@ -74,8 +73,8 @@ int btbcm_check_bdaddr(struct hci_dev *hdev) ...@@ -74,8 +73,8 @@ int btbcm_check_bdaddr(struct hci_dev *hdev)
if (!bacmp(&bda->bdaddr, BDADDR_BCM20702A0) || if (!bacmp(&bda->bdaddr, BDADDR_BCM20702A0) ||
!bacmp(&bda->bdaddr, BDADDR_BCM4324B3) || !bacmp(&bda->bdaddr, BDADDR_BCM4324B3) ||
!bacmp(&bda->bdaddr, BDADDR_BCM4330B1)) { !bacmp(&bda->bdaddr, BDADDR_BCM4330B1)) {
BT_INFO("%s: BCM: Using default device address (%pMR)", bt_dev_info(hdev, "BCM: Using default device address (%pMR)",
hdev->name, &bda->bdaddr); &bda->bdaddr);
set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks); set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
} }
...@@ -93,8 +92,7 @@ int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) ...@@ -93,8 +92,7 @@ int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
skb = __hci_cmd_sync(hdev, 0xfc01, 6, bdaddr, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, 0xfc01, 6, bdaddr, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
err = PTR_ERR(skb); err = PTR_ERR(skb);
BT_ERR("%s: BCM: Change address command failed (%d)", bt_dev_err(hdev, "BCM: Change address command failed (%d)", err);
hdev->name, err);
return err; return err;
} }
kfree_skb(skb); kfree_skb(skb);
...@@ -116,8 +114,8 @@ int btbcm_patchram(struct hci_dev *hdev, const struct firmware *fw) ...@@ -116,8 +114,8 @@ int btbcm_patchram(struct hci_dev *hdev, const struct firmware *fw)
skb = __hci_cmd_sync(hdev, 0xfc2e, 0, NULL, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, 0xfc2e, 0, NULL, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
err = PTR_ERR(skb); err = PTR_ERR(skb);
BT_ERR("%s: BCM: Download Minidrv command failed (%d)", bt_dev_err(hdev, "BCM: Download Minidrv command failed (%d)",
hdev->name, err); err);
goto done; goto done;
} }
kfree_skb(skb); kfree_skb(skb);
...@@ -136,7 +134,7 @@ int btbcm_patchram(struct hci_dev *hdev, const struct firmware *fw) ...@@ -136,7 +134,7 @@ int btbcm_patchram(struct hci_dev *hdev, const struct firmware *fw)
fw_size -= sizeof(*cmd); fw_size -= sizeof(*cmd);
if (fw_size < cmd->plen) { if (fw_size < cmd->plen) {
BT_ERR("%s: BCM: Patch is corrupted", hdev->name); bt_dev_err(hdev, "BCM: Patch is corrupted");
err = -EINVAL; err = -EINVAL;
goto done; goto done;
} }
...@@ -151,8 +149,8 @@ int btbcm_patchram(struct hci_dev *hdev, const struct firmware *fw) ...@@ -151,8 +149,8 @@ int btbcm_patchram(struct hci_dev *hdev, const struct firmware *fw)
HCI_INIT_TIMEOUT); HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
err = PTR_ERR(skb); err = PTR_ERR(skb);
BT_ERR("%s: BCM: Patch command %04x failed (%d)", bt_dev_err(hdev, "BCM: Patch command %04x failed (%d)",
hdev->name, opcode, err); opcode, err);
goto done; goto done;
} }
kfree_skb(skb); kfree_skb(skb);
...@@ -173,7 +171,7 @@ static int btbcm_reset(struct hci_dev *hdev) ...@@ -173,7 +171,7 @@ static int btbcm_reset(struct hci_dev *hdev)
skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
int err = PTR_ERR(skb); int err = PTR_ERR(skb);
BT_ERR("%s: BCM: Reset failed (%d)", hdev->name, err); bt_dev_err(hdev, "BCM: Reset failed (%d)", err);
return err; return err;
} }
kfree_skb(skb); kfree_skb(skb);
...@@ -191,13 +189,13 @@ static struct sk_buff *btbcm_read_local_name(struct hci_dev *hdev) ...@@ -191,13 +189,13 @@ static struct sk_buff *btbcm_read_local_name(struct hci_dev *hdev)
skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_NAME, 0, NULL, skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_NAME, 0, NULL,
HCI_INIT_TIMEOUT); HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
BT_ERR("%s: BCM: Reading local name failed (%ld)", bt_dev_err(hdev, "BCM: Reading local name failed (%ld)",
hdev->name, PTR_ERR(skb)); PTR_ERR(skb));
return skb; return skb;
} }
if (skb->len != sizeof(struct hci_rp_read_local_name)) { if (skb->len != sizeof(struct hci_rp_read_local_name)) {
BT_ERR("%s: BCM: Local name length mismatch", hdev->name); bt_dev_err(hdev, "BCM: Local name length mismatch");
kfree_skb(skb); kfree_skb(skb);
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
} }
...@@ -212,13 +210,13 @@ static struct sk_buff *btbcm_read_local_version(struct hci_dev *hdev) ...@@ -212,13 +210,13 @@ static struct sk_buff *btbcm_read_local_version(struct hci_dev *hdev)
skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL, skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL,
HCI_INIT_TIMEOUT); HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
BT_ERR("%s: BCM: Reading local version info failed (%ld)", bt_dev_err(hdev, "BCM: Reading local version info failed (%ld)",
hdev->name, PTR_ERR(skb)); PTR_ERR(skb));
return skb; return skb;
} }
if (skb->len != sizeof(struct hci_rp_read_local_version)) { if (skb->len != sizeof(struct hci_rp_read_local_version)) {
BT_ERR("%s: BCM: Local version length mismatch", hdev->name); bt_dev_err(hdev, "BCM: Local version length mismatch");
kfree_skb(skb); kfree_skb(skb);
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
} }
...@@ -232,13 +230,13 @@ static struct sk_buff *btbcm_read_verbose_config(struct hci_dev *hdev) ...@@ -232,13 +230,13 @@ static struct sk_buff *btbcm_read_verbose_config(struct hci_dev *hdev)
skb = __hci_cmd_sync(hdev, 0xfc79, 0, NULL, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, 0xfc79, 0, NULL, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
BT_ERR("%s: BCM: Read verbose config info failed (%ld)", bt_dev_err(hdev, "BCM: Read verbose config info failed (%ld)",
hdev->name, PTR_ERR(skb)); PTR_ERR(skb));
return skb; return skb;
} }
if (skb->len != 7) { if (skb->len != 7) {
BT_ERR("%s: BCM: Verbose config length mismatch", hdev->name); bt_dev_err(hdev, "BCM: Verbose config length mismatch");
kfree_skb(skb); kfree_skb(skb);
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
} }
...@@ -252,14 +250,13 @@ static struct sk_buff *btbcm_read_controller_features(struct hci_dev *hdev) ...@@ -252,14 +250,13 @@ static struct sk_buff *btbcm_read_controller_features(struct hci_dev *hdev)
skb = __hci_cmd_sync(hdev, 0xfc6e, 0, NULL, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, 0xfc6e, 0, NULL, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
BT_ERR("%s: BCM: Read controller features failed (%ld)", bt_dev_err(hdev, "BCM: Read controller features failed (%ld)",
hdev->name, PTR_ERR(skb)); PTR_ERR(skb));
return skb; return skb;
} }
if (skb->len != 9) { if (skb->len != 9) {
BT_ERR("%s: BCM: Controller features length mismatch", bt_dev_err(hdev, "BCM: Controller features length mismatch");
hdev->name);
kfree_skb(skb); kfree_skb(skb);
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
} }
...@@ -273,13 +270,13 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev) ...@@ -273,13 +270,13 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
skb = __hci_cmd_sync(hdev, 0xfc5a, 0, NULL, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, 0xfc5a, 0, NULL, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
BT_ERR("%s: BCM: Read USB product info failed (%ld)", bt_dev_err(hdev, "BCM: Read USB product info failed (%ld)",
hdev->name, PTR_ERR(skb)); PTR_ERR(skb));
return skb; return skb;
} }
if (skb->len != 5) { if (skb->len != 5) {
BT_ERR("%s: BCM: USB product length mismatch", hdev->name); bt_dev_err(hdev, "BCM: USB product length mismatch");
kfree_skb(skb); kfree_skb(skb);
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
} }
...@@ -296,7 +293,7 @@ static int btbcm_read_info(struct hci_dev *hdev) ...@@ -296,7 +293,7 @@ static int btbcm_read_info(struct hci_dev *hdev)
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
BT_INFO("%s: BCM: chip id %u", hdev->name, skb->data[1]); bt_dev_info(hdev, "BCM: chip id %u", skb->data[1]);
kfree_skb(skb); kfree_skb(skb);
/* Read Controller Features */ /* Read Controller Features */
...@@ -304,7 +301,7 @@ static int btbcm_read_info(struct hci_dev *hdev) ...@@ -304,7 +301,7 @@ static int btbcm_read_info(struct hci_dev *hdev)
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
BT_INFO("%s: BCM: features 0x%2.2x", hdev->name, skb->data[1]); bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
kfree_skb(skb); kfree_skb(skb);
/* Read Local Name */ /* Read Local Name */
...@@ -312,7 +309,7 @@ static int btbcm_read_info(struct hci_dev *hdev) ...@@ -312,7 +309,7 @@ static int btbcm_read_info(struct hci_dev *hdev)
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
BT_INFO("%s: %s", hdev->name, (char *)(skb->data + 1)); bt_dev_info(hdev, "%s", (char *)(skb->data + 1));
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
...@@ -378,7 +375,7 @@ int btbcm_initialize(struct hci_dev *hdev, char *fw_name, size_t len) ...@@ -378,7 +375,7 @@ int btbcm_initialize(struct hci_dev *hdev, char *fw_name, size_t len)
return 0; return 0;
} }
BT_INFO("%s: %s (%3.3u.%3.3u.%3.3u) build %4.4u", hdev->name, bt_dev_info(hdev, "%s (%3.3u.%3.3u.%3.3u) build %4.4u",
hw_name ? : "BCM", (subver & 0xe000) >> 13, hw_name ? : "BCM", (subver & 0xe000) >> 13,
(subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff); (subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff);
...@@ -408,7 +405,7 @@ int btbcm_finalize(struct hci_dev *hdev) ...@@ -408,7 +405,7 @@ int btbcm_finalize(struct hci_dev *hdev)
subver = le16_to_cpu(ver->lmp_subver); subver = le16_to_cpu(ver->lmp_subver);
kfree_skb(skb); kfree_skb(skb);
BT_INFO("%s: BCM (%3.3u.%3.3u.%3.3u) build %4.4u", hdev->name, bt_dev_info(hdev, "BCM (%3.3u.%3.3u.%3.3u) build %4.4u",
(subver & 0xe000) >> 13, (subver & 0x1f00) >> 8, (subver & 0xe000) >> 13, (subver & 0x1f00) >> 8,
(subver & 0x00ff), rev & 0x0fff); (subver & 0x00ff), rev & 0x0fff);
...@@ -505,13 +502,13 @@ int btbcm_setup_patchram(struct hci_dev *hdev) ...@@ -505,13 +502,13 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
return 0; return 0;
} }
BT_INFO("%s: %s (%3.3u.%3.3u.%3.3u) build %4.4u", hdev->name, bt_dev_info(hdev, "%s (%3.3u.%3.3u.%3.3u) build %4.4u",
hw_name ? : "BCM", (subver & 0xe000) >> 13, hw_name ? : "BCM", (subver & 0xe000) >> 13,
(subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff); (subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff);
err = request_firmware(&fw, fw_name, &hdev->dev); err = request_firmware(&fw, fw_name, &hdev->dev);
if (err < 0) { if (err < 0) {
BT_INFO("%s: BCM: Patch %s not found", hdev->name, fw_name); bt_dev_info(hdev, "BCM: Patch %s not found", fw_name);
goto done; goto done;
} }
...@@ -534,7 +531,7 @@ int btbcm_setup_patchram(struct hci_dev *hdev) ...@@ -534,7 +531,7 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
subver = le16_to_cpu(ver->lmp_subver); subver = le16_to_cpu(ver->lmp_subver);
kfree_skb(skb); kfree_skb(skb);
BT_INFO("%s: %s (%3.3u.%3.3u.%3.3u) build %4.4u", hdev->name, bt_dev_info(hdev, "%s (%3.3u.%3.3u.%3.3u) build %4.4u",
hw_name ? : "BCM", (subver & 0xe000) >> 13, hw_name ? : "BCM", (subver & 0xe000) >> 13,
(subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff); (subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff);
...@@ -543,7 +540,7 @@ int btbcm_setup_patchram(struct hci_dev *hdev) ...@@ -543,7 +540,7 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
BT_INFO("%s: %s", hdev->name, (char *)(skb->data + 1)); bt_dev_info(hdev, "%s", (char *)(skb->data + 1));
kfree_skb(skb); kfree_skb(skb);
done: done:
...@@ -568,7 +565,7 @@ int btbcm_setup_apple(struct hci_dev *hdev) ...@@ -568,7 +565,7 @@ int btbcm_setup_apple(struct hci_dev *hdev)
/* Read Verbose Config Version Info */ /* Read Verbose Config Version Info */
skb = btbcm_read_verbose_config(hdev); skb = btbcm_read_verbose_config(hdev);
if (!IS_ERR(skb)) { if (!IS_ERR(skb)) {
BT_INFO("%s: BCM: chip id %u build %4.4u", hdev->name, bt_dev_info(hdev, "BCM: chip id %u build %4.4u",
skb->data[1], get_unaligned_le16(skb->data + 5)); skb->data[1], get_unaligned_le16(skb->data + 5));
kfree_skb(skb); kfree_skb(skb);
} }
...@@ -576,7 +573,7 @@ int btbcm_setup_apple(struct hci_dev *hdev) ...@@ -576,7 +573,7 @@ int btbcm_setup_apple(struct hci_dev *hdev)
/* Read USB Product Info */ /* Read USB Product Info */
skb = btbcm_read_usb_product(hdev); skb = btbcm_read_usb_product(hdev);
if (!IS_ERR(skb)) { if (!IS_ERR(skb)) {
BT_INFO("%s: BCM: product %4.4x:%4.4x", hdev->name, bt_dev_info(hdev, "BCM: product %4.4x:%4.4x",
get_unaligned_le16(skb->data + 1), get_unaligned_le16(skb->data + 1),
get_unaligned_le16(skb->data + 3)); get_unaligned_le16(skb->data + 3));
kfree_skb(skb); kfree_skb(skb);
...@@ -585,14 +582,14 @@ int btbcm_setup_apple(struct hci_dev *hdev) ...@@ -585,14 +582,14 @@ int btbcm_setup_apple(struct hci_dev *hdev)
/* Read Controller Features */ /* Read Controller Features */
skb = btbcm_read_controller_features(hdev); skb = btbcm_read_controller_features(hdev);
if (!IS_ERR(skb)) { if (!IS_ERR(skb)) {
BT_INFO("%s: BCM: features 0x%2.2x", hdev->name, skb->data[1]); bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
kfree_skb(skb); kfree_skb(skb);
} }
/* Read Local Name */ /* Read Local Name */
skb = btbcm_read_local_name(hdev); skb = btbcm_read_local_name(hdev);
if (!IS_ERR(skb)) { if (!IS_ERR(skb)) {
BT_INFO("%s: %s", hdev->name, (char *)(skb->data + 1)); bt_dev_info(hdev, "%s", (char *)(skb->data + 1));
kfree_skb(skb); kfree_skb(skb);
} }
......
...@@ -43,13 +43,13 @@ int btintel_check_bdaddr(struct hci_dev *hdev) ...@@ -43,13 +43,13 @@ int btintel_check_bdaddr(struct hci_dev *hdev)
HCI_INIT_TIMEOUT); HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
int err = PTR_ERR(skb); int err = PTR_ERR(skb);
BT_ERR("%s: Reading Intel device address failed (%d)", bt_dev_err(hdev, "Reading Intel device address failed (%d)",
hdev->name, err); err);
return err; return err;
} }
if (skb->len != sizeof(*bda)) { if (skb->len != sizeof(*bda)) {
BT_ERR("%s: Intel device address length mismatch", hdev->name); bt_dev_err(hdev, "Intel device address length mismatch");
kfree_skb(skb); kfree_skb(skb);
return -EIO; return -EIO;
} }
...@@ -62,8 +62,8 @@ int btintel_check_bdaddr(struct hci_dev *hdev) ...@@ -62,8 +62,8 @@ int btintel_check_bdaddr(struct hci_dev *hdev)
* and that in turn can cause problems with Bluetooth operation. * and that in turn can cause problems with Bluetooth operation.
*/ */
if (!bacmp(&bda->bdaddr, BDADDR_INTEL)) { if (!bacmp(&bda->bdaddr, BDADDR_INTEL)) {
BT_ERR("%s: Found Intel default device address (%pMR)", bt_dev_err(hdev, "Found Intel default device address (%pMR)",
hdev->name, &bda->bdaddr); &bda->bdaddr);
set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks); set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
} }
...@@ -123,8 +123,8 @@ int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) ...@@ -123,8 +123,8 @@ int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
skb = __hci_cmd_sync(hdev, 0xfc31, 6, bdaddr, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, 0xfc31, 6, bdaddr, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
err = PTR_ERR(skb); err = PTR_ERR(skb);
BT_ERR("%s: Changing Intel device address failed (%d)", bt_dev_err(hdev, "Changing Intel device address failed (%d)",
hdev->name, err); err);
return err; return err;
} }
kfree_skb(skb); kfree_skb(skb);
...@@ -154,8 +154,8 @@ int btintel_set_diag(struct hci_dev *hdev, bool enable) ...@@ -154,8 +154,8 @@ int btintel_set_diag(struct hci_dev *hdev, bool enable)
err = PTR_ERR(skb); err = PTR_ERR(skb);
if (err == -ENODATA) if (err == -ENODATA)
goto done; goto done;
BT_ERR("%s: Changing Intel diagnostic mode failed (%d)", bt_dev_err(hdev, "Changing Intel diagnostic mode failed (%d)",
hdev->name, err); err);
return err; return err;
} }
kfree_skb(skb); kfree_skb(skb);
...@@ -189,30 +189,30 @@ void btintel_hw_error(struct hci_dev *hdev, u8 code) ...@@ -189,30 +189,30 @@ void btintel_hw_error(struct hci_dev *hdev, u8 code)
struct sk_buff *skb; struct sk_buff *skb;
u8 type = 0x00; u8 type = 0x00;
BT_ERR("%s: Hardware error 0x%2.2x", hdev->name, code); bt_dev_err(hdev, "Hardware error 0x%2.2x", code);
skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
BT_ERR("%s: Reset after hardware error failed (%ld)", bt_dev_err(hdev, "Reset after hardware error failed (%ld)",
hdev->name, PTR_ERR(skb)); PTR_ERR(skb));
return; return;
} }
kfree_skb(skb); kfree_skb(skb);
skb = __hci_cmd_sync(hdev, 0xfc22, 1, &type, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, 0xfc22, 1, &type, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
BT_ERR("%s: Retrieving Intel exception info failed (%ld)", bt_dev_err(hdev, "Retrieving Intel exception info failed (%ld)",
hdev->name, PTR_ERR(skb)); PTR_ERR(skb));
return; return;
} }
if (skb->len != 13) { if (skb->len != 13) {
BT_ERR("%s: Exception info size mismatch", hdev->name); bt_dev_err(hdev, "Exception info size mismatch");
kfree_skb(skb); kfree_skb(skb);
return; return;
} }
BT_ERR("%s: Exception info %s", hdev->name, (char *)(skb->data + 1)); bt_dev_err(hdev, "Exception info %s", (char *)(skb->data + 1));
kfree_skb(skb); kfree_skb(skb);
} }
...@@ -233,9 +233,10 @@ void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver) ...@@ -233,9 +233,10 @@ void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver)
return; return;
} }
BT_INFO("%s: %s revision %u.%u build %u week %u %u", hdev->name, bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u",
variant, ver->fw_revision >> 4, ver->fw_revision & 0x0f, variant, ver->fw_revision >> 4, ver->fw_revision & 0x0f,
ver->fw_build_num, ver->fw_build_ww, 2000 + ver->fw_build_yy); ver->fw_build_num, ver->fw_build_ww,
2000 + ver->fw_build_yy);
} }
EXPORT_SYMBOL_GPL(btintel_version_info); EXPORT_SYMBOL_GPL(btintel_version_info);
...@@ -321,8 +322,7 @@ int btintel_set_event_mask(struct hci_dev *hdev, bool debug) ...@@ -321,8 +322,7 @@ int btintel_set_event_mask(struct hci_dev *hdev, bool debug)
skb = __hci_cmd_sync(hdev, 0xfc52, 8, mask, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, 0xfc52, 8, mask, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
err = PTR_ERR(skb); err = PTR_ERR(skb);
BT_ERR("%s: Setting Intel event mask failed (%d)", bt_dev_err(hdev, "Setting Intel event mask failed (%d)", err);
hdev->name, err);
return err; return err;
} }
kfree_skb(skb); kfree_skb(skb);
......
...@@ -287,7 +287,7 @@ static int rome_download_firmware(struct hci_dev *hdev, ...@@ -287,7 +287,7 @@ static int rome_download_firmware(struct hci_dev *hdev,
const struct firmware *fw; const struct firmware *fw;
int ret; int ret;
BT_INFO("%s: ROME Downloading %s", hdev->name, config->fwname); bt_dev_info(hdev, "ROME Downloading %s", config->fwname);
ret = request_firmware(&fw, config->fwname, &hdev->dev); ret = request_firmware(&fw, config->fwname, &hdev->dev);
if (ret) { if (ret) {
...@@ -351,7 +351,7 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate) ...@@ -351,7 +351,7 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate)
return err; return err;
} }
BT_INFO("%s: ROME controller version 0x%08x", hdev->name, rome_ver); bt_dev_info(hdev, "ROME controller version 0x%08x", rome_ver);
/* Download rampatch file */ /* Download rampatch file */
config.type = TLV_TYPE_PATCH; config.type = TLV_TYPE_PATCH;
...@@ -380,7 +380,7 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate) ...@@ -380,7 +380,7 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate)
return err; return err;
} }
BT_INFO("%s: ROME setup on UART is completed", hdev->name); bt_dev_info(hdev, "ROME setup on UART is completed");
return 0; return 0;
} }
......
...@@ -55,8 +55,8 @@ static int rtl_read_rom_version(struct hci_dev *hdev, u8 *version) ...@@ -55,8 +55,8 @@ static int rtl_read_rom_version(struct hci_dev *hdev, u8 *version)
} }
rom_version = (struct rtl_rom_version_evt *)skb->data; rom_version = (struct rtl_rom_version_evt *)skb->data;
BT_INFO("%s: rom_version status=%x version=%x", bt_dev_info(hdev, "rom_version status=%x version=%x",
hdev->name, rom_version->status, rom_version->version); rom_version->status, rom_version->version);
*version = rom_version->version; *version = rom_version->version;
...@@ -273,7 +273,7 @@ static int rtl_load_config(struct hci_dev *hdev, const char *name, u8 **buff) ...@@ -273,7 +273,7 @@ static int rtl_load_config(struct hci_dev *hdev, const char *name, u8 **buff)
const struct firmware *fw; const struct firmware *fw;
int ret; int ret;
BT_INFO("%s: rtl: loading %s", hdev->name, name); bt_dev_info(hdev, "rtl: loading %s", name);
ret = request_firmware(&fw, name, &hdev->dev); ret = request_firmware(&fw, name, &hdev->dev);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -292,7 +292,7 @@ static int btrtl_setup_rtl8723a(struct hci_dev *hdev) ...@@ -292,7 +292,7 @@ static int btrtl_setup_rtl8723a(struct hci_dev *hdev)
const struct firmware *fw; const struct firmware *fw;
int ret; int ret;
BT_INFO("%s: rtl: loading rtl_bt/rtl8723a_fw.bin", hdev->name); bt_dev_info(hdev, "rtl: loading rtl_bt/rtl8723a_fw.bin");
ret = request_firmware(&fw, "rtl_bt/rtl8723a_fw.bin", &hdev->dev); ret = request_firmware(&fw, "rtl_bt/rtl8723a_fw.bin", &hdev->dev);
if (ret < 0) { if (ret < 0) {
BT_ERR("%s: Failed to load rtl_bt/rtl8723a_fw.bin", hdev->name); BT_ERR("%s: Failed to load rtl_bt/rtl8723a_fw.bin", hdev->name);
...@@ -363,7 +363,7 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, u16 lmp_subver, ...@@ -363,7 +363,7 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, u16 lmp_subver,
} else } else
cfg_sz = 0; cfg_sz = 0;
BT_INFO("%s: rtl: loading %s", hdev->name, fw_name); bt_dev_info(hdev, "rtl: loading %s", fw_name);
ret = request_firmware(&fw, fw_name, &hdev->dev); ret = request_firmware(&fw, fw_name, &hdev->dev);
if (ret < 0) { if (ret < 0) {
BT_ERR("%s: Failed to load %s", hdev->name, fw_name); BT_ERR("%s: Failed to load %s", hdev->name, fw_name);
...@@ -390,7 +390,7 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, u16 lmp_subver, ...@@ -390,7 +390,7 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, u16 lmp_subver,
fw_data = tbuff; fw_data = tbuff;
} }
BT_INFO("cfg_sz %d, total size %d", cfg_sz, ret); bt_dev_info(hdev, "cfg_sz %d, total size %d", cfg_sz, ret);
ret = rtl_download_firmware(hdev, fw_data, ret); ret = rtl_download_firmware(hdev, fw_data, ret);
...@@ -436,8 +436,9 @@ int btrtl_setup_realtek(struct hci_dev *hdev) ...@@ -436,8 +436,9 @@ int btrtl_setup_realtek(struct hci_dev *hdev)
return -PTR_ERR(skb); return -PTR_ERR(skb);
resp = (struct hci_rp_read_local_version *)skb->data; resp = (struct hci_rp_read_local_version *)skb->data;
BT_INFO("%s: rtl: examining hci_ver=%02x hci_rev=%04x lmp_ver=%02x " bt_dev_info(hdev, "rtl: examining hci_ver=%02x hci_rev=%04x "
"lmp_subver=%04x", hdev->name, resp->hci_ver, resp->hci_rev, "lmp_ver=%02x lmp_subver=%04x",
resp->hci_ver, resp->hci_rev,
resp->lmp_ver, resp->lmp_subver); resp->lmp_ver, resp->lmp_subver);
lmp_subver = le16_to_cpu(resp->lmp_subver); lmp_subver = le16_to_cpu(resp->lmp_subver);
...@@ -466,7 +467,7 @@ int btrtl_setup_realtek(struct hci_dev *hdev) ...@@ -466,7 +467,7 @@ int btrtl_setup_realtek(struct hci_dev *hdev)
return btrtl_setup_rtl8723b(hdev, lmp_subver, return btrtl_setup_rtl8723b(hdev, lmp_subver,
"rtl_bt/rtl8822b_fw.bin"); "rtl_bt/rtl8822b_fw.bin");
default: default:
BT_INFO("rtl: assuming no firmware upload needed."); bt_dev_info(hdev, "rtl: assuming no firmware upload needed");
return 0; return 0;
} }
} }
......
...@@ -267,6 +267,7 @@ static const struct usb_device_id blacklist_table[] = { ...@@ -267,6 +267,7 @@ static const struct usb_device_id blacklist_table[] = {
{ USB_DEVICE(0x0cf3, 0xe301), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x0cf3, 0xe301), .driver_info = BTUSB_QCA_ROME },
{ USB_DEVICE(0x0cf3, 0xe360), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x0cf3, 0xe360), .driver_info = BTUSB_QCA_ROME },
{ USB_DEVICE(0x0489, 0xe092), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x0489, 0xe092), .driver_info = BTUSB_QCA_ROME },
{ USB_DEVICE(0x0489, 0xe09f), .driver_info = BTUSB_QCA_ROME },
{ USB_DEVICE(0x0489, 0xe0a2), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x0489, 0xe0a2), .driver_info = BTUSB_QCA_ROME },
{ USB_DEVICE(0x04ca, 0x3011), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x04ca, 0x3011), .driver_info = BTUSB_QCA_ROME },
{ USB_DEVICE(0x04ca, 0x3016), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x04ca, 0x3016), .driver_info = BTUSB_QCA_ROME },
...@@ -396,6 +397,7 @@ struct btusb_data { ...@@ -396,6 +397,7 @@ struct btusb_data {
struct usb_interface *intf; struct usb_interface *intf;
struct usb_interface *isoc; struct usb_interface *isoc;
struct usb_interface *diag; struct usb_interface *diag;
unsigned isoc_ifnum;
unsigned long flags; unsigned long flags;
...@@ -642,7 +644,7 @@ static void btusb_intr_complete(struct urb *urb) ...@@ -642,7 +644,7 @@ static void btusb_intr_complete(struct urb *urb)
if (btusb_recv_intr(data, urb->transfer_buffer, if (btusb_recv_intr(data, urb->transfer_buffer,
urb->actual_length) < 0) { urb->actual_length) < 0) {
BT_ERR("%s corrupted event packet", hdev->name); bt_dev_err(hdev, "corrupted event packet");
hdev->stat.err_rx++; hdev->stat.err_rx++;
} }
} else if (urb->status == -ENOENT) { } else if (urb->status == -ENOENT) {
...@@ -662,8 +664,8 @@ static void btusb_intr_complete(struct urb *urb) ...@@ -662,8 +664,8 @@ static void btusb_intr_complete(struct urb *urb)
* -ENODEV: device got disconnected * -ENODEV: device got disconnected
*/ */
if (err != -EPERM && err != -ENODEV) if (err != -EPERM && err != -ENODEV)
BT_ERR("%s urb %p failed to resubmit (%d)", bt_dev_err(hdev, "urb %p failed to resubmit (%d)",
hdev->name, urb, -err); urb, -err);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} }
} }
...@@ -705,8 +707,8 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags) ...@@ -705,8 +707,8 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags)
err = usb_submit_urb(urb, mem_flags); err = usb_submit_urb(urb, mem_flags);
if (err < 0) { if (err < 0) {
if (err != -EPERM && err != -ENODEV) if (err != -EPERM && err != -ENODEV)
BT_ERR("%s urb %p submission failed (%d)", bt_dev_err(hdev, "urb %p submission failed (%d)",
hdev->name, urb, -err); urb, -err);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} }
...@@ -732,7 +734,7 @@ static void btusb_bulk_complete(struct urb *urb) ...@@ -732,7 +734,7 @@ static void btusb_bulk_complete(struct urb *urb)
if (data->recv_bulk(data, urb->transfer_buffer, if (data->recv_bulk(data, urb->transfer_buffer,
urb->actual_length) < 0) { urb->actual_length) < 0) {
BT_ERR("%s corrupted ACL packet", hdev->name); bt_dev_err(hdev, "corrupted ACL packet");
hdev->stat.err_rx++; hdev->stat.err_rx++;
} }
} else if (urb->status == -ENOENT) { } else if (urb->status == -ENOENT) {
...@@ -752,8 +754,8 @@ static void btusb_bulk_complete(struct urb *urb) ...@@ -752,8 +754,8 @@ static void btusb_bulk_complete(struct urb *urb)
* -ENODEV: device got disconnected * -ENODEV: device got disconnected
*/ */
if (err != -EPERM && err != -ENODEV) if (err != -EPERM && err != -ENODEV)
BT_ERR("%s urb %p failed to resubmit (%d)", bt_dev_err(hdev, "urb %p failed to resubmit (%d)",
hdev->name, urb, -err); urb, -err);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} }
} }
...@@ -794,8 +796,8 @@ static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags) ...@@ -794,8 +796,8 @@ static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags)
err = usb_submit_urb(urb, mem_flags); err = usb_submit_urb(urb, mem_flags);
if (err < 0) { if (err < 0) {
if (err != -EPERM && err != -ENODEV) if (err != -EPERM && err != -ENODEV)
BT_ERR("%s urb %p submission failed (%d)", bt_dev_err(hdev, "urb %p submission failed (%d)",
hdev->name, urb, -err); urb, -err);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} }
...@@ -828,7 +830,7 @@ static void btusb_isoc_complete(struct urb *urb) ...@@ -828,7 +830,7 @@ static void btusb_isoc_complete(struct urb *urb)
if (btusb_recv_isoc(data, urb->transfer_buffer + offset, if (btusb_recv_isoc(data, urb->transfer_buffer + offset,
length) < 0) { length) < 0) {
BT_ERR("%s corrupted SCO packet", hdev->name); bt_dev_err(hdev, "corrupted SCO packet");
hdev->stat.err_rx++; hdev->stat.err_rx++;
} }
} }
...@@ -848,8 +850,8 @@ static void btusb_isoc_complete(struct urb *urb) ...@@ -848,8 +850,8 @@ static void btusb_isoc_complete(struct urb *urb)
* -ENODEV: device got disconnected * -ENODEV: device got disconnected
*/ */
if (err != -EPERM && err != -ENODEV) if (err != -EPERM && err != -ENODEV)
BT_ERR("%s urb %p failed to resubmit (%d)", bt_dev_err(hdev, "urb %p failed to resubmit (%d)",
hdev->name, urb, -err); urb, -err);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} }
} }
...@@ -916,8 +918,8 @@ static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags) ...@@ -916,8 +918,8 @@ static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags)
err = usb_submit_urb(urb, mem_flags); err = usb_submit_urb(urb, mem_flags);
if (err < 0) { if (err < 0) {
if (err != -EPERM && err != -ENODEV) if (err != -EPERM && err != -ENODEV)
BT_ERR("%s urb %p submission failed (%d)", bt_dev_err(hdev, "urb %p submission failed (%d)",
hdev->name, urb, -err); urb, -err);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} }
...@@ -961,8 +963,8 @@ static void btusb_diag_complete(struct urb *urb) ...@@ -961,8 +963,8 @@ static void btusb_diag_complete(struct urb *urb)
* -ENODEV: device got disconnected * -ENODEV: device got disconnected
*/ */
if (err != -EPERM && err != -ENODEV) if (err != -EPERM && err != -ENODEV)
BT_ERR("%s urb %p failed to resubmit (%d)", bt_dev_err(hdev, "urb %p failed to resubmit (%d)",
hdev->name, urb, -err); urb, -err);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} }
} }
...@@ -1003,8 +1005,8 @@ static int btusb_submit_diag_urb(struct hci_dev *hdev, gfp_t mem_flags) ...@@ -1003,8 +1005,8 @@ static int btusb_submit_diag_urb(struct hci_dev *hdev, gfp_t mem_flags)
err = usb_submit_urb(urb, mem_flags); err = usb_submit_urb(urb, mem_flags);
if (err < 0) { if (err < 0) {
if (err != -EPERM && err != -ENODEV) if (err != -EPERM && err != -ENODEV)
BT_ERR("%s urb %p submission failed (%d)", bt_dev_err(hdev, "urb %p submission failed (%d)",
hdev->name, urb, -err); urb, -err);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} }
...@@ -1265,8 +1267,8 @@ static int submit_tx_urb(struct hci_dev *hdev, struct urb *urb) ...@@ -1265,8 +1267,8 @@ static int submit_tx_urb(struct hci_dev *hdev, struct urb *urb)
err = usb_submit_urb(urb, GFP_KERNEL); err = usb_submit_urb(urb, GFP_KERNEL);
if (err < 0) { if (err < 0) {
if (err != -EPERM && err != -ENODEV) if (err != -EPERM && err != -ENODEV)
BT_ERR("%s urb %p submission failed (%d)", bt_dev_err(hdev, "urb %p submission failed (%d)",
hdev->name, urb, -err); urb, -err);
kfree(urb->setup_packet); kfree(urb->setup_packet);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
} else { } else {
...@@ -1359,9 +1361,9 @@ static inline int __set_isoc_interface(struct hci_dev *hdev, int altsetting) ...@@ -1359,9 +1361,9 @@ static inline int __set_isoc_interface(struct hci_dev *hdev, int altsetting)
if (!data->isoc) if (!data->isoc)
return -ENODEV; return -ENODEV;
err = usb_set_interface(data->udev, 1, altsetting); err = usb_set_interface(data->udev, data->isoc_ifnum, altsetting);
if (err < 0) { if (err < 0) {
BT_ERR("%s setting interface failed (%d)", hdev->name, -err); bt_dev_err(hdev, "setting interface failed (%d)", -err);
return err; return err;
} }
...@@ -1385,7 +1387,7 @@ static inline int __set_isoc_interface(struct hci_dev *hdev, int altsetting) ...@@ -1385,7 +1387,7 @@ static inline int __set_isoc_interface(struct hci_dev *hdev, int altsetting)
} }
if (!data->isoc_tx_ep || !data->isoc_rx_ep) { if (!data->isoc_tx_ep || !data->isoc_rx_ep) {
BT_ERR("%s invalid SCO descriptors", hdev->name); bt_dev_err(hdev, "invalid SCO descriptors");
return -ENODEV; return -ENODEV;
} }
...@@ -1480,7 +1482,7 @@ static int btusb_setup_bcm92035(struct hci_dev *hdev) ...@@ -1480,7 +1482,7 @@ static int btusb_setup_bcm92035(struct hci_dev *hdev)
skb = __hci_cmd_sync(hdev, 0xfc3b, 1, &val, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, 0xfc3b, 1, &val, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) if (IS_ERR(skb))
BT_ERR("BCM92035 command failed (%ld)", -PTR_ERR(skb)); bt_dev_err(hdev, "BCM92035 command failed (%ld)", PTR_ERR(skb));
else else
kfree_skb(skb); kfree_skb(skb);
...@@ -1498,12 +1500,12 @@ static int btusb_setup_csr(struct hci_dev *hdev) ...@@ -1498,12 +1500,12 @@ static int btusb_setup_csr(struct hci_dev *hdev)
HCI_INIT_TIMEOUT); HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
int err = PTR_ERR(skb); int err = PTR_ERR(skb);
BT_ERR("%s: CSR: Local version failed (%d)", hdev->name, err); bt_dev_err(hdev, "CSR: Local version failed (%d)", err);
return err; return err;
} }
if (skb->len != sizeof(struct hci_rp_read_local_version)) { if (skb->len != sizeof(struct hci_rp_read_local_version)) {
BT_ERR("%s: CSR: Local version length mismatch", hdev->name); bt_dev_err(hdev, "CSR: Local version length mismatch");
kfree_skb(skb); kfree_skb(skb);
return -EIO; return -EIO;
} }
...@@ -1565,7 +1567,7 @@ static const struct firmware *btusb_setup_intel_get_fw(struct hci_dev *hdev, ...@@ -1565,7 +1567,7 @@ static const struct firmware *btusb_setup_intel_get_fw(struct hci_dev *hdev,
} }
} }
BT_INFO("%s: Intel Bluetooth firmware file: %s", hdev->name, fwname); bt_dev_info(hdev, "Intel Bluetooth firmware file: %s", fwname);
return fw; return fw;
} }
...@@ -1721,8 +1723,8 @@ static int btusb_setup_intel(struct hci_dev *hdev) ...@@ -1721,8 +1723,8 @@ static int btusb_setup_intel(struct hci_dev *hdev)
if (err) if (err)
return err; return err;
BT_INFO("%s: read Intel version: %02x%02x%02x%02x%02x%02x%02x%02x%02x", bt_dev_info(hdev, "read Intel version: %02x%02x%02x%02x%02x%02x%02x%02x%02x",
hdev->name, ver.hw_platform, ver.hw_variant, ver.hw_revision, ver.hw_platform, ver.hw_variant, ver.hw_revision,
ver.fw_variant, ver.fw_revision, ver.fw_build_num, ver.fw_variant, ver.fw_revision, ver.fw_build_num,
ver.fw_build_ww, ver.fw_build_yy, ver.fw_patch_num); ver.fw_build_ww, ver.fw_build_yy, ver.fw_patch_num);
...@@ -1731,8 +1733,8 @@ static int btusb_setup_intel(struct hci_dev *hdev) ...@@ -1731,8 +1733,8 @@ static int btusb_setup_intel(struct hci_dev *hdev)
* So, if it is other than 0x00, no need to patch the device again. * So, if it is other than 0x00, no need to patch the device again.
*/ */
if (ver.fw_patch_num) { if (ver.fw_patch_num) {
BT_INFO("%s: Intel device is already patched. patch num: %02x", bt_dev_info(hdev, "Intel device is already patched. "
hdev->name, ver.fw_patch_num); "patch num: %02x", ver.fw_patch_num);
goto complete; goto complete;
} }
...@@ -1800,8 +1802,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) ...@@ -1800,8 +1802,7 @@ static int btusb_setup_intel(struct hci_dev *hdev)
if (err) if (err)
return err; return err;
BT_INFO("%s: Intel Bluetooth firmware patch completed and activated", bt_dev_info(hdev, "Intel firmware patch completed and activated");
hdev->name);
goto complete; goto complete;
...@@ -1811,7 +1812,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) ...@@ -1811,7 +1812,7 @@ static int btusb_setup_intel(struct hci_dev *hdev)
if (err) if (err)
return err; return err;
BT_INFO("%s: Intel Bluetooth firmware patch completed", hdev->name); bt_dev_info(hdev, "Intel firmware patch completed");
goto complete; goto complete;
...@@ -1825,8 +1826,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) ...@@ -1825,8 +1826,7 @@ static int btusb_setup_intel(struct hci_dev *hdev)
if (err) if (err)
return err; return err;
BT_INFO("%s: Intel Bluetooth firmware patch completed and deactivated", bt_dev_info(hdev, "Intel firmware patch completed and deactivated");
hdev->name);
complete: complete:
/* Set the event mask for Intel specific vendor events. This enables /* Set the event mask for Intel specific vendor events. This enables
...@@ -2107,22 +2107,22 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) ...@@ -2107,22 +2107,22 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
params = (struct intel_boot_params *)skb->data; params = (struct intel_boot_params *)skb->data;
BT_INFO("%s: Device revision is %u", hdev->name, bt_dev_info(hdev, "Device revision is %u",
le16_to_cpu(params->dev_revid)); le16_to_cpu(params->dev_revid));
BT_INFO("%s: Secure boot is %s", hdev->name, bt_dev_info(hdev, "Secure boot is %s",
params->secure_boot ? "enabled" : "disabled"); params->secure_boot ? "enabled" : "disabled");
BT_INFO("%s: OTP lock is %s", hdev->name, bt_dev_info(hdev, "OTP lock is %s",
params->otp_lock ? "enabled" : "disabled"); params->otp_lock ? "enabled" : "disabled");
BT_INFO("%s: API lock is %s", hdev->name, bt_dev_info(hdev, "API lock is %s",
params->api_lock ? "enabled" : "disabled"); params->api_lock ? "enabled" : "disabled");
BT_INFO("%s: Debug lock is %s", hdev->name, bt_dev_info(hdev, "Debug lock is %s",
params->debug_lock ? "enabled" : "disabled"); params->debug_lock ? "enabled" : "disabled");
BT_INFO("%s: Minimum firmware build %u week %u %u", hdev->name, bt_dev_info(hdev, "Minimum firmware build %u week %u %u",
params->min_fw_build_nn, params->min_fw_build_cw, params->min_fw_build_nn, params->min_fw_build_cw,
2000 + params->min_fw_build_yy); 2000 + params->min_fw_build_yy);
...@@ -2141,24 +2141,49 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) ...@@ -2141,24 +2141,49 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
* also be no valid address for the operational firmware. * also be no valid address for the operational firmware.
*/ */
if (!bacmp(&params->otp_bdaddr, BDADDR_ANY)) { if (!bacmp(&params->otp_bdaddr, BDADDR_ANY)) {
BT_INFO("%s: No device address configured", hdev->name); bt_dev_info(hdev, "No device address configured");
set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks); set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
} }
/* With this Intel bootloader only the hardware variant and device /* With this Intel bootloader only the hardware variant and device
* revision information are used to select the right firmware. * revision information are used to select the right firmware for SfP
* and WsP.
* *
* The firmware filename is ibt-<hw_variant>-<dev_revid>.sfi. * The firmware filename is ibt-<hw_variant>-<dev_revid>.sfi.
* *
* Currently the supported hardware variants are: * Currently the supported hardware variants are:
* 11 (0x0b) for iBT3.0 (LnP/SfP) * 11 (0x0b) for iBT3.0 (LnP/SfP)
* 12 (0x0c) for iBT3.5 (WsP) * 12 (0x0c) for iBT3.5 (WsP)
*
* For ThP/JfP and for future SKU's, the FW name varies based on HW
* variant, HW revision and FW revision, as these are dependent on CNVi
* and RF Combination.
*
* 17 (0x11) for iBT3.5 (JfP) * 17 (0x11) for iBT3.5 (JfP)
* 18 (0x12) for iBT3.5 (ThP) * 18 (0x12) for iBT3.5 (ThP)
*
* The firmware file name for these will be
* ibt-<hw_variant>-<hw_revision>-<fw_revision>.sfi.
*
*/ */
switch (ver.hw_variant) {
case 0x0b: /* SfP */
case 0x0c: /* WsP */
snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.sfi", snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.sfi",
le16_to_cpu(ver.hw_variant), le16_to_cpu(ver.hw_variant),
le16_to_cpu(params->dev_revid)); le16_to_cpu(params->dev_revid));
break;
case 0x11: /* JfP */
case 0x12: /* ThP */
snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u-%u.sfi",
le16_to_cpu(ver.hw_variant),
le16_to_cpu(ver.hw_revision),
le16_to_cpu(ver.fw_revision));
break;
default:
BT_ERR("%s: Unsupported Intel firmware naming", hdev->name);
return -EINVAL;
}
err = request_firmware(&fw, fwname, &hdev->dev); err = request_firmware(&fw, fwname, &hdev->dev);
if (err < 0) { if (err < 0) {
...@@ -2168,14 +2193,29 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) ...@@ -2168,14 +2193,29 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
return err; return err;
} }
BT_INFO("%s: Found device firmware: %s", hdev->name, fwname); bt_dev_info(hdev, "Found device firmware: %s", fwname);
/* Save the DDC file name for later use to apply once the firmware /* Save the DDC file name for later use to apply once the firmware
* downloading is done. * downloading is done.
*/ */
switch (ver.hw_variant) {
case 0x0b: /* SfP */
case 0x0c: /* WsP */
snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.ddc", snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.ddc",
le16_to_cpu(ver.hw_variant), le16_to_cpu(ver.hw_variant),
le16_to_cpu(params->dev_revid)); le16_to_cpu(params->dev_revid));
break;
case 0x11: /* JfP */
case 0x12: /* ThP */
snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u-%u.ddc",
le16_to_cpu(ver.hw_variant),
le16_to_cpu(ver.hw_revision),
le16_to_cpu(ver.fw_revision));
break;
default:
BT_ERR("%s: Unsupported Intel firmware naming", hdev->name);
return -EINVAL;
}
kfree_skb(skb); kfree_skb(skb);
...@@ -2249,7 +2289,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) ...@@ -2249,7 +2289,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
set_bit(BTUSB_FIRMWARE_LOADED, &data->flags); set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
BT_INFO("%s: Waiting for firmware download to complete", hdev->name); bt_dev_info(hdev, "Waiting for firmware download to complete");
/* Before switching the device into operational mode and with that /* Before switching the device into operational mode and with that
* booting the loaded firmware, wait for the bootloader notification * booting the loaded firmware, wait for the bootloader notification
...@@ -2286,7 +2326,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) ...@@ -2286,7 +2326,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
delta = ktime_sub(rettime, calltime); delta = ktime_sub(rettime, calltime);
duration = (unsigned long long) ktime_to_ns(delta) >> 10; duration = (unsigned long long) ktime_to_ns(delta) >> 10;
BT_INFO("%s: Firmware loaded in %llu usecs", hdev->name, duration); bt_dev_info(hdev, "Firmware loaded in %llu usecs", duration);
done: done:
release_firmware(fw); release_firmware(fw);
...@@ -2312,7 +2352,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) ...@@ -2312,7 +2352,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
* 1 second. However if that happens, then just fail the setup * 1 second. However if that happens, then just fail the setup
* since something went wrong. * since something went wrong.
*/ */
BT_INFO("%s: Waiting for device to boot", hdev->name); bt_dev_info(hdev, "Waiting for device to boot");
err = wait_on_bit_timeout(&data->flags, BTUSB_BOOTING, err = wait_on_bit_timeout(&data->flags, BTUSB_BOOTING,
TASK_INTERRUPTIBLE, TASK_INTERRUPTIBLE,
...@@ -2332,7 +2372,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) ...@@ -2332,7 +2372,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
delta = ktime_sub(rettime, calltime); delta = ktime_sub(rettime, calltime);
duration = (unsigned long long) ktime_to_ns(delta) >> 10; duration = (unsigned long long) ktime_to_ns(delta) >> 10;
BT_INFO("%s: Device booted in %llu usecs", hdev->name, duration); bt_dev_info(hdev, "Device booted in %llu usecs", duration);
clear_bit(BTUSB_BOOTLOADER, &data->flags); clear_bit(BTUSB_BOOTLOADER, &data->flags);
...@@ -2435,8 +2475,8 @@ static int btusb_set_bdaddr_marvell(struct hci_dev *hdev, ...@@ -2435,8 +2475,8 @@ static int btusb_set_bdaddr_marvell(struct hci_dev *hdev,
skb = __hci_cmd_sync(hdev, 0xfc22, sizeof(buf), buf, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, 0xfc22, sizeof(buf), buf, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
ret = PTR_ERR(skb); ret = PTR_ERR(skb);
BT_ERR("%s: changing Marvell device address failed (%ld)", bt_dev_err(hdev, "changing Marvell device address failed (%ld)",
hdev->name, ret); ret);
return ret; return ret;
} }
kfree_skb(skb); kfree_skb(skb);
...@@ -2460,8 +2500,7 @@ static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev, ...@@ -2460,8 +2500,7 @@ static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev,
skb = __hci_cmd_sync(hdev, 0xfc0b, sizeof(buf), buf, HCI_INIT_TIMEOUT); skb = __hci_cmd_sync(hdev, 0xfc0b, sizeof(buf), buf, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
ret = PTR_ERR(skb); ret = PTR_ERR(skb);
BT_ERR("%s: Change address command failed (%ld)", bt_dev_err(hdev, "Change address command failed (%ld)", ret);
hdev->name, ret);
return ret; return ret;
} }
kfree_skb(skb); kfree_skb(skb);
...@@ -2527,7 +2566,7 @@ static int btusb_qca_send_vendor_req(struct hci_dev *hdev, u8 request, ...@@ -2527,7 +2566,7 @@ static int btusb_qca_send_vendor_req(struct hci_dev *hdev, u8 request,
err = usb_control_msg(udev, pipe, request, USB_TYPE_VENDOR | USB_DIR_IN, err = usb_control_msg(udev, pipe, request, USB_TYPE_VENDOR | USB_DIR_IN,
0, 0, buf, size, USB_CTRL_SET_TIMEOUT); 0, 0, buf, size, USB_CTRL_SET_TIMEOUT);
if (err < 0) { if (err < 0) {
BT_ERR("%s: Failed to access otp area (%d)", hdev->name, err); bt_dev_err(hdev, "Failed to access otp area (%d)", err);
goto done; goto done;
} }
...@@ -2567,7 +2606,7 @@ static int btusb_setup_qca_download_fw(struct hci_dev *hdev, ...@@ -2567,7 +2606,7 @@ static int btusb_setup_qca_download_fw(struct hci_dev *hdev,
err = usb_control_msg(udev, pipe, QCA_DFU_DOWNLOAD, USB_TYPE_VENDOR, err = usb_control_msg(udev, pipe, QCA_DFU_DOWNLOAD, USB_TYPE_VENDOR,
0, 0, buf, size, USB_CTRL_SET_TIMEOUT); 0, 0, buf, size, USB_CTRL_SET_TIMEOUT);
if (err < 0) { if (err < 0) {
BT_ERR("%s: Failed to send headers (%d)", hdev->name, err); bt_dev_err(hdev, "Failed to send headers (%d)", err);
goto done; goto done;
} }
...@@ -2583,13 +2622,13 @@ static int btusb_setup_qca_download_fw(struct hci_dev *hdev, ...@@ -2583,13 +2622,13 @@ static int btusb_setup_qca_download_fw(struct hci_dev *hdev,
err = usb_bulk_msg(udev, pipe, buf, size, &len, err = usb_bulk_msg(udev, pipe, buf, size, &len,
QCA_DFU_TIMEOUT); QCA_DFU_TIMEOUT);
if (err < 0) { if (err < 0) {
BT_ERR("%s: Failed to send body at %zd of %zd (%d)", bt_dev_err(hdev, "Failed to send body at %zd of %zd (%d)",
hdev->name, sent, firmware->size, err); sent, firmware->size, err);
break; break;
} }
if (size != len) { if (size != len) {
BT_ERR("%s: Failed to get bulk buffer", hdev->name); bt_dev_err(hdev, "Failed to get bulk buffer");
err = -EILSEQ; err = -EILSEQ;
break; break;
} }
...@@ -2621,24 +2660,23 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, ...@@ -2621,24 +2660,23 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev,
err = request_firmware(&fw, fwname, &hdev->dev); err = request_firmware(&fw, fwname, &hdev->dev);
if (err) { if (err) {
BT_ERR("%s: failed to request rampatch file: %s (%d)", bt_dev_err(hdev, "failed to request rampatch file: %s (%d)",
hdev->name, fwname, err); fwname, err);
return err; return err;
} }
BT_INFO("%s: using rampatch file: %s", hdev->name, fwname); bt_dev_info(hdev, "using rampatch file: %s", fwname);
rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset); rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset);
rver_rom = le16_to_cpu(rver->rom_version); rver_rom = le16_to_cpu(rver->rom_version);
rver_patch = le16_to_cpu(rver->patch_version); rver_patch = le16_to_cpu(rver->patch_version);
BT_INFO("%s: QCA: patch rome 0x%x build 0x%x, firmware rome 0x%x " bt_dev_info(hdev, "QCA: patch rome 0x%x build 0x%x, "
"build 0x%x", hdev->name, rver_rom, rver_patch, ver_rom, "firmware rome 0x%x build 0x%x",
ver_patch); rver_rom, rver_patch, ver_rom, ver_patch);
if (rver_rom != ver_rom || rver_patch <= ver_patch) { if (rver_rom != ver_rom || rver_patch <= ver_patch) {
BT_ERR("%s: rampatch file version did not match with firmware", bt_dev_err(hdev, "rampatch file version did not match with firmware");
hdev->name);
err = -EINVAL; err = -EINVAL;
goto done; goto done;
} }
...@@ -2664,12 +2702,12 @@ static int btusb_setup_qca_load_nvm(struct hci_dev *hdev, ...@@ -2664,12 +2702,12 @@ static int btusb_setup_qca_load_nvm(struct hci_dev *hdev,
err = request_firmware(&fw, fwname, &hdev->dev); err = request_firmware(&fw, fwname, &hdev->dev);
if (err) { if (err) {
BT_ERR("%s: failed to request NVM file: %s (%d)", bt_dev_err(hdev, "failed to request NVM file: %s (%d)",
hdev->name, fwname, err); fwname, err);
return err; return err;
} }
BT_INFO("%s: using NVM file: %s", hdev->name, fwname); bt_dev_info(hdev, "using NVM file: %s", fwname);
err = btusb_setup_qca_download_fw(hdev, fw, info->nvm_hdr); err = btusb_setup_qca_download_fw(hdev, fw, info->nvm_hdr);
...@@ -2697,8 +2735,7 @@ static int btusb_setup_qca(struct hci_dev *hdev) ...@@ -2697,8 +2735,7 @@ static int btusb_setup_qca(struct hci_dev *hdev)
info = &qca_devices_table[i]; info = &qca_devices_table[i];
} }
if (!info) { if (!info) {
BT_ERR("%s: don't support firmware rome 0x%x", hdev->name, bt_dev_err(hdev, "don't support firmware rome 0x%x", ver_rom);
ver_rom);
return -ENODEV; return -ENODEV;
} }
...@@ -2752,7 +2789,7 @@ static inline int __set_diag_interface(struct hci_dev *hdev) ...@@ -2752,7 +2789,7 @@ static inline int __set_diag_interface(struct hci_dev *hdev)
} }
if (!data->diag_tx_ep || !data->diag_rx_ep) { if (!data->diag_tx_ep || !data->diag_rx_ep) {
BT_ERR("%s invalid diagnostic descriptors", hdev->name); bt_dev_err(hdev, "invalid diagnostic descriptors");
return -ENODEV; return -ENODEV;
} }
...@@ -3106,6 +3143,7 @@ static int btusb_probe(struct usb_interface *intf, ...@@ -3106,6 +3143,7 @@ static int btusb_probe(struct usb_interface *intf,
} else { } else {
/* Interface orders are hardcoded in the specification */ /* Interface orders are hardcoded in the specification */
data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1);
data->isoc_ifnum = ifnum_base + 1;
} }
if (!reset) if (!reset)
......
...@@ -50,6 +50,17 @@ struct ath_struct { ...@@ -50,6 +50,17 @@ struct ath_struct {
struct work_struct ctxtsw; struct work_struct ctxtsw;
}; };
#define OP_WRITE_TAG 0x01
#define INDEX_BDADDR 0x01
struct ath_vendor_cmd {
__u8 opcode;
__le16 index;
__u8 len;
__u8 data[251];
} __packed;
static int ath_wakeup_ar3k(struct tty_struct *tty) static int ath_wakeup_ar3k(struct tty_struct *tty)
{ {
int status = tty->driver->ops->tiocmget(tty); int status = tty->driver->ops->tiocmget(tty);
...@@ -144,30 +155,34 @@ static int ath_flush(struct hci_uart *hu) ...@@ -144,30 +155,34 @@ static int ath_flush(struct hci_uart *hu)
return 0; return 0;
} }
static int ath_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) static int ath_vendor_cmd(struct hci_dev *hdev, uint8_t opcode, uint16_t index,
const void *data, size_t dlen)
{ {
struct sk_buff *skb; struct sk_buff *skb;
u8 buf[10]; struct ath_vendor_cmd cmd;
int err;
if (dlen > sizeof(cmd.data))
buf[0] = 0x01; return -EINVAL;
buf[1] = 0x01;
buf[2] = 0x00; cmd.opcode = opcode;
buf[3] = sizeof(bdaddr_t); cmd.index = cpu_to_le16(index);
memcpy(buf + 4, bdaddr, sizeof(bdaddr_t)); cmd.len = dlen;
memcpy(cmd.data, data, dlen);
skb = __hci_cmd_sync(hdev, 0xfc0b, sizeof(buf), buf, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { skb = __hci_cmd_sync(hdev, 0xfc0b, dlen + 4, &cmd, HCI_INIT_TIMEOUT);
err = PTR_ERR(skb); if (IS_ERR(skb))
BT_ERR("%s: Change address command failed (%d)", return PTR_ERR(skb);
hdev->name, err);
return err;
}
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
} }
static int ath_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
{
return ath_vendor_cmd(hdev, OP_WRITE_TAG, INDEX_BDADDR, bdaddr,
sizeof(*bdaddr));
}
static int ath_setup(struct hci_uart *hu) static int ath_setup(struct hci_uart *hu)
{ {
BT_DBG("hu %p", hu); BT_DBG("hu %p", hu);
...@@ -191,7 +206,7 @@ static int ath_recv(struct hci_uart *hu, const void *data, int count) ...@@ -191,7 +206,7 @@ static int ath_recv(struct hci_uart *hu, const void *data, int count)
ath_recv_pkts, ARRAY_SIZE(ath_recv_pkts)); ath_recv_pkts, ARRAY_SIZE(ath_recv_pkts));
if (IS_ERR(ath->rx_skb)) { if (IS_ERR(ath->rx_skb)) {
int err = PTR_ERR(ath->rx_skb); int err = PTR_ERR(ath->rx_skb);
BT_ERR("%s: Frame reassembly failed (%d)", hu->hdev->name, err); bt_dev_err(hu->hdev, "Frame reassembly failed (%d)", err);
ath->rx_skb = NULL; ath->rx_skb = NULL;
return err; return err;
} }
......
...@@ -132,7 +132,7 @@ static int h4_recv(struct hci_uart *hu, const void *data, int count) ...@@ -132,7 +132,7 @@ static int h4_recv(struct hci_uart *hu, const void *data, int count)
h4_recv_pkts, ARRAY_SIZE(h4_recv_pkts)); h4_recv_pkts, ARRAY_SIZE(h4_recv_pkts));
if (IS_ERR(h4->rx_skb)) { if (IS_ERR(h4->rx_skb)) {
int err = PTR_ERR(h4->rx_skb); int err = PTR_ERR(h4->rx_skb);
BT_ERR("%s: Frame reassembly failed (%d)", hu->hdev->name, err); bt_dev_err(hu->hdev, "Frame reassembly failed (%d)", err);
h4->rx_skb = NULL; h4->rx_skb = NULL;
return err; return err;
} }
......
...@@ -115,12 +115,12 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu) ...@@ -115,12 +115,12 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu)
struct sk_buff *skb = hu->tx_skb; struct sk_buff *skb = hu->tx_skb;
if (!skb) { if (!skb) {
read_lock(&hu->proto_lock); percpu_down_read(&hu->proto_lock);
if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) if (test_bit(HCI_UART_PROTO_READY, &hu->flags))
skb = hu->proto->dequeue(hu); skb = hu->proto->dequeue(hu);
read_unlock(&hu->proto_lock); percpu_up_read(&hu->proto_lock);
} else { } else {
hu->tx_skb = NULL; hu->tx_skb = NULL;
} }
...@@ -130,7 +130,14 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu) ...@@ -130,7 +130,14 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu)
int hci_uart_tx_wakeup(struct hci_uart *hu) int hci_uart_tx_wakeup(struct hci_uart *hu)
{ {
read_lock(&hu->proto_lock); /* This may be called in an IRQ context, so we can't sleep. Therefore
* we try to acquire the lock only, and if that fails we assume the
* tty is being closed because that is the only time the write lock is
* acquired. If, however, at some point in the future the write lock
* is also acquired in other situations, then this must be revisited.
*/
if (!percpu_down_read_trylock(&hu->proto_lock))
return 0;
if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) if (!test_bit(HCI_UART_PROTO_READY, &hu->flags))
goto no_schedule; goto no_schedule;
...@@ -145,7 +152,7 @@ int hci_uart_tx_wakeup(struct hci_uart *hu) ...@@ -145,7 +152,7 @@ int hci_uart_tx_wakeup(struct hci_uart *hu)
schedule_work(&hu->write_work); schedule_work(&hu->write_work);
no_schedule: no_schedule:
read_unlock(&hu->proto_lock); percpu_up_read(&hu->proto_lock);
return 0; return 0;
} }
...@@ -247,12 +254,12 @@ static int hci_uart_flush(struct hci_dev *hdev) ...@@ -247,12 +254,12 @@ static int hci_uart_flush(struct hci_dev *hdev)
tty_ldisc_flush(tty); tty_ldisc_flush(tty);
tty_driver_flush_buffer(tty); tty_driver_flush_buffer(tty);
read_lock(&hu->proto_lock); percpu_down_read(&hu->proto_lock);
if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) if (test_bit(HCI_UART_PROTO_READY, &hu->flags))
hu->proto->flush(hu); hu->proto->flush(hu);
read_unlock(&hu->proto_lock); percpu_up_read(&hu->proto_lock);
return 0; return 0;
} }
...@@ -275,15 +282,15 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -275,15 +282,15 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
BT_DBG("%s: type %d len %d", hdev->name, hci_skb_pkt_type(skb), BT_DBG("%s: type %d len %d", hdev->name, hci_skb_pkt_type(skb),
skb->len); skb->len);
read_lock(&hu->proto_lock); percpu_down_read(&hu->proto_lock);
if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) { if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
read_unlock(&hu->proto_lock); percpu_up_read(&hu->proto_lock);
return -EUNATCH; return -EUNATCH;
} }
hu->proto->enqueue(hu, skb); hu->proto->enqueue(hu, skb);
read_unlock(&hu->proto_lock); percpu_up_read(&hu->proto_lock);
hci_uart_tx_wakeup(hu); hci_uart_tx_wakeup(hu);
...@@ -486,7 +493,7 @@ static int hci_uart_tty_open(struct tty_struct *tty) ...@@ -486,7 +493,7 @@ static int hci_uart_tty_open(struct tty_struct *tty)
INIT_WORK(&hu->init_ready, hci_uart_init_work); INIT_WORK(&hu->init_ready, hci_uart_init_work);
INIT_WORK(&hu->write_work, hci_uart_write_work); INIT_WORK(&hu->write_work, hci_uart_write_work);
rwlock_init(&hu->proto_lock); percpu_init_rwsem(&hu->proto_lock);
/* Flush any pending characters in the driver */ /* Flush any pending characters in the driver */
tty_driver_flush_buffer(tty); tty_driver_flush_buffer(tty);
...@@ -503,7 +510,6 @@ static void hci_uart_tty_close(struct tty_struct *tty) ...@@ -503,7 +510,6 @@ static void hci_uart_tty_close(struct tty_struct *tty)
{ {
struct hci_uart *hu = tty->disc_data; struct hci_uart *hu = tty->disc_data;
struct hci_dev *hdev; struct hci_dev *hdev;
unsigned long flags;
BT_DBG("tty %p", tty); BT_DBG("tty %p", tty);
...@@ -517,12 +523,12 @@ static void hci_uart_tty_close(struct tty_struct *tty) ...@@ -517,12 +523,12 @@ static void hci_uart_tty_close(struct tty_struct *tty)
if (hdev) if (hdev)
hci_uart_close(hdev); hci_uart_close(hdev);
cancel_work_sync(&hu->write_work);
if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) { if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
write_lock_irqsave(&hu->proto_lock, flags); percpu_down_write(&hu->proto_lock);
clear_bit(HCI_UART_PROTO_READY, &hu->flags); clear_bit(HCI_UART_PROTO_READY, &hu->flags);
write_unlock_irqrestore(&hu->proto_lock, flags); percpu_up_write(&hu->proto_lock);
cancel_work_sync(&hu->write_work);
if (hdev) { if (hdev) {
if (test_bit(HCI_UART_REGISTERED, &hu->flags)) if (test_bit(HCI_UART_REGISTERED, &hu->flags))
...@@ -582,10 +588,10 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, ...@@ -582,10 +588,10 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data,
if (!hu || tty != hu->tty) if (!hu || tty != hu->tty)
return; return;
read_lock(&hu->proto_lock); percpu_down_read(&hu->proto_lock);
if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) { if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
read_unlock(&hu->proto_lock); percpu_up_read(&hu->proto_lock);
return; return;
} }
...@@ -593,7 +599,7 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, ...@@ -593,7 +599,7 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data,
* tty caller * tty caller
*/ */
hu->proto->recv(hu, data, count); hu->proto->recv(hu, data, count);
read_unlock(&hu->proto_lock); percpu_up_read(&hu->proto_lock);
if (hu->hdev) if (hu->hdev)
hu->hdev->stat.byte_rx += count; hu->hdev->stat.byte_rx += count;
......
...@@ -800,7 +800,7 @@ static int qca_recv(struct hci_uart *hu, const void *data, int count) ...@@ -800,7 +800,7 @@ static int qca_recv(struct hci_uart *hu, const void *data, int count)
qca_recv_pkts, ARRAY_SIZE(qca_recv_pkts)); qca_recv_pkts, ARRAY_SIZE(qca_recv_pkts));
if (IS_ERR(qca->rx_skb)) { if (IS_ERR(qca->rx_skb)) {
int err = PTR_ERR(qca->rx_skb); int err = PTR_ERR(qca->rx_skb);
BT_ERR("%s: Frame reassembly failed (%d)", hu->hdev->name, err); bt_dev_err(hu->hdev, "Frame reassembly failed (%d)", err);
qca->rx_skb = NULL; qca->rx_skb = NULL;
return err; return err;
} }
...@@ -863,7 +863,7 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate) ...@@ -863,7 +863,7 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
skb = bt_skb_alloc(sizeof(cmd), GFP_ATOMIC); skb = bt_skb_alloc(sizeof(cmd), GFP_ATOMIC);
if (!skb) { if (!skb) {
BT_ERR("Failed to allocate memory for baudrate packet"); bt_dev_err(hdev, "Failed to allocate baudrate packet");
return -ENOMEM; return -ENOMEM;
} }
...@@ -892,7 +892,7 @@ static int qca_setup(struct hci_uart *hu) ...@@ -892,7 +892,7 @@ static int qca_setup(struct hci_uart *hu)
unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200; unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200;
int ret; int ret;
BT_INFO("%s: ROME setup", hdev->name); bt_dev_info(hdev, "ROME setup");
/* Patch downloading has to be done without IBS mode */ /* Patch downloading has to be done without IBS mode */
clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
...@@ -917,11 +917,11 @@ static int qca_setup(struct hci_uart *hu) ...@@ -917,11 +917,11 @@ static int qca_setup(struct hci_uart *hu)
if (speed) { if (speed) {
qca_baudrate = qca_get_baudrate_value(speed); qca_baudrate = qca_get_baudrate_value(speed);
BT_INFO("%s: Set UART speed to %d", hdev->name, speed); bt_dev_info(hdev, "Set UART speed to %d", speed);
ret = qca_set_baudrate(hdev, qca_baudrate); ret = qca_set_baudrate(hdev, qca_baudrate);
if (ret) { if (ret) {
BT_ERR("%s: Failed to change the baud rate (%d)", bt_dev_err(hdev, "Failed to change the baud rate (%d)",
hdev->name, ret); ret);
return ret; return ret;
} }
hci_uart_set_baudrate(hu, speed); hci_uart_set_baudrate(hu, speed);
......
...@@ -185,7 +185,7 @@ static int hci_uart_setup(struct hci_dev *hdev) ...@@ -185,7 +185,7 @@ static int hci_uart_setup(struct hci_dev *hdev)
if (hu->proto->set_baudrate && speed) { if (hu->proto->set_baudrate && speed) {
err = hu->proto->set_baudrate(hu, speed); err = hu->proto->set_baudrate(hu, speed);
if (err) if (err)
BT_ERR("%s: failed to set baudrate", hdev->name); bt_dev_err(hdev, "Failed to set baudrate");
else else
serdev_device_set_baudrate(hu->serdev, speed); serdev_device_set_baudrate(hu->serdev, speed);
} }
...@@ -199,14 +199,13 @@ static int hci_uart_setup(struct hci_dev *hdev) ...@@ -199,14 +199,13 @@ static int hci_uart_setup(struct hci_dev *hdev)
skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL, skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL,
HCI_INIT_TIMEOUT); HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) { if (IS_ERR(skb)) {
BT_ERR("%s: Reading local version information failed (%ld)", bt_dev_err(hdev, "Reading local version info failed (%ld)",
hdev->name, PTR_ERR(skb)); PTR_ERR(skb));
return 0; return 0;
} }
if (skb->len != sizeof(*ver)) { if (skb->len != sizeof(*ver)) {
BT_ERR("%s: Event length mismatch for version information", bt_dev_err(hdev, "Event length mismatch for version info");
hdev->name);
} }
kfree_skb(skb); kfree_skb(skb);
......
...@@ -87,7 +87,7 @@ struct hci_uart { ...@@ -87,7 +87,7 @@ struct hci_uart {
struct work_struct write_work; struct work_struct write_work;
const struct hci_uart_proto *proto; const struct hci_uart_proto *proto;
rwlock_t proto_lock; /* Stop work for proto close */ struct percpu_rw_semaphore proto_lock; /* Stop work for proto close */
void *priv; void *priv;
struct sk_buff *tx_skb; struct sk_buff *tx_skb;
......
...@@ -147,6 +147,9 @@ void bt_err_ratelimited(const char *fmt, ...); ...@@ -147,6 +147,9 @@ void bt_err_ratelimited(const char *fmt, ...);
#define bt_dev_dbg(hdev, fmt, ...) \ #define bt_dev_dbg(hdev, fmt, ...) \
BT_DBG("%s: " fmt, (hdev)->name, ##__VA_ARGS__) BT_DBG("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
#define bt_dev_err_ratelimited(hdev, fmt, ...) \
BT_ERR_RATELIMITED("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
/* Connection and socket states */ /* Connection and socket states */
enum { enum {
BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */ BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
......
...@@ -273,7 +273,7 @@ enum { ...@@ -273,7 +273,7 @@ enum {
#define HCI_AUTO_OFF_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */ #define HCI_AUTO_OFF_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
#define HCI_POWER_OFF_TIMEOUT msecs_to_jiffies(5000) /* 5 seconds */ #define HCI_POWER_OFF_TIMEOUT msecs_to_jiffies(5000) /* 5 seconds */
#define HCI_LE_CONN_TIMEOUT msecs_to_jiffies(20000) /* 20 seconds */ #define HCI_LE_CONN_TIMEOUT msecs_to_jiffies(20000) /* 20 seconds */
#define HCI_LE_AUTOCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */ #define HCI_LE_AUTOCONN_TIMEOUT msecs_to_jiffies(4000) /* 4 seconds */
/* HCI data types */ /* HCI data types */
#define HCI_COMMAND_PKT 0x01 #define HCI_COMMAND_PKT 0x01
......
...@@ -573,7 +573,7 @@ static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, ...@@ -573,7 +573,7 @@ static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
hcon = hci_conn_hash_lookup_ba(hdev, AMP_LINK, hcon = hci_conn_hash_lookup_ba(hdev, AMP_LINK,
&mgr->l2cap_conn->hcon->dst); &mgr->l2cap_conn->hcon->dst);
if (!hcon) { if (!hcon) {
BT_ERR("No phys link exist"); bt_dev_err(hdev, "no phys link exist");
rsp.status = A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS; rsp.status = A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS;
goto clean; goto clean;
} }
......
...@@ -187,7 +187,7 @@ int phylink_gen_key(struct hci_conn *conn, u8 *data, u8 *len, u8 *type) ...@@ -187,7 +187,7 @@ int phylink_gen_key(struct hci_conn *conn, u8 *data, u8 *len, u8 *type)
/* Legacy key */ /* Legacy key */
if (conn->key_type < 3) { if (conn->key_type < 3) {
BT_ERR("Legacy key type %d", conn->key_type); bt_dev_err(hdev, "legacy key type %d", conn->key_type);
return -EACCES; return -EACCES;
} }
...@@ -207,7 +207,7 @@ int phylink_gen_key(struct hci_conn *conn, u8 *data, u8 *len, u8 *type) ...@@ -207,7 +207,7 @@ int phylink_gen_key(struct hci_conn *conn, u8 *data, u8 *len, u8 *type)
/* Derive Generic AMP Link Key (gamp) */ /* Derive Generic AMP Link Key (gamp) */
err = hmac_sha256(keybuf, HCI_AMP_LINK_KEY_SIZE, "gamp", 4, gamp_key); err = hmac_sha256(keybuf, HCI_AMP_LINK_KEY_SIZE, "gamp", 4, gamp_key);
if (err) { if (err) {
BT_ERR("Could not derive Generic AMP Key: err %d", err); bt_dev_err(hdev, "could not derive Generic AMP Key: err %d", err);
return err; return err;
} }
......
...@@ -729,8 +729,8 @@ static void create_le_conn_complete(struct hci_dev *hdev, u8 status, u16 opcode) ...@@ -729,8 +729,8 @@ static void create_le_conn_complete(struct hci_dev *hdev, u8 status, u16 opcode)
goto done; goto done;
} }
BT_ERR("HCI request failed to create LE connection: status 0x%2.2x", bt_dev_err(hdev, "request failed to create LE connection: "
status); "status 0x%2.2x", status);
if (!conn) if (!conn)
goto done; goto done;
...@@ -907,7 +907,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, ...@@ -907,7 +907,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
*/ */
if (hci_dev_test_flag(hdev, HCI_LE_SCAN) && if (hci_dev_test_flag(hdev, HCI_LE_SCAN) &&
hdev->le_scan_type == LE_SCAN_ACTIVE) { hdev->le_scan_type == LE_SCAN_ACTIVE) {
skb_queue_purge(&req.cmd_q); hci_req_purge(&req);
hci_conn_del(conn); hci_conn_del(conn);
return ERR_PTR(-EBUSY); return ERR_PTR(-EBUSY);
} }
......
...@@ -267,7 +267,7 @@ static int hci_init1_req(struct hci_request *req, unsigned long opt) ...@@ -267,7 +267,7 @@ static int hci_init1_req(struct hci_request *req, unsigned long opt)
amp_init1(req); amp_init1(req);
break; break;
default: default:
BT_ERR("Unknown device type %d", hdev->dev_type); bt_dev_err(hdev, "Unknown device type %d", hdev->dev_type);
break; break;
} }
...@@ -2150,8 +2150,7 @@ static void hci_error_reset(struct work_struct *work) ...@@ -2150,8 +2150,7 @@ static void hci_error_reset(struct work_struct *work)
if (hdev->hw_error) if (hdev->hw_error)
hdev->hw_error(hdev, hdev->hw_error_code); hdev->hw_error(hdev, hdev->hw_error_code);
else else
BT_ERR("%s hardware error 0x%2.2x", hdev->name, bt_dev_err(hdev, "hardware error 0x%2.2x", hdev->hw_error_code);
hdev->hw_error_code);
if (hci_dev_do_close(hdev)) if (hci_dev_do_close(hdev))
return; return;
...@@ -2524,9 +2523,9 @@ static void hci_cmd_timeout(struct work_struct *work) ...@@ -2524,9 +2523,9 @@ static void hci_cmd_timeout(struct work_struct *work)
struct hci_command_hdr *sent = (void *) hdev->sent_cmd->data; struct hci_command_hdr *sent = (void *) hdev->sent_cmd->data;
u16 opcode = __le16_to_cpu(sent->opcode); u16 opcode = __le16_to_cpu(sent->opcode);
BT_ERR("%s command 0x%4.4x tx timeout", hdev->name, opcode); bt_dev_err(hdev, "command 0x%4.4x tx timeout", opcode);
} else { } else {
BT_ERR("%s command tx timeout", hdev->name); bt_dev_err(hdev, "command tx timeout");
} }
atomic_set(&hdev->cmd_cnt, 1); atomic_set(&hdev->cmd_cnt, 1);
...@@ -2858,7 +2857,7 @@ struct hci_conn_params *hci_conn_params_add(struct hci_dev *hdev, ...@@ -2858,7 +2857,7 @@ struct hci_conn_params *hci_conn_params_add(struct hci_dev *hdev,
params = kzalloc(sizeof(*params), GFP_KERNEL); params = kzalloc(sizeof(*params), GFP_KERNEL);
if (!params) { if (!params) {
BT_ERR("Out of memory"); bt_dev_err(hdev, "out of memory");
return NULL; return NULL;
} }
...@@ -3393,7 +3392,7 @@ static void hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -3393,7 +3392,7 @@ static void hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
err = hdev->send(hdev, skb); err = hdev->send(hdev, skb);
if (err < 0) { if (err < 0) {
BT_ERR("%s sending frame failed (%d)", hdev->name, err); bt_dev_err(hdev, "sending frame failed (%d)", err);
kfree_skb(skb); kfree_skb(skb);
} }
} }
...@@ -3408,7 +3407,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, ...@@ -3408,7 +3407,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen,
skb = hci_prepare_cmd(hdev, opcode, plen, param); skb = hci_prepare_cmd(hdev, opcode, plen, param);
if (!skb) { if (!skb) {
BT_ERR("%s no memory for command", hdev->name); bt_dev_err(hdev, "no memory for command");
return -ENOMEM; return -ENOMEM;
} }
...@@ -3493,7 +3492,7 @@ static void hci_queue_acl(struct hci_chan *chan, struct sk_buff_head *queue, ...@@ -3493,7 +3492,7 @@ static void hci_queue_acl(struct hci_chan *chan, struct sk_buff_head *queue,
hci_add_acl_hdr(skb, chan->handle, flags); hci_add_acl_hdr(skb, chan->handle, flags);
break; break;
default: default:
BT_ERR("%s unknown dev_type %d", hdev->name, hdev->dev_type); bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type);
return; return;
} }
...@@ -3618,7 +3617,7 @@ static struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, ...@@ -3618,7 +3617,7 @@ static struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type,
break; break;
default: default:
cnt = 0; cnt = 0;
BT_ERR("Unknown link type"); bt_dev_err(hdev, "unknown link type %d", conn->type);
} }
q = cnt / num; q = cnt / num;
...@@ -3635,15 +3634,15 @@ static void hci_link_tx_to(struct hci_dev *hdev, __u8 type) ...@@ -3635,15 +3634,15 @@ static void hci_link_tx_to(struct hci_dev *hdev, __u8 type)
struct hci_conn_hash *h = &hdev->conn_hash; struct hci_conn_hash *h = &hdev->conn_hash;
struct hci_conn *c; struct hci_conn *c;
BT_ERR("%s link tx timeout", hdev->name); bt_dev_err(hdev, "link tx timeout");
rcu_read_lock(); rcu_read_lock();
/* Kill stalled connections */ /* Kill stalled connections */
list_for_each_entry_rcu(c, &h->list, list) { list_for_each_entry_rcu(c, &h->list, list) {
if (c->type == type && c->sent) { if (c->type == type && c->sent) {
BT_ERR("%s killing stalled connection %pMR", bt_dev_err(hdev, "killing stalled connection %pMR",
hdev->name, &c->dst); &c->dst);
hci_disconnect(c, HCI_ERROR_REMOTE_USER_TERM); hci_disconnect(c, HCI_ERROR_REMOTE_USER_TERM);
} }
} }
...@@ -3724,7 +3723,7 @@ static struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type, ...@@ -3724,7 +3723,7 @@ static struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type,
break; break;
default: default:
cnt = 0; cnt = 0;
BT_ERR("Unknown link type"); bt_dev_err(hdev, "unknown link type %d", chan->conn->type);
} }
q = cnt / num; q = cnt / num;
...@@ -4066,8 +4065,8 @@ static void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -4066,8 +4065,8 @@ static void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
l2cap_recv_acldata(conn, skb, flags); l2cap_recv_acldata(conn, skb, flags);
return; return;
} else { } else {
BT_ERR("%s ACL packet for unknown connection handle %d", bt_dev_err(hdev, "ACL packet for unknown connection handle %d",
hdev->name, handle); handle);
} }
kfree_skb(skb); kfree_skb(skb);
...@@ -4097,8 +4096,8 @@ static void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -4097,8 +4096,8 @@ static void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb)
sco_recv_scodata(conn, skb); sco_recv_scodata(conn, skb);
return; return;
} else { } else {
BT_ERR("%s SCO packet for unknown connection handle %d", bt_dev_err(hdev, "SCO packet for unknown connection handle %d",
hdev->name, handle); handle);
} }
kfree_skb(skb); kfree_skb(skb);
......
...@@ -1188,7 +1188,8 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, ...@@ -1188,7 +1188,8 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
break; break;
default: default:
BT_ERR("Used reserved LE_Scan_Enable param %d", cp->enable); bt_dev_err(hdev, "use of reserved LE_Scan_Enable param %d",
cp->enable);
break; break;
} }
...@@ -1485,7 +1486,7 @@ static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) ...@@ -1485,7 +1486,7 @@ static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr, conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr,
HCI_ROLE_MASTER); HCI_ROLE_MASTER);
if (!conn) if (!conn)
BT_ERR("No memory for new connection"); bt_dev_err(hdev, "no memory for new connection");
} }
} }
...@@ -2269,7 +2270,7 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -2269,7 +2270,7 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr,
HCI_ROLE_SLAVE); HCI_ROLE_SLAVE);
if (!conn) { if (!conn) {
BT_ERR("No memory for new connection"); bt_dev_err(hdev, "no memory for new connection");
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
return; return;
} }
...@@ -2431,7 +2432,7 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -2431,7 +2432,7 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
if (!hci_conn_ssp_enabled(conn) && if (!hci_conn_ssp_enabled(conn) &&
test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) {
BT_INFO("re-auth of legacy device is not possible."); bt_dev_info(hdev, "re-auth of legacy device is not possible.");
} else { } else {
set_bit(HCI_CONN_AUTH, &conn->flags); set_bit(HCI_CONN_AUTH, &conn->flags);
conn->sec_level = conn->pending_sec_level; conn->sec_level = conn->pending_sec_level;
...@@ -2535,8 +2536,7 @@ static void read_enc_key_size_complete(struct hci_dev *hdev, u8 status, ...@@ -2535,8 +2536,7 @@ static void read_enc_key_size_complete(struct hci_dev *hdev, u8 status,
BT_DBG("%s status 0x%02x", hdev->name, status); BT_DBG("%s status 0x%02x", hdev->name, status);
if (!skb || skb->len < sizeof(*rp)) { if (!skb || skb->len < sizeof(*rp)) {
BT_ERR("%s invalid HCI Read Encryption Key Size response", bt_dev_err(hdev, "invalid read key size response");
hdev->name);
return; return;
} }
...@@ -2554,7 +2554,7 @@ static void read_enc_key_size_complete(struct hci_dev *hdev, u8 status, ...@@ -2554,7 +2554,7 @@ static void read_enc_key_size_complete(struct hci_dev *hdev, u8 status,
* supported. * supported.
*/ */
if (rp->status) { if (rp->status) {
BT_ERR("%s failed to read key size for handle %u", hdev->name, bt_dev_err(hdev, "failed to read key size for handle %u",
handle); handle);
conn->enc_key_size = HCI_LINK_KEY_SIZE; conn->enc_key_size = HCI_LINK_KEY_SIZE;
} else { } else {
...@@ -2664,7 +2664,7 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -2664,7 +2664,7 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
hci_req_add(&req, HCI_OP_READ_ENC_KEY_SIZE, sizeof(cp), &cp); hci_req_add(&req, HCI_OP_READ_ENC_KEY_SIZE, sizeof(cp), &cp);
if (hci_req_run_skb(&req, read_enc_key_size_complete)) { if (hci_req_run_skb(&req, read_enc_key_size_complete)) {
BT_ERR("Sending HCI Read Encryption Key Size failed"); bt_dev_err(hdev, "sending read key size failed");
conn->enc_key_size = HCI_LINK_KEY_SIZE; conn->enc_key_size = HCI_LINK_KEY_SIZE;
goto notify; goto notify;
} }
...@@ -3197,7 +3197,7 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -3197,7 +3197,7 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
int i; int i;
if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) { if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) {
BT_ERR("Wrong event for mode %d", hdev->flow_ctl_mode); bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode);
return; return;
} }
...@@ -3249,7 +3249,8 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -3249,7 +3249,8 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
break; break;
default: default:
BT_ERR("Unknown type %d conn %p", conn->type, conn); bt_dev_err(hdev, "unknown type %d conn %p",
conn->type, conn);
break; break;
} }
} }
...@@ -3271,7 +3272,7 @@ static struct hci_conn *__hci_conn_lookup_handle(struct hci_dev *hdev, ...@@ -3271,7 +3272,7 @@ static struct hci_conn *__hci_conn_lookup_handle(struct hci_dev *hdev,
return chan->conn; return chan->conn;
break; break;
default: default:
BT_ERR("%s unknown dev_type %d", hdev->name, hdev->dev_type); bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type);
break; break;
} }
...@@ -3284,7 +3285,7 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -3284,7 +3285,7 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
int i; int i;
if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) { if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) {
BT_ERR("Wrong event for mode %d", hdev->flow_ctl_mode); bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode);
return; return;
} }
...@@ -3320,7 +3321,8 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -3320,7 +3321,8 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
break; break;
default: default:
BT_ERR("Unknown type %d conn %p", conn->type, conn); bt_dev_err(hdev, "unknown type %d conn %p",
conn->type, conn);
break; break;
} }
} }
...@@ -4479,7 +4481,7 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -4479,7 +4481,7 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
if (!conn) { if (!conn) {
conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr, ev->role); conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr, ev->role);
if (!conn) { if (!conn) {
BT_ERR("No memory for new connection"); bt_dev_err(hdev, "no memory for new connection");
goto unlock; goto unlock;
} }
...@@ -4749,8 +4751,8 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr, ...@@ -4749,8 +4751,8 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
case LE_ADV_SCAN_RSP: case LE_ADV_SCAN_RSP:
break; break;
default: default:
BT_ERR_RATELIMITED("Unknown advertising packet type: 0x%02x", bt_dev_err_ratelimited(hdev, "unknown advertising packet "
type); "type: 0x%02x", type);
return; return;
} }
...@@ -4769,8 +4771,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr, ...@@ -4769,8 +4771,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
/* Adjust for actual length */ /* Adjust for actual length */
if (len != real_len) { if (len != real_len) {
BT_ERR_RATELIMITED("%s advertising data length corrected", bt_dev_err_ratelimited(hdev, "advertising data len corrected");
hdev->name);
len = real_len; len = real_len;
} }
...@@ -5192,7 +5193,7 @@ static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, ...@@ -5192,7 +5193,7 @@ static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode,
return false; return false;
if (skb->len < sizeof(*hdr)) { if (skb->len < sizeof(*hdr)) {
BT_ERR("Too short HCI event"); bt_dev_err(hdev, "too short HCI event");
return false; return false;
} }
...@@ -5206,12 +5207,13 @@ static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, ...@@ -5206,12 +5207,13 @@ static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode,
} }
if (hdr->evt != HCI_EV_CMD_COMPLETE) { if (hdr->evt != HCI_EV_CMD_COMPLETE) {
BT_DBG("Last event is not cmd complete (0x%2.2x)", hdr->evt); bt_dev_err(hdev, "last event is not cmd complete (0x%2.2x)",
hdr->evt);
return false; return false;
} }
if (skb->len < sizeof(*ev)) { if (skb->len < sizeof(*ev)) {
BT_ERR("Too short cmd_complete event"); bt_dev_err(hdev, "too short cmd_complete event");
return false; return false;
} }
......
...@@ -41,6 +41,11 @@ void hci_req_init(struct hci_request *req, struct hci_dev *hdev) ...@@ -41,6 +41,11 @@ void hci_req_init(struct hci_request *req, struct hci_dev *hdev)
req->err = 0; req->err = 0;
} }
void hci_req_purge(struct hci_request *req)
{
skb_queue_purge(&req->cmd_q);
}
static int req_run(struct hci_request *req, hci_req_complete_t complete, static int req_run(struct hci_request *req, hci_req_complete_t complete,
hci_req_complete_skb_t complete_skb) hci_req_complete_skb_t complete_skb)
{ {
...@@ -331,8 +336,8 @@ void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen, ...@@ -331,8 +336,8 @@ void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen,
skb = hci_prepare_cmd(hdev, opcode, plen, param); skb = hci_prepare_cmd(hdev, opcode, plen, param);
if (!skb) { if (!skb) {
BT_ERR("%s no memory for command (opcode 0x%4.4x)", bt_dev_err(hdev, "no memory for command (opcode 0x%4.4x)",
hdev->name, opcode); opcode);
req->err = -ENOMEM; req->err = -ENOMEM;
return; return;
} }
...@@ -1421,7 +1426,7 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, ...@@ -1421,7 +1426,7 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy,
err = smp_generate_rpa(hdev, hdev->irk, &hdev->rpa); err = smp_generate_rpa(hdev, hdev->irk, &hdev->rpa);
if (err < 0) { if (err < 0) {
BT_ERR("%s failed to generate new RPA", hdev->name); bt_dev_err(hdev, "failed to generate new RPA");
return err; return err;
} }
...@@ -1783,7 +1788,7 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason) ...@@ -1783,7 +1788,7 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason)
err = hci_req_run(&req, abort_conn_complete); err = hci_req_run(&req, abort_conn_complete);
if (err && err != -ENODATA) { if (err && err != -ENODATA) {
BT_ERR("Failed to run HCI request: err %d", err); bt_dev_err(conn->hdev, "failed to run HCI request: err %d", err);
return err; return err;
} }
...@@ -1867,7 +1872,8 @@ static void le_scan_disable_work(struct work_struct *work) ...@@ -1867,7 +1872,8 @@ static void le_scan_disable_work(struct work_struct *work)
hci_req_sync(hdev, le_scan_disable, 0, HCI_CMD_TIMEOUT, &status); hci_req_sync(hdev, le_scan_disable, 0, HCI_CMD_TIMEOUT, &status);
if (status) { if (status) {
BT_ERR("Failed to disable LE scan: status 0x%02x", status); bt_dev_err(hdev, "failed to disable LE scan: status 0x%02x",
status);
return; return;
} }
...@@ -1898,7 +1904,7 @@ static void le_scan_disable_work(struct work_struct *work) ...@@ -1898,7 +1904,7 @@ static void le_scan_disable_work(struct work_struct *work)
hci_req_sync(hdev, bredr_inquiry, DISCOV_INTERLEAVED_INQUIRY_LEN, hci_req_sync(hdev, bredr_inquiry, DISCOV_INTERLEAVED_INQUIRY_LEN,
HCI_CMD_TIMEOUT, &status); HCI_CMD_TIMEOUT, &status);
if (status) { if (status) {
BT_ERR("Inquiry failed: status 0x%02x", status); bt_dev_err(hdev, "inquiry failed: status 0x%02x", status);
goto discov_stopped; goto discov_stopped;
} }
...@@ -1940,7 +1946,8 @@ static void le_scan_restart_work(struct work_struct *work) ...@@ -1940,7 +1946,8 @@ static void le_scan_restart_work(struct work_struct *work)
hci_req_sync(hdev, le_scan_restart, 0, HCI_CMD_TIMEOUT, &status); hci_req_sync(hdev, le_scan_restart, 0, HCI_CMD_TIMEOUT, &status);
if (status) { if (status) {
BT_ERR("Failed to restart LE scan: status %d", status); bt_dev_err(hdev, "failed to restart LE scan: status %d",
status);
return; return;
} }
......
...@@ -36,6 +36,7 @@ struct hci_request { ...@@ -36,6 +36,7 @@ struct hci_request {
}; };
void hci_req_init(struct hci_request *req, struct hci_dev *hdev); void hci_req_init(struct hci_request *req, struct hci_dev *hdev);
void hci_req_purge(struct hci_request *req);
int hci_req_run(struct hci_request *req, hci_req_complete_t complete); int hci_req_run(struct hci_request *req, hci_req_complete_t complete);
int hci_req_run_skb(struct hci_request *req, hci_req_complete_skb_t complete); int hci_req_run_skb(struct hci_request *req, hci_req_complete_skb_t complete);
void hci_req_add(struct hci_request *req, u16 opcode, u32 plen, void hci_req_add(struct hci_request *req, u16 opcode, u32 plen,
......
...@@ -251,15 +251,13 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -251,15 +251,13 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb)
} }
/* Send frame to sockets with specific channel */ /* Send frame to sockets with specific channel */
void hci_send_to_channel(unsigned short channel, struct sk_buff *skb, static void __hci_send_to_channel(unsigned short channel, struct sk_buff *skb,
int flag, struct sock *skip_sk) int flag, struct sock *skip_sk)
{ {
struct sock *sk; struct sock *sk;
BT_DBG("channel %u len %d", channel, skb->len); BT_DBG("channel %u len %d", channel, skb->len);
read_lock(&hci_sk_list.lock);
sk_for_each(sk, &hci_sk_list.head) { sk_for_each(sk, &hci_sk_list.head) {
struct sk_buff *nskb; struct sk_buff *nskb;
...@@ -285,6 +283,13 @@ void hci_send_to_channel(unsigned short channel, struct sk_buff *skb, ...@@ -285,6 +283,13 @@ void hci_send_to_channel(unsigned short channel, struct sk_buff *skb,
kfree_skb(nskb); kfree_skb(nskb);
} }
}
void hci_send_to_channel(unsigned short channel, struct sk_buff *skb,
int flag, struct sock *skip_sk)
{
read_lock(&hci_sk_list.lock);
__hci_send_to_channel(channel, skb, flag, skip_sk);
read_unlock(&hci_sk_list.lock); read_unlock(&hci_sk_list.lock);
} }
...@@ -388,7 +393,7 @@ void hci_send_monitor_ctrl_event(struct hci_dev *hdev, u16 event, ...@@ -388,7 +393,7 @@ void hci_send_monitor_ctrl_event(struct hci_dev *hdev, u16 event,
hdr->index = index; hdr->index = index;
hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE);
hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, __hci_send_to_channel(HCI_CHANNEL_MONITOR, skb,
HCI_SOCK_TRUSTED, NULL); HCI_SOCK_TRUSTED, NULL);
kfree_skb(skb); kfree_skb(skb);
} }
......
...@@ -50,7 +50,7 @@ void hci_conn_add_sysfs(struct hci_conn *conn) ...@@ -50,7 +50,7 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle); dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle);
if (device_add(&conn->dev) < 0) { if (device_add(&conn->dev) < 0) {
BT_ERR("Failed to register connection device"); bt_dev_err(hdev, "failed to register connection device");
return; return;
} }
......
...@@ -2159,7 +2159,7 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -2159,7 +2159,7 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
key_count = __le16_to_cpu(cp->key_count); key_count = __le16_to_cpu(cp->key_count);
if (key_count > max_key_count) { if (key_count > max_key_count) {
BT_ERR("load_link_keys: too big key_count value %u", bt_dev_err(hdev, "load_link_keys: too big key_count value %u",
key_count); key_count);
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
...@@ -2168,7 +2168,7 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -2168,7 +2168,7 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
expected_len = sizeof(*cp) + key_count * expected_len = sizeof(*cp) + key_count *
sizeof(struct mgmt_link_key_info); sizeof(struct mgmt_link_key_info);
if (expected_len != len) { if (expected_len != len) {
BT_ERR("load_link_keys: expected %u bytes, got %u bytes", bt_dev_err(hdev, "load_link_keys: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
...@@ -2561,7 +2561,7 @@ static int pin_code_reply(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -2561,7 +2561,7 @@ static int pin_code_reply(struct sock *sk, struct hci_dev *hdev, void *data,
memcpy(&ncp.addr, &cp->addr, sizeof(ncp.addr)); memcpy(&ncp.addr, &cp->addr, sizeof(ncp.addr));
BT_ERR("PIN code is not 16 bytes long"); bt_dev_err(hdev, "PIN code is not 16 bytes long");
err = send_pin_code_neg_reply(sk, hdev, &ncp); err = send_pin_code_neg_reply(sk, hdev, &ncp);
if (err >= 0) if (err >= 0)
...@@ -3391,7 +3391,8 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, ...@@ -3391,7 +3391,8 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,
MGMT_OP_ADD_REMOTE_OOB_DATA, MGMT_OP_ADD_REMOTE_OOB_DATA,
status, &cp->addr, sizeof(cp->addr)); status, &cp->addr, sizeof(cp->addr));
} else { } else {
BT_ERR("add_remote_oob_data: invalid length of %u bytes", len); bt_dev_err(hdev, "add_remote_oob_data: invalid len of %u bytes",
len);
err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
...@@ -3604,7 +3605,7 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev, ...@@ -3604,7 +3605,7 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev,
uuid_count = __le16_to_cpu(cp->uuid_count); uuid_count = __le16_to_cpu(cp->uuid_count);
if (uuid_count > max_uuid_count) { if (uuid_count > max_uuid_count) {
BT_ERR("service_discovery: too big uuid_count value %u", bt_dev_err(hdev, "service_discovery: too big uuid_count value %u",
uuid_count); uuid_count);
err = mgmt_cmd_complete(sk, hdev->id, err = mgmt_cmd_complete(sk, hdev->id,
MGMT_OP_START_SERVICE_DISCOVERY, MGMT_OP_START_SERVICE_DISCOVERY,
...@@ -3615,7 +3616,7 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev, ...@@ -3615,7 +3616,7 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev,
expected_len = sizeof(*cp) + uuid_count * 16; expected_len = sizeof(*cp) + uuid_count * 16;
if (expected_len != len) { if (expected_len != len) {
BT_ERR("service_discovery: expected %u bytes, got %u bytes", bt_dev_err(hdev, "service_discovery: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
err = mgmt_cmd_complete(sk, hdev->id, err = mgmt_cmd_complete(sk, hdev->id,
MGMT_OP_START_SERVICE_DISCOVERY, MGMT_OP_START_SERVICE_DISCOVERY,
...@@ -3943,7 +3944,7 @@ static void set_advertising_complete(struct hci_dev *hdev, u8 status, ...@@ -3943,7 +3944,7 @@ static void set_advertising_complete(struct hci_dev *hdev, u8 status,
err = hci_req_run(&req, enable_advertising_instance); err = hci_req_run(&req, enable_advertising_instance);
if (err) if (err)
BT_ERR("Failed to re-configure advertising"); bt_dev_err(hdev, "failed to re-configure advertising");
unlock: unlock:
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
...@@ -4664,14 +4665,15 @@ static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data, ...@@ -4664,14 +4665,15 @@ static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data,
irk_count = __le16_to_cpu(cp->irk_count); irk_count = __le16_to_cpu(cp->irk_count);
if (irk_count > max_irk_count) { if (irk_count > max_irk_count) {
BT_ERR("load_irks: too big irk_count value %u", irk_count); bt_dev_err(hdev, "load_irks: too big irk_count value %u",
irk_count);
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
expected_len = sizeof(*cp) + irk_count * sizeof(struct mgmt_irk_info); expected_len = sizeof(*cp) + irk_count * sizeof(struct mgmt_irk_info);
if (expected_len != len) { if (expected_len != len) {
BT_ERR("load_irks: expected %u bytes, got %u bytes", bt_dev_err(hdev, "load_irks: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
...@@ -4745,7 +4747,8 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, ...@@ -4745,7 +4747,8 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
key_count = __le16_to_cpu(cp->key_count); key_count = __le16_to_cpu(cp->key_count);
if (key_count > max_key_count) { if (key_count > max_key_count) {
BT_ERR("load_ltks: too big key_count value %u", key_count); bt_dev_err(hdev, "load_ltks: too big key_count value %u",
key_count);
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
...@@ -4753,7 +4756,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, ...@@ -4753,7 +4756,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
expected_len = sizeof(*cp) + key_count * expected_len = sizeof(*cp) + key_count *
sizeof(struct mgmt_ltk_info); sizeof(struct mgmt_ltk_info);
if (expected_len != len) { if (expected_len != len) {
BT_ERR("load_keys: expected %u bytes, got %u bytes", bt_dev_err(hdev, "load_keys: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
...@@ -4873,14 +4876,15 @@ static void conn_info_refresh_complete(struct hci_dev *hdev, u8 hci_status, ...@@ -4873,14 +4876,15 @@ static void conn_info_refresh_complete(struct hci_dev *hdev, u8 hci_status,
} }
if (!cp) { if (!cp) {
BT_ERR("invalid sent_cmd in conn_info response"); bt_dev_err(hdev, "invalid sent_cmd in conn_info response");
goto unlock; goto unlock;
} }
handle = __le16_to_cpu(cp->handle); handle = __le16_to_cpu(cp->handle);
conn = hci_conn_hash_lookup_handle(hdev, handle); conn = hci_conn_hash_lookup_handle(hdev, handle);
if (!conn) { if (!conn) {
BT_ERR("unknown handle (%d) in conn_info response", handle); bt_dev_err(hdev, "unknown handle (%d) in conn_info response",
handle);
goto unlock; goto unlock;
} }
...@@ -5477,7 +5481,7 @@ static int load_conn_param(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -5477,7 +5481,7 @@ static int load_conn_param(struct sock *sk, struct hci_dev *hdev, void *data,
param_count = __le16_to_cpu(cp->param_count); param_count = __le16_to_cpu(cp->param_count);
if (param_count > max_param_count) { if (param_count > max_param_count) {
BT_ERR("load_conn_param: too big param_count value %u", bt_dev_err(hdev, "load_conn_param: too big param_count value %u",
param_count); param_count);
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
...@@ -5486,7 +5490,7 @@ static int load_conn_param(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -5486,7 +5490,7 @@ static int load_conn_param(struct sock *sk, struct hci_dev *hdev, void *data,
expected_len = sizeof(*cp) + param_count * expected_len = sizeof(*cp) + param_count *
sizeof(struct mgmt_conn_param); sizeof(struct mgmt_conn_param);
if (expected_len != len) { if (expected_len != len) {
BT_ERR("load_conn_param: expected %u bytes, got %u bytes", bt_dev_err(hdev, "load_conn_param: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
...@@ -5512,7 +5516,7 @@ static int load_conn_param(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -5512,7 +5516,7 @@ static int load_conn_param(struct sock *sk, struct hci_dev *hdev, void *data,
} else if (param->addr.type == BDADDR_LE_RANDOM) { } else if (param->addr.type == BDADDR_LE_RANDOM) {
addr_type = ADDR_LE_DEV_RANDOM; addr_type = ADDR_LE_DEV_RANDOM;
} else { } else {
BT_ERR("Ignoring invalid connection parameters"); bt_dev_err(hdev, "ignoring invalid connection parameters");
continue; continue;
} }
...@@ -5525,14 +5529,14 @@ static int load_conn_param(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -5525,14 +5529,14 @@ static int load_conn_param(struct sock *sk, struct hci_dev *hdev, void *data,
min, max, latency, timeout); min, max, latency, timeout);
if (hci_check_conn_params(min, max, latency, timeout) < 0) { if (hci_check_conn_params(min, max, latency, timeout) < 0) {
BT_ERR("Ignoring invalid connection parameters"); bt_dev_err(hdev, "ignoring invalid connection parameters");
continue; continue;
} }
hci_param = hci_conn_params_add(hdev, &param->addr.bdaddr, hci_param = hci_conn_params_add(hdev, &param->addr.bdaddr,
addr_type); addr_type);
if (!hci_param) { if (!hci_param) {
BT_ERR("Failed to add connection parameters"); bt_dev_err(hdev, "failed to add connection parameters");
continue; continue;
} }
...@@ -6383,6 +6387,7 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev, ...@@ -6383,6 +6387,7 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev,
if (skb_queue_empty(&req.cmd_q) || if (skb_queue_empty(&req.cmd_q) ||
!hdev_is_powered(hdev) || !hdev_is_powered(hdev) ||
hci_dev_test_flag(hdev, HCI_ADVERTISING)) { hci_dev_test_flag(hdev, HCI_ADVERTISING)) {
hci_req_purge(&req);
rp.instance = cp->instance; rp.instance = cp->instance;
err = mgmt_cmd_complete(sk, hdev->id, err = mgmt_cmd_complete(sk, hdev->id,
MGMT_OP_REMOVE_ADVERTISING, MGMT_OP_REMOVE_ADVERTISING,
......
...@@ -996,7 +996,8 @@ static u8 smp_random(struct smp_chan *smp) ...@@ -996,7 +996,8 @@ static u8 smp_random(struct smp_chan *smp)
return SMP_UNSPECIFIED; return SMP_UNSPECIFIED;
if (crypto_memneq(smp->pcnf, confirm, sizeof(smp->pcnf))) { if (crypto_memneq(smp->pcnf, confirm, sizeof(smp->pcnf))) {
BT_ERR("Pairing failed (confirmation values mismatch)"); bt_dev_err(hcon->hdev, "pairing failed "
"(confirmation values mismatch)");
return SMP_CONFIRM_FAILED; return SMP_CONFIRM_FAILED;
} }
...@@ -1210,7 +1211,7 @@ static void sc_generate_ltk(struct smp_chan *smp) ...@@ -1210,7 +1211,7 @@ static void sc_generate_ltk(struct smp_chan *smp)
key = hci_find_link_key(hdev, &hcon->dst); key = hci_find_link_key(hdev, &hcon->dst);
if (!key) { if (!key) {
BT_ERR("%s No Link Key found to generate LTK", hdev->name); bt_dev_err(hdev, "no Link Key found to generate LTK");
return; return;
} }
...@@ -2067,11 +2068,11 @@ static int fixup_sc_false_positive(struct smp_chan *smp) ...@@ -2067,11 +2068,11 @@ static int fixup_sc_false_positive(struct smp_chan *smp)
return SMP_UNSPECIFIED; return SMP_UNSPECIFIED;
if (hci_dev_test_flag(hdev, HCI_SC_ONLY)) { if (hci_dev_test_flag(hdev, HCI_SC_ONLY)) {
BT_ERR("Refusing SMP SC -> legacy fallback in SC-only mode"); bt_dev_err(hdev, "refusing legacy fallback in SC-only mode");
return SMP_UNSPECIFIED; return SMP_UNSPECIFIED;
} }
BT_ERR("Trying to fall back to legacy SMP"); bt_dev_err(hdev, "trying to fall back to legacy SMP");
req = (void *) &smp->preq[1]; req = (void *) &smp->preq[1];
rsp = (void *) &smp->prsp[1]; rsp = (void *) &smp->prsp[1];
...@@ -2082,7 +2083,7 @@ static int fixup_sc_false_positive(struct smp_chan *smp) ...@@ -2082,7 +2083,7 @@ static int fixup_sc_false_positive(struct smp_chan *smp)
auth = req->auth_req & AUTH_REQ_MASK(hdev); auth = req->auth_req & AUTH_REQ_MASK(hdev);
if (tk_request(conn, 0, auth, rsp->io_capability, req->io_capability)) { if (tk_request(conn, 0, auth, rsp->io_capability, req->io_capability)) {
BT_ERR("Failed to fall back to legacy SMP"); bt_dev_err(hdev, "failed to fall back to legacy SMP");
return SMP_UNSPECIFIED; return SMP_UNSPECIFIED;
} }
...@@ -2355,7 +2356,7 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) ...@@ -2355,7 +2356,7 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
chan = conn->smp; chan = conn->smp;
if (!chan) { if (!chan) {
BT_ERR("SMP security requested but not available"); bt_dev_err(hcon->hdev, "security requested but not available");
return 1; return 1;
} }
...@@ -2548,7 +2549,7 @@ static int smp_cmd_ident_addr_info(struct l2cap_conn *conn, ...@@ -2548,7 +2549,7 @@ static int smp_cmd_ident_addr_info(struct l2cap_conn *conn,
*/ */
if (!bacmp(&info->bdaddr, BDADDR_ANY) || if (!bacmp(&info->bdaddr, BDADDR_ANY) ||
!hci_is_identity_address(&info->bdaddr, info->addr_type)) { !hci_is_identity_address(&info->bdaddr, info->addr_type)) {
BT_ERR("Ignoring IRK with no identity address"); bt_dev_err(hcon->hdev, "ignoring IRK with no identity address");
goto distribute; goto distribute;
} }
...@@ -2953,7 +2954,7 @@ static int smp_sig_channel(struct l2cap_chan *chan, struct sk_buff *skb) ...@@ -2953,7 +2954,7 @@ static int smp_sig_channel(struct l2cap_chan *chan, struct sk_buff *skb)
return err; return err;
drop: drop:
BT_ERR("%s unexpected SMP command 0x%02x from %pMR", hcon->hdev->name, bt_dev_err(hcon->hdev, "unexpected SMP command 0x%02x from %pMR",
code, &hcon->dst); code, &hcon->dst);
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
...@@ -3021,8 +3022,7 @@ static void bredr_pairing(struct l2cap_chan *chan) ...@@ -3021,8 +3022,7 @@ static void bredr_pairing(struct l2cap_chan *chan)
smp = smp_chan_create(conn); smp = smp_chan_create(conn);
if (!smp) { if (!smp) {
BT_ERR("%s unable to create SMP context for BR/EDR", bt_dev_err(hdev, "unable to create SMP context for BR/EDR");
hdev->name);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment