From patchwork Tue Aug 9 16:32:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitkumar Karwar X-Patchwork-Id: 9271701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DF84560839 for ; Tue, 9 Aug 2016 16:33:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFECC28364 for ; Tue, 9 Aug 2016 16:33:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3D172839B; Tue, 9 Aug 2016 16:33:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6810228364 for ; Tue, 9 Aug 2016 16:33:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bX9yK-00014H-0Y; Tue, 09 Aug 2016 16:33:44 +0000 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bX9yH-0000xf-OS for linux-rockchip@lists.infradead.org; Tue, 09 Aug 2016 16:33:43 +0000 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u79GU8xR000462; Tue, 9 Aug 2016 09:33:17 -0700 Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 24nfdkdt4e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 09 Aug 2016 09:33:17 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Tue, 9 Aug 2016 09:33:15 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1104.5 via Frontend Transport; Tue, 9 Aug 2016 09:33:15 -0700 Received: from pe-lt949 (unknown [10.31.130.73]) by maili.marvell.com (Postfix) with ESMTP id 40F7C3F703F; Tue, 9 Aug 2016 09:33:14 -0700 (PDT) Received: from pe-lt949 (piotr-probook.localdomain [127.0.0.1]) by pe-lt949 (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id u79GWkfp002428; Tue, 9 Aug 2016 22:02:46 +0530 Received: (from root@localhost) by pe-lt949 (8.14.4/8.14.4/Submit) id u79GWg5A002427; Tue, 9 Aug 2016 22:02:42 +0530 From: Amitkumar Karwar To: Subject: [PATCH v12 1/3] Bluetooth: hci_uart: add prepare callbacks to hci_uart_proto structure. Date: Tue, 9 Aug 2016 22:02:31 +0530 Message-ID: <1470760353-2394-1-git-send-email-akarwar@marvell.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-08-09_06:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608090168 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160809_093341_977735_7D550322 X-CRM114-Status: GOOD ( 11.66 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, marcel@holtmann.org, Amitkumar Karwar , linux-kernel@vger.kernel.org, Ganapathi Bhat Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 dda9739..d7184dc 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); };