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

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

?? scanner.c

?? linux qt的圖形設計實際例子
?? C
?? 第 1 頁 / 共 3 頁
字號:

	dbg("open_scanner: scn_minor:%d", scn_minor);

	if (!p_scn_table[scn_minor]) {
		up(&scn_mutex);
		MOD_DEC_USE_COUNT;
		err("open_scanner(%d): Unable to access minor data", scn_minor);
		return -ENODEV;
	}

	scn = p_scn_table[scn_minor];

	dev = scn->scn_dev;

	down(&(scn->sem));	/* Now protect the scn_usb_data structure */ 

	up(&scn_mutex); /* Now handled by the above */

	if (!dev) {
		err("open_scanner(%d): Scanner device not present", scn_minor);
		err = -ENODEV;
		goto out_error;
	}

	if (!scn->present) {
		err("open_scanner(%d): Scanner is not present", scn_minor);
		err = -ENODEV;
		goto out_error;
	}

	if (scn->isopen) {
		err("open_scanner(%d): Scanner device is already open", scn_minor);
		err = -EBUSY;
		goto out_error;
	}

	init_waitqueue_head(&scn->rd_wait_q);

	scn->isopen = 1;

	file->private_data = scn; /* Used by the read and write methods */


out_error:

	up(&(scn->sem)); /* Wake up any possible contending processes */

	if (err)
		MOD_DEC_USE_COUNT;

	return err;
}

static int
close_scanner(struct inode * inode, struct file * file)
{
	struct scn_usb_data *scn;

	int scn_minor;

	scn_minor = USB_SCN_MINOR (inode);

	dbg("close_scanner: scn_minor:%d", scn_minor);

	if (!p_scn_table[scn_minor]) {
		err("close_scanner(%d): invalid scn_minor", scn_minor);
		return -ENODEV;
	}

	down(&scn_mutex);

	scn = p_scn_table[scn_minor];
	down(&(scn->sem));
	scn->isopen = 0;

	file->private_data = NULL;

	up(&scn_mutex);
	up(&(scn->sem));

	MOD_DEC_USE_COUNT;

	return 0;
}

static ssize_t
write_scanner(struct file * file, const char * buffer,
              size_t count, loff_t *ppos)
{
	struct scn_usb_data *scn;
	struct usb_device *dev;

	ssize_t bytes_written = 0; /* Overall count of bytes written */
	ssize_t ret = 0;

	int scn_minor;

	int this_write;		/* Number of bytes to write */
	int partial;		/* Number of bytes successfully written */
	int result = 0;

	char *obuf;

	scn = file->private_data;

	down(&(scn->sem));

	scn_minor = scn->scn_minor;

	obuf = scn->obuf;

	dev = scn->scn_dev;

	file->f_dentry->d_inode->i_atime = CURRENT_TIME;

	while (count > 0) {

		if (signal_pending(current)) {
			ret = -ERESTARTSYS;
			break;
		}

		this_write = (count >= OBUF_SIZE) ? OBUF_SIZE : count;

		if (copy_from_user(scn->obuf, buffer, this_write)) {
			ret = -EFAULT;
			break;
		}

		result = usb_bulk_msg(dev,usb_sndbulkpipe(dev, scn->bulk_out_ep), obuf, this_write, &partial, 60*HZ);
		dbg("write stats(%d): result:%d this_write:%d partial:%d", scn_minor, result, this_write, partial);

		if (result == -ETIMEDOUT) {	/* NAK -- shouldn't happen */
			warn("write_scanner: NAK received.");
			ret = result;
			break;
		} else if (result < 0) { /* We should not get any I/O errors */
			warn("write_scanner(%d): funky result: %d. Consult Documentataion/usb/scanner.txt.", scn_minor, result);
			ret = -EIO;
			break;
		}

#ifdef WR_DATA_DUMP
		if (partial) {
			unsigned char cnt, cnt_max;
			cnt_max = (partial > 24) ? 24 : partial;
			printk(KERN_DEBUG "dump(%d): ", scn_minor);
			for (cnt=0; cnt < cnt_max; cnt++) {
				printk("%X ", obuf[cnt]);
			}
			printk("\n");
		}
#endif
		if (partial != this_write) { /* Unable to write all contents of obuf */
			ret = -EIO;
			break;
		}

		if (partial) { /* Data written */
			buffer += partial;
			count -= partial;
			bytes_written += partial;
		} else { /* No data written */
			ret = 0;
			break;
		}
	}
	up(&(scn->sem));
	mdelay(5);		/* This seems to help with SANE queries */
	return ret ? ret : bytes_written;
}

