Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: btnxpuart: Move vendor specific initialization to .post_init

This moves change baudrate and power save vendor commands from
nxp_setup() to nxp_post_init().

This also moves the baudrate restore logic from nxp_serdev_remove() to
nxp_shutdown() which ensure baudrate is restored even when HCI dev is
down, preventing baudrate mismatch between host and controller when
device is probed again next time.

In case of removal when the hdev is up and running, we have to call the
shutdown procedure explicitly before unregistering the hdev.

Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
Co-developed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Neeraj Sanjay Kale and committed by
Luiz Augusto von Dentz
6fca6781 07e6bddb

+28 -19
+28 -19
drivers/bluetooth/btnxpuart.c
··· 630 630 631 631 psdata->cur_psmode = PS_MODE_DISABLE; 632 632 psdata->target_ps_mode = DEFAULT_PS_MODE; 633 - 634 - if (psdata->cur_h2c_wakeupmode != psdata->h2c_wakeupmode) 635 - hci_cmd_sync_queue(hdev, send_wakeup_method_cmd, NULL, NULL); 636 - if (psdata->cur_psmode != psdata->target_ps_mode) 637 - hci_cmd_sync_queue(hdev, send_ps_cmd, NULL, NULL); 638 633 } 639 634 640 635 /* NXP Firmware Download Feature */ ··· 1223 1228 serdev_device_set_baudrate(nxpdev->serdev, nxpdev->fw_init_baudrate); 1224 1229 nxpdev->current_baudrate = nxpdev->fw_init_baudrate; 1225 1230 1226 - if (nxpdev->current_baudrate != HCI_NXP_SEC_BAUDRATE) { 1227 - nxpdev->new_baudrate = HCI_NXP_SEC_BAUDRATE; 1228 - hci_cmd_sync_queue(hdev, nxp_set_baudrate_cmd, NULL, NULL); 1229 - } 1230 - 1231 1231 ps_init(hdev); 1232 1232 1233 1233 if (test_and_clear_bit(BTNXPUART_IR_IN_PROGRESS, &nxpdev->tx_state)) 1234 1234 hci_dev_clear_flag(hdev, HCI_SETUP); 1235 1235 1236 + return 0; 1237 + } 1238 + 1239 + static int nxp_post_init(struct hci_dev *hdev) 1240 + { 1241 + struct btnxpuart_dev *nxpdev = hci_get_drvdata(hdev); 1242 + struct ps_data *psdata = &nxpdev->psdata; 1243 + 1244 + if (nxpdev->current_baudrate != HCI_NXP_SEC_BAUDRATE) { 1245 + nxpdev->new_baudrate = HCI_NXP_SEC_BAUDRATE; 1246 + nxp_set_baudrate_cmd(hdev, NULL); 1247 + } 1248 + if (psdata->cur_h2c_wakeupmode != psdata->h2c_wakeupmode) 1249 + send_wakeup_method_cmd(hdev, NULL); 1250 + if (psdata->cur_psmode != psdata->target_ps_mode) 1251 + send_ps_cmd(hdev, NULL); 1236 1252 return 0; 1237 1253 } 1238 1254 ··· 1279 1273 set_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); 1280 1274 } 1281 1275 kfree_skb(skb); 1276 + } else if (nxpdev->current_baudrate != nxpdev->fw_init_baudrate) { 1277 + nxpdev->new_baudrate = nxpdev->fw_init_baudrate; 1278 + nxp_set_baudrate_cmd(hdev, NULL); 1282 1279 } 1283 1280 1284 1281 return 0; ··· 1575 1566 hdev->close = btnxpuart_close; 1576 1567 hdev->flush = btnxpuart_flush; 1577 1568 hdev->setup = nxp_setup; 1569 + hdev->post_init = nxp_post_init; 1578 1570 hdev->send = nxp_enqueue; 1579 1571 hdev->hw_error = nxp_hw_err; 1580 1572 hdev->shutdown = nxp_shutdown; ··· 1607 1597 clear_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); 1608 1598 wake_up_interruptible(&nxpdev->check_boot_sign_wait_q); 1609 1599 wake_up_interruptible(&nxpdev->fw_dnld_done_wait_q); 1610 - } else { 1611 - /* Restore FW baudrate to fw_init_baudrate if changed. 1612 - * This will ensure FW baudrate is in sync with 1613 - * driver baudrate in case this driver is re-inserted. 1614 - */ 1615 - if (nxpdev->current_baudrate != nxpdev->fw_init_baudrate) { 1616 - nxpdev->new_baudrate = nxpdev->fw_init_baudrate; 1617 - nxp_set_baudrate_cmd(hdev, NULL); 1618 - } 1619 1600 } 1601 + 1602 + if (test_bit(HCI_RUNNING, &hdev->flags)) { 1603 + /* Ensure shutdown callback is executed before unregistering, so 1604 + * that baudrate is reset to initial value. 1605 + */ 1606 + nxp_shutdown(hdev); 1607 + } 1608 + 1620 1609 ps_cleanup(nxpdev); 1621 1610 hci_unregister_dev(hdev); 1622 1611 hci_free_dev(hdev);