Skip to content

Commit 906a039

Browse files
committed
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-08-01 Here's our first batch of Bluetooth patches for the 4.14 kernel: - Several new USB IDs for the btusb driver - Memory leak fix in btusb driver - Cleanups & fixes to hci_nokia, hci_serdev and hci_bcm drivers - Fixed cleanup path in mrf24j40 (802.15.4) driver probe function - A few other smaller cleanups & fixes to drivers Please let me know if there are any issues pulling. Thanks. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents c613c20 + d829b9e commit 906a039

File tree

18 files changed

+101
-57
lines changed

18 files changed

+101
-57
lines changed

drivers/bluetooth/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ config BT_HCIUART_NOKIA
9898
depends on BT_HCIUART_SERDEV
9999
depends on PM
100100
select BT_HCIUART_H4
101+
select BT_BCM
101102
help
102103
Nokia H4+ is serial protocol for communication between Bluetooth
103104
device and host. This protocol is required for Bluetooth devices

drivers/bluetooth/ath3k.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ MODULE_DEVICE_TABLE(usb, ath3k_table);
140140

141141
#define BTUSB_ATH3012 0x80
142142
/* This table is to load patch and sysconfig files
143-
* for AR3012 */
143+
* for AR3012
144+
*/
144145
static const struct usb_device_id ath3k_blist_tbl[] = {
145146

146147
/* Atheros AR3012 with sflash firmware*/

drivers/bluetooth/bt3c_cs.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,14 +684,16 @@ static int bt3c_config(struct pcmcia_device *link)
684684
unsigned long try;
685685

686686
/* First pass: look for a config entry that looks normal.
687-
Two tries: without IO aliases, then with aliases */
687+
* Two tries: without IO aliases, then with aliases
688+
*/
688689
for (try = 0; try < 2; try++)
689690
if (!pcmcia_loop_config(link, bt3c_check_config, (void *) try))
690691
goto found_port;
691692

692693
/* Second pass: try to find an entry that isn't picky about
693-
its base address, then try to grab any standard serial port
694-
address, and finally try to get any free port. */
694+
* its base address, then try to grab any standard serial port
695+
* address, and finally try to get any free port.
696+
*/
695697
if (!pcmcia_loop_config(link, bt3c_check_config_notpicky, NULL))
696698
goto found_port;
697699

drivers/bluetooth/btmrvl_sdio.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,8 @@ static void btmrvl_sdio_dump_firmware(struct btmrvl_private *priv)
14551455
fw_dump_ptr = fw_dump_data;
14561456

14571457
/* Dump all the memory data into single file, a userspace script will
1458-
be used to split all the memory data to multiple files*/
1458+
* be used to split all the memory data to multiple files
1459+
*/
14591460
BT_INFO("== btmrvl firmware dump to /sys/class/devcoredump start");
14601461
for (idx = 0; idx < dump_num; idx++) {
14611462
struct memory_type_mapping *entry = &mem_type_mapping_tbl[idx];
@@ -1482,7 +1483,8 @@ static void btmrvl_sdio_dump_firmware(struct btmrvl_private *priv)
14821483
}
14831484

14841485
/* fw_dump_data will be free in device coredump release function
1485-
after 5 min*/
1486+
* after 5 min
1487+
*/
14861488
dev_coredumpv(&card->func->dev, fw_dump_data, fw_dump_len, GFP_KERNEL);
14871489
BT_INFO("== btmrvl firmware dump to /sys/class/devcoredump end");
14881490
}

drivers/bluetooth/btqca.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)
8181
* and lower 2 bytes from patch will be used.
8282
*/
8383
*rome_version = (le32_to_cpu(ver->soc_id) << 16) |
84-
(le16_to_cpu(ver->rome_ver) & 0x0000ffff);
84+
(le16_to_cpu(ver->rome_ver) & 0x0000ffff);
8585