static ssize_t
read_scanner(struct file * file, char * buffer,
             size_t count, loff_t *ppos)
{
	struct scn_usb_data *scn;
	struct usb_device *dev;

	ssize_t bytes_read;	/* Overall count of bytes_read */
	ssize_t ret;

	int scn_minor;
	int partial;		/* Number of bytes successfully read */
	int this_read;		/* Max number of bytes to read */
	int result;
	int rd_expire = RD_EXPIRE;

	char *ibuf;

	scn = file->private_data;

	down(&(scn->sem));

	scn_minor = scn->scn_minor;

	ibuf = scn->ibuf;

	dev = scn->scn_dev;

	bytes_read = 0;
	ret = 0;

	file->f_dentry->d_inode->i_atime = CURRENT_TIME; /* Update the
                                                            atime of
                                                            the device
                                                            node */
	while (count > 0) {
		if (signal_pending(current)) {
			ret = -ERESTARTSYS;
			break;
		}

		this_read = (count >= IBUF_SIZE) ? IBUF_SIZE : count;

		result = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, scn->bulk_in_ep), ibuf, this_read, &partial, scn->rd_nak_timeout);
		dbg("read stats(%d): result:%d this_read:%d partial:%d count:%d", scn_minor, result, this_read, partial, count);

/*
 * Scanners are sometimes inheriently slow since they are mechanical
 * in nature.  USB bulk reads tend to timeout while the scanner is
 * positioning, resetting, warming up the lamp, etc if the timeout is
 * set too low.  A very long timeout parameter for bulk reads was used
 * to overcome this limitation, but this sometimes resulted in folks
 * having to wait for the timeout to expire after pressing Ctrl-C from
 * an application. The user was sometimes left with the impression
 * that something had hung or crashed when in fact the USB read was
 * just waiting on data.  So, the below code retains the same long
 * timeout period, but splits it up into smaller parts so that
 * Ctrl-C's are acted upon in a reasonable amount of time.
 */

		if (result == -ETIMEDOUT) { /* NAK */
			if (!partial) { /* No data */
				if (--rd_expire <= 0) {	/* Give it up */
					warn("read_scanner(%d): excessive NAK's received", scn_minor);
					ret = result;
					break;
				} else { /* Keep trying to read data */
					interruptible_sleep_on_timeout(&scn->rd_wait_q, scn->rd_nak_timeout);
					continue;
				}
			} else { /* Timeout w/ some data */
				goto data_recvd;
			}
		}
		
		if (result == -EPIPE) { /* No hope */
			if(usb_clear_halt(dev, scn->bulk_in_ep)) {
				err("read_scanner(%d): Failure to clear endpoint halt condition (%Zd).", scn_minor, ret);
			}
			ret = result;
			break;
		} else if ((result < 0) && (result != -EREMOTEIO)) {
			warn("read_scanner(%d): funky result:%d. Consult Documentation/usb/scanner.txt.", scn_minor, (int)result);
			ret = -EIO;
			break;
		}

	data_recvd:

#ifdef RD_DATA_DUMP
		if (partial) {
			unsigned char cnt, cnt_max;
			cnt_max = (partial > 24) ? 24 : partial;
			printk(KERN_DEBUG "dump(%d): ", scn_minor);
			for (cnt=0; cnt < cnt_max; cnt++) {
				printk("%X ", ibuf[cnt]);
			}
			printk("\n");
		}
#endif

		if (partial) { /* Data returned */
			if (copy_to_user(buffer, ibuf, partial)) {
				ret = -EFAULT;
				break;
			}
			count -= this_read; /* Compensate for short reads */
			bytes_read += partial; /* Keep tally of what actually was read */
			buffer += partial;
		} else {
			ret = 0;
			break;
		}
	}
	up(&(scn->sem));
	return ret ? ret : bytes_read;
}

