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

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

?? i2c-dev.c

?? linux下S3C2410的I2C總線的驅動
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*    i2c-dev.c - i2c-bus driver, char device interface      Copyright (C) 1995-97 Simon G. Vogl    Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>    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., 675 Mass Ave, Cambridge, MA 02139, USA.*//* Note that this is a complete rewrite of Simon Vogl's i2c-dev module.   But I have used so much of his original code and ideas that it seems   only fair to recognize him as co-author -- Frodo *//* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> *//* The devfs code is contributed by Philipp Matthias Hahn    <pmhahn@titan.lahn.de> *//* $Id: i2c-dev.c,v 1.2 2004/02/06 13:19:45 laputa Exp $ */#include <linux/config.h>#include <linux/kernel.h>#include <linux/module.h>#include <linux/fs.h>#include <linux/slab.h>#include <linux/version.h>#if LINUX_KERNEL_VERSION >= KERNEL_VERSION(2,4,0)#include <linux/smp_lock.h>#endif /* LINUX_KERNEL_VERSION >= KERNEL_VERSION(2,4,0) */#ifdef CONFIG_DEVFS_FS#include <linux/devfs_fs_kernel.h>#endif/* If you want debugging uncomment: *//* #define DEBUG */#include <linux/init.h>#include <asm/uaccess.h>#include <linux/i2c.h>#include <linux/i2c-dev.h>//laputa debug msg 030901//#define LAPUTA_DEBUG_MSG	1#include "dbg_msg.h"/* struct file_operations changed too often in the 2.1 series for nice code */#if LINUX_KERNEL_VERSION < KERNEL_VERSION(2,4,9)static loff_t i2cdev_lseek (struct file *file, loff_t offset, int origin);#endif//laputa unsigned char for iic data format 030903//static ssize_t i2cdev_read (struct file *file, char *buf, size_t count,  // -- remove static ssize_t i2cdev_read (struct file *file, unsigned char *buf, size_t count,  // +- modify                             loff_t *offset);//laputa unsigned char for iic data format 030903 //static ssize_t i2cdev_write (struct file *file, const char *buf, size_t count, //--remove static ssize_t i2cdev_write (struct file *file, const unsigned char *buf, size_t count,  //+-modify                             loff_t *offset);static int i2cdev_ioctl (struct inode *inode, struct file *file,                          unsigned int cmd, unsigned long arg);static int i2cdev_open (struct inode *inode, struct file *file);static int i2cdev_release (struct inode *inode, struct file *file);static int i2cdev_attach_adapter(struct i2c_adapter *adap);static int i2cdev_detach_client(struct i2c_client *client);static int i2cdev_command(struct i2c_client *client, unsigned int cmd,                           void *arg);static int __init i2c_dev_init(void);static void i2cdev_cleanup(void);static struct file_operations i2cdev_fops = {#if LINUX_KERNEL_VERSION >= KERNEL_VERSION(2,4,0)	owner:		THIS_MODULE,#endif /* LINUX_KERNEL_VERSION >= KERNEL_VERSION(2,4,0) */#if LINUX_KERNEL_VERSION < KERNEL_VERSION(2,4,9)	llseek:		i2cdev_lseek,#else	llseek:		no_llseek,#endif	read:		i2cdev_read,	write:		i2cdev_write,	ioctl:		i2cdev_ioctl,	open:		i2cdev_open,	release:	i2cdev_release,};#define I2CDEV_ADAPS_MAX I2C_ADAP_MAXstatic struct i2c_adapter *i2cdev_adaps[I2CDEV_ADAPS_MAX];#ifdef CONFIG_DEVFS_FSstatic devfs_handle_t devfs_i2c[I2CDEV_ADAPS_MAX];static devfs_handle_t devfs_handle = NULL;#endifstatic struct i2c_driver i2cdev_driver = {	name:		"i2c-dev dummy driver",	id:		I2C_DRIVERID_I2CDEV,	flags:		I2C_DF_DUMMY,	attach_adapter:	i2cdev_attach_adapter,	detach_client:	i2cdev_detach_client,	command:	i2cdev_command,/*	inc_use:	NULL,	dec_use:	NULL, */};static struct i2c_client i2cdev_client_template = {	name:		"I2C /dev entry",	id:		1,	flags:		0,	addr:		-1,/*	adapter:	NULL, */	driver:		&i2cdev_driver,/*	data:		NULL */};static int i2cdev_initialized;#if LINUX_KERNEL_VERSION < KERNEL_VERSION(2,4,9)/* Note that the lseek function is called llseek in 2.1 kernels. But things   are complicated enough as is. */loff_t i2cdev_lseek (struct file *file, loff_t offset, int origin){#ifdef DEBUG	struct inode *inode = file->f_dentry->d_inode;	printk("i2c-dev.o: i2c-%d lseek to %ld bytes relative to %d.\n",	       MINOR(inode->i_rdev),(long) offset,origin);#endif /* DEBUG */	return -ESPIPE;}#endif//laputa must be unsgined char type for the iic data 030903//static ssize_t i2cdev_read (struct file *file, char *buf, size_t count,static ssize_t i2cdev_read (struct file *file, unsigned char *buf, size_t count,                            loff_t *offset){	//char *tmp;     	// laputa -- remove	unsigned char *tmp; // laputa +- modify 030903	int ret;#ifdef DEBUG	struct inode *inode = file->f_dentry->d_inode;#endif /* DEBUG */	struct i2c_client *client = (struct i2c_client *)file->private_data;	/* copy user space data to kernel space. */	tmp = kmalloc(count,GFP_KERNEL);	if (tmp==NULL)		return -ENOMEM;#ifdef DEBUG	printk("i2c-dev.o: i2c-%d reading %d bytes.\n",MINOR(inode->i_rdev),	       count);#endif	DbgMsg(LAPUTA_DEBUG_MSG,printk("--> reading %d bytes.\n",count));		ret = i2c_master_recv(client,tmp,count);	if (ret >= 0)		ret = copy_to_user(buf,tmp,count)?-EFAULT:ret;	kfree(tmp);	return ret;}//laputa must be unsgined char type for the iic data 030903//static ssize_t i2cdev_write (struct file *file, const char *buf, size_t count,static ssize_t i2cdev_write (struct file *file, const unsigned char *buf, size_t count,                             loff_t *offset){	int ret;	// char *tmp; 			//--remove 	unsigned char *tmp;     // +- modify 030903 	struct i2c_client *client = (struct i2c_client *)file->private_data;#ifdef DEBUG	struct inode *inode = file->f_dentry->d_inode;#endif /* DEBUG */	//laputa check for buf chip addres setting & transfer data 030901	DbgMsg(LAPUTA_DEBUG_MSG,printk("==>i2c dev  write buf [%s] addr[%x] \n",buf,client->addr));	/* copy user space data to kernel space. */	tmp = kmalloc(count,GFP_KERNEL);	if (tmp==NULL)		return -ENOMEM;	if (copy_from_user(tmp,buf,count)) {		kfree(tmp);		return -EFAULT;	}#ifdef DEBUG	printk("i2c-dev.o: i2c-%d writing %d bytes.\n",MINOR(inode->i_rdev),	       count);#endif	ret = i2c_master_send(client,tmp,count);	kfree(tmp);	return ret;}int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd,                   unsigned long arg){	struct i2c_client *client = (struct i2c_client *)file->private_data;	struct i2c_rdwr_ioctl_data rdwr_arg;	struct i2c_smbus_ioctl_data data_arg;	union i2c_smbus_data temp;	struct i2c_msg *rdwr_pa;	int i,datasize,res;	unsigned long funcs;#ifdef DEBUG	printk("i2c-dev.o: i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n", 	       MINOR(inode->i_rdev),cmd, arg);#endif /* DEBUG */	//laputa check for argument at ioctl 030830	DbgMsg(LAPUTA_DEBUG_MSG,printk("client->name:%s:arg=%x\n",client->name,arg));	switch ( cmd ) {	case I2C_SLAVE:	case I2C_SLAVE_FORCE:		if ((arg > 0x3ff) || 		    (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f))			return -EINVAL;				if ((cmd == I2C_SLAVE) && i2c_check_addr(client->adapter,arg))			return -EBUSY;		client->addr = arg;	//laputa for to checked a address setting value 030830	DbgMsg(LAPUTA_DEBUG_MSG,printk("==>I2C_SLAVE_FORCE ADD [%x]\n",client->addr));		return 0;	case I2C_TENBIT:		if (arg)			client->flags |= I2C_M_TEN;		else			client->flags &= ~I2C_M_TEN;		return 0;	case I2C_FUNCS:		funcs = i2c_get_functionality(client->adapter);		return (copy_to_user((unsigned long *)arg,&funcs,		                     sizeof(unsigned long)))?-EFAULT:0;    case I2C_RDWR:		if (copy_from_user(&rdwr_arg, 				   (struct i2c_rdwr_ioctl_data *)arg, 				   sizeof(rdwr_arg)))			return -EFAULT;		//laputa test only return value checked 030830		DbgMsg(LAPUTA_DEBUG_MSG,printk("+++> receive data %s\n",rdwr_arg.msgs->buf));		rdwr_pa = (struct i2c_msg *)			kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), 			GFP_KERNEL);		if (rdwr_pa == NULL) return -ENOMEM;		res = 0;		for( i=0; i<rdwr_arg.nmsgs; i++ )		{		    	if(copy_from_user(&(rdwr_pa[i]),					&(rdwr_arg.msgs[i]),					sizeof(rdwr_pa[i])))			{			        res = -EFAULT;				break;			}			rdwr_pa[i].buf = kmalloc(rdwr_pa[i].len, GFP_KERNEL);			if(rdwr_pa[i].buf == NULL)			{				res = -ENOMEM;				break;			}			if(copy_from_user(rdwr_pa[i].buf,				rdwr_arg.msgs[i].buf,				rdwr_pa[i].len))			{			    	kfree(rdwr_pa[i].buf);			    	res = -EFAULT;				break;			}		}		//laputa test only error checked 030830		DbgMsg(LAPUTA_DEBUG_MSG,printk("+ res =  %d\n",res));

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美日韩在线看| 国产日韩欧美不卡在线| av在线这里只有精品| 国产91精品一区二区麻豆亚洲| 免费观看30秒视频久久| 日本不卡的三区四区五区| 日产精品久久久久久久性色 | 久久精品99国产精品| 天堂资源在线中文精品| 日本午夜精品一区二区三区电影| 午夜精品一区在线观看| 久久国产成人午夜av影院| 国内精品国产三级国产a久久| 精品亚洲成a人在线观看| 国产成人精品1024| 91免费看片在线观看| 欧美日韩亚州综合| 精品久久久久久久久久久院品网 | 久久久久久夜精品精品免费| 精品第一国产综合精品aⅴ| 久久精品欧美日韩| 亚洲激情图片一区| 日韩va欧美va亚洲va久久| 狠狠v欧美v日韩v亚洲ⅴ| 成人91在线观看| 欧美日韩在线播放| 国产日产精品1区| 亚洲福利视频导航| 国产a区久久久| 欧美日韩国产高清一区二区 | 色av成人天堂桃色av| 91麻豆精品国产91久久久资源速度| 精品欧美一区二区久久| 国产精品久久久久久亚洲伦 | 亚洲国产精品久久久久婷婷884| 日本一道高清亚洲日美韩| 国产69精品久久777的优势| 欧美吞精做爰啪啪高潮| www精品美女久久久tv| 亚洲一区二区三区小说| 粉嫩av一区二区三区| 欧美高清激情brazzers| 中文字幕乱码日本亚洲一区二区 | 国产精品色呦呦| 亚洲国产精品天堂| 99久久99久久久精品齐齐| 精品国产伦一区二区三区观看方式 | 在线亚洲精品福利网址导航| 日韩欧美亚洲另类制服综合在线| 亚洲男同1069视频| 国产不卡在线播放| 久久综合色8888| 日韩精品高清不卡| 色国产综合视频| 国产精品久久久久7777按摩| 久久精品国产网站| 欧美日韩精品电影| 亚洲一区成人在线| 色综合久久久久综合| 国产欧美精品区一区二区三区| 丝袜美腿亚洲一区二区图片| 色素色在线综合| 欧美激情在线免费观看| 国产制服丝袜一区| 欧美一激情一区二区三区| 亚洲一本大道在线| 欧美色涩在线第一页| 亚洲精品国产无天堂网2021| 99久久99久久精品国产片果冻 | 色婷婷一区二区| 亚洲色图欧美偷拍| 色88888久久久久久影院按摩| 中文字幕一区二区三区色视频| 国产91丝袜在线18| 欧美激情一区在线| 懂色av一区二区三区蜜臀| 国产日韩欧美制服另类| 丰满少妇在线播放bd日韩电影| 国产性色一区二区| 成人免费看黄yyy456| 国产精品二区一区二区aⅴ污介绍| 国产69精品久久久久777| 国产视频亚洲色图| eeuss鲁一区二区三区| 亚洲天堂福利av| 欧洲精品视频在线观看| 图片区小说区区亚洲影院| 777精品伊人久久久久大香线蕉| 日本伊人色综合网| 久久九九影视网| av网站免费线看精品| 一区二区三区日韩| 91精品国产一区二区三区香蕉| 美女视频网站久久| 欧美国产1区2区| 91成人免费在线| 蜜臀精品久久久久久蜜臀| 精品久久国产老人久久综合| 成人性生交大片免费看在线播放 | 亚洲精品日产精品乱码不卡| 欧美精品色综合| 国产传媒一区在线| 亚洲精品国产a| 精品日韩在线观看| 91女厕偷拍女厕偷拍高清| 婷婷六月综合亚洲| 国产精品久久一卡二卡| 欧美另类videos死尸| 国产精品一区二区视频| 亚洲在线中文字幕| 国产亚洲精品bt天堂精选| 欧美性生活大片视频| 国产自产视频一区二区三区| 亚洲精品一二三四区| 久久精品在线免费观看| 精品视频全国免费看| 岛国精品在线观看| 久久99久久久欧美国产| 一区二区三区四区精品在线视频| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 91亚洲国产成人精品一区二三| 日韩在线a电影| 亚洲日本丝袜连裤袜办公室| 精品av久久707| 欧美精品欧美精品系列| 91捆绑美女网站| 国产一区在线视频| 日韩电影一二三区| 亚洲精品一二三区| 1区2区3区欧美| 欧美国产日韩精品免费观看| 欧美一区二区成人| 在线免费观看日本一区| 波多野结衣在线aⅴ中文字幕不卡| 蜜臀av一级做a爰片久久| 亚洲国产一区二区三区| 一区二区三区四区蜜桃| 综合激情网...| 亚洲色图.com| 中文字幕亚洲一区二区va在线| 久久蜜桃av一区精品变态类天堂| 日韩视频永久免费| 69精品人人人人| 51精品秘密在线观看| 欧美精品免费视频| 欧美乱熟臀69xxxxxx| 欧美日韩国产首页| 制服丝袜亚洲精品中文字幕| 欧美日韩中字一区| 欧美日本国产一区| 欧美色图天堂网| 欧美高清性hdvideosex| 欧美精品xxxxbbbb| 日韩视频一区二区在线观看| 精品国一区二区三区| 久久久久久久网| 中文字幕的久久| 1000部国产精品成人观看| 亚洲老司机在线| 午夜视频久久久久久| 免费不卡在线视频| 国产麻豆精品久久一二三| 粉嫩嫩av羞羞动漫久久久| 99久久精品免费看国产| 91精品福利视频| 88在线观看91蜜桃国自产| 精品裸体舞一区二区三区| 欧美国产乱子伦 | 国产一区二区精品久久91| 国产老妇另类xxxxx| 成人精品gif动图一区| a亚洲天堂av| 欧美色图第一页| 日韩久久精品一区| 中文字幕在线不卡视频| 一区二区激情小说| 久热成人在线视频| 不卡av免费在线观看| 欧美乱妇15p| 国产精品久久久久一区 | 亚洲国产精品成人综合| 亚洲综合久久av| 国内不卡的二区三区中文字幕| 成人小视频免费观看| 欧美日韩一区二区三区不卡| 精品精品国产高清一毛片一天堂| 国产精品无人区| 日日夜夜一区二区| 国产成人av一区二区三区在线观看| 色综合天天综合色综合av| 欧美一区二区三区爱爱| 亚洲视频一区二区在线观看| 久草精品在线观看| 91福利在线播放| 国产精品麻豆网站| 国产精品亚洲一区二区三区在线| 欧美日韩亚洲综合一区| 亚洲色图视频网| 国产高清久久久| 欧美一二三四在线|