2015-03-25 14:19:30

by Loic Poulain

[permalink] [raw]
Subject: [PATCH] Bluetooth: hci_ldisc: Add setup callback

Some Bluetooth controllers require initialization before
being used (vendor config, firmware download).
Add possibility for a HCI UART proto to implement this
early init via the setup callback.

Signed-off-by: Loic Poulain <[email protected]>
---
drivers/bluetooth/hci_ldisc.c | 11 +++++++++++
drivers/bluetooth/hci_uart.h | 1 +
2 files changed, 12 insertions(+)

diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index dc487b5..48a0c25 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -261,6 +261,16 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
return 0;
}

+static int hci_uart_setup(struct hci_dev *hdev)
+{
+ struct hci_uart *hu = hci_get_drvdata(hdev);
+
+ if (hu->proto->setup)
+ return hu->proto->setup(hu);
+
+ return 0;
+}
+
/* ------ LDISC part ------ */
/* hci_uart_tty_open
*
@@ -426,6 +436,7 @@ static int hci_uart_register_dev(struct hci_uart *hu)
hdev->close = hci_uart_close;
hdev->flush = hci_uart_flush;
hdev->send = hci_uart_send_frame;
+ hdev->setup = hci_uart_setup;
SET_HCIDEV_DEV(hdev, hu->tty->dev);

if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags))
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index 247488e..074ed29 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -59,6 +59,7 @@ struct hci_uart_proto {
int (*flush)(struct hci_uart *hu);
int (*recv)(struct hci_uart *hu, void *data, int len);
int (*enqueue)(struct hci_uart *hu, struct sk_buff *skb);
+ int (*setup)(struct hci_uart *hu);
struct sk_buff *(*dequeue)(struct hci_uart *hu);
};

--
1.9.1


2015-03-25 16:35:08

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: hci_ldisc: Add setup callback

Hi Loic,

> Some Bluetooth controllers require initialization before
> being used (vendor config, firmware download).
> Add possibility for a HCI UART proto to implement this
> early init via the setup callback.
>
> Signed-off-by: Loic Poulain <[email protected]>
> ---
> drivers/bluetooth/hci_ldisc.c | 11 +++++++++++
> drivers/bluetooth/hci_uart.h | 1 +
> 2 files changed, 12 insertions(+)

patch has been applied to bluetooth-next tree.

However I changed to subject to mention hci_uart and not hci_ldisc. Please use hci_uart to refer to the driver.

Regards

Marcel