static int
ioctl_scanner(struct inode *inode, struct file *file,
	      unsigned int cmd, unsigned long arg)
{
	struct usb_device *dev;

	int scn_minor;

	scn_minor = USB_SCN_MINOR(inode);

	if (!p_scn_table[scn_minor]) {
		err("ioctl_scanner(%d): invalid scn_minor", scn_minor);
		return -ENODEV;
	}

	dev = p_scn_table[scn_minor]->scn_dev;

	switch (cmd)
	{
	case SCANNER_IOCTL_VENDOR :
		return (put_user(dev->descriptor.idVendor, (unsigned int *) arg));
	case SCANNER_IOCTL_PRODUCT :
		return (put_user(dev->descriptor.idProduct, (unsigned int *) arg));
#ifdef PV8630
	case PV8630_IOCTL_INREQUEST :
	{
		int result;

		struct {
			__u8  data;
			__u8  request;
			__u16 value;
			__u16 index;
		} args;

		if (copy_from_user(&args, (void *)arg, sizeof(args)))
			return -EFAULT;

		result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
					 args.request, USB_TYPE_VENDOR|
					 USB_RECIP_DEVICE|USB_DIR_IN,
					 args.value, args.index, &args.data,
					 1, HZ*5);

		dbg("ioctl_scanner(%d): inreq: args.data:%x args.value:%x args.index:%x args.request:%x\n", scn_minor, args.data, args.value, args.index, args.request);

		if (copy_to_user((void *)arg, &args, sizeof(args)))
			return -EFAULT;

		dbg("ioctl_scanner(%d): inreq: result:%d\n", scn_minor, result);

		return result;
	}
	case PV8630_IOCTL_OUTREQUEST :
	{
		int result;

		struct {
			__u8  request;
			__u16 value;
			__u16 index;
		} args;

		if (copy_from_user(&args, (void *)arg, sizeof(args)))
			return -EFAULT;

		dbg("ioctl_scanner(%d): outreq: args.value:%x args.index:%x args.request:%x\n", scn_minor, args.value, args.index, args.request);

		result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
					 args.request, USB_TYPE_VENDOR|
					 USB_RECIP_DEVICE|USB_DIR_OUT,
					 args.value, args.index, NULL,
					 0, HZ*5);

		dbg("ioctl_scanner(%d): outreq: result:%d\n", scn_minor, result);

		return result;
	}
