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

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

?? i2c-proc.c

?? linux下S3C2410的I2C總線的驅動
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*    i2c-proc.c - Part of lm_sensors, Linux kernel modules for hardware                monitoring    Copyright (c) 1998 - 2001 Frodo Looijaard <frodol@dds.nl> and    Mark D. Studebaker <mdsxyz123@yahoo.com>    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.*//*    This driver puts entries in /proc/sys/dev/sensors for each I2C device*/#include <linux/version.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/slab.h>#include <linux/ctype.h>#include <linux/sysctl.h>#include <linux/proc_fs.h>#include <linux/ioport.h>#include <asm/uaccess.h>#include <linux/i2c.h>#include <linux/i2c-proc.h>#include <linux/init.h>/* FIXME need i2c versioning */#define LM_DATE "20010825"#define LM_VERSION "2.6.1"#ifndef THIS_MODULE#define THIS_MODULE NULL#endifstatic int i2c_create_name(char **name, const char *prefix,			       struct i2c_adapter *adapter, int addr);static int i2c_parse_reals(int *nrels, void *buffer, int bufsize,			       long *results, int magnitude);static int i2c_write_reals(int nrels, void *buffer, int *bufsize,			       long *results, int magnitude);static int i2c_proc_chips(ctl_table * ctl, int write,			      struct file *filp, void *buffer,			      size_t * lenp);static int i2c_sysctl_chips(ctl_table * table, int *name, int nlen,				void *oldval, size_t * oldlenp,				void *newval, size_t newlen,				void **context);int __init sensors_init(void);#define SENSORS_ENTRY_MAX 20static struct ctl_table_header *i2c_entries[SENSORS_ENTRY_MAX];static struct i2c_client *i2c_clients[SENSORS_ENTRY_MAX];static unsigned short i2c_inodes[SENSORS_ENTRY_MAX];#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)static void i2c_fill_inode(struct inode *inode, int fill);static void i2c_dir_fill_inode(struct inode *inode, int fill);#endif			/* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1) */static ctl_table sysctl_table[] = {	{CTL_DEV, "dev", NULL, 0, 0555},	{0},	{DEV_SENSORS, "sensors", NULL, 0, 0555},	{0},	{0, NULL, NULL, 0, 0555},	{0}};static ctl_table i2c_proc_dev_sensors[] = {	{SENSORS_CHIPS, "chips", NULL, 0, 0644, NULL, &i2c_proc_chips,	 &i2c_sysctl_chips},	{0}};static ctl_table i2c_proc_dev[] = {	{DEV_SENSORS, "sensors", NULL, 0, 0555, i2c_proc_dev_sensors},	{0},};static ctl_table i2c_proc[] = {	{CTL_DEV, "dev", NULL, 0, 0555, i2c_proc_dev},	{0}};static struct ctl_table_header *i2c_proc_header;static int i2c_initialized;/* This returns a nice name for a new directory; for example lm78-isa-0310   (for a LM78 chip on the ISA bus at port 0x310), or lm75-i2c-3-4e (for   a LM75 chip on the third i2c bus at address 0x4e).     name is allocated first. */int i2c_create_name(char **name, const char *prefix,			struct i2c_adapter *adapter, int addr){	char name_buffer[50];	int id;	if (i2c_is_isa_adapter(adapter))		sprintf(name_buffer, "%s-isa-%04x", prefix, addr);	else {		if ((id = i2c_adapter_id(adapter)) < 0)			return -ENOENT;		sprintf(name_buffer, "%s-i2c-%d-%02x", prefix, id, addr);	}	*name = kmalloc(strlen(name_buffer) + 1, GFP_KERNEL);	if (!*name) {		printk (KERN_WARNING "i2c_create_name: not enough memory\n");		return -ENOMEM;	}	strcpy(*name, name_buffer);	return 0;}/* This rather complex function must be called when you want to add an entry   to /proc/sys/dev/sensors/chips. It also creates a new directory within    /proc/sys/dev/sensors/.   ctl_template should be a template of the newly created directory. It is   copied in memory. The extra2 field of each file is set to point to client.   If any driver wants subdirectories within the newly created directory,   this function must be updated!    controlling_mod is the controlling module. It should usually be   THIS_MODULE when calling. Note that this symbol is not defined in   kernels before 2.3.13; define it to NULL in that case. We will not use it   for anything older than 2.3.27 anyway. */int i2c_register_entry(struct i2c_client *client, const char *prefix,			   ctl_table * ctl_template,			   struct module *controlling_mod){	int i, res, len, id;	ctl_table *new_table;	char *name;	struct ctl_table_header *new_header;	if ((res = i2c_create_name(&name, prefix, client->adapter,				       client->addr))) return res;	for (id = 0; id < SENSORS_ENTRY_MAX; id++)		if (!i2c_entries[id]) {			break;		}	if (id == SENSORS_ENTRY_MAX) {		kfree(name);		return -ENOMEM;	}	id += 256;	len = 0;	while (ctl_template[len].procname)		len++;	len += 7;	if (!(new_table = kmalloc(sizeof(ctl_table) * len, GFP_KERNEL))) {		kfree(name);		return -ENOMEM;	}	memcpy(new_table, sysctl_table, 6 * sizeof(ctl_table));	new_table[0].child = &new_table[2];	new_table[2].child = &new_table[4];	new_table[4].child = &new_table[6];	new_table[4].procname = name;	new_table[4].ctl_name = id;	memcpy(new_table + 6, ctl_template, (len - 6) * sizeof(ctl_table));	for (i = 6; i < len; i++)		new_table[i].extra2 = client;	if (!(new_header = register_sysctl_table(new_table, 0))) {		kfree(new_table);		kfree(name);		return -ENOMEM;	}	i2c_entries[id - 256] = new_header;	i2c_clients[id - 256] = client;#ifdef DEBUG	if (!new_header || !new_header->ctl_table ||	    !new_header->ctl_table->child ||	    !new_header->ctl_table->child->child ||	    !new_header->ctl_table->child->child->de) {		printk		    ("i2c-proc.o: NULL pointer when trying to install fill_inode fix!\n");		return id;	}#endif				/* DEBUG */	i2c_inodes[id - 256] =	    new_header->ctl_table->child->child->de->low_ino;#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27))	new_header->ctl_table->child->child->de->owner = controlling_mod;#else	new_header->ctl_table->child->child->de->fill_inode =	    &i2c_dir_fill_inode;#endif	/* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27)) */	return id;}void i2c_deregister_entry(int id){	ctl_table *table;	char *temp;	id -= 256;	if (i2c_entries[id]) {		table = i2c_entries[id]->ctl_table;		unregister_sysctl_table(i2c_entries[id]);		/* 2-step kfree needed to keep gcc happy about const points */		(const char *) temp = table[4].procname;		kfree(temp);		kfree(table);		i2c_entries[id] = NULL;		i2c_clients[id] = NULL;	}}/* Monitor access for /proc/sys/dev/sensors; make unloading i2c-proc.o    impossible if some process still uses it or some file in it */void i2c_fill_inode(struct inode *inode, int fill){	if (fill)		MOD_INC_USE_COUNT;	else		MOD_DEC_USE_COUNT;}/* Monitor access for /proc/sys/dev/sensors/ directories; make unloading   the corresponding module impossible if some process still uses it or   some file in it */void i2c_dir_fill_inode(struct inode *inode, int fill){	int i;	struct i2c_client *client;#ifdef DEBUG	if (!inode) {		printk("i2c-proc.o: Warning: inode NULL in fill_inode()\n");		return;	}#endif				/* def DEBUG */	for (i = 0; i < SENSORS_ENTRY_MAX; i++)		if (i2c_clients[i]		    && (i2c_inodes[i] == inode->i_ino)) break;#ifdef DEBUG	if (i == SENSORS_ENTRY_MAX) {		printk		    ("i2c-proc.o: Warning: inode (%ld) not found in fill_inode()\n",		     inode->i_ino);		return;	}#endif				/* def DEBUG */	client = i2c_clients[i];	if (fill)		client->driver->inc_use(client);	else		client->driver->dec_use(client);}int i2c_proc_chips(ctl_table * ctl, int write, struct file *filp,		       void *buffer, size_t * lenp){	char BUF[SENSORS_PREFIX_MAX + 30];	int buflen, curbufsize, i;	struct ctl_table *client_tbl;	if (write)		return 0;	/* If buffer is size 0, or we try to read when not at the start, we	   return nothing. Note that I think writing when not at the start	   does not work either, but anyway, this is straight from the kernel	   sources. */	if (!*lenp || (filp->f_pos && !write)) {		*lenp = 0;		return 0;	}	curbufsize = 0;	for (i = 0; i < SENSORS_ENTRY_MAX; i++)		if (i2c_entries[i]) {			client_tbl =			    i2c_entries[i]->ctl_table->child->child;			buflen =			    sprintf(BUF, "%d\t%s\n", client_tbl->ctl_name,				    client_tbl->procname);			if (buflen + curbufsize > *lenp)				buflen = *lenp - curbufsize;			if(copy_to_user(buffer, BUF, buflen))				return -EFAULT;			curbufsize += buflen;			(char *) buffer += buflen;		}	*lenp = curbufsize;	filp->f_pos += curbufsize;	return 0;}int i2c_sysctl_chips(ctl_table * table, int *name, int nlen,			 void *oldval, size_t * oldlenp, void *newval,			 size_t newlen, void **context){	struct i2c_chips_data data;	int i, oldlen, nrels, maxels,ret=0;	struct ctl_table *client_tbl;	if (oldval && oldlenp && !((ret = get_user(oldlen, oldlenp))) && 	    oldlen) {		maxels = oldlen / sizeof(struct i2c_chips_data);		nrels = 0;		for (i = 0; (i < SENSORS_ENTRY_MAX) && (nrels < maxels);		     i++)			if (i2c_entries[i]) {				client_tbl =				    i2c_entries[i]->ctl_table->child->				    child;				data.sysctl_id = client_tbl->ctl_name;				strcpy(data.name, client_tbl->procname);				if(copy_to_user(oldval, &data,					     sizeof(struct						    i2c_chips_data)))					return -EFAULT;				(char *) oldval +=				    sizeof(struct i2c_chips_data);				nrels++;			}		oldlen = nrels * sizeof(struct i2c_chips_data);		if(put_user(oldlen, oldlenp))			return -EFAULT;	}	return ret;}/* This funcion reads or writes a 'real' value (encoded by the combination   of an integer and a magnitude, the last is the power of ten the value   should be divided with) to a /proc/sys directory. To use this function,   you must (before registering the ctl_table) set the extra2 field to the   client, and the extra1 field to a function of the form:      void func(struct i2c_client *client, int operation, int ctl_name,                int *nrels_mag, long *results)   This function can be called for three values of operation. If operation   equals SENSORS_PROC_REAL_INFO, the magnitude should be returned in    nrels_mag. If operation equals SENSORS_PROC_REAL_READ, values should   be read into results. nrels_mag should return the number of elements   read; the maximum number is put in it on entry. Finally, if operation   equals SENSORS_PROC_REAL_WRITE, the values in results should be   written to the chip. nrels_mag contains on entry the number of elements   found.   In all cases, client points to the client we wish to interact with,   and ctl_name is the SYSCTL id of the file we are accessing. */int i2c_proc_real(ctl_table * ctl, int write, struct file *filp,		      void *buffer, size_t * lenp){#define MAX_RESULTS 32	int mag, nrels = MAX_RESULTS;	long results[MAX_RESULTS];	i2c_real_callback callback = ctl->extra1;	struct i2c_client *client = ctl->extra2;	int res;	/* If buffer is size 0, or we try to read when not at the start, we	   return nothing. Note that I think writing when not at the start	   does not work either, but anyway, this is straight from the kernel	   sources. */	if (!*lenp || (filp->f_pos && !write)) {		*lenp = 0;		return 0;	}	/* Get the magnitude */	callback(client, SENSORS_PROC_REAL_INFO, ctl->ctl_name, &mag,		 NULL);	if (write) {		/* Read the complete input into results, converting to longs */		res = i2c_parse_reals(&nrels, buffer, *lenp, results, mag);		if (res)			return res;		if (!nrels)			return 0;		/* Now feed this information back to the client */		callback(client, SENSORS_PROC_REAL_WRITE, ctl->ctl_name,			 &nrels, results);		filp->f_pos += *lenp;		return 0;	} else {		/* read */		/* Get the information from the client into results */		callback(client, SENSORS_PROC_REAL_READ, ctl->ctl_name,			 &nrels, results);		/* And write them to buffer, converting to reals */		res = i2c_write_reals(nrels, buffer, lenp, results, mag);		if (res)			return res;		filp->f_pos += *lenp;		return 0;	}}/* This function is equivalent to i2c_proc_real, only it interacts with   the sysctl(2) syscall, and returns no reals, but integers */int i2c_sysctl_real(ctl_table * table, int *name, int nlen,			void *oldval, size_t * oldlenp, void *newval,			size_t newlen, void **context){	long results[MAX_RESULTS];	int oldlen, nrels = MAX_RESULTS,ret=0;	i2c_real_callback callback = table->extra1;	struct i2c_client *client = table->extra2;	/* Check if we need to output the old values */	if (oldval && oldlenp && !((ret=get_user(oldlen, oldlenp))) && oldlen) {		callback(client, SENSORS_PROC_REAL_READ, table->ctl_name,			 &nrels, results);		/* Note the rounding factor! */		if (nrels * sizeof(long) < oldlen)			oldlen = nrels * sizeof(long);		oldlen = (oldlen / sizeof(long)) * sizeof(long);		if(copy_to_user(oldval, results, oldlen))			return -EFAULT;		if(put_user(oldlen, oldlenp))			return -EFAULT;	}	if (newval && newlen) {		/* Note the rounding factor! */		newlen -= newlen % sizeof(long);		nrels = newlen / sizeof(long);		if(copy_from_user(results, newval, newlen))			return -EFAULT;		/* Get the new values back to the client */		callback(client, SENSORS_PROC_REAL_WRITE, table->ctl_name,			 &nrels, results);	}	return ret;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久久久久久久免费丝袜| 国产精品1024| 精品午夜久久福利影院 | av中文一区二区三区| 欧美色倩网站大全免费| 欧美国产乱子伦| 美女国产一区二区| 色哟哟国产精品| 久久久久成人黄色影片| 日韩精品电影在线观看| 99精品久久久久久| 欧美激情综合在线| 美女视频黄 久久| 欧美男人的天堂一二区| 亚洲精品视频一区| 成人h精品动漫一区二区三区| 精品人伦一区二区色婷婷| 亚洲妇熟xx妇色黄| 欧美性极品少妇| 亚洲乱码精品一二三四区日韩在线 | 色婷婷精品大视频在线蜜桃视频 | 国产精品久久久久久久久久久免费看 | 国产视频在线观看一区二区三区| 午夜精品国产更新| 99re在线视频这里只有精品| 国产婷婷色一区二区三区| 久久成人18免费观看| 制服.丝袜.亚洲.中文.综合| 亚洲不卡一区二区三区| 欧美视频在线一区二区三区| 亚洲激情av在线| 欧美熟乱第一页| 五月天中文字幕一区二区| 欧美日韩国产精选| 亚洲成人资源网| 7777精品伊人久久久大香线蕉的| 亚洲成人中文在线| 欧美一区二区网站| 精品一区二区三区免费| 久久婷婷一区二区三区| 丁香天五香天堂综合| 中文在线一区二区| 99视频有精品| 亚洲r级在线视频| 制服.丝袜.亚洲.另类.中文| 另类小说视频一区二区| 国产午夜亚洲精品理论片色戒| 国产精品亚洲专一区二区三区 | 91丨porny丨国产入口| 亚洲免费在线看| 欧美伦理影视网| 麻豆精品一区二区综合av| 日韩限制级电影在线观看| 国产成人午夜精品5599| 一区在线观看免费| 欧美日韩国产免费一区二区 | 成人禁用看黄a在线| 亚洲乱码中文字幕综合| 欧美绝品在线观看成人午夜影视| 秋霞国产午夜精品免费视频| 久久蜜桃av一区二区天堂| 91女人视频在线观看| 丝袜亚洲另类欧美综合| 欧美激情中文字幕一区二区| 色哟哟一区二区在线观看| 天天综合色天天综合| 久久蜜桃av一区精品变态类天堂| 91小视频在线观看| 日韩国产欧美在线观看| 国产精品色呦呦| 欧美另类一区二区三区| 国产成人aaa| 日韩二区三区四区| 1区2区3区国产精品| 精品嫩草影院久久| 欧美在线免费观看视频| 国产乱色国产精品免费视频| 亚洲成在人线在线播放| 国产欧美日韩久久| 91精品国产欧美一区二区18| 不卡的av电影在线观看| 蜜桃久久久久久| 一区二区三区在线视频播放| 久久久久久久久久久久久久久99| 欧美体内she精视频| 懂色av一区二区三区免费看| 日本欧美一区二区在线观看| 亚洲综合一二区| 欧美激情一区二区三区在线| 欧美一级在线观看| 欧洲精品视频在线观看| bt欧美亚洲午夜电影天堂| 狠狠v欧美v日韩v亚洲ⅴ| 偷拍与自拍一区| 亚洲一区二区在线观看视频 | 亚洲午夜久久久久久久久电影网| 日韩午夜在线观看视频| 国产一区二区三区免费观看| 亚洲成av人综合在线观看| 亚洲人成影院在线观看| 中文av一区二区| 久久久精品国产免大香伊| 欧美一区二区三区在线视频| 欧美日韩精品一区二区在线播放| 99久久婷婷国产综合精品| 国产剧情一区二区三区| 激情成人午夜视频| 麻豆91精品视频| 日本不卡在线视频| 日本最新不卡在线| 午夜精品久久久久| 日韩精品成人一区二区三区| 午夜久久电影网| 午夜精品福利久久久| 亚洲一区二区三区四区在线 | 色94色欧美sute亚洲13| hitomi一区二区三区精品| 成人午夜电影久久影院| 丁香网亚洲国际| 成人国产在线观看| 99亚偷拍自图区亚洲| 91蝌蚪porny| 色天使久久综合网天天| 欧洲国内综合视频| 欧美人与禽zozo性伦| 欧美一三区三区四区免费在线看| 91精品欧美综合在线观看最新| 91.xcao| 337p日本欧洲亚洲大胆色噜噜| xfplay精品久久| 国产精品久久毛片a| 亚洲尤物在线视频观看| 日日夜夜精品视频天天综合网| 人人狠狠综合久久亚洲| 国产精品影视网| 99久久国产综合精品女不卡| 欧美日韩精品欧美日韩精品一综合| 欧美精品久久久久久久久老牛影院 | 久久在线观看免费| 国产精品国产三级国产有无不卡 | 国产在线国偷精品产拍免费yy| 国产黑丝在线一区二区三区| 成人性生交大合| 在线播放日韩导航| 久久久精品人体av艺术| 一区二区三区日本| 看国产成人h片视频| 国产精品456| 欧美色区777第一页| 久久亚洲二区三区| 一区二区三区在线免费播放| 久久精品国产精品亚洲综合| 成人性生交大片免费| 欧美一区二区免费视频| 国产精品久久久久久久蜜臀 | 一区二区三区中文字幕| 美女视频黄 久久| 91麻豆视频网站| 欧美成人福利视频| 亚洲精品视频在线看| 国产在线精品一区二区不卡了| 在线中文字幕一区| 国产欧美精品日韩区二区麻豆天美| 亚洲小说欧美激情另类| 国产.精品.日韩.另类.中文.在线.播放 | 国产精品资源在线| 在线播放日韩导航| 亚洲美女偷拍久久| 国产高清无密码一区二区三区| 91免费看片在线观看| 久久久精品2019中文字幕之3| 亚洲一区二区三区四区在线免费观看 | 欧美在线观看视频一区二区 | 一本久道中文字幕精品亚洲嫩| 日韩欧美自拍偷拍| 亚洲综合999| 色哟哟一区二区三区| 国产精品视频一二| 国产精品一区二区在线观看网站 | 欧美亚洲一区二区在线| 国产精品家庭影院| 国产精品中文字幕一区二区三区| 欧美日韩视频在线观看一区二区三区| 亚洲国产精品高清| 国产一区三区三区| wwww国产精品欧美| 老司机免费视频一区二区三区| 欧美日韩三级在线| 亚洲综合色噜噜狠狠| 日本道色综合久久| 亚洲视频你懂的| 成人精品小蝌蚪| 亚洲国产精品成人综合 | 国产精品国产成人国产三级| 国产一区二区三区黄视频 | 欧美一二三四区在线| 天使萌一区二区三区免费观看| 欧美性色黄大片| 五月婷婷久久综合| 欧美一区二区三区播放老司机|