From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751398AbcFXGEL (ORCPT ); Fri, 24 Jun 2016 02:04:11 -0400 Received: from regular1.263xmail.com ([211.150.99.139]:52657 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751249AbcFXGEJ (ORCPT ); Fri, 24 Jun 2016 02:04:09 -0400 X-Greylist: delayed 306 seconds by postgrey-1.27 at vger.kernel.org; Fri, 24 Jun 2016 02:04:08 EDT X-263anti-spam: KSV:0;BIG:0;ABS:1;DNS:0;ATT:0;SPF:S; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 1 X-SKE-CHECKED: 1 X-ADDR-CHECKED: 0 X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: gbhat@marvell.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: <0f5dc88cfac8c66eaf309cd565ce4a34> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Subject: Re: [v11, 1/3] Bluetooth: hci_uart: add prepare callbacks to hci_uart_proto structure. To: Amitkumar Karwar , linux-bluetooth@vger.kernel.org References: <1462548714-7971-1-git-send-email-akarwar@marvell.com> Cc: linux-kernel@vger.kernel.org, Ganapathi Bhat From: Jeffy Chen Message-ID: <576CCCC4.9050509@rock-chips.com> Date: Fri, 24 Jun 2016 14:01:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1462548714-7971-1-git-send-email-akarwar@marvell.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016-5-6 23:31, Amitkumar Karwar wrote: > From: Ganapathi Bhat > > The new callback is used to prepare the device before HCI becomes > ready. One can use this to download firmware if the download process > doesn't use HCI commands. Also recv_for_prepare callback is > introduced for receiving data from devices during prepare phase. > > Signed-off-by: Ganapathi Bhat > Signed-off-by: Amitkumar Karwar > --- > drivers/bluetooth/hci_ldisc.c | 11 ++++++++++- > drivers/bluetooth/hci_uart.h | 3 +++ > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c > index 49b3e1e..b4ee682 100644 > --- a/drivers/bluetooth/hci_ldisc.c > +++ b/drivers/bluetooth/hci_ldisc.c > @@ -551,8 +551,11 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, > if (!hu || tty != hu->tty) > return; > > - if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) > + if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) { > + if (hu->proto->recv_for_prepare) > + hu->proto->recv_for_prepare(hu, data, count); > return; > + } > > /* It does not need a lock here as it is already protected by a mutex in > * tty caller > @@ -639,6 +642,12 @@ static int hci_uart_set_proto(struct hci_uart *hu, int id) > return err; > > hu->proto = p; > + if (p->prepare) { > + err = p->prepare(hu); > + if (err) > + return err; > + } > + > set_bit(HCI_UART_PROTO_READY, &hu->flags); > > err = hci_uart_register_dev(hu); > diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h > index 839bad1..17ba3b4 100644 > --- a/drivers/bluetooth/hci_uart.h > +++ b/drivers/bluetooth/hci_uart.h > @@ -67,8 +67,11 @@ struct hci_uart_proto { > int (*close)(struct hci_uart *hu); > int (*flush)(struct hci_uart *hu); > int (*setup)(struct hci_uart *hu); > + int (*prepare)(struct hci_uart *hu); > int (*set_baudrate)(struct hci_uart *hu, unsigned int speed); > int (*recv)(struct hci_uart *hu, const void *data, int len); > + int (*recv_for_prepare)(struct hci_uart *hu, const void *data, > + int len); > int (*enqueue)(struct hci_uart *hu, struct sk_buff *skb); > struct sk_buff *(*dequeue)(struct hci_uart *hu); > }; > > This serial of patches work well on my device... Tested-by: Jeffy Chen