aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth/btwilink.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-07-22Bluetooth: Style fix - align block commentsDerek Robson1-3/+3
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. Silva1-1/+1
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-05-23Bluetooth: btwilink: Fix unexpected skb freeLoic Poulain1-1/+0
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>
2016-10-20Bluetooth: btwilink: Fix probe return valueJacob Siverskog1-1/+1
Probe functions should return 0 on success. This driver's probe returns the value returned by hci_register_dev(), which is the hci index. This works for systems with only one hci device (id = 0) but for systems where the btwilink device ends up with an id larger than 0, things will start to fall apart. Make the probe function return 0 on success. Signed-off-by: Jacob Siverskog <jacob@teenage.engineering> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-09-22Bluetooth: btwilink: Save the packet type before sendingLaura Abbott1-1/+3
Running with KASAN produces some messages: BUG: KASAN: use-after-free in ti_st_send_frame+0x9c/0x16c at addr ffffffc064868fe8 Read of size 1 by task kworker/u17:1/1266 <KASAN output trimmed> Hardware name: HiKey Development Board (DT) Workqueue: hci0 hci_cmd_work Call trace: [<ffffffc00008c00c>] dump_backtrace+0x0/0x178 [<ffffffc00008c1a4>] show_stack+0x20/0x28 [<ffffffc00067da38>] dump_stack+0xa8/0xe0 [<ffffffc000288430>] print_trailer+0x110/0x174 [<ffffffc00028aedc>] object_err+0x4c/0x5c [<ffffffc00028f714>] kasan_report_error+0x254/0x54c [<ffffffc00028fa70>] kasan_report+0x64/0x70 [<ffffffc00028eb8c>] __asan_load1+0x4c/0x54 [<ffffffc000b59b24>] ti_st_send_frame+0x9c/0x16c [<ffffffc000ee8dcc>] hci_send_frame+0xb4/0x118 [<ffffffc000ee8efc>] hci_cmd_work+0xcc/0x154 [<ffffffc0000f6c48>] process_one_work+0x26c/0x7a4 [<ffffffc0000f721c>] worker_thread+0x9c/0x73c [<ffffffc000100250>] kthread+0x138/0x154 [<ffffffc000085c50>] ret_from_fork+0x10/0x40 The packet is being accessed for statistics after it has been freed. Save the packet type before sending for statistics afterwards. Signed-off-by: Laura Abbott <labbott@redhat.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-07-17drivers: misc: ti-st: Use int instead of fuzzy char for callback statusGeert Uytterhoeven1-2/+2
On mips and parisc: drivers/bluetooth/btwilink.c: In function 'ti_st_open': drivers/bluetooth/btwilink.c:174:21: warning: overflow in implicit constant conversion [-Woverflow] hst->reg_status = -EINPROGRESS; drivers/nfc/nfcwilink.c: In function 'nfcwilink_open': drivers/nfc/nfcwilink.c:396:31: warning: overflow in implicit constant conversion [-Woverflow] drv->st_register_cb_status = -EINPROGRESS; There are actually two issues: 1. Whether "char" is signed or unsigned depends on the architecture. As the completion callback data is used to pass a (negative) error code, it should always be signed. 2. EINPROGRESS is 150 on mips, 245 on parisc. Hence -EINPROGRESS doesn't fit in a signed 8-bit number. Change the callback status from "char" to "int" to fix these. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Acked-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-11-19Bluetooth: Use new hci_skb_pkt_* wrappers for driversMarcel Holtmann1-4/+4
The new hci_skb_pkt_* wrappers are mainly intented for drivers to require less knowledge about bt_cb(sbk) handling. So after converting the core packet handling, convert all drivers. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-10-05Bluetooth: Move handling of HCI_RUNNING flag into coreMarcel Holtmann1-10/+0
Setting and clearing of HCI_RUNNING flag in each and every driver is just duplicating the same code all over the place. So instead of having the driver do it in their hdev->open and hdev->close callbacks, set it globally in the core transport handling. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-10-05Bluetooth: Move HCI_RUNNING check into hci_send_frameMarcel Holtmann1-3/+0
In all callbacks for hdev->send the status of HCI_RUNNING is checked. So instead of repeating that code in every driver, move the check into the hci_send_frame function before calling hdev->send. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-05-13Bluetooth: btwilink: remove DEBUG defineLeo Yan1-1/+1
Remove the DEBUG define as the debug code; so can remove mass debug info from log buffer when using dmesg. Signed-off-by: Leo Yan <leo.yan@linaro.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2014-10-20bluetooth: drop owner assignment from platform_driversWolfram Sang1-1/+0
A platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2013-10-11Bluetooth: Add hdev parameter to hdev->send driver callbackMarcel Holtmann1-4/+1
Instead of masking hdev inside the skb->dev parameter, hand it directly to the driver as a parameter to hdev->send. This makes the driver interface more clear and simpler. This patch fixes all drivers to accept and handle the new parameter of hdev->send callback. Special care has been taken for bpa10x and btusb drivers that require having skb->dev set to hdev for the URB transmit complete handlers. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-11Bluetooth: Provide hdev parameter to hci_recv_frame() driver callbackMarcel Holtmann1-3/+1
To avoid casting skb->dev into hdev, just let the drivers provide the hdev directly when calling hci_recv_frame() function. This patch also fixes up all drivers to provide the hdev. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-09-08Bluetooth: Use module_platform_driver() in btwilink.c fileSachin Kamat1-15/+1
module_platform_driver() makes the code simpler by eliminating module_init and module_exit calls. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
2012-08-06Bluetooth: Use devm_kzalloc in btwilink.c fileSachin Kamat1-6/+2
devm_kzalloc() eliminates the need to free memory explicitly thereby saving some cleanup code. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
2012-02-13Bluetooth: Remove hci_dev->driver_dataDavid Herrmann1-4/+4
The linux device model provides dev_set/get_drvdata so we can use this to save private driver data. This also removes several unnecessary casts. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-02-13Bluetooth: Remove HCI-owner fieldDavid Herrmann1-1/+0
After unregistering an hci_dev object a bluetooth driver does not have any callbacks in the hci_dev structure left over. Therefore, there is no need to keep a reference to the module. Previously, we needed this to protect the hci-destruct callback. However, this callback is no longer available so we do not need this owner field, anymore. Drivers now call hci_unregister_dev() and they are done with the object. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-02-13Bluetooth: btwilink: Remove empty destruct cbDavid Herrmann1-9/+0
The destruct cb is optional so remove our empty dummy cb. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2011-10-31bluetooth: add module.h to drivers/bluetooth files as required.Paul Gortmaker1-0/+1
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2011-09-17Bluetooth: Fixed BT ST Channel reg orderChen Ganir1-8/+8
Reordered the BT ST channel registration, to make sure that the event channel is registered before all others. This prevents a situation where incoming events may cause kernel panic in the ST driver if the event channel is not yet registered to handle incoming events.In addition, the deregistration of the channels was also modified, to be in the reversed order of the registration, to allow the event channel to be the last one unregistered. Signed-off-by: Chen Ganir <chen.ganir@ti.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-02-23Bluetooth: btwilink driverPavan Savoy1-0/+395
This is the bluetooth protocol driver for the TI WiLink7 chipsets. Texas Instrument's WiLink chipsets combine wireless technologies like BT, FM, GPS and WLAN onto a single chip. This Bluetooth driver works on top of the TI_ST shared transport line discipline driver which also allows other drivers like FM V4L2 and GPS character driver to make use of the same UART interface. Kconfig and Makefile modifications to enable the Bluetooth driver for Texas Instrument's WiLink 7 chipset. Signed-off-by: Pavan Savoy <pavan_savoy@ti.com> Acked-by: Gustavo F. Padovan <padovan@profusion.mobi> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>