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

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

?? hub.c

?? 是關于linux2.5.1的完全源碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * USB hub driver. * * (C) Copyright 1999 Linus Torvalds * (C) Copyright 1999 Johannes Erdfelt * (C) Copyright 1999 Gregory P. Smith * (C) Copyright 2001 Brad Hards (bhards@bigpond.net.au) * */#include <linux/config.h>#include <linux/kernel.h>#include <linux/errno.h>#include <linux/module.h>#include <linux/completion.h>#include <linux/sched.h>#include <linux/list.h>#include <linux/slab.h>#include <linux/smp_lock.h>#ifdef CONFIG_USB_DEBUG	#define DEBUG#else	#undef DEBUG#endif#include <linux/usb.h>#include <linux/usbdevice_fs.h>#include <asm/semaphore.h>#include <asm/uaccess.h>#include <asm/byteorder.h>#include "hcd.h"#include "hub.h"/* Wakes up khubd */static spinlock_t hub_event_lock = SPIN_LOCK_UNLOCKED;static DECLARE_MUTEX(usb_address0_sem);static LIST_HEAD(hub_event_list);	/* List of hubs needing servicing */static LIST_HEAD(hub_list);		/* List of all hubs (for cleanup) */static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);static int khubd_pid = 0;			/* PID of khubd */static DECLARE_COMPLETION(khubd_exited);#ifdef	DEBUGstatic inline char *portspeed (int portstatus){	if (portstatus & (1 << USB_PORT_FEAT_HIGHSPEED))    		return "480 Mb/s";	else if (portstatus & (1 << USB_PORT_FEAT_LOWSPEED))		return "1.5 Mb/s";	else		return "12 Mb/s";}#endif/* USB 2.0 spec Section 11.24.4.5 */static int usb_get_hub_descriptor(struct usb_device *dev, void *data, int size){	return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),		USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB,		USB_DT_HUB << 8, 0, data, size, HZ);}/* * USB 2.0 spec Section 11.24.2.1 */static int usb_clear_hub_feature(struct usb_device *dev, int feature){	return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),		USB_REQ_CLEAR_FEATURE, USB_RT_HUB, feature, 0, NULL, 0, HZ);}/* * USB 2.0 spec Section 11.24.2.2 * BUG: doesn't handle port indicator selector in high byte of wIndex */static int usb_clear_port_feature(struct usb_device *dev, int port, int feature){	return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),		USB_REQ_CLEAR_FEATURE, USB_RT_PORT, feature, port, NULL, 0, HZ);}/* * USB 2.0 spec Section 11.24.2.13 * BUG: doesn't handle port indicator selector in high byte of wIndex */static int usb_set_port_feature(struct usb_device *dev, int port, int feature){	return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),		USB_REQ_SET_FEATURE, USB_RT_PORT, feature, port, NULL, 0, HZ);}/* * USB 2.0 spec Section 11.24.2.6 */static int usb_get_hub_status(struct usb_device *dev, void *data){	return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),		USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_HUB, 0, 0,		data, sizeof(struct usb_hub_status), HZ);}/* * USB 2.0 spec Section 11.24.2.7 */static int usb_get_port_status(struct usb_device *dev, int port, void *data){	return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),		USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port,		data, sizeof(struct usb_hub_status), HZ);}/* completion function, fires on port status changes and various faults */static void hub_irq(struct urb *urb){	struct usb_hub *hub = (struct usb_hub *)urb->context;	unsigned long flags;	switch (urb->status) {	case -ENOENT:		/* synchronous unlink */	case -ECONNRESET:	/* async unlink */	case -ESHUTDOWN:	/* hardware going away */		return;	default:		/* presumably an error */		/* Cause a hub reset after 10 consecutive errors */		dbg("hub '%s' status %d for interrupt transfer",			urb->dev->devpath, urb->status);		if ((++hub->nerrors < 10) || hub->error)			return;		hub->error = urb->status;		/* FALL THROUGH */		/* let khubd handle things */	case 0:			/* we got data:  port status changed */		break;	}	hub->nerrors = 0;	/* Something happened, let khubd figure it out */	spin_lock_irqsave(&hub_event_lock, flags);	if (list_empty(&hub->event_list)) {		list_add(&hub->event_list, &hub_event_list);		wake_up(&khubd_wait);	}	spin_unlock_irqrestore(&hub_event_lock, flags);}static void usb_hub_power_on(struct usb_hub *hub){	int i;	/* Enable power to the ports */	dbg("enabling power on all ports");	for (i = 0; i < hub->descriptor->bNbrPorts; i++)		usb_set_port_feature(hub->dev, i + 1, USB_PORT_FEAT_POWER);	/* Wait for power to be enabled */	wait_ms(hub->descriptor->bPwrOn2PwrGood * 2);}static int usb_hub_configure(struct usb_hub *hub,	struct usb_endpoint_descriptor *endpoint){	struct usb_device *dev = hub->dev;	struct usb_hub_status hubstatus;	char portstr[USB_MAXCHILDREN + 1];	unsigned int pipe;	int i, maxp, ret;	hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL);	if (!hub->descriptor) {		err("Unable to kmalloc %Zd bytes for hub descriptor",			sizeof(*hub->descriptor));		return -1;	}	/* Request the entire hub descriptor.	 * hub->descriptor can handle USB_MAXCHILDREN ports,	 * but the hub can/will return fewer bytes here.	 */	ret = usb_get_hub_descriptor(dev, hub->descriptor,			sizeof(*hub->descriptor));	if (ret < 0) {		err("Unable to get hub descriptor (err = %d)", ret);		kfree(hub->descriptor);		return -1;	} else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) {		err("Hub is too big! %d children", hub->descriptor->bNbrPorts);		kfree(hub->descriptor);		return -1;	}	dev->maxchild = hub->descriptor->bNbrPorts;	info("%d port%s detected", dev->maxchild,		(dev->maxchild == 1) ? "" : "s");	le16_to_cpus(&hub->descriptor->wHubCharacteristics);	if (hub->descriptor->wHubCharacteristics & HUB_CHAR_COMPOUND)		dbg("part of a compound device");	else		dbg("standalone hub");	switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_LPSM) {		case 0x00:			dbg("ganged power switching");			break;		case 0x01:			dbg("individual port power switching");			break;		case 0x02:		case 0x03:			dbg("unknown reserved power switching mode");			break;	}	switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_OCPM) {		case 0x00:			dbg("global over-current protection");			break;		case 0x08:			dbg("individual port over-current protection");			break;		case 0x10:		case 0x18:			dbg("no over-current protection");                        break;	}	switch (dev->descriptor.bDeviceProtocol) {		case 0:			break;		case 1:			dbg("Single TT");			hub->tt.hub = dev;			break;		case 2:			dbg("TT per port");			hub->tt.hub = dev;			hub->tt.multi = 1;			break;		default:			dbg("Unrecognized hub protocol %d",				dev->descriptor.bDeviceProtocol);			break;	}	switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_TTTT) {		case 0x00:			if (dev->descriptor.bDeviceProtocol != 0)				dbg("TT requires at most 8 FS bit times");			break;		case 0x20:			dbg("TT requires at most 16 FS bit times");			break;		case 0x40:			dbg("TT requires at most 24 FS bit times");			break;		case 0x60:			dbg("TT requires at most 32 FS bit times");			break;	}	dbg("Port indicators are %s supported", 	    (hub->descriptor->wHubCharacteristics & HUB_CHAR_PORTIND)	    	? "" : "not");	dbg("power on to power good time: %dms",		hub->descriptor->bPwrOn2PwrGood * 2);	dbg("hub controller current requirement: %dmA",		hub->descriptor->bHubContrCurrent);	for (i = 0; i < dev->maxchild; i++)		portstr[i] = hub->descriptor->DeviceRemovable			    [((i + 1) / 8)] & (1 << ((i + 1) % 8))			? 'F' : 'R';	portstr[dev->maxchild] = 0;	dbg("port removable status: %s", portstr);	ret = usb_get_hub_status(dev, &hubstatus);	if (ret < 0) {		err("Unable to get hub status (err = %d)", ret);		kfree(hub->descriptor);		return -1;	}	le16_to_cpus(&hubstatus.wHubStatus);	dbg("local power source is %s",		(hubstatus.wHubStatus & HUB_STATUS_LOCAL_POWER)		? "lost (inactive)" : "good");	dbg("%sover-current condition exists",		(hubstatus.wHubStatus & HUB_STATUS_OVERCURRENT) ? "" : "no ");	/* Start the interrupt endpoint */	pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);	maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));	if (maxp > sizeof(hub->buffer))		maxp = sizeof(hub->buffer);	hub->urb = usb_alloc_urb(0, GFP_KERNEL);	if (!hub->urb) {		err("couldn't allocate interrupt urb");		kfree(hub->descriptor);		return -1;	}	FILL_INT_URB(hub->urb, dev, pipe, hub->buffer, maxp, hub_irq,		hub, endpoint->bInterval);	ret = usb_submit_urb(hub->urb, GFP_KERNEL);	if (ret) {		err("usb_submit_urb failed (%d)", ret);		kfree(hub->descriptor);		return -1;	}			/* Wake up khubd */	wake_up(&khubd_wait);	usb_hub_power_on(hub);	return 0;}static void *hub_probe(struct usb_device *dev, unsigned int i,		       const struct usb_device_id *id){	struct usb_interface_descriptor *interface;	struct usb_endpoint_descriptor *endpoint;	struct usb_hub *hub;	unsigned long flags;	interface = &dev->actconfig->interface[i].altsetting[0];	/* Some hubs have a subclass of 1, which AFAICT according to the */	/*  specs is not defined, but it works */	if ((interface->bInterfaceSubClass != 0) &&	    (interface->bInterfaceSubClass != 1)) {		err("invalid subclass (%d) for USB hub device #%d",			interface->bInterfaceSubClass, dev->devnum);		return NULL;	}	/* Multiple endpoints? What kind of mutant ninja-hub is this? */	if (interface->bNumEndpoints != 1) {		err("invalid bNumEndpoints (%d) for USB hub device #%d",			interface->bNumEndpoints, dev->devnum);		return NULL;	}	endpoint = &interface->endpoint[0];	/* Output endpoint? Curiousier and curiousier.. */	if (!(endpoint->bEndpointAddress & USB_DIR_IN)) {		err("Device #%d is hub class, but has output endpoint?",			dev->devnum);		return NULL;	}	/* If it's not an interrupt endpoint, we'd better punt! */	if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)			!= USB_ENDPOINT_XFER_INT) {		err("Device #%d is hub class, but endpoint is not interrupt?",			dev->devnum);		return NULL;	}	/* We found a hub */	info("USB hub found at %s", dev->devpath);	hub = kmalloc(sizeof(*hub), GFP_KERNEL);	if (!hub) {		err("couldn't kmalloc hub struct");		return NULL;	}	memset(hub, 0, sizeof(*hub));	INIT_LIST_HEAD(&hub->event_list);	hub->dev = dev;	init_MUTEX(&hub->khubd_sem);	/* Record the new hub's existence */	spin_lock_irqsave(&hub_event_lock, flags);	INIT_LIST_HEAD(&hub->hub_list);	list_add(&hub->hub_list, &hub_list);	spin_unlock_irqrestore(&hub_event_lock, flags);	if (usb_hub_configure(hub, endpoint) >= 0)		return hub;	err("hub configuration failed for device at %s", dev->devpath);	/* free hub, but first clean up its list. */	spin_lock_irqsave(&hub_event_lock, flags);	/* Delete it and then reset it */	list_del(&hub->event_list);	INIT_LIST_HEAD(&hub->event_list);	list_del(&hub->hub_list);	INIT_LIST_HEAD(&hub->hub_list);	spin_unlock_irqrestore(&hub_event_lock, flags);	kfree(hub);	return NULL;}static void hub_disconnect(struct usb_device *dev, void *ptr){	struct usb_hub *hub = (struct usb_hub *)ptr;	unsigned long flags;	spin_lock_irqsave(&hub_event_lock, flags);	/* Delete it and then reset it */	list_del(&hub->event_list);	INIT_LIST_HEAD(&hub->event_list);	list_del(&hub->hub_list);	INIT_LIST_HEAD(&hub->hub_list);	spin_unlock_irqrestore(&hub_event_lock, flags);	down(&hub->khubd_sem); /* Wait for khubd to leave this hub alone. */	up(&hub->khubd_sem);	if (hub->urb) {		usb_unlink_urb(hub->urb);		usb_free_urb(hub->urb);		hub->urb = NULL;	}	if (hub->descriptor) {		kfree(hub->descriptor);		hub->descriptor = NULL;	}	/* Free the memory */	kfree(hub);}static int hub_ioctl(struct usb_device *hub, unsigned int code, void *user_data){	/* assert ifno == 0 (part of hub spec) */	switch (code) {	case USBDEVFS_HUB_PORTINFO: {		struct usbdevfs_hub_portinfo *info = user_data;		unsigned long flags;		int i;		spin_lock_irqsave(&hub_event_lock, flags);		if (hub->devnum <= 0)			info->nports = 0;		else {			info->nports = hub->maxchild;			for (i = 0; i < info->nports; i++) {				if (hub->children[i] == NULL)					info->port[i] = 0;				else					info->port[i] =						hub->children[i]->devnum;			}		}		spin_unlock_irqrestore(&hub_event_lock, flags);		return info->nports + 1;		}	default:		return -ENOSYS;	}}static int usb_hub_reset(struct usb_hub *hub){	struct usb_device *dev = hub->dev;	int i;	/* Disconnect any attached devices */	for (i = 0; i < hub->descriptor->bNbrPorts; i++) {		if (dev->children[i])			usb_disconnect(&dev->children[i]);	}	/* Attempt to reset the hub */	if (hub->urb)		usb_unlink_urb(hub->urb);	else		return -1;	if (usb_reset_device(dev))		return -1;	hub->urb->dev = dev;                                                    	if (usb_submit_urb(hub->urb, GFP_KERNEL))		return -1;	usb_hub_power_on(hub);	return 0;}static void usb_hub_disconnect(struct usb_device *dev){	struct usb_device *parent = dev->parent;	int i;	/* Find the device pointer to disconnect */	if (parent) {		for (i = 0; i < parent->maxchild; i++) {			if (parent->children[i] == dev) {				usb_disconnect(&parent->children[i]);				return;			}		}	}	err("cannot disconnect hub %s", dev->devpath);}static int usb_hub_port_status(struct usb_device *hub, int port,			       u16 *status, u16 *change){	struct usb_port_status *portsts;	int ret = -ENOMEM;	portsts = kmalloc(sizeof(*portsts), GFP_KERNEL);	if (portsts) {		ret = usb_get_port_status(hub, port + 1, portsts);		if (ret < 0)			err("%s(%s) failed (err = %d)", __FUNCTION__, hub->devpath, ret);		else {			*status = le16_to_cpu(portsts->wPortStatus);			*change = le16_to_cpu(portsts->wPortChange); 			dbg("port %d, portstatus %x, change %x, %s", port + 1,				*status, *change, portspeed(*status));			ret = 0;		}		kfree(portsts);	}	return ret;}#define HUB_RESET_TRIES		5#define HUB_PROBE_TRIES		2#define HUB_SHORT_RESET_TIME	10#define HUB_LONG_RESET_TIME	200#define HUB_RESET_TIMEOUT	500/* return: -1 on error, 0 on success, 1 on disconnect.  */static int usb_hub_port_wait_reset(struct usb_device *hub, int port,				struct usb_device *dev, unsigned int delay){	int delay_time, ret;	u16 portstatus;	u16 portchange;	for (delay_time = 0;			delay_time < HUB_RESET_TIMEOUT;			delay_time += delay) {		/* wait to give the device a chance to reset */		wait_ms(delay);		/* read and decode port status */		ret = usb_hub_port_status(hub, port, &portstatus, &portchange);		if (ret < 0) {			return -1;		}		/* Device went away? */		if (!(portstatus & USB_PORT_STAT_CONNECTION))			return 1;		/* bomb out completely if something weird happened */		if ((portchange & USB_PORT_STAT_C_CONNECTION))			return -1;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91丨九色丨蝌蚪富婆spa| 欧美欧美午夜aⅴ在线观看| 韩国欧美一区二区| 日本伊人色综合网| 性欧美疯狂xxxxbbbb| 亚洲一线二线三线久久久| 亚洲乱码一区二区三区在线观看| 国产精品美女久久久久久久网站| 久久精品男人天堂av| 久久美女高清视频| 国产日韩欧美麻豆| 欧美高清在线一区二区| 国产农村妇女毛片精品久久麻豆| 久久久久久久久伊人| 在线不卡免费av| 欧美一区二区在线免费播放| 欧美一卡二卡三卡| 美女视频黄免费的久久 | 欧美精品色一区二区三区| 欧美日韩在线免费视频| 6080国产精品一区二区| 91精品欧美一区二区三区综合在| 日韩三级在线免费观看| 欧美电视剧在线看免费| 国产性天天综合网| 综合欧美亚洲日本| 亚洲一区二区欧美日韩| 婷婷夜色潮精品综合在线| 麻豆精品精品国产自在97香蕉| 国产综合久久久久久久久久久久 | 欧美日韩综合不卡| 欧美日韩免费一区二区三区视频| 欧美一区二区三区人| 久久午夜国产精品| 亚洲日本成人在线观看| 亚洲福利视频导航| 狠狠色2019综合网| 99r精品视频| 欧美日韩高清在线播放| 欧美精品一区视频| 亚洲色欲色欲www在线观看| 亚洲综合自拍偷拍| 久久成人av少妇免费| 99久久久精品| 91精品国产麻豆| 国产婷婷一区二区| 亚洲一区二区三区影院| 国产做a爰片久久毛片| 不卡的电视剧免费网站有什么| 91福利在线免费观看| 日韩欧美国产高清| ...xxx性欧美| 麻豆成人久久精品二区三区红 | 亚洲一区二区三区不卡国产欧美 | 亚洲午夜私人影院| 欧美一级片在线观看| 久久精品一区八戒影视| 亚洲综合在线第一页| 国产一区免费电影| 在线观看91视频| 国产亚洲欧美日韩日本| 亚洲成av人片在www色猫咪| 国模娜娜一区二区三区| 欧美午夜视频网站| 欧美激情综合五月色丁香小说| 午夜久久电影网| 成人高清在线视频| 日韩免费一区二区| 亚洲午夜激情网页| 成人激情动漫在线观看| 欧美一二三四区在线| 亚洲美女在线一区| 国产91丝袜在线18| 日韩欧美成人一区二区| 一区二区三区不卡视频在线观看| 国产激情一区二区三区四区| 4438x成人网最大色成网站| 亚洲视频一二三区| 国产高清一区日本| 欧美zozozo| 天堂一区二区在线| 在线观看视频91| 中文字幕一区不卡| 国产一区二区久久| 欧美一个色资源| 午夜精品视频在线观看| 91女人视频在线观看| 日本一区二区免费在线观看视频 | 欧美日韩综合在线免费观看| 成人综合婷婷国产精品久久免费| 日韩一级欧美一级| 亚洲va国产天堂va久久en| 99精品久久久久久| 中文成人综合网| 国产精品99久久久久久宅男| 精品少妇一区二区三区免费观看| 视频一区视频二区在线观看| 在线观看三级视频欧美| 亚洲色图欧洲色图| 99精品桃花视频在线观看| 国产日韩视频一区二区三区| 久久99这里只有精品| 日韩一级视频免费观看在线| 人禽交欧美网站| 欧美一区二区日韩| 日本美女视频一区二区| 欧美福利视频导航| 免费人成黄页网站在线一区二区| 欧美三级韩国三级日本三斤| 亚洲成人久久影院| 欧美日韩成人综合| 亚洲sss视频在线视频| 欧美日韩另类国产亚洲欧美一级| 午夜视频在线观看一区二区三区| 欧美日韩精品系列| 7777精品久久久大香线蕉| 午夜不卡av在线| 欧美一级片免费看| 极品尤物av久久免费看| 久久久蜜桃精品| 成人性生交大片| 亚洲日本在线天堂| 欧美日韩aaa| 日本免费新一区视频| 精品久久久久久久一区二区蜜臀| 国产一区二区三区av电影| 久久久久久久综合狠狠综合| 国产成人日日夜夜| 日韩伦理av电影| 欧美三级中文字幕在线观看| 五月婷婷欧美视频| 精品美女在线观看| 国产高清久久久| 亚洲视频一二区| 69p69国产精品| 国产乱人伦偷精品视频不卡| 中文字幕av不卡| 欧美在线一区二区| 日本在线不卡视频| 国产日本一区二区| 91国内精品野花午夜精品| 蜜桃传媒麻豆第一区在线观看| 久久久精品中文字幕麻豆发布| a级高清视频欧美日韩| 亚洲国产成人av网| 精品国产免费久久 | 亚洲1区2区3区4区| 欧美日高清视频| 久久aⅴ国产欧美74aaa| 国产精品国产三级国产aⅴ无密码| 在线一区二区视频| 老司机精品视频导航| 国产精品天美传媒| 欧美亚洲一区二区在线| 韩国av一区二区| 一区二区三区中文字幕电影| 日韩一区国产二区欧美三区| 成人综合日日夜夜| 日韩精品成人一区二区在线| 国产欧美一区在线| 精品1区2区3区| 岛国一区二区在线观看| 亚洲二区在线观看| 亚洲国产成人私人影院tom| 欧美日韩国产系列| 国产精品 日产精品 欧美精品| 亚洲在线视频免费观看| 欧美mv和日韩mv的网站| 欧洲人成人精品| 国产不卡视频在线播放| 日韩精品一二三区| 亚洲人成小说网站色在线| 欧美v亚洲v综合ⅴ国产v| 在线一区二区视频| 成人午夜激情在线| 日韩电影免费在线观看网站| 成人免费在线视频| 久久久亚洲欧洲日产国码αv| 欧美色手机在线观看| 成人av在线播放网址| 激情综合亚洲精品| 香蕉久久一区二区不卡无毒影院 | 日韩和欧美一区二区三区| 国产精品麻豆视频| 亚洲精品一区在线观看| 在线不卡欧美精品一区二区三区| 色呦呦日韩精品| 不卡视频在线看| 国产福利不卡视频| 麻豆精品精品国产自在97香蕉| 亚洲一区电影777| 中文字幕字幕中文在线中不卡视频| 久久日韩粉嫩一区二区三区| 777亚洲妇女| 欧美日韩第一区日日骚| 色综合天天综合色综合av| 国产精品1024久久| 激情欧美一区二区三区在线观看| 天堂午夜影视日韩欧美一区二区| 亚洲一二三区视频在线观看|