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: btusb: mediatek: refactor the function btusb_mtk_reset

Extract the function btusb_mtk_subsys_reset from the btusb_mtk_reset
for the future handling of resetting bluetooth controller without
the USB reset.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Hao Qin <hao.qin@mediatek.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Hao Qin and committed by
Luiz Augusto von Dentz
4c0c28f2 7f935b21

+27 -18
+27 -18
drivers/bluetooth/btusb.c
··· 3033 3033 return val & MTK_BT_RST_DONE; 3034 3034 } 3035 3035 3036 - static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data) 3036 + static int btusb_mtk_subsys_reset(struct hci_dev *hdev, u32 dev_id) 3037 3037 { 3038 3038 struct btusb_data *data = hci_get_drvdata(hdev); 3039 - struct btmediatek_data *mediatek; 3040 3039 u32 val; 3041 3040 int err; 3042 3041 3043 - /* It's MediaTek specific bluetooth reset mechanism via USB */ 3044 - if (test_and_set_bit(BTUSB_HW_RESET_ACTIVE, &data->flags)) { 3045 - bt_dev_err(hdev, "last reset failed? Not resetting again"); 3046 - return -EBUSY; 3047 - } 3048 - 3049 - err = usb_autopm_get_interface(data->intf); 3050 - if (err < 0) 3051 - return err; 3052 - 3053 - btusb_stop_traffic(data); 3054 - usb_kill_anchored_urbs(&data->tx_anchor); 3055 - mediatek = hci_get_priv(hdev); 3056 - 3057 - if (mediatek->dev_id == 0x7925) { 3042 + if (dev_id == 0x7925) { 3058 3043 btusb_mtk_uhw_reg_read(data, MTK_BT_RESET_REG_CONNV3, &val); 3059 3044 val |= (1 << 5); 3060 3045 btusb_mtk_uhw_reg_write(data, MTK_BT_RESET_REG_CONNV3, val); ··· 3083 3098 if (!val) 3084 3099 bt_dev_err(hdev, "Can't get device id, subsys reset fail."); 3085 3100 3086 - usb_queue_reset_device(data->intf); 3101 + return err; 3102 + } 3087 3103 3104 + static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data) 3105 + { 3106 + struct btusb_data *data = hci_get_drvdata(hdev); 3107 + struct btmediatek_data *mtk_data; 3108 + int err; 3109 + 3110 + /* It's MediaTek specific bluetooth reset mechanism via USB */ 3111 + if (test_and_set_bit(BTUSB_HW_RESET_ACTIVE, &data->flags)) { 3112 + bt_dev_err(hdev, "last reset failed? Not resetting again"); 3113 + return -EBUSY; 3114 + } 3115 + 3116 + err = usb_autopm_get_interface(data->intf); 3117 + if (err < 0) 3118 + return err; 3119 + 3120 + btusb_stop_traffic(data); 3121 + usb_kill_anchored_urbs(&data->tx_anchor); 3122 + mtk_data = hci_get_priv(hdev); 3123 + 3124 + err = btusb_mtk_subsys_reset(hdev, mtk_data->dev_id); 3125 + 3126 + usb_queue_reset_device(data->intf); 3088 3127 clear_bit(BTUSB_HW_RESET_ACTIVE, &data->flags); 3089 3128 3090 3129 return err;