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

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

?? inode.c

?? 優龍2410linux2.6.8內核源代碼
?? C
?? 第 1 頁 / 共 4 頁
字號:
/* * inode.c -- user mode filesystem api for usb gadget controllers * * Copyright (C) 2003 David Brownell * Copyright (C) 2003 Agilent Technologies * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#define	DEBUG 1			/* data to help fault diagnosis */// #define	VERBOSE		/* extra debug messages (success too) */#include <linux/init.h>#include <linux/module.h>#include <linux/fs.h>#include <linux/pagemap.h>#include <linux/uts.h>#include <linux/wait.h>#include <linux/compiler.h>#include <asm/uaccess.h>#include <linux/slab.h>#include <linux/device.h>#include <linux/moduleparam.h>#include <linux/usb_gadgetfs.h>#include <linux/usb_gadget.h>/* * The gadgetfs API maps each endpoint to a file descriptor so that you * can use standard synchronous read/write calls for I/O.  There's some * O_NONBLOCK and O_ASYNC/FASYNC style i/o support.  Example usermode * drivers show how this works in practice. * * Key parts that must be USB-specific are protocols defining how the * read/write operations relate to the hardware state machines.  There * are two types of files.  One type is for the device, implementing ep0. * The other type is for each IN or OUT endpoint.  In both cases, the * user mode driver must configure the hardware before using it. * * - First, dev_config() is called when /dev/gadget/$CHIP is configured *   (by writing configuration and device descriptors).  Afterwards it *   may serve as a source of device events, used to handle all control *   requests other than basic enumeration. * * - Then either immediately, or after a SET_CONFIGURATION control request, *   ep_config() is called when each /dev/gadget/ep* file is configured *   (by writing endpoint descriptors).  Afterwards these files are used *   to write() IN data or to read() OUT data.  To halt the endpoint, a *   "wrong direction" request is issued (like reading an IN endpoint). * * Unlike "usbfs" the only ioctl()s are for things that are rare, and maybe * not possible on all hardware.  For example, precise fault handling with * respect to data left in endpoint fifos after aborted operations; or * selective clearing of endpoint halts, to implement SET_INTERFACE. */#define	DRIVER_DESC	"USB Gadget filesystem"#define	DRIVER_VERSION	"20 Aug 2003"static const char driver_desc [] = DRIVER_DESC;static const char shortname [] = "gadgetfs";MODULE_DESCRIPTION (DRIVER_DESC);MODULE_AUTHOR ("David Brownell");MODULE_LICENSE ("GPL");/*----------------------------------------------------------------------*/#define GADGETFS_MAGIC		0xaee71ee7#define DMA_ADDR_INVALID	(~(dma_addr_t)0)/* /dev/gadget/$CHIP represents ep0 and the whole device */enum ep0_state {	/* DISBLED is the initial state.	 */	STATE_DEV_DISABLED = 0,	/* Only one open() of /dev/gadget/$CHIP; only one file tracks	 * ep0/device i/o modes and binding to the controller.  Driver	 * must always write descriptors to initialize the device, then	 * the device becomes UNCONNECTED until enumeration.	 */	STATE_OPENED,	/* From then on, ep0 fd is in either of two basic modes:	 * - (UN)CONNECTED: read usb_gadgetfs_event(s) from it	 * - SETUP: read/write will transfer control data and succeed;	 *   or if "wrong direction", performs protocol stall	 */	STATE_UNCONNECTED,	STATE_CONNECTED,	STATE_SETUP,	/* UNBOUND means the driver closed ep0, so the device won't be	 * accessible again (DEV_DISABLED) until all fds are closed.	 */	STATE_DEV_UNBOUND,};/* enough for the whole queue: most events invalidate others */#define	N_EVENT			5struct dev_data {	spinlock_t			lock;	atomic_t			count;	enum ep0_state			state;	struct usb_gadgetfs_event	event [N_EVENT];	unsigned			ev_next;	struct fasync_struct		*fasync;	u8				current_config;	/* drivers reading ep0 MUST handle control requests (SETUP)	 * reported that way; else the host will time out.	 */	unsigned			usermode_setup : 1,					setup_in : 1,					setup_can_stall : 1,					setup_out_ready : 1,					setup_out_error : 1,					setup_abort : 1;	/* the rest is basically write-once */	struct usb_config_descriptor	*config, *hs_config;	struct usb_device_descriptor	*dev;	struct usb_request		*req;	struct usb_gadget		*gadget;	struct list_head		epfiles;	void				*buf;	wait_queue_head_t		wait;	struct super_block		*sb;	struct dentry			*dentry;	/* except this scratch i/o buffer for ep0 */	u8				rbuf [256];};static inline void get_dev (struct dev_data *data){	atomic_inc (&data->count);}static void put_dev (struct dev_data *data){	if (likely (!atomic_dec_and_test (&data->count)))		return;	/* needs no more cleanup */	BUG_ON (waitqueue_active (&data->wait));	kfree (data);}static struct dev_data *dev_new (void){	struct dev_data		*dev;	dev = kmalloc (sizeof *dev, GFP_KERNEL);	if (!dev)		return 0;	memset (dev, 0, sizeof *dev);	dev->state = STATE_DEV_DISABLED;	atomic_set (&dev->count, 1);	spin_lock_init (&dev->lock);	INIT_LIST_HEAD (&dev->epfiles);	init_waitqueue_head (&dev->wait);	return dev;}/*----------------------------------------------------------------------*//* other /dev/gadget/$ENDPOINT files represent endpoints */enum ep_state {	STATE_EP_DISABLED = 0,	STATE_EP_READY,	STATE_EP_DEFER_ENABLE,	STATE_EP_ENABLED,	STATE_EP_UNBOUND,};struct ep_data {	struct semaphore		lock;	enum ep_state			state;	atomic_t			count;	struct dev_data			*dev;	/* must hold dev->lock before accessing ep or req */	struct usb_ep			*ep;	struct usb_request		*req;	ssize_t				status;	char				name [16];	struct usb_endpoint_descriptor	desc, hs_desc;	struct list_head		epfiles;	wait_queue_head_t		wait;	struct dentry			*dentry;	struct inode			*inode;};static inline void get_ep (struct ep_data *data){	atomic_inc (&data->count);}static void put_ep (struct ep_data *data){	if (likely (!atomic_dec_and_test (&data->count)))		return;	put_dev (data->dev);	/* needs no more cleanup */	BUG_ON (!list_empty (&data->epfiles));	BUG_ON (waitqueue_active (&data->wait));	BUG_ON (down_trylock (&data->lock) != 0);	kfree (data);}/*----------------------------------------------------------------------*//* most "how to use the hardware" policy choices are in userspace: * mapping endpoint roles the driver needs to the capabilities that * the usb controller exposes. */#ifdef	CONFIG_USB_GADGET_DUMMY_HCD/* act (mostly) like a net2280 */#define CONFIG_USB_GADGET_NET2280#endif#ifdef	CONFIG_USB_GADGET_NET2280#define CHIP			"net2280"#define HIGHSPEED#endif#ifdef	CONFIG_USB_GADGET_PXA2XX#define CHIP			"pxa2xx_udc"/* earlier hardware doesn't have UDCCFR, races set_{config,interface} */#warning works best with pxa255 or newer#endif#ifdef	CONFIG_USB_GADGET_GOKU#define CHIP			"goku_udc"#endif#ifdef	CONFIG_USB_GADGET_SA1100#define CHIP			"sa1100"#endif/*----------------------------------------------------------------------*//* NOTE:  don't use dev_printk calls before binding to the gadget * at the end of ep0 configuration, or after unbind. *//* too wordy: dev_printk(level , &(d)->gadget->dev , fmt , ## args) */#define xprintk(d,level,fmt,args...) \	printk(level "%s: " fmt , shortname , ## args)#ifdef DEBUG#define DBG(dev,fmt,args...) \	xprintk(dev , KERN_DEBUG , fmt , ## args)#else#define DBG(dev,fmt,args...) \	do { } while (0)#endif /* DEBUG */#ifdef VERBOSE#define VDEBUG	DBG#else#define VDEBUG(dev,fmt,args...) \	do { } while (0)#endif /* DEBUG */#define ERROR(dev,fmt,args...) \	xprintk(dev , KERN_ERR , fmt , ## args)#define WARN(dev,fmt,args...) \	xprintk(dev , KERN_WARNING , fmt , ## args)#define INFO(dev,fmt,args...) \	xprintk(dev , KERN_INFO , fmt , ## args)/*----------------------------------------------------------------------*//* SYNCHRONOUS ENDPOINT OPERATIONS (bulk/intr/iso) * * After opening, configure non-control endpoints.  Then use normal * stream read() and write() requests; and maybe ioctl() to get more * precise FIFO status when recovering from cancelation. */static void epio_complete (struct usb_ep *ep, struct usb_request *req){	struct ep_data	*epdata = ep->driver_data;	if (!req->context)		return;	if (req->status)		epdata->status = req->status;	else		epdata->status = req->actual;	complete ((struct completion *)req->context);}/* tasklock endpoint, returning when it's connected. * still need dev->lock to use epdata->ep. */static intget_ready_ep (unsigned f_flags, struct ep_data *epdata){	int	val;	if (f_flags & O_NONBLOCK) {		if (down_trylock (&epdata->lock) != 0)			goto nonblock;		if (epdata->state != STATE_EP_ENABLED) {			up (&epdata->lock);nonblock:			val = -EAGAIN;		} else			val = 0;		return val;	}	if ((val = down_interruptible (&epdata->lock)) < 0)		return val;newstate:	switch (epdata->state) {	case STATE_EP_ENABLED:		break;	case STATE_EP_DEFER_ENABLE:		DBG (epdata->dev, "%s wait for host\n", epdata->name);		if ((val = wait_event_interruptible (epdata->wait, 				epdata->state != STATE_EP_DEFER_ENABLE				|| epdata->dev->state == STATE_DEV_UNBOUND				)) < 0)			goto fail;		goto newstate;	// case STATE_EP_DISABLED:		/* "can't happen" */	// case STATE_EP_READY:			/* "can't happen" */	default:				/* error! */		pr_debug ("%s: ep %p not available, state %d\n",				shortname, epdata, epdata->state);		// FALLTHROUGH	case STATE_EP_UNBOUND:			/* clean disconnect */		val = -ENODEV;fail:		up (&epdata->lock);	}	return val;}static ssize_tep_io (struct ep_data *epdata, void *buf, unsigned len){	DECLARE_COMPLETION (done);	int value;	spin_lock_irq (&epdata->dev->lock);	if (likely (epdata->ep != NULL)) {		struct usb_request	*req = epdata->req;		req->context = &done;		req->complete = epio_complete;		req->buf = buf;		req->length = len;		value = usb_ep_queue (epdata->ep, req, GFP_ATOMIC);	} else		value = -ENODEV;	spin_unlock_irq (&epdata->dev->lock);	if (likely (value == 0)) {		value = wait_event_interruptible (done.wait, done.done);		if (value != 0) {			spin_lock_irq (&epdata->dev->lock);			if (likely (epdata->ep != NULL)) {				DBG (epdata->dev, "%s i/o interrupted\n",						epdata->name);				usb_ep_dequeue (epdata->ep, epdata->req);				spin_unlock_irq (&epdata->dev->lock);				wait_event (done.wait, done.done);				if (epdata->status == -ECONNRESET)					epdata->status = -EINTR;			} else {				spin_unlock_irq (&epdata->dev->lock);				DBG (epdata->dev, "endpoint gone\n");				epdata->status = -ENODEV;			}		}		return epdata->status;	}	return value;}/* handle a synchronous OUT bulk/intr/iso transfer */static ssize_tep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr){	struct ep_data		*data = fd->private_data;	void			*kbuf;	ssize_t			value;	if ((value = get_ready_ep (fd->f_flags, data)) < 0)		return value;	/* halt any endpoint by doing a "wrong direction" i/o call */	if (data->desc.bEndpointAddress & USB_DIR_IN) {		if ((data->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)				== USB_ENDPOINT_XFER_ISOC)			return -EINVAL;		DBG (data->dev, "%s halt\n", data->name);		spin_lock_irq (&data->dev->lock);		if (likely (data->ep != NULL))			usb_ep_set_halt (data->ep);		spin_unlock_irq (&data->dev->lock);		up (&data->lock);		return -EBADMSG;	}	/* FIXME readahead for O_NONBLOCK and poll(); careful with ZLPs */	value = -ENOMEM;	kbuf = kmalloc (len, SLAB_KERNEL);	if (unlikely (!kbuf))		goto free1;	value = ep_io (data, kbuf, len);	VDEBUG (data->dev, "%s read %d OUT, status %d\n",		data->name, len, value);	if (value >= 0 && copy_to_user (buf, kbuf, value))		value = -EFAULT;free1:	up (&data->lock);	kfree (kbuf);	return value;}/* handle a synchronous IN bulk/intr/iso transfer */static ssize_tep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr){	struct ep_data		*data = fd->private_data;	void			*kbuf;	ssize_t			value;	if ((value = get_ready_ep (fd->f_flags, data)) < 0)		return value;	/* halt any endpoint by doing a "wrong direction" i/o call */	if (!(data->desc.bEndpointAddress & USB_DIR_IN)) {		if ((data->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)				== USB_ENDPOINT_XFER_ISOC)			return -EINVAL;		DBG (data->dev, "%s halt\n", data->name);		spin_lock_irq (&data->dev->lock);		if (likely (data->ep != NULL))			usb_ep_set_halt (data->ep);		spin_unlock_irq (&data->dev->lock);		up (&data->lock);		return -EBADMSG;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91伊人久久大香线蕉| 国产精品伦理在线| 国产一区二区三区免费播放| 欧美精品一区二区三| 国产一区二区三区在线看麻豆| 国产亚洲午夜高清国产拍精品 | 亚洲mv在线观看| 欧美伦理影视网| 久久激情五月婷婷| 国产网站一区二区三区| 91蜜桃婷婷狠狠久久综合9色| 亚洲国产日产av| 精品久久久久香蕉网| 国产精品一级片| 自拍偷拍国产亚洲| 欧美视频一区二区三区在线观看| 蜜臀精品久久久久久蜜臀| 国产亚洲短视频| 在线一区二区视频| 另类人妖一区二区av| 国产精品国模大尺度视频| 欧美无乱码久久久免费午夜一区| 美女一区二区三区| 国产精品护士白丝一区av| 欧美日韩一区中文字幕| 国产一区视频在线看| 亚洲视频1区2区| 7777精品伊人久久久大香线蕉的| 国产高清精品网站| 一区二区三区欧美日| 日韩免费一区二区| 91亚洲国产成人精品一区二区三| 日本不卡一区二区三区| 国产精品伦一区二区三级视频| 欧美精品日韩一区| 春色校园综合激情亚洲| 午夜精品久久久久久久| 国产午夜精品久久| 欧美日韩国产成人在线免费| 国产高清不卡一区二区| 亚洲自拍与偷拍| 国产亚洲精品中文字幕| 欧美日韩一区二区在线观看| 国产黑丝在线一区二区三区| 亚洲123区在线观看| 国产欧美一区二区三区鸳鸯浴| 欧美日韩精品欧美日韩精品| 成人网在线免费视频| 五月天激情小说综合| 国产精品剧情在线亚洲| 日韩午夜精品视频| 色菇凉天天综合网| 国产精品香蕉一区二区三区| 丝袜美腿成人在线| 亚洲色图视频网站| 久久这里只有精品首页| 欧美日韩不卡视频| 91在线观看地址| 国产精品18久久久久久久网站| 亚洲va欧美va国产va天堂影院| 国产精品国产自产拍在线| 日韩精品自拍偷拍| 欧美影视一区二区三区| av成人免费在线观看| 精品一区二区综合| 亚洲成人你懂的| 中文字幕日韩精品一区| 国产性天天综合网| 欧美一级片在线看| 欧美亚洲国产怡红院影院| 国产精品资源网| 美女mm1313爽爽久久久蜜臀| 亚洲成人免费视频| 亚洲色大成网站www久久九九| 国产午夜亚洲精品不卡| 欧美成人伊人久久综合网| 精品视频免费在线| 色94色欧美sute亚洲线路一久| 成人精品电影在线观看| 国产伦精一区二区三区| 美国十次了思思久久精品导航| 亚洲成a人片综合在线| 一区二区三区日韩在线观看| 中文字幕永久在线不卡| 国产欧美一区二区精品久导航 | 日韩午夜电影在线观看| 欧美男人的天堂一二区| 欧美色网一区二区| 欧美综合在线视频| 91久久香蕉国产日韩欧美9色| 99综合电影在线视频| 成人高清免费在线播放| 国产精品一区二区在线观看不卡 | 欧美色网一区二区| 91福利在线播放| 91丨porny丨在线| 91丨porny丨中文| 91香蕉国产在线观看软件| av不卡在线观看| 91在线国产福利| 91蜜桃视频在线| 色综合久久99| 在线精品亚洲一区二区不卡| 在线精品观看国产| 欧美在线观看你懂的| 欧美三级三级三级爽爽爽| 精品视频一区二区三区免费| 欧美午夜电影网| 欧美日韩国产精品自在自线| 欧美日韩免费在线视频| 欧美日韩电影在线播放| 制服丝袜一区二区三区| 欧美一卡2卡3卡4卡| 欧美videos中文字幕| 精品久久国产97色综合| 2017欧美狠狠色| 欧美国产日本韩| 日韩理论片在线| 一区二区三区中文字幕电影 | 国产福利精品一区| 国产ts人妖一区二区| 成人一二三区视频| 99re免费视频精品全部| 在线观看视频欧美| 7777女厕盗摄久久久| 日韩美女在线视频| 久久久高清一区二区三区| 国产精品久久一卡二卡| 亚洲精品成人悠悠色影视| 亚洲小少妇裸体bbw| 日韩精品午夜视频| 国产一区视频导航| 丁香激情综合国产| 一本大道久久a久久综合| 欧美日韩黄色影视| 精品成人私密视频| 中文字幕在线不卡国产视频| 亚洲午夜羞羞片| 久久av中文字幕片| 成人av电影免费观看| 欧美日韩精品一区二区在线播放| 欧美videos大乳护士334| 国产亚洲成aⅴ人片在线观看| 亚洲男人的天堂在线观看| 偷拍亚洲欧洲综合| 国产麻豆9l精品三级站| 色综合咪咪久久| 日韩一级免费一区| 中国av一区二区三区| 亚洲成人第一页| 国产精品亚洲专一区二区三区| 一本色道久久加勒比精品 | 亚洲五月六月丁香激情| 免费欧美高清视频| 成人精品国产一区二区4080| 欧美日韩精品一区二区天天拍小说| 精品国产一区二区三区不卡| 亚洲欧洲综合另类在线| 91网页版在线| 欧美日韩国产天堂| 国产亚洲欧美在线| 亚洲bt欧美bt精品| 成人网在线播放| 欧美精品国产精品| 国产欧美精品一区| 五月天丁香久久| 成人免费看视频| 欧美一区二区日韩| 亚洲欧美一区二区在线观看| 蜜臀久久99精品久久久久宅男| 成人激情动漫在线观看| 91精品国产欧美一区二区18| 亚洲欧洲99久久| 蜜桃久久久久久| 色婷婷av一区二区三区之一色屋| 日韩精品一区二区三区中文不卡 | 天天色 色综合| 国产传媒欧美日韩成人| 欧美裸体一区二区三区| 中文字幕+乱码+中文字幕一区| 日本特黄久久久高潮| 99re热这里只有精品免费视频| 精品国产免费一区二区三区香蕉| 一区二区三区不卡视频在线观看| 国产一区二区三区电影在线观看| 欧美亚洲高清一区二区三区不卡| 欧美经典三级视频一区二区三区| 日本不卡一区二区三区 | 一本大道久久a久久综合婷婷| 亚洲精品在线电影| 亚洲一本大道在线| 成人国产精品视频| 日韩免费观看高清完整版 | 日本va欧美va瓶| 91国偷自产一区二区使用方法| 久久综合资源网| 日一区二区三区| 欧洲在线/亚洲| 日韩久久一区二区| 国产一区二区三区四 |