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