3、/proc_fs.h>#include/*O_ACCMODE*/#include#include#include#include#include/*cli(),*_flags*/#include/*copy_*_user*/#include#defineLED_NUM4
4、structled_dev{structcdevdev;unsignedport;unsignedlongoffset;};structled_devled[4];dev_tdev=0;staticstructresource*led_resource;intled_open(structinode*inode,structfile*filp){structled_dev*led;/*deviceinformation*/led=container_of(inode->i_cdev,structled_d
5、ev,dev);filp->private_data=led;/*forothermethods*/return0;/*success*/}intled_release(structinode*inode,structfile*filp){return0;}ssize_tled_read(structfile*filp,char__user*buf,size_tcount,loff_t*f_pos){return0;}ssize_tled_write(structfile*filp,constchar__
6、user*buf,size_tcount,loff_t*f_pos){chardata;structled_dev*led;u32value;printk(KERN_INFO"debugbybaikal:leddevwrite");led=(structled_dev*)filp->private_data;copy_from_user(&data,buf,count);if(data=='0'){printk(KERN_INFO"debugbybaikal:ledoff");value=inl(
7、(unsigned)(S3C2410_GPBDAT));outl(value
8、1<offset,(unsigned)(S3C2410_GPBDAT));//value=ioread32(led->base);//iowrite32(value
9、1<offset,led->base);}else{printk(KERN_INFO"debugbybaikal:ledon");value=inl((unsigned)(S3C2410_GPBDAT));outl(value&~(1<<
10、led->offset),(unsigned)(S3C2410_GPBDAT));//value=ioread32(led->base);//iowrite32(value&~(1<offset),led->base);}}structfile_operationsled_fops={.owner=THIS_MODULE,.read=led_read,.write=led_write,//.ioctl=led_io