Bluetooth: hci_serdev: Introduce hci_uart_unregister_device()
authorIan Molton <ian@mnementh.co.uk>
Sat, 8 Jul 2017 16:37:41 +0000 (17:37 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 20 Jul 2017 09:18:36 +0000 (11:18 +0200)
Several drivers have the same (and incorrect) code in their
_remove() handler.

Coalesce this into a shared function.

Signed-off-by: Ian Molton <ian@mnementh.co.uk>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/hci_serdev.c
drivers/bluetooth/hci_uart.h

index aea930101dd2b9e8415d7666eccc4b971d0620f6..b725ac4f7ff67dfaab9745668e9839d0a0783de5 100644 (file)
@@ -354,3 +354,16 @@ err_alloc:
        return err;
 }
 EXPORT_SYMBOL_GPL(hci_uart_register_device);
+
+void hci_uart_unregister_device(struct hci_uart *hu)
+{
+       struct hci_dev *hdev = hu->hdev;
+
+       hci_unregister_dev(hdev);
+       hci_free_dev(hdev);
+
+       cancel_work_sync(&hu->write_work);
+
+       hu->proto->close(hu);
+}
+EXPORT_SYMBOL_GPL(hci_uart_unregister_device);
index c6e9e1cf63f886698d4bde03d510171fc62174f5..d9cd95d81149b1f9dc43506edcd02b9a86b03526 100644 (file)
@@ -112,6 +112,7 @@ struct hci_uart {
 int hci_uart_register_proto(const struct hci_uart_proto *p);
 int hci_uart_unregister_proto(const struct hci_uart_proto *p);
 int hci_uart_register_device(struct hci_uart *hu, const struct hci_uart_proto *p);
+void hci_uart_unregister_device(struct hci_uart *hu);
 
 int hci_uart_tx_wakeup(struct hci_uart *hu);
 int hci_uart_init_ready(struct hci_uart *hu);