Skip to content

Commit

Permalink
Bluetooth: btmtk: Fix failed to send func ctrl for MediaTek devices.
Browse files Browse the repository at this point in the history
[ Upstream commit 67dba2c28fe0af7e25ea1aeade677162ed05310a ]

Use usb_autopm_get_interface() and usb_autopm_put_interface()
in btmtk_usb_shutdown(), it could send func ctrl after enabling
autosuspend.

Bluetooth: btmtk_usb_hci_wmt_sync() hci0: Execution of wmt command
           timed out
Bluetooth: btmtk_usb_shutdown() hci0: Failed to send wmt func ctrl
           (-110)

Fixes: 5c5e8c52e3ca ("Bluetooth: btmtk: move btusb_mtk_[setup, shutdown] to btmtk.c")
Signed-off-by: Chris Lu <[email protected]>
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
(cherry picked from commit cd4522bd3632489626d09b3d197fa887cf623c74)
  • Loading branch information
ChrisCH-Lu authored and opsiff committed Jan 23, 2025
1 parent c534a5f commit a8875ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions drivers/bluetooth/btmtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1473,10 +1473,15 @@ EXPORT_SYMBOL_GPL(btmtk_usb_setup);

int btmtk_usb_shutdown(struct hci_dev *hdev)
{
struct btmtk_data *data = hci_get_priv(hdev);
struct btmtk_hci_wmt_params wmt_params;
u8 param = 0;
int err;

err = usb_autopm_get_interface(data->intf);
if (err < 0)
return err;

/* Disable the device */
wmt_params.op = BTMTK_WMT_FUNC_CTRL;
wmt_params.flag = 0;
Expand All @@ -1487,9 +1492,11 @@ int btmtk_usb_shutdown(struct hci_dev *hdev)
err = btmtk_usb_hci_wmt_sync(hdev, &wmt_params);
if (err < 0) {
bt_dev_err(hdev, "Failed to send wmt func ctrl (%d)", err);
usb_autopm_put_interface(data->intf);
return err;
}

usb_autopm_put_interface(data->intf);
return 0;
}
EXPORT_SYMBOL_GPL(btmtk_usb_shutdown);
Expand Down
4 changes: 2 additions & 2 deletions net/bluetooth/rfcomm/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ static ssize_t address_show(struct device *tty_dev,
struct device_attribute *attr, char *buf)
{
struct rfcomm_dev *dev = dev_get_drvdata(tty_dev);
return sprintf(buf, "%pMR\n", &dev->dst);
return sysfs_emit(buf, "%pMR\n", &dev->dst);
}

static ssize_t channel_show(struct device *tty_dev,
struct device_attribute *attr, char *buf)
{
struct rfcomm_dev *dev = dev_get_drvdata(tty_dev);
return sprintf(buf, "%d\n", dev->channel);
return sysfs_emit(buf, "%d\n", dev->channel);
}

static DEVICE_ATTR_RO(address);
Expand Down

0 comments on commit a8875ed

Please sign in to comment.