#endif /* PV8630 */
 	case SCANNER_IOCTL_CTRLMSG:
 	{
 		struct ctrlmsg_ioctl {
 			struct usb_ctrlrequest	req;
 			void			*data;
 		} cmsg;
 		int pipe, nb, ret;
 		unsigned char buf[64];
 
 		if (copy_from_user(&cmsg, (void *)arg, sizeof(cmsg)))
 			return -EFAULT;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产做a爰片久久毛片| 日韩一级欧美一级| 国产精品卡一卡二| 成人动漫在线一区| 国产精品久久久久久亚洲伦| 成人性生交大片免费看视频在线| 国产精品美女久久久久久2018 | 亚洲h精品动漫在线观看| 91成人免费在线| 亚洲午夜精品在线| 欧美日韩五月天| 美女视频黄久久| 国产日韩精品一区二区三区在线| 粉嫩高潮美女一区二区三区| 国产精品免费视频一区| av影院午夜一区| 亚洲国产毛片aaaaa无费看| 51午夜精品国产| 国产乱子伦视频一区二区三区 | 蜜臀av性久久久久蜜臀aⅴ四虎| 日韩一区二区免费高清| 九九热在线视频观看这里只有精品| 日韩一卡二卡三卡四卡| 高清不卡一二三区| 亚洲自拍欧美精品| 日韩欧美一二三四区| 国产精品主播直播| 亚洲一区二区美女| 久久―日本道色综合久久| 色视频欧美一区二区三区| 美女在线一区二区| 亚洲天堂中文字幕| 日韩欧美一级精品久久| 91啪在线观看| 久久99在线观看| 亚洲黄一区二区三区| 精品国产伦一区二区三区观看方式| zzijzzij亚洲日本少妇熟睡| 日韩成人精品在线观看| 国产精品久久久久久久蜜臀 | 91麻豆免费观看| 蜜臀国产一区二区三区在线播放| 国产精品欧美一区喷水| 欧美一区三区四区| 99久久综合精品| 经典三级视频一区| 五月开心婷婷久久| 亚洲欧美日韩国产综合在线| 久久一日本道色综合| 欧美日韩一区二区在线观看 | 国精品**一区二区三区在线蜜桃| 亚洲一区二区三区美女| 亚洲欧美在线观看| 久久伊人中文字幕| 欧美va日韩va| 欧美乱妇23p| 色婷婷av一区二区三区软件 | 欧美日韩一区二区三区不卡| 一区二区三区美女视频| 亚洲国产精品ⅴa在线观看| 91精品婷婷国产综合久久性色| 99riav久久精品riav| 国产精品99久久久久久久vr| 日韩国产在线观看一区| 亚洲二区视频在线| 一区二区三区中文免费| 国产精品成人免费在线| 欧美激情在线看| 久久综合中文字幕| xvideos.蜜桃一区二区| 欧美zozo另类异族| 欧美不卡在线视频| 日韩一区二区中文字幕| 51精品久久久久久久蜜臀| 在线观看欧美日本| 日本韩国欧美一区二区三区| 91同城在线观看| 色综合天天综合| 色呦呦国产精品| 色欲综合视频天天天| 在线免费不卡视频| 91激情五月电影| 91成人免费电影| 在线观看国产一区二区| 欧美中文字幕一区二区三区| 91搞黄在线观看| 精品婷婷伊人一区三区三| 欧美日韩不卡在线| 91精品免费在线观看| 日韩你懂的电影在线观看| 精品国产乱码91久久久久久网站| 日韩精品中文字幕一区| 国产亚洲欧美激情| 国产精品久久久久天堂| 一区二区三区色| 日韩精品免费视频人成| 免费成人av资源网| 国产一区二区三区高清播放| 丁香另类激情小说| 日本高清免费不卡视频| 777奇米四色成人影色区| 精品久久久久久久久久久久包黑料| 亚洲精品一线二线三线无人区| 久久精品一区八戒影视| 日韩理论片一区二区| 亚洲成人激情社区| 韩国欧美国产一区| av在线这里只有精品| 欧美日韩在线播放三区四区| 日韩欧美亚洲一区二区| 中文字幕不卡的av| 亚洲福利一二三区| 国产在线不卡一卡二卡三卡四卡| 北条麻妃一区二区三区| 欧美日韩一区二区在线观看| 精品福利一区二区三区免费视频| 国产精品久久午夜夜伦鲁鲁| 午夜日韩在线观看| 国产成人在线网站| 欧美日韩成人一区| 欧美国产精品一区二区三区| 亚洲午夜久久久| 成人精品小蝌蚪| 欧美一区永久视频免费观看| **欧美大码日韩| 精品一区二区三区免费毛片爱| 91欧美一区二区| 久久夜色精品一区| 日本免费在线视频不卡一不卡二| 成人av网站在线观看免费| 欧美一区二区三区免费在线看 | 成人av资源下载| 在线亚洲高清视频| 欧美国产精品劲爆| 亚洲福利视频一区| 国产一区 二区| 欧美综合亚洲图片综合区| 欧美激情一区二区三区蜜桃视频| 亚洲卡通欧美制服中文| 久久激情五月婷婷| 色综合久久中文字幕综合网 | 理论电影国产精品| 9色porny自拍视频一区二区| 欧美日本视频在线| 国产精品丝袜黑色高跟| 日韩精品三区四区| 国产尤物一区二区| 欧美不卡在线视频| 亚洲成a人片综合在线| 成人小视频在线观看| 欧美日韩国产区一| 26uuu亚洲综合色欧美| 亚洲国产wwwccc36天堂| 99精品在线观看视频| 精品福利在线导航| 日韩精品欧美精品| 91黄色免费看| 亚洲蜜臀av乱码久久精品蜜桃| 激情都市一区二区| 欧美丰满高潮xxxx喷水动漫 | 日韩欧美一区二区久久婷婷| 亚洲观看高清完整版在线观看| 粉嫩绯色av一区二区在线观看| 欧美精品免费视频| 一区二区三区在线不卡| 91片黄在线观看| 中文字幕国产一区| 国产毛片精品国产一区二区三区| 91超碰这里只有精品国产| 日韩一区精品字幕| 欧美视频日韩视频| 亚洲欧美日韩久久| 91麻豆精品在线观看| 亚洲精品成人a在线观看| 成人va在线观看| 中文字幕乱码亚洲精品一区| 国产麻豆91精品| 日本一区二区电影| 国产乱一区二区| 国产亚洲欧美色| 蜜臀av性久久久久蜜臀aⅴ| 欧美一级精品在线| 日韩高清不卡在线| 91精选在线观看| 午夜久久久影院| 91精品一区二区三区久久久久久 | 在线日韩国产精品| 亚洲一区二区三区爽爽爽爽爽| a美女胸又www黄视频久久| 亚洲欧美另类图片小说| 日本韩国精品一区二区在线观看| 亚洲精品成人在线| 日本电影欧美片| 美日韩一级片在线观看| 精品久久久久久久久久久院品网| 国产自产视频一区二区三区| 欧美videos中文字幕| 国产成人免费在线| 最好看的中文字幕久久| 欧洲亚洲精品在线|