linux/drivers/bluetooth/hci_h4.c
<<
val14./spa 14./form 14.a val14 href="../linux+v3.8.6/drivers/bn> tooth/hci_h4.c"> val14.img src="../.static/gfx/right.png" alt=">>"> v./spa v.spa class="lxr_search"> val ="+search" method="post" onsubmit="return do_search(this);"> val14.input typ hidden" nam navtarget" ion> "> val14.input typ text" nam search" id search"> val14.buttopttyp submit">Search val14Prefs 14./a> v./spa al14 4./div al14 4.form ac > ="ajax+*" method="post" onsubmit="return false;"> v.input typ hidden" nam ajax_lookup" id ajax_lookup" ion> "> al14 4./form al14 4.div class="headingbottom">
.div id file_contents"
4 41./a>.spa
 class="comment">/*./spa
  4 42./a>.spa
 class="comment"> *./spa
  4 43./a>.spa
 class="comment"> *  Bn>
tooth HCI UART driver./spa
  4 44./a>.spa
 class="comment"> *./spa
  4 45./a>.spa
 class="comment"> *  Copyright (C) 2000-2001  Qualcomm Incorporated./spa
  4 46./a>.spa
 class="comment"> *  Copyright (C) 2002-2003  Maxim Krasnyansky <maxk@qualcomm.com>./spa
  4 47./a>.spa
 class="comment"> *  Copyright (C) 2004-2005  Marcel Holtmann <marcel@holtmann.org>./spa
  4 48./a>.spa
 class="comment"> *./spa
  4 49./a>.spa
 class="comment"> *./spa
  4 .9"
a>.spa
 class="comment"> *  This program is free software; you ca
 redistribute it and/or modify./spa
  4 11./a>.spa
 class="comment"> *  it under the terms of the GNU General Public License as published by./spa
  4 12./a>.spa
 class="comment"> *  the Free Software Founda  >
; either vers/opt2 of the License, or./spa
  4 13./a>.spa
 class="comment"> *  (at your 
	  >
) any later vers/op../spa
  4 14./a>.spa
 class="comment"> *./spa
  4 15./a>.spa
 class="comment"> *  This program is distributed in the hope that it will be useful,./spa
  4 16./a>.spa
 class="comment"> *  but WITHOUT ANY WARRANTY; without even the implied warranty of./spa
  4 17./a>.spa
 class="comment"> *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the./spa
  4 18./a>.spa
 class="comment"> *  GNU General Public License for more details../spa
  4 19./a>.spa
 class="comment"> *./spa
  4 29"
a>.spa
 class="comment"> *  You should have received a copy of the GNU General Public License./spa
  4 21./a>.spa
 class="comment"> *  along with this program; if not, write to the Free Software./spa
  4 22./a>.spa
 class="comment"> *  Founda  >
, Inc., 59 Temple Place, Suite 330, Bost>
, MA  02111-1307  USA./spa
  4 23./a>.spa
 class="comment"> *./spa
  4 24./a>.spa
 class="comment"> */./spa
  4 25./a> 4 26./a>#include <linux/module.h./a>> 4 27./a> 4 28./a>#include <linux/kernel.h./a>> 4 29./a>#include <linux/init.h./a>> 4 30./a>#include <linux/typ
