]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/bluetooth/hci_h4p/fw-ti.c
Merge branch 'omap-fixes'
[linux-2.6-omap-h63xx.git] / drivers / bluetooth / hci_h4p / fw-ti.c
1 /*
2  * This file is part of hci_h4p bluetooth driver
3  *
4  * Copyright (C) 2005, 2006 Nokia Corporation.
5  *
6  * Contact: Ville Tervo <ville.tervo@nokia.com>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * version 2 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23
24 #include <linux/skbuff.h>
25
26 #include "hci_h4p.h"
27
28 void hci_h4p_brf6150_parse_fw_event(struct hci_h4p_info *info,
29                                     struct sk_buff *skb)
30 {
31         struct hci_fw_event *ev;
32         int err = 0;
33
34         if (bt_cb(skb)->pkt_type != H4_EVT_PKT) {
35                 dev_err(info->dev, "Got non event fw packet.\n");
36                 err = -EPROTO;
37                 goto ret;
38         }
39
40         ev = (struct hci_fw_event *)skb->data;
41         if (ev->hev.evt != HCI_EV_CMD_COMPLETE) {
42                 dev_err(info->dev, "Got non cmd complete fw event\n");
43                 err = -EPROTO;
44                 goto ret;
45         }
46
47         if (ev->status != 0) {
48                 dev_err(info->dev, "Got error status from fw command\n");
49                 err = -EPROTO;
50                 goto ret;
51         }
52
53 ret:
54         info->fw_error = err;
55         complete(&info->fw_completion);
56 }
57
58 int hci_h4p_brf6150_send_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue)
59 {
60         struct sk_buff *skb;
61         int err = 0;
62
63         info->fw_error = 0;
64
65         while ((skb = skb_dequeue(fw_queue)) != NULL) {
66                 /* We should allways send word aligned data to h4+ devices */
67                 if (skb->len % 2) {
68                         err = skb_pad(skb, 1);
69                 }
70                 if (err)
71                         return err;
72
73                 init_completion(&info->fw_completion);
74                 skb_queue_tail(&info->txq, skb);
75                 tasklet_schedule(&info->tx_task);
76
77                 if (!wait_for_completion_timeout(&info->fw_completion, HZ)) {
78                         dev_err(info->dev, "Timeout while sending brf6150 fw\n");
79                         return -ETIMEDOUT;
80                 }
81
82                 if (info->fw_error) {
83                         dev_err(info->dev, "There was fw_error while sending bfr6150 fw\n");
84                         return -EPROTO;
85                 }
86         }
87         NBT_DBG_FW("Firmware sent\n");
88
89         return 0;
90 }