aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
AgeCommit message (Collapse)Author
2017-08-07Bluetooth: bluecard: fix LED behaviorOndrej Zary
Keep power LED on during activity. LED timer races with power LED disabling in hci_close(), resulting in power LED left on after closing. Stop LED timer before disabling power LED. BTW. On cards without an activity LED, the behavior is a bit weird: The LED is on after hci_open() but only until the first data transfer. Then it's off in idle and on during activity. It could be improved by keeping the LED on in idle and flashing during activity. Signed-off-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-08-07Bluetooth: bluecard: Always enable LEDs (fix for Anycom CF-300)Ondrej Zary
Anycom CF-300 (HP C8249A) has both power and activity LEDs. However the id read in bluecard_open() is 0x73 so the driver does not enable the LEDs. Remove the CARD_HAS_PCCARD_ID check to enable LEDs. Signed-off-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-08-01Bluetooth: btusb: add ID for LiteOn 04ca:3016Brian Norris
Contains a QCA6174A-5 chipset, with USB BT. Let's support loading firmware on it. From usb-devices: T: Bus=02 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=12 MxCh= 0 D: Ver= 2.01 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=04ca ProdID=3016 Rev=00.01 C: #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I: If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb I: If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb Signed-off-by: Brian Norris <briannorris@chromium.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-07-31Bluetooth: hci_uart: Fix uninitialized alignment valueLoic Poulain
Force alignment value to the default one (1 byte) if uninitialized. This fixes hci_ll serdev driver (alignment = 0) and avoid any further issues with upcoming drivers. Signed-off-by: Loic Poulain <loic.poulain@gmail.com> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-07-28Bluetooth: btrtl: Fix a error code in rtl_load_config()Dan Carpenter
We accidentally return success if the kmemdup() fails. It results in a NULL dereference in the caller. Fixes: 1110a2dbe698 ("Bluetooth: btrtl: Add RTL8822BE Bluetooth device") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-07-24Bluetooth: hci_nokia: select BT_BCM for btbcm_set_bdaddr()Marcel Holtmann
The Nokia devices require the setup of its Public Bluetooth Device Address and for that it is required to depend on vendor specific commands. For Broadcom based Nokia devices, that is part of btbcm module and can be selected via BT_BCM config option. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-07-24Bluetooth: btusb: Fix memory leak in play_deferredJeffy Chen
Currently we are calling usb_submit_urb directly to submit deferred tx urbs after unanchor them. So the usb_giveback_urb_bh would failed to unref it in usb_unanchor_urb and cause memory leak: unreferenced object 0xffffffc0ce0fa400 (size 256): ... backtrace: [<ffffffc00034a9a8>] __save_stack_trace+0x48/0x6c [<ffffffc00034b088>] create_object+0x138/0x254 [<ffffffc0009d5504>] kmemleak_alloc+0x58/0x8c [<ffffffc000345f78>] __kmalloc+0x1d4/0x2a0 [<ffffffc0006765bc>] usb_alloc_urb+0x30/0x60 [<ffffffbffc128598>] alloc_ctrl_urb+0x38/0x120 [btusb] [<ffffffbffc129e7c>] btusb_send_frame+0x64/0xf8 [btusb] Put those urbs in tx_anchor to avoid the leak, and also fix the error handling. Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> Reviewed-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-07-22Bluetooth: Style fix - align block commentsDerek Robson
Fixed alignment of all block comments. Found using checkpatch Signed-off-by: Derek Robson <robsonde@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-07-20Bluetooth: btwilink: remove unnecessary static in bt_ti_probe()Gustavo A. R. Silva
Remove unnecessary static on local variable hst. Such variable is initialized before being used, on every execution path throughout the function. The static has no benefit and, removing it reduces the object file size. This issue was detected using Coccinelle and the following semantic patch: @bad exists@ position p; identifier x; type T; @@ static T x@p; ... x = <+...x...+> @@ identifier x; expression e; type T; position p != bad.p; @@ -static T x@p; ... when != x when strict ?x = e; In the following log you can see the difference in the object file size. This log is the output of the size command, before and after the code change: before: text data bss dec hex filename 4029 2528 128 6685 1a1d drivers/bluetooth/btwilink.o after: text data bss dec hex filename 4007 2472 64 6543 198f drivers/bluetooth/btwilink.o Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-07-20Bluetooth: hci_ll: Use new hci_uart_unregister_device() functionIan Molton
Convert hci_ll to use hci_uart_unregister_device(). This simplifies the _remove() handler as well as fixes a potential race condition on unload. Signed-off-by: Ian Molton <ian@mnementh.co.uk> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabor.co.uk> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-07-20Bluetooth: hci_nokia: Use new hci_uart_unregister_device() functionIan Molton
Simplify _remove() path for hci_nokia.c Signed-off-by: Ian Molton <ian@mnementh.co.uk> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabor.co.uk> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-07-20Bluetooth: hci_serdev: Introduce hci_uart_unregister_device()Ian Molton
Several drivers have the same (and incorrect) code in their _remove() handler. Coalesce this into a shared function. Signed-off-by: Ian Molton <ian@mnementh.co.uk> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-07-20Bluetooth: btusb: fix QCA Rome suspend/resumeLeif Liddy
There's been numerous reported instances where BTUSB_QCA_ROME bluetooth controllers stop functioning upon resume from suspend. These devices seem to be losing power during suspend. Patch will detect a status change on resume and perform a reset. Signed-off-by: Leif Liddy <leif.linux@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-07-20Bluetooth: hci_nokia: remove duplicate call to pm_runtime_disable()Ian Molton
pm_runtime_disable() is called in the _close() handler. Since we call the _close() handler on remove, there is no need to call pm_runtime_disable() a second time. Signed-off-by: Ian Molton <ian@mnementh.co.uk> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-07-20Bluetooth: hci_nokia: prevent crash on module removalIan Molton
Only cancel any ongoing work after making sure, that no new work can be scheduled. This fixes a race condition in the remove handler. Signed-off-by: Ian Molton <ian@mnementh.co.uk> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-07-20Bluetooth: btqca: Fixed a coding style errorJoan Jani
Fixed this coding style erro ./drivers/bluetooth/btqca.c:84: ERROR: code indent should use tabs where possible Signed-off-by: Joan Jani <igiann@hotmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-07-20Bluetooth: btusb: Add support of all Foxconn (105b) Broadcom devicesDmitry Tunin
There is another device T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=12 MxCh= 0 D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=105b ProdID=e066 Rev=01.12 S: Manufacturer=Broadcom Corp S: Product=BCM20702A0 S: SerialNumber=342387DAE35E C: #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=0mA I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none) I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none) I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none) I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none) Since we have Cls=ff, we can add all of them. Signed-off-by: Dmitry Tunin <hanipouspilot@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-07-20Bluetooth: hci_bcm: Make bcm_request_irq fail if no IRQ resourceLoic Poulain
In case of no IRQ resource associated to the bcm_device, requesting IRQ should return an error in order to not enable low power mgmt. Signed-off-by: Loic Poulain <loic.poulain@gmail.com> Reported-by: Ian Molton <ian@mnementh.co.uk> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-07-05Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-nextLinus Torvalds
Pull networking updates from David Miller: "Reasonably busy this cycle, but perhaps not as busy as in the 4.12 merge window: 1) Several optimizations for UDP processing under high load from Paolo Abeni. 2) Support pacing internally in TCP when using the sch_fq packet scheduler for this is not practical. From Eric Dumazet. 3) Support mutliple filter chains per qdisc, from Jiri Pirko. 4) Move to 1ms TCP timestamp clock, from Eric Dumazet. 5) Add batch dequeueing to vhost_net, from Jason Wang. 6) Flesh out more completely SCTP checksum offload support, from Davide Caratti. 7) More plumbing of extended netlink ACKs, from David Ahern, Pablo Neira Ayuso, and Matthias Schiffer. 8) Add devlink support to nfp driver, from Simon Horman. 9) Add RTM_F_FIB_MATCH flag to RTM_GETROUTE queries, from Roopa Prabhu. 10) Add stack depth tracking to BPF verifier and use this information in the various eBPF JITs. From Alexei Starovoitov. 11) Support XDP on qed device VFs, from Yuval Mintz. 12) Introduce BPF PROG ID for better introspection of installed BPF programs. From Martin KaFai Lau. 13) Add bpf_set_hash helper for TC bpf programs, from Daniel Borkmann. 14) For loads, allow narrower accesses in bpf verifier checking, from Yonghong Song. 15) Support MIPS in the BPF selftests and samples infrastructure, the MIPS eBPF JIT will be merged in via the MIPS GIT tree. From David Daney. 16) Support kernel based TLS, from Dave Watson and others. 17) Remove completely DST garbage collection, from Wei Wang. 18) Allow installing TCP MD5 rules using prefixes, from Ivan Delalande. 19) Add XDP support to Intel i40e driver, from Björn Töpel 20) Add support for TC flower offload in nfp driver, from Simon Horman, Pieter Jansen van Vuuren, Benjamin LaHaise, Jakub Kicinski, and Bert van Leeuwen. 21) IPSEC offloading support in mlx5, from Ilan Tayari. 22) Add HW PTP support to macb driver, from Rafal Ozieblo. 23) Networking refcount_t conversions, From Elena Reshetova. 24) Add sock_ops support to BPF, from Lawrence Brako. This is useful for tuning the TCP sockopt settings of a group of applications, currently via CGROUPs" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1899 commits) net: phy: dp83867: add workaround for incorrect RX_CTRL pin strap dt-bindings: phy: dp83867: provide a workaround for incorrect RX_CTRL pin strap cxgb4: Support for get_ts_info ethtool method cxgb4: Add PTP Hardware Clock (PHC) support cxgb4: time stamping interface for PTP nfp: default to chained metadata prepend format nfp: remove legacy MAC address lookup nfp: improve order of interfaces in breakout mode net: macb: remove extraneous return when MACB_EXT_DESC is defined bpf: add missing break in for the TCP_BPF_SNDCWND_CLAMP case bpf: fix return in load_bpf_file mpls: fix rtm policy in mpls_getroute net, ax25: convert ax25_cb.refcount from atomic_t to refcount_t net, ax25: convert ax25_route.refcount from atomic_t to refcount_t net, ax25: convert ax25_uid_assoc.refcount from atomic_t to refcount_t net, sctp: convert sctp_ep_common.refcnt from atomic_t to refcount_t net, sctp: convert sctp_transport.refcnt from atomic_t to refcount_t net, sctp: convert sctp_chunk.refcnt from atomic_t to refcount_t net, sctp: convert sctp_datamsg.refcnt from atomic_t to refcount_t net, sctp: convert sctp_auth_bytes.refcnt from atomic_t to refcount_t ...
2017-06-29Bluetooth: btbcm: Add entry for BCM43430 UART bluetoothIan Molton
This patch adds the device ID for the bluetooth chip used in the Broadcom BCM43430 SDIO WiFi / UART BT chip. Successfully tested using Firmware version 0x0182 Signed-off-by: Ian Molton <ian@mnementh.co.uk> Reported-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-06-29Bluetooth: hci_bcm: Add active_low irq polarity quirk for Asus T100CHIHans de Goede
Just like the T100TA the host-wake irq on the Asus T100CHI is active low. Having a quirk for this is actually extra important on the T100CHI as it ships with a bluetooth keyboard dock, which does not work properly without this quirk. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-06-27Bluetooth: hci_bcm: Fix unwanted error reporting if no bcm devLoic Poulain
The hci_bcm proto is able to operate without bcm platform device linked to its uart port. In that case, firmware can be applied, but there is no power operation (no gpio/irq resources mgmt). However, the current implementation breaks this use case because of reporting a ENODEV error in the bcm setup procedure if bcm_request_irq fails (which is the case if no bcm device linked). Fix this by removing bcm_request_irq error forwarding. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Reported-by: Ian Molton <ian@mnementh.co.uk> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-06-23Bluetooth: hci_serdev: make hci_serdev_client_ops staticColin Ian King
The structure hci_serdev_client_ops does not need to be in global scope and is not modified, so make it static. Cleans up sparse warning: "symbol 'hci_serdev_client_ops' was not declared. Should it be static?" Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-06-20sched/wait: Rename wait_queue_t => wait_queue_entry_tIngo Molnar
Rename: wait_queue_t => wait_queue_entry_t 'wait_queue_t' was always a slight misnomer: its name implies that it's a "queue", but in reality it's a queue *entry*. The 'real' queue is the wait queue head, which had to carry the name. Start sorting this out by renaming it to 'wait_queue_entry_t'. This also allows the real structure name 'struct __wait_queue' to lose its double underscore and become 'struct wait_queue_entry', which is the more canonical nomenclature for such data types. Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-06-16networking: add and use skb_put_u8()Johannes Berg
Joe and Bjørn suggested that it'd be nicer to not have the cast in the fairly common case of doing *(u8 *)skb_put(skb, 1) = c; Add skb_put_u8() for this case, and use it across the code, using the following spatch: @@ expression SKB, C, S; typedef u8; identifier fn = {skb_put}; fresh identifier fn2 = fn ## "_u8"; @@ - *(u8 *)fn(SKB, S) = C; + fn2(SKB, C); Note that due to the "S", the spatch isn't perfect, it should have checked that S is 1, but there's also places that use a sizeof expression like sizeof(var) or sizeof(u8) etc. Turns out that nobody ever did something like *(u8 *)skb_put(skb, 2) = c; which would be wrong anyway since the second byte wouldn't be initialized. Suggested-by: Joe Perches <joe@perches.com> Suggested-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16networking: make skb_push & __skb_push return void pointersJohannes Berg
It seems like a historic accident that these return unsigned char *, and in many places that means casts are required, more often than not. Make these functions return void * and remove all the casts across the tree, adding a (u8 *) cast only where the unsigned char pointer was used directly, all done with the following spatch: @@ expression SKB, LEN; typedef u8; identifier fn = { skb_push, __skb_push, skb_push_rcsum }; @@ - *(fn(SKB, LEN)) + *(u8 *)fn(SKB, LEN) @@ expression E, SKB, LEN; identifier fn = { skb_push, __skb_push, skb_push_rcsum }; type T; @@ - E = ((T *)(fn(SKB, LEN))) + E = fn(SKB, LEN) @@ expression SKB, LEN; identifier fn = { skb_push, __skb_push, skb_push_rcsum }; @@ - fn(SKB, LEN)[0] + *(u8 *)fn(SKB, LEN) Note that the last part there converts from push(...)[0] to the more idiomatic *(u8 *)push(...). Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16networking: make skb_pull & friends return void pointersJohannes Berg
It seems like a historic accident that these return unsigned char *, and in many places that means casts are required, more often than not. Make these functions return void * and remove all the casts across the tree, adding a (u8 *) cast only where the unsigned char pointer was used directly, all done with the following spatch: @@ expression SKB, LEN; typedef u8; identifier fn = { skb_pull, __skb_pull, skb_pull_inline, __pskb_pull_tail, __pskb_pull, pskb_pull }; @@ - *(fn(SKB, LEN)) + *(u8 *)fn(SKB, LEN) @@ expression E, SKB, LEN; identifier fn = { skb_pull, __skb_pull, skb_pull_inline, __pskb_pull_tail, __pskb_pull, pskb_pull }; type T; @@ - E = ((T *)(fn(SKB, LEN))) + E = fn(SKB, LEN) Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16networking: make skb_put & friends return void pointersJohannes Berg
It seems like a historic accident that these return unsigned char *, and in many places that means casts are required, more often than not. Make these functions (skb_put, __skb_put and pskb_put) return void * and remove all the casts across the tree, adding a (u8 *) cast only where the unsigned char pointer was used directly, all done with the following spatch: @@ expression SKB, LEN; typedef u8; identifier fn = { skb_put, __skb_put }; @@ - *(fn(SKB, LEN)) + *(u8 *)fn(SKB, LEN) @@ expression E, SKB, LEN; identifier fn = { skb_put, __skb_put }; type T; @@ - E = ((T *)(fn(SKB, LEN))) + E = fn(SKB, LEN) which actually doesn't cover pskb_put since there are only three users overall. A handful of stragglers were converted manually, notably a macro in drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many instances in net/bluetooth/hci_sock.c. In the former file, I also had to fix one whitespace problem spatch introduced. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16networking: introduce and use skb_put_data()Johannes Berg
A common pattern with skb_put() is to just want to memcpy() some data into the new space, introduce skb_put_data() for this. An spatch similar to the one for skb_put_zero() converts many of the places using it: @@ identifier p, p2; expression len, skb, data; type t, t2; @@ ( -p = skb_put(skb, len); +p = skb_put_data(skb, data, len); | -p = (t)skb_put(skb, len); +p = skb_put_data(skb, data, len); ) ( p2 = (t2)p; -memcpy(p2, data, len); | -memcpy(p, data, len); ) @@ type t, t2; identifier p, p2; expression skb, data; @@ t *p; ... ( -p = skb_put(skb, sizeof(t)); +p = skb_put_data(skb, data, sizeof(t)); | -p = (t *)skb_put(skb, sizeof(t)); +p = skb_put_data(skb, data, sizeof(t)); ) ( p2 = (t2)p; -memcpy(p2, data, sizeof(*p)); | -memcpy(p, data, sizeof(*p)); ) @@ expression skb, len, data; @@ -memcpy(skb_put(skb, len), data, len); +skb_put_data(skb, data, len); (again, manually post-processed to retain some comments) Reviewed-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-14Bluetooth: btusb: Add support for 0489:e0a2 QCA_ROME deviceShih-Yuan Lee (FourDollars)
T: Bus=01 Lev=01 Prnt=01 Port=06 Cnt=03 Dev#= 3 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0489 ProdID=e0a2 Rev=00.01 C: #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I: If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb I: If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb Signed-off-by: Shih-Yuan Lee (FourDollars) <sylee@canonical.com> Suggested-by: Owen Lin <olin@rivetnetworks.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-06-12Bluetooth: btbcm: Read controller features during configurationMarcel Holtmann
Read the Broadcom specific controller features during configuration and print them for informational purposes. < HCI Command: Broadcom Read Controller Features (0x3f|0x006e) plen 0 > HCI Event: Command Complete (0x0e) plen 12 Broadcom Read Controller Features (0x3f|0x006e) ncmd 1 Status: Success (0x00) Features: 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Multi-AV transport bandwidth reducer WBS SBC FW LC-PLC Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2017-06-09Bluetooth: hci_intel: Add GPIO ACPI mapping tableAndy Shevchenko
In order to make GPIO ACPI library stricter prepare users of gpiod_get_index() to correctly behave when there no mapping is provided by firmware. Here we add explicit mapping between _CRS GpioIo() resources and their names used in the driver. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-06-09Bluetooth: hci_bcm: Switch to devm_acpi_dev_add_driver_gpios()Andy Shevchenko
Switch to use managed variant of acpi_dev_add_driver_gpios() to simplify error path and fix potentially wrong assingment if ->probe() fails. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-06-09Bluetooth: hci_ll: Add support for the external clockUlf Hansson
Add support to manage the external clock provided to the WiLink combo chip as it's needed for any of the transport interfaces. To avoid breaking platforms not yet specifying the external clock, we make it optional. In case the clock is successfully fetched during ->probe(), let's manage it via the ->open|close() callbacks, to make sure the device get properly powered on/off. Fixes: ea452678734e ("arm64: dts: hikey: Fix WiFi support") Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Tested-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-06-09Bluetooth: hci_ll: Add compatible values for more WL chipsSebastian Reichel
Add compatible values for WiLink chips from 128x and 180x series. Also the DT binding already contained compatible values for the 127x series, but the driver did not. This brings the list on par with the list from wlcore (the wifi driver). Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-05-23Bluetooth: btintel: Add MODULE_FIRMWARE entries for iBT 3.5 controllersJürg Billeter
The iBT 3.5 controllers (Intel 8265, Windstorm Peak) need intel/ibt-12-16.sfi and intel/ibt-12-16.ddc firmware files from linux-firmware repository. Signed-off-by: Jürg Billeter <j@bitron.ch> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-05-23Bluetooth: btwilink: Fix unexpected skb freeLoic Poulain
The caller (hci_core) still owns the skb in case of error, releasing it inside the send function can lead to use-after-free errors. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-05-23Bluetooth: hci_ll: Fix download_firmware() return when __hci_cmd_sync failsGuodong Xu
When __hci_cmd_sync() fails, download_firmware() should also fail, and the same error value should be returned as PTR_ERR(skb). Without this fix, download_firmware() will return a success when it actually failed in __hci_cmd_sync(). Fixes: 371805522f87 ("bluetooth: hci_uart: add LL protocol serdev driver support") Signed-off-by: Guodong Xu <guodong.xu@linaro.org> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-05-18Bluetooth: hci_nokia: select BT_HCIUART_H4Tobias Regnery
We see the following build failure with CONFIG_BT_HCIUART_NOKIA=y and CONFIG_BT_HCIUART_H4=n: drivers/bluetooth/hci_nokia.c: In function 'nokia_recv': drivers/bluetooth/hci_nokia.c:644:18: error: implicit declaration of function 'h4_recv_buf' [-Werror=implicit-function-declaration] ... Fix this by selecting the BT_HCIUART_H4 symbol like all the other users of the protocoll. Fixes: 7bb318680e86 ("Bluetooth: add nokia driver") Signed-off-by: Tobias Regnery <tobias.regnery@gmail.com> Reviewed-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-05-18Bluetooth: hci_ldisc: Use rwlocking to avoid closing proto racesDean Jenkins
When HCI_UART_PROTO_READY is in the set state, the Data Link protocol layer (proto) is bound to the HCI UART driver. This state allows the registered proto function pointers to be used by the HCI UART driver. When unbinding (closing) the Data Link protocol layer, the proto function pointers much be prevented from being used immediately before running the proto close function pointer. Otherwise, there is a risk that a proto non-close function pointer is used during or after the proto close function pointer is used. The consequences are likely to be a kernel crash because the proto close function pointer will free resources used in the Data Link protocol layer. Therefore, add a reader writer lock (rwlock) solution to prevent the close proto function pointer from running by using write_lock_irqsave() whilst the other proto function pointers are protected using read_lock(). This means HCI_UART_PROTO_READY can safely be cleared in the knowledge that no proto function pointers are running. When flag HCI_UART_PROTO_READY is put into the clear state, proto close function pointer can safely be run. Note flag HCI_UART_PROTO_SET being in the set state prevents the proto open function pointer from being run so there is no race condition between proto open and close function pointers. Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-05-18Bluetooth: hci_uart: fix kconfig dependencyTobias Regnery
We see the following link error with CONFIG_BT_HCIUART=y, CONFIG_BT_HCIUART_LL=y and CONFIG_SERIAL_DEV_BUS=m: drivers/built-in.o: In function 'll_close': supp.c:(.text+0x55add4): undefined reference to 'serdev_device_close' supp.c:(.text+0x55add4): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol 'serdev_device_close' drivers/built-in.o: In function 'll_open': supp.c:(.text+0x55aed0): undefined reference to 'serdev_device_open' supp.c:(.text+0x55aed0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol 'serdev_device_open' drivers/built-in.o: In function `hci_ti_probe': supp.c:(.text+0x55b00c): undefined reference to 'hci_uart_register_device' supp.c:(.text+0x55b00c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol 'hci_uart_register_device' drivers/built-in.o: In function `ll_setup': supp.c:(.text+0x55b08c): undefined reference to 'serdev_device_set_flow_control' supp.c:(.text+0x55b08c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol 'serdev_device_set_flow_control' supp.c:(.text+0x55b324): undefined reference to 'serdev_device_set_baudrate' supp.c:(.text+0x55b324): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol 'serdev_device_set_baudrate' drivers/built-in.o: In function 'll_init': supp.c:(.init.text+0x1b508): undefined reference to '__serdev_device_driver_register' supp.c:(.init.text+0x1b508): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol '__serdev_device_driver_register' Fix this by dependig BT_HCIUART_LL on the BT_HCIUART_SERDEV symbol. This implies a dependency on BT_HCIUART and hci_ll.c is only compiled in if SERIAl_DEV_BUS is built in or SERIAL_DEV_BUS and BT_HCIUART are modules. Fixes: 371805522f87 ("bluetooth: hci_uart: add LL protocol serdev driver support") Signed-off-by: Tobias Regnery <tobias.regnery@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-05-18Bluetooth: Add support for Intel Bluetooth device 9460/9560 [8087:0aaa]Tedd Ho-Jeong An
This patch adds support for Intel Bluetooth device 9460/9560 also known as Jefferson Peak (JfP). The firmware downloading mechanism is same as previous generation. So include the new USB product identifier and whitelist the hardware variant. T: Bus=01 Lev=01 Prnt=01 Port=09 Cnt=04 Dev#= 5 Spd=12 MxCh= 0 D: Ver= 2.01 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=8087 ProdID=0aaa Rev= 0.02 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 64 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms I: If#= 1 Alt= 6 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 63 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 63 Ivl=1ms Bootloader version: < HCI Command: Intel Read Version (0x3f|0x0005) plen 0 > HCI Event: Command Complete (0x0e) plen 13 Intel Read Version (0x3f|0x0005) ncmd 32 Status: Success (0x00) Hardware platform: 0x37 Hardware variant: 0x11 Hardware revision: 0.0 Firmware variant: 0x06 Firmware revision: 0.1 Firmware build: 42-52.2015 Firmware patch: 0 Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-30Bluetooth: hci_ldisc: Add protocol check to hci_uart_tx_wakeup()Dean Jenkins
Before attempting to schedule a work-item onto hu->write_work in hci_uart_tx_wakeup(), check that the Data Link protocol layer is still bound to the HCI UART driver. Failure to perform this protocol check causes a race condition between the work queue hu->write_work running hci_uart_write_work() and the Data Link protocol layer being unbound (closed) in hci_uart_tty_close(). Note hci_uart_tty_close() does have a "cancel_work_sync(&hu->write_work)" but it is ineffective because it cannot prevent work-items being added to hu->write_work after cancel_work_sync() has run. Therefore, add a check for HCI_UART_PROTO_READY into hci_uart_tx_wakeup() which prevents scheduling of the work queue when HCI_UART_PROTO_READY is in the clear state. However, note a small race condition remains because the hci_uart_tx_wakeup() thread can run in parallel with the hci_uart_tty_close() thread so it is possible that a schedule of hu->write_work can occur when HCI_UART_PROTO_READY is cleared. A complete solution needs locking of the threads which is implemented in a future commit. Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-30Bluetooth: hci_ldisc: Add protocol check to hci_uart_dequeue()Dean Jenkins
Before attempting to dequeue a Data Link protocol encapsulated message, check that the Data Link protocol is still bound to the HCI UART driver. This makes the code consistent with the usage of the other proto function pointers. Therefore, add a check for HCI_UART_PROTO_READY into hci_uart_dequeue() and return NULL if the Data Link protocol is not bound. This is needed for robustness as there is a scheduling race condition. hci_uart_write_work() is scheduled to run via work queue hu->write_work from hci_uart_tx_wakeup(). Therefore, there is a delay between scheduling hci_uart_write_work() to run and hci_uart_dequeue() running whereby the Data Link protocol layer could become unbound during the scheduling delay. In this case, without the check, the call to the unbound Data Link protocol layer dequeue function can crash. It is noted that hci_uart_tty_close() has a "cancel_work_sync(&hu->write_work)" statement but this only reduces the window of the race condition because it is possible for a new work-item to be added to work queue hu->write_work after the call to cancel_work_sync(). For example, Data Link layer retransmissions can be added to the work queue after the cancel_work_sync() has finished. Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-30Bluetooth: hci_ldisc: Add protocol check to hci_uart_send_frame()Dean Jenkins
Before attempting to send a HCI message, check that the Data Link protocol is still bound to the HCI UART driver. This makes the code consistent with the usage of the other proto function pointers. Therefore, add a check for HCI_UART_PROTO_READY into hci_uart_send_frame() and return -EUNATCH if the Data Link protocol is not bound. This also allows hci_send_frame() to report the error of an unbound Data Link protocol layer. Therefore, it assists with diagnostics into why HCI messages are being sent when the Data Link protocol is not bound and avoids potential crashes. Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-30Bluetooth: Add module license for HCI UART Nokia H4+Frédéric Danis
Fix the following error preventing to load Nokia H4+ module: kernel: [ 826.461619] hci_nokia: module license 'unspecified' taints kernel. kernel: [ 826.461629] Disabling lock debugging due to kernel taint kernel: [ 826.461836] hci_nokia: Unknown symbol gpiod_get_value_cansleep (err 0) kernel: [ 826.461876] hci_nokia: Unknown symbol devm_kmalloc (err 0) kernel: [ 826.461908] hci_nokia: Unknown symbol gpiod_set_value (err 0) kernel: [ 826.461937] hci_nokia: Unknown symbol serdev_device_set_baudrate (err 0) kernel: [ 826.461994] hci_nokia: Unknown symbol gpiod_set_value_cansleep (err 0) kernel: [ 826.462021] hci_nokia: Unknown symbol hci_uart_tx_wakeup (err 0) kernel: [ 826.462043] hci_nokia: Unknown symbol serdev_device_set_flow_control (err 0) kernel: [ 826.462064] hci_nokia: Unknown symbol gpiod_to_irq (err 0) kernel: [ 826.462085] hci_nokia: Unknown symbol serdev_device_open (err 0) kernel: [ 826.462106] hci_nokia: Unknown symbol gpiod_get_value (err 0) kernel: [ 826.462150] hci_nokia: Unknown symbol clk_prepare (err 0) kernel: [ 826.462182] hci_nokia: Unknown symbol pm_runtime_enable (err 0) kernel: [ 826.462204] hci_nokia: Unknown symbol h4_recv_buf (err 0) kernel: [ 826.462246] hci_nokia: Unknown symbol serdev_device_write_flush (err 0) kernel: [ 826.462268] hci_nokia: Unknown symbol serdev_device_get_tiocm (err 0) kernel: [ 826.462298] hci_nokia: Unknown symbol driver_unregister (err 0) kernel: [ 826.462318] hci_nokia: Unknown symbol serdev_device_wait_until_sent (err 0) kernel: [ 826.462347] hci_nokia: Unknown symbol __serdev_device_driver_register (err 0) kernel: [ 826.462384] hci_nokia: Unknown symbol serdev_device_set_tiocm (err 0) kernel: [ 826.462417] hci_nokia: Unknown symbol clk_get_rate (err 0) kernel: [ 826.462454] hci_nokia: Unknown symbol __pm_runtime_resume (err 0) kernel: [ 826.462486] hci_nokia: Unknown symbol serdev_device_close (err 0) kernel: [ 826.462524] hci_nokia: Unknown symbol cancel_work_sync (err 0) kernel: [ 826.462546] hci_nokia: Unknown symbol btbcm_set_bdaddr (err 0) kernel: [ 826.462567] hci_nokia: Unknown symbol clk_disable (err 0) kernel: [ 826.462610] hci_nokia: Unknown symbol __pm_runtime_disable (err 0) kernel: [ 826.462632] hci_nokia: Unknown symbol hci_uart_register_device (err 0) kernel: [ 826.462653] hci_nokia: Unknown symbol clk_enable (err 0) kernel: [ 826.462675] hci_nokia: Unknown symbol __pm_runtime_idle (err 0) kernel: [ 826.462700] hci_nokia: Unknown symbol clk_unprepare (err 0) Signed-off-by: Frédéric Danis <frederic.danis.oss@gmail.com> Acked-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-22Bluetooth: hci_ldisc: Add missing clear HCI_UART_PROTO_READYDean Jenkins
Ensure that HCI_UART_PROTO_READY is cleared before close(hu) is called which closes the Data Link protocol layer. Therefore, add the missing bit clear of HCI_UART_PROTO_READY to hci_uart_init_work() so that the flag is cleared when hci_register_dev fails. Without the fix, the functions of the Data Link protocol layer could potentially be accessed after that layer has been closed. This could lead to a crash as memory would have been freed in that layer. Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-22Bluetooth: hci_ldisc: Ensure hu->hdev set to NULL before freeing hdevDean Jenkins
When hci_register_dev() fails, hu->hdev should be set to NULL before freeing hdev. This avoids potential use of hu->hdev after it has been freed. This commit sets hu->hdev to NULL before calling hci_free_dev() in error handling scenarios in hci_uart_init_work() and hci_uart_register_dev(). Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-22Bluetooth: hci_ldisc: Add missing return in hci_uart_init_work()Dean Jenkins
If hci_register_dev() returns an error in hci_uart_init_work() then the HCI_UART_REGISTERED bit gets erroneously set due to a missing return statement. Therefore, add the missing return statement. The consequence of the missing return is that the HCI UART is not registered but HCI_UART_REGISTERED is set which allows the code to think that hu->hdev is safe to access but hu->hdev has been freed so could lead to a crash. Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-22Bluetooth: try to improve CONFIG_SERIAL_DEV_BUS dependencyArnd Bergmann
With CONFIG_SERIAL_DEV_BUS=m, the hci_serdev.o file does not actually get built into hci_uart.o as the Makefile doesn't pick it up, leading to a link error with anything referring to it: ERROR: "hci_uart_register_device" [drivers/bluetooth/hci_nokia.ko] undefined! scripts/Makefile.modpost:91: recipe for target '__modpost' failed Changing this in the Makefile would cause another problem when hci_uart itself is built-in and cannot reference symbols from the serdev module. This tries to address both problems by introducing a new hidden Kconfig symbol that controls both the compilation of hci_serdev.o and whether the Nokia driver can be selected. This seems to address the problem for me, though there might be a better way to do it. Fixes: 7bb318680e86 ("Bluetooth: add nokia driver") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>