Re: [PATCH 2/2] Bluetooth: support to send power management enable during hci open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 21, 2010 at 8:33 AM, Suraj Sumangala <suraj@xxxxxxxxxxx> wrote:
> This patch enables HCI_UART_ATH3K transport driver to support
> sending Vendor specific hci commands during hci open
> to enable or disable power management feature.

Why? shouldn't this be done from the hciattach? like for the other
manufacturers?
If you want it to be sent before hci0 interface is exposed, send it
over ttyXX, you have your _init function and if you require it to be
sent after the hci0 is exposed - do it in the _post function.

> Signed-off-by: Suraj Sumangala <suraj@xxxxxxxxxxx>
> ---
> Âdrivers/bluetooth/hci_ath.c | Â 59 +++++++++++++++++++++++++++++++++++++++++++
> Â1 files changed, 59 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c
> index 6a160c1..d4b0653 100644
> --- a/drivers/bluetooth/hci_ath.c
> +++ b/drivers/bluetooth/hci_ath.c
> @@ -49,6 +49,37 @@ struct ath_struct {
> Â Â Â Âstruct work_struct ctxtsw;
> Â};
>
> +/* Form HCI command */
> +static struct sk_buff *form_hci_cmd(struct hci_dev *hdev, __u16 opcode,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â__u32 plen, void *param)
> +{
> + Â Â Â int len = HCI_COMMAND_HDR_SIZE + plen;
> + Â Â Â struct hci_command_hdr *hdr;
> + Â Â Â struct sk_buff *skb;
> +
> + Â Â Â BT_DBG("%s opcode 0x%x plen %d", hdev->name, opcode, plen);
> +
> + Â Â Â skb = bt_skb_alloc(len, GFP_ATOMIC);
> + Â Â Â if (!skb) {
> + Â Â Â Â Â Â Â BT_ERR("%s no memory for command", hdev->name);
> + Â Â Â Â Â Â Â return NULL;
> + Â Â Â }
> +
> + Â Â Â hdr = (struct hci_command_hdr *) skb_put(skb, HCI_COMMAND_HDR_SIZE);
> + Â Â Â hdr->opcode = cpu_to_le16(opcode);
> +    hdr->plen  = plen;
> +
> + Â Â Â if (plen)
> + Â Â Â Â Â Â Â memcpy(skb_put(skb, plen), param, plen);
> +
> + Â Â Â BT_DBG("skb len %d", skb->len);
> +
> + Â Â Â bt_cb(skb)->pkt_type = HCI_COMMAND_PKT;
> + Â Â Â skb->dev = (void *) hdev;
> +
> + Â Â Â return skb;
> +}
> +
> Âstatic int ath_wakeup_ar3k(struct tty_struct *tty)
> Â{
> Â Â Â Âstruct termios settings;
> @@ -81,6 +112,26 @@ static int ath_wakeup_ar3k(struct tty_struct *tty)
> Â Â Â Âreturn status;
> Â}
>
> +#define HCI_OP_SLEEP_SET Â Â Â Â Â Â Â Â Â Â Â 0xFC04
> +static void ath_hci_init_driver(struct hci_uart *hu)
> +{
> + Â Â Â struct ath_struct *ath = hu->priv;
> + Â Â Â struct hci_dev *hdev = hu->hdev;
> + Â Â Â struct sk_buff *skb;
> +
> + Â Â Â if (!hdev)
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â if (!ath)
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â skb = form_hci_cmd(hdev, HCI_OP_SLEEP_SET, 1, &ath->cur_sleep);
> + Â Â Â if (!skb)
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â skb_queue_head(&hdev->driver_init, skb);
> +}
> +
> Âstatic void ath_hci_uart_work(struct work_struct *work)
> Â{
> Â Â Â Âint status;
> @@ -126,6 +177,13 @@ static int ath_open(struct hci_uart *hu)
> Â Â Â Âreturn 0;
> Â}
>
> +static int ath_hci_open(struct hci_uart *hu)
> +{
> + Â Â Â ath_hci_init_driver(hu);
> +
> + Â Â Â return 0;
> +}
> +
> Â/* Flush protocol data */
> Âstatic int ath_flush(struct hci_uart *hu)
> Â{
> @@ -210,6 +268,7 @@ static int ath_recv(struct hci_uart *hu, void *data, int count)
> Âstatic struct hci_uart_proto athp = {
> Â Â Â Â.id = HCI_UART_ATH3K,
> Â Â Â Â.open = ath_open,
> + Â Â Â .hci_open = ath_hci_open,
> Â Â Â Â.close = ath_close,
> Â Â Â Â.recv = ath_recv,
> Â Â Â Â.enqueue = ath_enqueue,
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux