From 9268834b60c0b08101c7a8522b6901cf4cd57a14 Mon Sep 17 00:00:00 2001 From: Tedd Ho-Jeong An Date: Mon, 6 Mar 2017 15:38:26 -0800 Subject: Bluetooth: Use switch statement for Intel hardware variants Multiple new hardware variants are planned and the simple if statement would get really complicated and unreadable. So instead replace it with a simple switch statement. The change is applied to both USB and UART. Based-on-patch-by: Marcel Holtmann Signed-off-by: Tedd Ho-Jeong An Signed-off-by: Marcel Holtmann --- drivers/bluetooth/hci_intel.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'drivers/bluetooth/hci_intel.c') diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c index 9e271286c5e5..bfd718c58d99 100644 --- a/drivers/bluetooth/hci_intel.c +++ b/drivers/bluetooth/hci_intel.c @@ -601,12 +601,17 @@ static int intel_setup(struct hci_uart *hu) return -EINVAL; } - /* At the moment only the hardware variant iBT 3.0 (LnP/SfP) is - * supported by this firmware loading method. This check has been - * put in place to ensure correct forward compatibility options - * when newer hardware variants come along. - */ - if (ver.hw_variant != 0x0b) { + /* Check for supported iBT hardware variants of this firmware + * loading method. + * + * This check has been put in place to ensure correct forward + * compatibility options when newer hardware variants come along. + */ + switch (ver.hw_variant) { + case 0x0b: /* LnP */ + case 0x0c: /* WsP */ + break; + default: bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)", ver.hw_variant); return -EINVAL; -- cgit v1.2.3 From b7da6a69defd195da66bfd6b35efeb376a252557 Mon Sep 17 00:00:00 2001 From: Tedd Ho-Jeong An Date: Mon, 6 Mar 2017 15:38:32 -0800 Subject: Bluetooth: hci_intel: Fix firmware file name to use hw_variant The format of Intel Bluetooth firmware for bootloader product is ibt--.sfi and .ddc. This patch uses a hw_variant value read from the device during runtime to form the firmware filenames instead of using a constant value, so it can support multiple prouducts. Signed-off-by: Tedd Ho-Jeong An Signed-off-by: Marcel Holtmann --- drivers/bluetooth/hci_intel.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'drivers/bluetooth/hci_intel.c') diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c index bfd718c58d99..71d0850fab10 100644 --- a/drivers/bluetooth/hci_intel.c +++ b/drivers/bluetooth/hci_intel.c @@ -704,11 +704,14 @@ static int intel_setup(struct hci_uart *hu) /* With this Intel bootloader only the hardware variant and device * revision information are used to select the right firmware. * - * Currently this bootloader support is limited to hardware variant - * iBT 3.0 (LnP/SfP) which is identified by the value 11 (0x0b). + * The firmware filename is ibt--.sfi. + * + * Currently the supported hardware variants are: + * 11 (0x0b) for iBT 3.0 (LnP/SfP) */ - snprintf(fwname, sizeof(fwname), "intel/ibt-11-%u.sfi", - le16_to_cpu(params->dev_revid)); + snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.sfi", + le16_to_cpu(ver.hw_variant), + le16_to_cpu(params->dev_revid)); err = request_firmware(&fw, fwname, &hdev->dev); if (err < 0) { @@ -721,8 +724,9 @@ static int intel_setup(struct hci_uart *hu) bt_dev_info(hdev, "Found device firmware: %s", fwname); /* Save the DDC file name for later */ - snprintf(fwname, sizeof(fwname), "intel/ibt-11-%u.ddc", - le16_to_cpu(params->dev_revid)); + snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.ddc", + le16_to_cpu(ver.hw_variant), + le16_to_cpu(params->dev_revid)); kfree_skb(skb); -- cgit v1.2.3 From 6c7bb7ebb58c0e17b11aebf928ffc5c295959a01 Mon Sep 17 00:00:00 2001 From: Tedd Ho-Jeong An Date: Mon, 6 Mar 2017 15:38:35 -0800 Subject: Bluetooth: hci_intel: Add support Intel Bluetooth device 9160/9260 for UART This patch adds support for Intel Bluetooth device 9160/9260 also known as ThunderPeak(ThP) for UART. Signed-off-by: Tedd Ho-Jeong An Signed-off-by: Marcel Holtmann --- drivers/bluetooth/hci_intel.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/bluetooth/hci_intel.c') diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c index 71d0850fab10..d915e7eee233 100644 --- a/drivers/bluetooth/hci_intel.c +++ b/drivers/bluetooth/hci_intel.c @@ -610,6 +610,7 @@ static int intel_setup(struct hci_uart *hu) switch (ver.hw_variant) { case 0x0b: /* LnP */ case 0x0c: /* WsP */ + case 0x12: /* ThP */ break; default: bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)", -- cgit v1.2.3 From dcb9cfaa5ea9aa0ec08aeb92582ccfe3e4c719a9 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 29 Mar 2017 18:15:28 +0200 Subject: Bluetooth: hci_intel: add missing tty-device sanity check Make sure to check the tty-device pointer before looking up the sibling platform device to avoid dereferencing a NULL-pointer when the tty is one end of a Unix98 pty. Fixes: 74cdad37cd24 ("Bluetooth: hci_intel: Add runtime PM support") Fixes: 1ab1f239bf17 ("Bluetooth: hci_intel: Add support for platform driver") Cc: stable # 4.3 Cc: Loic Poulain Signed-off-by: Johan Hovold Signed-off-by: Marcel Holtmann --- drivers/bluetooth/hci_intel.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'drivers/bluetooth/hci_intel.c') diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c index d915e7eee233..fa5099986f1b 100644 --- a/drivers/bluetooth/hci_intel.c +++ b/drivers/bluetooth/hci_intel.c @@ -307,6 +307,9 @@ static int intel_set_power(struct hci_uart *hu, bool powered) struct list_head *p; int err = -ENODEV; + if (!hu->tty->dev) + return err; + mutex_lock(&intel_device_list_lock); list_for_each(p, &intel_device_list) { @@ -379,6 +382,9 @@ static void intel_busy_work(struct work_struct *work) struct intel_data *intel = container_of(work, struct intel_data, busy_work); + if (!intel->hu->tty->dev) + return; + /* Link is busy, delay the suspend */ mutex_lock(&intel_device_list_lock); list_for_each(p, &intel_device_list) { @@ -899,6 +905,8 @@ done: list_for_each(p, &intel_device_list) { struct intel_device *dev = list_entry(p, struct intel_device, list); + if (!hu->tty->dev) + break; if (hu->tty->dev->parent == dev->pdev->dev.parent) { if (device_may_wakeup(&dev->pdev->dev)) { set_bit(STATE_LPM_ENABLED, &intel->flags); @@ -1066,6 +1074,9 @@ static int intel_enqueue(struct hci_uart *hu, struct sk_buff *skb) BT_DBG("hu %p skb %p", hu, skb); + if (!hu->tty->dev) + goto out_enqueue; + /* Be sure our controller is resumed and potential LPM transaction * completed before enqueuing any packet. */ @@ -1082,7 +1093,7 @@ static int intel_enqueue(struct hci_uart *hu, struct sk_buff *skb) } } mutex_unlock(&intel_device_list_lock); - +out_enqueue: skb_queue_tail(&intel->txq, skb); return 0; -- cgit v1.2.3