8686
out:
8787
kfree_skb(skb);

drivers/bluetooth/btrtl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ static int rtl_load_config(struct hci_dev *hdev, const char *name, u8 **buff)
279279
return ret;
280280
ret = fw->size;
281281
*buff = kmemdup(fw->data, ret, GFP_KERNEL);
282+
if (!*buff)
283+
ret = -ENOMEM;
282284

283285
release_firmware(fw);
284286

drivers/bluetooth/btsdio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ static int btsdio_rx_packet(struct btsdio_data *data)
144144
if (!skb) {
145145
/* Out of memory. Prepare a read retry and just
146146
* return with the expectation that the next time
147-
* we're called we'll have more memory. */
147+
* we're called we'll have more memory.
148+
*/
148149
return -ENOMEM;
149150
}
150151

drivers/bluetooth/btuart_cs.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,16 @@ static int btuart_config(struct pcmcia_device *link)
614614
int try;
615615

616616
/* First pass: look for a config entry that looks normal.
617-
Two tries: without IO aliases, then with aliases */
617+
* Two tries: without IO aliases, then with aliases
618+
*/
618619
for (try = 0; try < 2; try++)
619620
if (!pcmcia_loop_config(link, btuart_check_config, &try))
620621
goto found_port;
621622

622623
/* Second pass: try to find an entry that isn't picky about
623-
its base address, then try to grab any standard serial port
624-
address, and finally try to get any free port. */
624+
* its base address, then try to grab any standard serial port
625+
* address, and finally try to get any free port.
626+
*/
625627
if (!pcmcia_loop_config(link, btuart_check_config_notpicky, NULL))
626628
goto found_port;
627629

