2.实现读写函数
[html]view plaincopystaticcharmsg[255];staticintdevice_proc_write(structfile*file,constchar*buf,size_tcount,loff_t*pos){char*value;char*temp;char*ptr;unsignedintbuff[3];inti=0;u32data=0;if(copy_from_user((void*)msg,buf,count))return-EFAULT;value=msg;//simple_strtoul(msg,NULL,0);ptr=strrchr(value,'w');while((temp=strsep(&value,""))!=NULL){if(i==0){sscanf(temp,"%x",&buff[0]);i++;}elsesscanf(temp,"%x",&buff[1]);}if(ptr!=NULL){printk("writercmdn");xxx_i2c_write(client->addr,buff[0],buff[1],10);}else{printk("readcmdn");xxx_i2c_read_byte(client->addr,buff[0],&data);printk("data%xn",data);}return0;}
xxx_i2c_write是你的驱动代码使用的i2c写函数,这个要自己实现。