]> git.ipfire.org Git - thirdparty/kernel/stable.git/blobdiff - drivers/bluetooth/hci_serdev.c
Bluetooth: hci_serdev: Move serdev_device_close/open into common hci_serdev code
[thirdparty/kernel/stable.git] / drivers / bluetooth / hci_serdev.c
index e0e6461b9200c027f7a04d8e577738f3af967864..7a3d6d636192d973ff0b745b70ce7e888131dd2f 100644 (file)
@@ -101,14 +101,6 @@ static void hci_uart_write_work(struct work_struct *work)
 
 /* ------- Interface to HCI layer ------ */
 
-/* Initialize device */
-static int hci_uart_open(struct hci_dev *hdev)
-{
-       BT_DBG("%s %p", hdev->name, hdev);
-
-       return 0;
-}
-
 /* Reset device */
 static int hci_uart_flush(struct hci_dev *hdev)
 {
@@ -129,6 +121,17 @@ static int hci_uart_flush(struct hci_dev *hdev)
        return 0;
 }
 
+/* Initialize device */
+static int hci_uart_open(struct hci_dev *hdev)
+{
+       BT_DBG("%s %p", hdev->name, hdev);
+
+       /* Undo clearing this from hci_uart_close() */
+       hdev->flush = hci_uart_flush;
+
+       return 0;
+}
+
 /* Close device */
 static int hci_uart_close(struct hci_dev *hdev)
 {
@@ -204,9 +207,8 @@ static int hci_uart_setup(struct hci_dev *hdev)
                return 0;
        }
 
-       if (skb->len != sizeof(*ver)) {
+       if (skb->len != sizeof(*ver))
                bt_dev_err(hdev, "Event length mismatch for version info");
-       }
 
        kfree_skb(skb);
        return 0;
@@ -282,10 +284,14 @@ int hci_uart_register_device(struct hci_uart *hu,
 
        serdev_device_set_client_ops(hu->serdev, &hci_serdev_client_ops);
 
-       err = p->open(hu);
+       err = serdev_device_open(hu->serdev);
        if (err)
                return err;
 
+       err = p->open(hu);
+       if (err)
+               goto err_open;
+
        hu->proto = p;
        set_bit(HCI_UART_PROTO_READY, &hu->flags);
 
@@ -351,6 +357,8 @@ err_register:
 err_alloc:
        clear_bit(HCI_UART_PROTO_READY, &hu->flags);
        p->close(hu);
+err_open:
+       serdev_device_close(hu->serdev);
        return err;
 }
 EXPORT_SYMBOL_GPL(hci_uart_register_device);
@@ -365,5 +373,6 @@ void hci_uart_unregister_device(struct hci_uart *hu)
        cancel_work_sync(&hu->write_work);
 
        hu->proto->close(hu);
+       serdev_device_close(hu->serdev);
 }
 EXPORT_SYMBOL_GPL(hci_uart_unregister_device);