drivers/bluetooth/btusb.c

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ static const struct usb_device_id btusb_table[] = {
131131
{ USB_DEVICE(0x19ff, 0x0239), .driver_info = BTUSB_BCM_PATCHRAM },
132132

133133
/* Broadcom BCM43142A0 (Foxconn/Lenovo) */
134-
{ USB_DEVICE(0x105b, 0xe065), .driver_info = BTUSB_BCM_PATCHRAM },
134+
{ USB_VENDOR_AND_INTERFACE_INFO(0x105b, 0xff, 0x01, 0x01),
135+
.driver_info = BTUSB_BCM_PATCHRAM },
135136

136137
/* Broadcom BCM920703 (HTC Vive) */
137138
{ USB_VENDOR_AND_INTERFACE_INFO(0x0bb4, 0xff, 0x01, 0x01),
@@ -268,6 +269,7 @@ static const struct usb_device_id blacklist_table[] = {
268269
{ USB_DEVICE(0x0489, 0xe092), .driver_info = BTUSB_QCA_ROME },
269270
{ USB_DEVICE(0x0489, 0xe0a2), .driver_info = BTUSB_QCA_ROME },
270271
{ USB_DEVICE(0x04ca, 0x3011), .driver_info = BTUSB_QCA_ROME },
272+
{ USB_DEVICE(0x04ca, 0x3016), .driver_info = BTUSB_QCA_ROME },
271273

272274
/* Broadcom BCM2035 */
273275
{ USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 },
@@ -656,7 +658,8 @@ static void btusb_intr_complete(struct urb *urb)
656658
err = usb_submit_urb(urb, GFP_ATOMIC);
657659
if (err < 0) {
658660
/* -EPERM: urb is being killed;
659-
* -ENODEV: device got disconnected */
661+
* -ENODEV: device got disconnected
662+
*/
660663
if (err != -EPERM && err != -ENODEV)
661664
BT_ERR("%s urb %p failed to resubmit (%d)",
662665
hdev->name, urb, -err);
@@ -745,7 +748,8 @@ static void btusb_bulk_complete(struct urb *urb)
745748
err = usb_submit_urb(urb, GFP_ATOMIC);
746749
if (err < 0) {
747750
/* -EPERM: urb is being killed;
748-
* -ENODEV: device got disconnected */
751+
* -ENODEV: device got disconnected
752+
*/
749753
if (err != -EPERM && err != -ENODEV)
750754
BT_ERR("%s urb %p failed to resubmit (%d)",
751755
hdev->name, urb, -err);
@@ -840,7 +844,8 @@ static void btusb_isoc_complete(struct urb *urb)
840844
err = usb_submit_urb(urb, GFP_ATOMIC);
841845
if (err < 0) {
842846
/* -EPERM: urb is being killed;
843-
* -ENODEV: device got disconnected */
847+
* -ENODEV: device got disconnected
848+
*/
844849
if (err != -EPERM && err != -ENODEV)
845850
BT_ERR("%s urb %p failed to resubmit (%d)",
846851
hdev->name, urb, -err);
@@ -952,7 +957,8 @@ static void btusb_diag_complete(struct urb *urb)
952957
err = usb_submit_urb(urb, GFP_ATOMIC);
953958
if (err < 0) {
954959
/* -EPERM: urb is being killed;
955-
* -ENODEV: device got disconnected */
960+
* -ENODEV: device got disconnected
961+
*/
956962
if (err != -EPERM && err != -ENODEV)
957963
BT_ERR("%s urb %p failed to resubmit (%d)",
958964
hdev->name, urb, -err);
@@ -2896,7 +2902,8 @@ static int btusb_probe(struct usb_interface *intf,
28962902
struct usb_device *udev = interface_to_usbdev(intf);
28972903

28982904
/* Old firmware would otherwise let ath3k driver load
2899-
* patch and sysconfig files */
2905+
* patch and sysconfig files
2906+
*/
29002907
if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001)
29012908
return -ENODEV;
29022909
}
@@ -3067,6 +3074,12 @@ static int btusb_probe(struct usb_interface *intf,
30673074
if (id->driver_info & BTUSB_QCA_ROME) {
30683075
data->setup_on_usb = btusb_setup_qca;
30693076
hdev->set_bdaddr = btusb_set_bdaddr_ath3012;
3077+
3078+
/* QCA Rome devices lose their updated firmware over suspend,
3079+
* but the USB hub doesn't notice any status change.
3080+
* Explicitly request a device reset on resume.
3081+
*/
3082+
set_bit(BTUSB_RESET_RESUME, &data->flags);
30703083
}
30713084

30723085
#ifdef CONFIG_BT_HCIBTUSB_RTL
@@ -3259,13 +3272,28 @@ static void play_deferred(struct btusb_data *data)
32593272
int err;
32603273

32613274
while ((urb = usb_get_from_anchor(&data->deferred))) {
3275+
usb_anchor_urb(urb, &data->tx_anchor);
3276+
32623277
err = usb_submit_urb(urb, GFP_ATOMIC);
3263-
if (err < 0)
3278+
if (err < 0) {
3279+
if (err != -EPERM && err != -ENODEV)
3280+
BT_ERR("%s urb %p submission failed (%d)",
3281+
data->hdev->name, urb, -err);
3282+
kfree(urb->setup_packet);
3283+
usb_unanchor_urb(urb);
3284+
usb_free_urb(urb);
32643285
break;
3286+
}
32653287

32663288
data->tx_in_flight++;
3289+
usb_free_urb(urb);
3290+
}
3291+
3292+
/* Cleanup the rest deferred urbs. */
3293+
while ((urb = usb_get_from_anchor(&data->deferred))) {
3294+
kfree(urb->setup_packet);
3295+
usb_free_urb(urb);
32673296
}
3268-
usb_scuttle_anchored_urbs(&data->deferred);
32693297
}
32703298

32713299
static int btusb_resume(struct usb_interface *intf)

drivers/bluetooth/btwilink.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ static void st_reg_completion_cb(void *priv_data, int data)
9393
complete(&lhst->wait_reg_completion);
9494
}
9595

96-
/* Called by Shared Transport layer when receive data is
97-
* available */
96+
/* Called by Shared Transport layer when receive data is available */
9897
static long st_receive(void *priv_data, struct sk_buff *skb)
9998
{
10099
struct ti_st *lhst = priv_data;
@@ -198,7 +197,8 @@ static int ti_st_open(struct hci_dev *hdev)
198197
}
199198

200199
/* Is ST registration callback
201-
* called with ERROR status? */
200+
* called with ERROR status?
201+
*/
202202
if (hst->reg_status != 0) {
203203
BT_ERR("ST registration completed with invalid "
204204
"status %d", hst->reg_status);
@@ -276,7 +276,7 @@ static int ti_st_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
276276

277277
static int bt_ti_probe(struct platform_device *pdev)
278278
{
279-
static struct ti_st *hst;
279+
struct ti_st *hst;
280280
struct hci_dev *hdev;
281281
int err;
282282

drivers/bluetooth/hci_bcm.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static irqreturn_t bcm_host_wake(int irq, void *data)
176176
static int bcm_request_irq(struct bcm_data *bcm)
177177
{
178178
struct bcm_device *bdev = bcm->dev;
179-
int err = 0;
179+
int err;
180180

181181
/* If this is not a platform device, do not enable PM functionalities */
182182
mutex_lock(&bcm_device_lock);
@@ -185,21 +185,23 @@ static int bcm_request_irq(struct bcm_data *bcm)
185185
goto unlock;
186186
}
187187

188-
if (bdev->irq > 0) {
189-
err = devm_request_irq(&bdev->pdev->dev, bdev->irq,
190-
bcm_host_wake, IRQF_TRIGGER_RISING,
191-
"host_wake", bdev);
192-
if (err)
193-
goto unlock;
188+
if (bdev->irq <= 0) {
189+
err = -EOPNOTSUPP;
190+
goto unlock;
191+
}
194192

195-
device_init_wakeup(&bdev->pdev->dev, true);
193+
err = devm_request_irq(&bdev->pdev->dev, bdev->irq, bcm_host_wake,
194+
IRQF_TRIGGER_RISING, "host_wake", bdev);
195+
if (err)
196+
goto unlock;
196197

197-
pm_runtime_set_autosuspend_delay(&bdev->pdev->dev,
198-
BCM_AUTOSUSPEND_DELAY);
199-
pm_runtime_use_autosuspend(&bdev->pdev->dev);
200-
pm_runtime_set_active(&bdev->pdev->dev);
201-
pm_runtime_enable(&bdev->pdev->dev);
202-
}
198+
device_init_wakeup(&bdev->pdev->dev, true);
199+
200+
pm_runtime_set_autosuspend_delay(&bdev->pdev->dev,
201+
BCM_AUTOSUSPEND_DELAY);
202+
pm_runtime_use_autosuspend(&bdev->pdev->dev);
203+
pm_runtime_set_active(&bdev->pdev->dev);
204+
pm_runtime_enable(&bdev->pdev->dev);
203205

204206
unlock:
205207
mutex_unlock(&bcm_device_lock);

drivers/bluetooth/hci_h4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
172172
const struct h4_recv_pkt *pkts, int pkts_count)
173173
{
174174
struct hci_uart *hu = hci_get_drvdata(hdev);
175-
u8 alignment = hu->alignment;
175+
u8 alignment = hu->alignment ? hu->alignment : 1;
176176

177177
while (count) {
178178
int i, len;

drivers/bluetooth/hci_ldisc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ static int hci_uart_tty_open(struct tty_struct *tty)
457457
BT_DBG("tty %p", tty);
458458

459459
/* Error if the tty has no write op instead of leaving an exploitable
460-
hole */
460+
* hole
461+
*/
461462
if (tty->ops->write == NULL)
462463
return -EOPNOTSUPP;
463464

drivers/bluetooth/hci_ll.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,8 @@ static int download_firmware(struct ll_device *lldev)
622622
cmd = (struct hci_command *)action_ptr;
623623
if (cmd->opcode == 0xff36) {
624624
/* ignore remote change
625-
* baud rate HCI VS command */
625+
* baud rate HCI VS command
626+
*/
626627
bt_dev_warn(lldev->hu.hdev, "change remote baud rate command in firmware");
627628
break;
628629
}
@@ -742,14 +743,8 @@ static int hci_ti_probe(struct serdev_device *serdev)
742743
static void hci_ti_remove(struct serdev_device *serdev)
743744
{
744745
struct ll_device *lldev = serdev_device_get_drvdata(serdev);
745-
struct hci_uart *hu = &lldev->hu;
746-
struct hci_dev *hdev = hu->hdev;
747746

748-
cancel_work_sync(&hu->write_work);
749-
750-
hci_unregister_dev(hdev);
751-
hci_free_dev(hdev);
752-
hu->proto->close(hu);
747+
hci_uart_unregister_device(&lldev->hu);
753748
}
754749

755750
static const struct of_device_id hci_ti_of_match[] = {

drivers/bluetooth/hci_nokia.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -767,16 +767,8 @@ static int nokia_bluetooth_serdev_probe(struct serdev_device *serdev)
767767
static void nokia_bluetooth_serdev_remove(struct serdev_device *serdev)
768768
{
769769
struct nokia_bt_dev *btdev = serdev_device_get_drvdata(serdev);
770-
struct hci_uart *hu = &btdev->hu;
771-
struct hci_dev *hdev = hu->hdev;
772770

773-
cancel_work_sync(&hu->write_work);
774-
775-
hci_unregister_dev(hdev);
776-
hci_free_dev(hdev);
777-
hu->proto->close(hu);
778-
779-
pm_runtime_disable(&btdev->serdev->dev);
771+
hci_uart_unregister_device(&btdev->hu);
780772
}
781773

782774
static int nokia_bluetooth_runtime_suspend(struct device *dev)

drivers/bluetooth/hci_serdev.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,16 @@ int hci_uart_register_device(struct hci_uart *hu,
354354
return err;
355355
}
356356
EXPORT_SYMBOL_GPL(hci_uart_register_device);
357+
358+
void hci_uart_unregister_device(struct hci_uart *hu)
359+
{
360+
struct hci_dev *hdev = hu->hdev;
361+
362+
hci_unregister_dev(hdev);
363+
hci_free_dev(hdev);
364+
365+
cancel_work_sync(&hu->write_work);
366+
367+
hu->proto->close(hu);
368+
}
369+
EXPORT_SYMBOL_GPL(hci_uart_unregister_device);

drivers/bluetooth/hci_uart.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ struct hci_uart {
112112
int hci_uart_register_proto(const struct hci_uart_proto *p);
113113
int hci_uart_unregister_proto(const struct hci_uart_proto *p);
114114
int hci_uart_register_device(struct hci_uart *hu, const struct hci_uart_proto *p);
115+
void hci_uart_unregister_device(struct hci_uart *hu);
115116

116117
int hci_uart_tx_wakeup(struct hci_uart *hu);
117118
int hci_uart_init_ready(struct hci_uart *hu);

drivers/net/ieee802154/mrf24j40.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,8 @@ static int mrf24j40_probe(struct spi_device *spi)
13301330
if (spi->max_speed_hz > MAX_SPI_SPEED_HZ) {
13311331
dev_warn(&spi->dev, "spi clock above possible maximum: %d",
13321332
MAX_SPI_SPEED_HZ);
1333-
return -EINVAL;
1333+
ret = -EINVAL;
1334+
goto err_register_device;
13341335
}
13351336

13361337
ret = mrf24j40_hw_init(devrec);

0 commit comments

Comments
 (0)