日期:2014-05-16 浏览次数:20782 次
MODULE_LICENSE("GPL"); #define TEST_ENA 0x00 #define TEST_SET_TIME 0x01 #define TEST_SET_DATE 0x02 #define TEST_SET_CH0_PIXEL 0x03 int test_ioctl(struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg) { unsigned int __user *argp=(unsigned int __user *)arg; unsigned char tmp_uchar; printk("CMD=%d",cmd); switch (cmd) { case TEST_ENA : break; case TEST_SET_TIME : break; case TEST_SET_DATE: break; case TEST_SET_CH0_PIXEL : break; default: break; }//end switch return 0; }
int main(void) { int wdt_fd = -1; int ret,nTimeout=20; int i; Osd_Date osd_date; wdt_fd = open("/dev/ti_test",O_WRONLY); if(wdt_fd == -1) { printf("CEM Open error!!\n"); } i=2; ret=ioctl(wdt_fd, i ,&nTimeout); printf("ret=%d \n",ret); return 0; }
int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned long arg) { int error = 0; int __user *argp = (int __user *)arg; struct inode *inode = filp->f_path.dentry->d_inode; switch (cmd) { case FIOCLEX: set_close_on_exec(fd, 1); break; case FIONCLEX: set_close_on_exec(fd, 0); break; case FIONBIO: error = ioctl_fionbio(filp, argp); break; case FIOASYNC: error = ioctl_fioasync(fd, filp, argp); break; case FIOQSIZE: if (S_ISDIR(inode->i_mode) || S_ISREG(inode->i_mode) || S_ISLNK(inode->i_mode)) { loff_t res = inode_get_bytes(inode); error = copy_to_user(argp, &res, sizeof(res)) ? -EFAULT : 0; } else error = -ENOTTY; break; case FIFREEZE: error = ioctl_fsfreeze(filp); break; case FITHAW: error = ioctl_fsthaw(filp); break; case FS_IOC_FIEMAP: return ioctl_fiemap(filp, arg); [b]case FIGETBSZ:[/b] return put_user(inode->i_sb->s_blocksize, argp); [b]default:[/b] if (S_ISREG(inode->i_mode)) error = file_ioctl(filp, cmd, arg); else error =[b] vfs_ioctl[/b](filp, cmd, arg); break; } return error; }