s.h./a>> 4 31./a>#include <linux/fcntl.h./a>> 4 32./a>#include <linux/interrupt.h./a>> 4 33./a>#include <linux/ptrace.h./a>> 4 34./a>#include <linux/poll.h./a>> 4 35./a> 4 36./a>#include <linux/slab.h./a>> 4 37./a>#include <linux/tty.h./a>> 4 38./a>#include <linux/errno.h./a>> 4 39./a>#include <linux/string.h./a>> 4 40./a>#include <linux/signal.h./a>> 4 41./a>#include <linux/ioctl.h./a>> 4 42./a>#include <linux/skbuff.h./a>> 4 43./a> 4 44./a>#include <net/bn>
tooth/bn>
tooth.h./a>> 4 45./a>#include <net/bn>
tooth/hci_core.h./a>> 4 46./a> 4 47./a>#include "hci_uart.h./a>" 4 48./a> 4 49./a>#define4.a href="+code=VERSION" class="sref">VERSION./a> .spa
 class="string">"1.2"4 50./a> 4 51./a>struct4.a href="+code=h4_struct" class="sref">h4_struct./a> { 4 52./a>        unsigned long .a href="+code=rx_state" class="sref">rx_state./a>; 4 53./a>        unsigned long .a href="+code=rx_count" class="sref">rx_count./a>; 4 54./a>        struct4.a href="+code=sk_buff" class="sref">sk_buff./a> *.a href="+code=rx_skb" class="sref">rx_skb./a>; 4 55./a>        struct4.a href="+code=sk_buff_head" class="sref">sk_buff_head./a> .a href="+code=txq" class="sref">txq./a>; 4 56./a>}; 4 57./a> 4 58./a>.spa
 class="comment">/* H4 receiver States */./spa
  4 59./a>#define4.a href="+code=H4_W4_PACKET_TYPE" class="sref">H4_W4_PACKET_TYPE./a>       0 4 60./a>#define4.a href="+code=H4_W4_EVENT_HDR" class="sref">H4_W4_EVENT_HDR./a>         1 4 61./a>#define4.a href="+code=H4_W4_ACL_HDR" class="sref">H4_W4_ACL_HDR./a>           2 4 62./a>#define4.a href="+code=H4_W4_SCO_HDR" class="sref">H4_W4_SCO_HDR./a>           3 4 63./a>#define4.a href="+code=H4_W4_DATA" class="sref">H4_W4_DATA./a>           4 44 4 64./a> 4 65./a>.spa
 class="comment">/* Initialize protocol */./spa
  4 66./a>static int4.a href="+code=h4_open" class="sref">h4_open./a>(struct4.a href="+code=hci_uart" class="sref">hci_uart./a> *.a href="+code=hu" class="sref">hu./a>) 4 67./a>{ 4 68./a>        struct4.a href="+code=h4_struct" class="sref">h4_struct./a> *.a href="+code=h4" class="sref">h4./a>; 4 69./a> 4 70./a>        .a href="+code=BT_DBG" class="sref">BT_DBG./a>(.spa
 class="string">"hu %p"hu./a>); 4 71./a> 4 72./a>        .a href="+code=h4" class="sref">h4./a> = .a href="+code=kzalloc" class="sref">kzalloc./a>(sizeof(*.a href="+code=h4" class="sref">h4./a>),4.a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL./a>); 4 73./a>        if (!.a href="+code=h4" class="sref">h4./a>) 4 74./a>           4 4  return -.a href="+code=ENOMEM" class="sref">ENOMEM./a>; 4 75./a> 4 76./a>        .a href="+code=skb_queue_head_init" class="sref">skb_queue_head_init./a>(&.a href="+code=h4" class="sref">h4./a>->.a href="+code=txq" class="sref">txq./a>); 4 77./a> 4 78./a>        .a href="+code=hu" class="sref">hu./a>->.a href="+code=priv" class="sref">priv./a> = .a href="+code=h4" class="sref">h4./a>; 4 79./a>        return 0; 4 80./a>} 4 81./a> 4 82./a>.spa
 class="comment">/* Flush protocol data */./spa
  4 83./a>static int4.a href="+code=h4_flush" class="sref">h4_flush./a>(struct4.a href="+code=hci_uart" class="sref">hci_uart./a> *.a href="+code=hu" class="sref">hu./a>) 4 84./a>{ 4 85./a>        struct4.a href="+code=h4_struct" class="sref">h4_struct./a> *.a href="+code=h4" class="sref">h4./a> = .a href="+code=hu" class="sref">hu./a>->.a href="+code=priv" class="sref">priv./a>; 4 86./a> 4 87./a>        .a href="+code=BT_DBG" class="sref">BT_DBG./a>(.spa
 class="string">"hu %p"hu./a>); 4 88./a> 4 89./a>        .a href="+code=skb_queue_purge" class="sref">skb_queue_purge./a>(&.a href="+code=h4" class="sref">h4./a>->.a href="+code=txq" class="sref">txq./a>); 4 90./a> 4 91./a>        return 0; 4 92./a>} 4 93./a> 4 94./a>.spa
 class="comment">/* Close protocol */./spa
  4 95./a>static int4.a href="+code=h4_close" class="sref">h4_close./a>(struct4.a href="+code=hci_uart" class="sref">hci_uart./a> *.a href="+code=hu" class="sref">hu./a>) 4 96./a>{ 4 97./a>        struct4.a href="+code=h4_struct" class="sref">h4_struct./a> *.a href="+code=h4" class="sref">h4./a> = .a href="+code=hu" class="sref">hu./a>->.a href="+code=priv" class="sref">priv./a>; 4 98./a> 4 99./a>        .a href="+code=hu" class="sref">hu./a>->.a href="+code=priv" class="sref">priv./a> = .a href="+code=NULL" class="sref">NULL./a>; 4100./a> 4101./a>        .a href="+code=BT_DBG" class="sref">BT_DBG./a>(.spa
 class="string">"hu %p"hu./a>); 4102./a> 4103./a>        .a href="+code=skb_queue_purge" class="sref">skb_queue_purge./a>(&.a href="+code=h4" class="sref">h4./a>->.a href="+code=txq" class="sref">txq./a>); 4104./a> 4105./a>        .a href="+code=kfree_skb" class="sref">kfree_skb./a>(.a href="+code=h4" class="sref">h4./a>->.a href="+code=rx_skb" class="sref">rx_skb./a>); 4106./a> 4107./a>        .a href="+code=hu" class="sref">hu./a>->.a href="+code=priv" class="sref">priv./a> = .a href="+code=NULL" class="sref">NULL./a>; 4108./a>        .a href="+code=kfree" class="sref">kfree./a>(.a href="+code=h4" class="sref">h4./a>); 4109./a> 4110./a>        return 0; 4111./a>} 4112./a> 4113./a>.spa
 class="comment">/* Enqueue fram
 for transmit4114./a>static int4.a href="+code=h4_enqueue" class="sref">h4_enqueue./a>(struct4.a href="+code=hci_uart" class="sref">hci_uart./a> *.a href="+code=hu" class="sref">hu./a>, struct4.a href="+code=sk_buff" class="sref">sk_buff./a> *.a href="+code=skb" class="sref">skb./a>) 4115./a>{ 4116./a>        struct4.a href="+code=h4_struct" class="sref">h4_struct./a> *.a href="+code=h4" class="sref">h4./a> = .a href="+code=hu" class="sref">hu./a>->.a href="+code=priv" class="sref">priv./a>; 4117./a> 4118./a>        .a href="+code=BT_DBG" class="sref">BT_DBG./a>(.spa
 class="string">"hu %p skb %p"hu./a>,4.a href="+code=skb" class="sref">skb./a>); 4119./a> 4120./a>        .spa
 class="comment">/* Prepend skb with fram
 typ
 */./spa
  4121./a>        .a href="+code=memcpy" class="sref">memcpy./a>(.a href="+code=skb_push" class="sref">skb_push./a>(.a href="+code=skb" class="sref">skb./a>, 1), &.a href="+code=bt_cb" class="sref">bt_cb./a>(.a href="+code=skb" class="sref">skb./a>)->.a href="+code=pkt_typ
" class="sref">pkt_typ
./a>, 1); 4122./a>        .a href="+code=skb_queue_tail" class="sref">skb_queue_tail./a>(&.a href="+code=h4" class="sref">h4./a>->.a href="+code=txq" class="sref">txq./a>,4.a href="+code=skb" class="sref">skb./a>); 4123./a> 4124./a>        return 0; 4125./a>} 4126./a> 4127./a>static .a href="+code=inline" class="sref">inline./a> int4.a href="+code=h4_check_data_len" class="sref">h4_check_data_len./a>(struct4.a href="+code=h4_struct" class="sref">h4_struct./a> *.a href="+code=h4" class="sref">h4./a>, int4.a href="+code=len" class="sref">len./a>) 4128./a>{ 4129./a>        int4.a href="+code=room" class="sref">room./a> = .a href="+code=skb_tailroom" class="sref">skb_tailroom./a>(.a href="+code=h4" class="sref">h4./a>->.a href="+code=rx_skb" class="sref">rx_skb./a>); 4130./a> 4131./a>        .a href="+code=BT_DBG" class="sref">BT_DBG./a>(.spa
 class="string">"len %d room %d"len./a>,4.a href="+code=room" class="sref">room./a>); 4132./a> 4133./a>        if (!.a href="+code=len" class="sref">len./a>) { 4134./a>           4 4  .a href="+code=hci_recv_fram
" class="sref">hci_recv_fram
./a>(.a href="+code=h4" class="sref">h4./a>->.a href="+code=rx_skb" class="sref">rx_skb./a>); 4135./a>        } else if (.a href="+code=len" class="sref">len./a> >4.a href="+code=room" class="sref">room./a>) { 4136./a>           4 4  .a href="+code=BT_ERR" class="sref">BT_ERR./a>(.spa
 class="string">"Data length is too large"4137./a>           4 4  .a href="+code=kfree_skb" class="sref">kfree_skb./a>(.a href="+code=h4" class="sref">h4./a>->.a href="+code=rx_skb" class="sref">rx_skb./a>); 4138./a>        } else { 4139./a>           4 4  .a href="+code=h4" class="sref">h4./a>->.a href="+code=rx_state" class="sref">rx_state./a> = .a href="+code=H4_W4_DATA" class="sref">H4_W4_DATA./a>; 4140./a>           4 4  .a href="+code=h4" class="sref">h4./a>->.a href="+code=rx_count" class="sref">rx_count./a> = .a href="+code=len" class="sref">len./a>; 4141./a>           4 4  return .a href="+code=len" class="sref">len./a>; 4142./a>        } 4143./a> 4144./a>        .a href="+code=h4" class="sref">h4./a>->.a href="+code=rx_state" class="sref">rx_state./a> = .a href="+code=H4_W4_PACKET_TYPE" class="sref">H4_W4_PACKET_TYPE./a>; 4145./a>        .a href="+code=h4" class="sref">h4./a>->.a href="+code=rx_skb" class="sref">rx_skb./a>   = .a href="+code=NULL" class="sref">NULL./a>; 4146./a>        .a href="+code=h4" class="sref">h4./a>->.a href="+code=rx_count" class="sref">rx_count./a> = 0; 4147./a> 4148./a>        return 0; 4149./a>} 4150./a> 4151./a>.spa
 class="comment">/* Recv data */./spa
  4152./a>static int4.a href="+code=h4_recv" class="sref">h4_recv./a>(struct4.a href="+code=hci_uart" class="sref">hci_uart./a> *.a href="+code=hu" class="sref">hu./a>, void *.a href="+code=data" class="sref">data./a>, int4.a href="+code=count" class="sref">count./a>) 4153./a>{ 4154./a>        int4.a href="+code=ret" class="sref">ret./a>; 4155./a> 4156./a>        .a href="+code=ret" class="sref">ret./a> = .a href="+code=hci_recv_stream_fragment" class="sref">hci_recv_stream_fragment./a>(.a href="+code=hu" class="sref">hu./a>->.a href="+code=hdev" class="sref">hdev./a>,4.a href="+code=data" class="sref">data./a>, .a href="+code=count" class="sref">count./a>); 4157./a>        if (.a href="+code=ret" class="sref">ret./a> < 0) { 4158./a>           4 4  .a href="+code=BT_ERR" class="sref">BT_ERR./a>(.spa
 class="string">"Fram
 Reassembly Failed"4159./a>           4 4  return .a href="+code=ret" class="sref">ret./a>; 4160./a>        } 4161./a> 4162./a>        return .a href="+code=count" class="sref">count./a>; 4163./a>} 4164./a> 4165./a>static struct4.a href="+code=sk_buff" class="sref">sk_buff./a> *.a href="+code=h4_dequeue" class="sref">h4_dequeue./a>(struct4.a href="+code=hci_uart" class="sref">hci_uart./a> *.a href="+code=hu" class="sref">hu./a>) 4166./a>{ 4167./a>        struct4.a href="+code=h4_struct" class="sref">h4_struct./a> *.a href="+code=h4" class="sref">h4./a> = .a href="+code=hu" class="sref">hu./a>->.a href="+code=priv" class="sref">priv./a>; 4168./a>        return .a href="+code=skb_dequeue" class="sref">skb_dequeue./a>(&.a href="+code=h4" class="sref">h4./a>->.a href="+code=txq" class="sref">txq./a>); 4169./a>} 4170./a> 4171./a>static struct4.a href="+code=hci_uart_proto" class="sref">hci_uart_proto./a> .a href="+code=h4p" class="sref">h4p./a> = { 4172./a>        ..a href="+code=id" class="sref">id./a>           4 = .a href="+code=HCI_UART_H4" class="sref">HCI_UART_H4./a>, 4173./a>        ..a href="+code=open" class="sref">open./a>         4 = .a href="+code=h4_open" class="sref">h4_open./a>, 4174./a>        ..a href="+code=close" class="sref">close./a>        4 = .a href="+code=h4_close" class="sref">h4_close./a>, 4175./a>        ..a href="+code=recv" class="sref">recv./a>         4 = .a href="+code=h4_recv" class="sref">h4_recv./a>, 4176./a>        ..a href="+code=enqueue" class="sref">enqueue./a>      4 = .a href="+code=h4_enqueue" class="sref">h4_enqueue./a>, 4177./a>        ..a href="+code=dequeue" class="sref">dequeue./a>      4 = .a href="+code=h4_dequeue" class="sref">h4_dequeue./a>, 4178./a>        ..a href="+code=flush" class="sref">flush./a>        4 = .a href="+code=h4_flush" class="sref">h4_flush./a>, 4179./a>}; 4180./a> 4181./a>int4.a href="+code=__init" class="sref">__init./a> .a href="+code=h4_init" class="sref">h4_init./a>(void) 4182./a>{ 4183./a>        int4.a href="+code=err" class="sref">err./a> = .a href="+code=hci_uart_register_proto" class="sref">hci_uart_register_proto./a>(&.a href="+code=h4p" class="sref">h4p./a>); 4184./a> 4185./a>        if (!.a href="+code=err" class="sref">err./a>) 4186./a>           4 4  .a href="+code=BT_INFO" class="sref">BT_INFO./a>(.spa
 class="string">"HCI H4 protocol initialized"4187./a>        else 4188./a>           4 4  .a href="+code=BT_ERR" class="sref">BT_ERR./a>(.spa
 class="string">"HCI H4 protocol registra  >
 failed"4189./a> 4190./a>        return .a href="+code=err" class="sref">err./a>; 4191./a>} 4192./a> 4193./a>int4.a href="+code=__exit" class="sref">__exit./a> .a href="+code=h4_deinit" class="sref">h4_deinit./a>(void) 4194./a>{ 4195./a>        return .a href="+code=hci_uart_unregister_proto" class="sref">hci_uart_unregister_proto./a>(&.a href="+code=h4p" class="sref">h4p./a>); 4196./a>} 4197./a>
The original LXR software by the LXR community./a>, this experimental vers > by lxr@linux.no./a>. ./div .div class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro AS./a>, provider of Linux consulting and opera > s services since41995. ./div ./body ./html