亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hci_vhci.c

?? 嵌入式Linux的藍牙模塊驅動
?? C
字號:
/*    BlueZ - Bluetooth protocol stack for Linux   Copyright (C) 2000-2001 Qualcomm Incorporated   Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License version 2 as   published by the Free Software Foundation;   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,    COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS    SOFTWARE IS DISCLAIMED.*//* * Bluetooth HCI virtual device driver. * * $Id: hci_vhci.c,v 1.3 2002/04/17 17:37:20 maxk Exp $  */#define VERSION "1.1"#include <linux/config.h>#include <linux/module.h>#include <linux/errno.h>#include <linux/kernel.h>#include <linux/major.h>#include <linux/sched.h>#include <linux/slab.h>#include <linux/poll.h>#include <linux/fcntl.h>#include <linux/init.h>#include <linux/random.h>#include <linux/skbuff.h>#include <linux/miscdevice.h>#include <asm/system.h>#include <asm/uaccess.h>#include <net/bluetooth/bluetooth.h>#include <net/bluetooth/hci_core.h>#include "hci_vhci.h"/* HCI device part */static int hci_vhci_open(struct hci_dev *hdev){	set_bit(HCI_RUNNING, &hdev->flags);	return 0;}static int hci_vhci_flush(struct hci_dev *hdev){	struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) hdev->driver_data;	skb_queue_purge(&hci_vhci->readq);	return 0;}static int hci_vhci_close(struct hci_dev *hdev){	if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))		return 0;	hci_vhci_flush(hdev);	return 0;}static void hci_vhci_destruct(struct hci_dev *hdev){	struct hci_vhci_struct *vhci;	if (!hdev) return;	vhci = (struct hci_vhci_struct *) hdev->driver_data;	kfree(vhci);}static int hci_vhci_send_frame(struct sk_buff *skb){	struct hci_dev* hdev = (struct hci_dev *) skb->dev;	struct hci_vhci_struct *hci_vhci;	if (!hdev) {		BT_ERR("Frame for uknown device (hdev=NULL)");		return -ENODEV;	}	if (!test_bit(HCI_RUNNING, &hdev->flags))		return -EBUSY;	hci_vhci = (struct hci_vhci_struct *) hdev->driver_data;	memcpy(skb_push(skb, 1), &skb->pkt_type, 1);	skb_queue_tail(&hci_vhci->readq, skb);	if (hci_vhci->flags & VHCI_FASYNC)		kill_fasync(&hci_vhci->fasync, SIGIO, POLL_IN);	wake_up_interruptible(&hci_vhci->read_wait);	return 0;}/* Character device part *//* Poll */static unsigned int hci_vhci_chr_poll(struct file *file, poll_table * wait){  	struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data;	poll_wait(file, &hci_vhci->read_wait, wait); 	if (skb_queue_len(&hci_vhci->readq))		return POLLIN | POLLRDNORM;	return POLLOUT | POLLWRNORM;}/* Get packet from user space buffer(already verified) */static inline ssize_t hci_vhci_get_user(struct hci_vhci_struct *hci_vhci, const char __user *buf, size_t count){	struct sk_buff *skb;	if (count > HCI_MAX_FRAME_SIZE)		return -EINVAL;	if (!(skb = bt_skb_alloc(count, GFP_KERNEL)))		return -ENOMEM;		if (copy_from_user(skb_put(skb, count), buf, count)) {		kfree_skb(skb);		return -EFAULT;	}	skb->dev = (void *) hci_vhci->hdev;	skb->pkt_type = *((__u8 *) skb->data);	skb_pull(skb, 1);	hci_recv_frame(skb);	return count;} /* Write */static ssize_t hci_vhci_chr_write(struct file * file, const char __user * buf, 			     size_t count, loff_t *pos){	struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data;	if (verify_area(VERIFY_READ, buf, count))		return -EFAULT;	return hci_vhci_get_user(hci_vhci, buf, count);}/* Put packet to user space buffer(already verified) */static inline ssize_t hci_vhci_put_user(struct hci_vhci_struct *hci_vhci,				       struct sk_buff *skb, char __user *buf,				       int count){	int len = count, total = 0;	char __user *ptr = buf;	len = min_t(unsigned int, skb->len, len);	if (copy_to_user(ptr, skb->data, len))		return -EFAULT;	total += len;	hci_vhci->hdev->stat.byte_tx += len;	switch (skb->pkt_type) {		case HCI_COMMAND_PKT:			hci_vhci->hdev->stat.cmd_tx++;			break;		case HCI_ACLDATA_PKT:			hci_vhci->hdev->stat.acl_tx++;			break;		case HCI_SCODATA_PKT:			hci_vhci->hdev->stat.cmd_tx++;			break;	};	return total;}/* Read */static ssize_t hci_vhci_chr_read(struct file * file, char __user * buf, size_t count, loff_t *pos){	struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data;	DECLARE_WAITQUEUE(wait, current);	struct sk_buff *skb;	ssize_t ret = 0;	add_wait_queue(&hci_vhci->read_wait, &wait);	while (count) {		set_current_state(TASK_INTERRUPTIBLE);		/* Read frames from device queue */		if (!(skb = skb_dequeue(&hci_vhci->readq))) {			if (file->f_flags & O_NONBLOCK) {				ret = -EAGAIN;				break;			}			if (signal_pending(current)) {				ret = -ERESTARTSYS;				break;			}			/* Nothing to read, let's sleep */			schedule();			continue;		}		if (!verify_area(VERIFY_WRITE, buf, count))			ret = hci_vhci_put_user(hci_vhci, skb, buf, count);		else			ret = -EFAULT;		kfree_skb(skb);		break;	}	set_current_state(TASK_RUNNING);	remove_wait_queue(&hci_vhci->read_wait, &wait);	return ret;}static loff_t hci_vhci_chr_lseek(struct file * file, loff_t offset, int origin){	return -ESPIPE;}static int hci_vhci_chr_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg){	return -EINVAL;}static int hci_vhci_chr_fasync(int fd, struct file *file, int on){	struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data;	int ret;	if ((ret = fasync_helper(fd, file, on, &hci_vhci->fasync)) < 0)		return ret;  	if (on)		hci_vhci->flags |= VHCI_FASYNC;	else 		hci_vhci->flags &= ~VHCI_FASYNC;	return 0;}static int hci_vhci_chr_open(struct inode *inode, struct file * file){	struct hci_vhci_struct *hci_vhci = NULL; 	struct hci_dev *hdev;	if (!(hci_vhci = kmalloc(sizeof(struct hci_vhci_struct), GFP_KERNEL)))		return -ENOMEM;	memset(hci_vhci, 0, sizeof(struct hci_vhci_struct));	skb_queue_head_init(&hci_vhci->readq);	init_waitqueue_head(&hci_vhci->read_wait);	/* Initialize and register HCI device */	hdev = hci_alloc_dev();	if (!hdev) {		kfree(hci_vhci);		return -ENOMEM;	}	hci_vhci->hdev = hdev;	hdev->type = HCI_VHCI;	hdev->driver_data = hci_vhci;	hdev->open  = hci_vhci_open;	hdev->close = hci_vhci_close;	hdev->flush = hci_vhci_flush;	hdev->send  = hci_vhci_send_frame;	hdev->destruct = hci_vhci_destruct;	hdev->owner = THIS_MODULE;		if (hci_register_dev(hdev) < 0) {		kfree(hci_vhci);		hci_free_dev(hdev);		return -EBUSY;	}	file->private_data = hci_vhci;	return nonseekable_open(inode, file);   }static int hci_vhci_chr_close(struct inode *inode, struct file *file){	struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data;	if (hci_unregister_dev(hci_vhci->hdev) < 0) {		BT_ERR("Can't unregister HCI device %s", hci_vhci->hdev->name);	}	hci_free_dev(hci_vhci->hdev);	file->private_data = NULL;	return 0;}static struct file_operations hci_vhci_fops = {	.owner	= THIS_MODULE,		.llseek	= hci_vhci_chr_lseek,	.read	= hci_vhci_chr_read,	.write	= hci_vhci_chr_write,	.poll	= hci_vhci_chr_poll,	.ioctl	= hci_vhci_chr_ioctl,	.open	= hci_vhci_chr_open,	.release	= hci_vhci_chr_close,	.fasync	= hci_vhci_chr_fasync		};static struct miscdevice hci_vhci_miscdev={        VHCI_MINOR,        "hci_vhci",        &hci_vhci_fops};int __init hci_vhci_init(void){	BT_INFO("VHCI driver ver %s", VERSION);	if (misc_register(&hci_vhci_miscdev)) {		BT_ERR("Can't register misc device %d\n", VHCI_MINOR);		return -EIO;	}	return 0;}void hci_vhci_cleanup(void){	misc_deregister(&hci_vhci_miscdev);}module_init(hci_vhci_init);module_exit(hci_vhci_cleanup);MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>");MODULE_DESCRIPTION("Bluetooth VHCI driver ver " VERSION);MODULE_LICENSE("GPL"); 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产一区二区三区久久久蜜月| 亚洲视频网在线直播| 久久久久国产精品免费免费搜索| 自拍偷拍国产亚洲| 蜜臀精品一区二区三区在线观看| 99国产精品一区| www激情久久| 婷婷中文字幕一区三区| 99久久99精品久久久久久 | 成人高清免费在线播放| 欧美日韩国产经典色站一区二区三区| 国产调教视频一区| 久久精品国产亚洲一区二区三区| 在线观看区一区二| 1024成人网色www| 懂色av一区二区在线播放| 欧美成人bangbros| 日韩激情av在线| 在线观看亚洲一区| 亚洲欧美另类图片小说| 福利一区福利二区| 国产清纯白嫩初高生在线观看91 | 欧美在线啊v一区| 中文字幕一区在线观看| 国产高清无密码一区二区三区| 欧美一区二区观看视频| 亚洲r级在线视频| 欧美午夜在线一二页| 一区av在线播放| 欧日韩精品视频| 亚洲国产色一区| 在线一区二区三区四区五区 | 精品区一区二区| 蜜桃久久久久久| 日韩精品一区二区三区老鸭窝| 日韩高清国产一区在线| 欧美一区二区在线不卡| 免费在线看成人av| 欧美成va人片在线观看| 激情综合网av| 中文字幕av在线一区二区三区| 高清不卡在线观看av| 欧美韩国一区二区| av一二三不卡影片| 亚洲国产人成综合网站| 欧美人妇做爰xxxⅹ性高电影| 五月激情综合色| 日韩午夜电影av| 国产福利一区二区| 国产精品白丝在线| 欧美午夜精品久久久久久孕妇| 亚洲国产aⅴ成人精品无吗| 欧美日韩国产123区| 蜜臀精品一区二区三区在线观看| 久久综合久色欧美综合狠狠| 国产精品一级片| 亚洲欧美视频在线观看视频| 欧美亚洲精品一区| 免费看日韩精品| 欧美韩国日本不卡| 欧美日韩视频一区二区| 激情综合网激情| 亚洲精品国产无套在线观| 欧美日韩国产另类不卡| 国产精品亚洲第一| 一区二区三区中文字幕精品精品| 欧美精品在线观看一区二区| 激情综合色综合久久综合| 中文字幕中文在线不卡住| 欧美制服丝袜第一页| 黄色小说综合网站| 亚洲欧美日韩人成在线播放| 欧美一区二区免费观在线| 国产sm精品调教视频网站| 亚洲影院理伦片| 国产午夜亚洲精品羞羞网站| 色哦色哦哦色天天综合| 久久99国内精品| 亚洲一二三区不卡| 久久久国产精品麻豆| 欧美日韩在线电影| 国产福利一区在线| 日韩1区2区3区| 亚洲欧美激情小说另类| 精品成a人在线观看| 在线观看一区不卡| 粉嫩蜜臀av国产精品网站| 天堂一区二区在线免费观看| 1024精品合集| 久久精品网站免费观看| 欧美群妇大交群中文字幕| 91年精品国产| 国产精品77777| 久久成人久久鬼色| 日日嗨av一区二区三区四区| 亚洲人快播电影网| 国产精品久久久久久久久晋中| 欧美一区二区精美| 欧美精品vⅰdeose4hd| 99re66热这里只有精品3直播| 国产一区二区在线视频| 无码av中文一区二区三区桃花岛| 亚洲女与黑人做爰| 国产精品久久国产精麻豆99网站 | 91传媒视频在线播放| 国产91精品入口| 国内成人精品2018免费看| 三级一区在线视频先锋| 亚洲国产婷婷综合在线精品| 亚洲天堂成人网| 亚洲男人的天堂av| 亚洲黄色小说网站| 亚洲精品写真福利| 亚洲国产中文字幕| 亚洲va天堂va国产va久| 亚洲国产视频一区二区| 亚洲成人免费影院| 偷拍一区二区三区| 秋霞午夜av一区二区三区| 免费不卡在线观看| 激情综合五月天| 国产成人av电影在线播放| 国产一级精品在线| 高清不卡一区二区在线| 国产成人av一区| 成人短视频下载| 色狠狠桃花综合| 欧美日韩亚州综合| 日韩午夜激情av| 久久久精品欧美丰满| 国产精品传媒在线| 一区二区三区毛片| 蜜臀久久99精品久久久久宅男| 六月丁香综合在线视频| 国产精品99久久久久久久女警 | 日韩精品免费视频人成| 久久精品久久99精品久久| 国产精品99久久久久| 色综合亚洲欧洲| 欧美一区二区黄色| 国产免费久久精品| 亚洲国产一区二区三区青草影视| 天天亚洲美女在线视频| 国产一区二区在线影院| 91老师片黄在线观看| 欧美年轻男男videosbes| 欧美精品一区二区三区蜜臀| 中文字幕电影一区| 亚洲成在线观看| 国产精品综合二区| 欧美在线播放高清精品| 精品噜噜噜噜久久久久久久久试看 | 精品日韩在线观看| 中文字幕亚洲区| 日本强好片久久久久久aaa| 国产精品系列在线播放| 99re亚洲国产精品| 欧美大片一区二区三区| 亚洲欧洲在线观看av| 日本欧美久久久久免费播放网| 高潮精品一区videoshd| 欧美日韩一区二区三区四区五区| 久久免费视频色| 亚洲成人av中文| youjizz久久| 久久影视一区二区| 性感美女极品91精品| 99免费精品视频| 久久午夜羞羞影院免费观看| 一区二区三区在线视频观看| 国产成人精品免费看| 日韩欧美中文字幕公布| 一区二区在线观看免费 | 精品国产一区二区三区忘忧草 | 欧美r级在线观看| 亚洲精品写真福利| 成人黄色电影在线| 精品国产亚洲在线| 爽好多水快深点欧美视频| 在线一区二区三区| 国产精品电影一区二区| 国产激情视频一区二区在线观看| 欧美精品乱码久久久久久| 一区二区三区在线视频播放| av资源网一区| 亚洲欧洲精品一区二区精品久久久 | 成人黄色大片在线观看| 久久精品亚洲一区二区三区浴池| 麻豆精品一区二区| 91国偷自产一区二区开放时间| 水蜜桃久久夜色精品一区的特点 | 成人app在线| 久久欧美一区二区| 九色综合狠狠综合久久| 欧美疯狂性受xxxxx喷水图片| 一区二区三区精品| 在线视频国产一区| 亚洲福利电影网| 欧美日韩精品专区| 三级欧美在线一区|