/* Copyright (c) Ixia 2003-2005 All rights reserved. */ #include #include #include #include #include #include #include #include #include int sClientMajorNum = 0; static int VNICClientIoctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); static int VNICClientStart(unsigned long arg); static struct file_operations VNICFops = { owner: THIS_MODULE, ioctl: VNICClientIoctl }; static int VNICClientStart(unsigned long arg) { unsigned int retryCnt = 30; DECLARE_WAIT_QUEUE_HEAD(wq); init_waitqueue_head(&wq); printk("\nretry count ----- : %d\n", retryCnt); while (retryCnt) { --retryCnt; printk("\nretry count : %d\n", retryCnt); if (!retryCnt) { return -1; } /* wait for small */ printk("\n++++before sleep+++\n"); interruptible_sleep_on_timeout(&wq, 2); printk("\n++++after sleep+++\n"); } /* end while (retryCnt)*/ return 0; /* for success */ } /* end VNICClientStart() */ static int VNICClientIoctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { switch (cmd) { //case VNIC_CLIENT_START: case 0: return VNICClientStart(arg); break; default : return 0 ; break; } /* End of switch */ return 0; /* VNIC_IOCTL_SUCCESS */ } int __init VNICClientModuleInit(void) { /* register the character device */ sClientMajorNum = register_chrdev(0, "VNICClient", &VNICFops); if (sClientMajorNum < 0) { return -EIO; } return 0; } void VNICClientModuleCleanUp(void) { /* unRegiter the character device(); */ unregister_chrdev(sClientMajorNum, "VNICClient"); } module_init(VNICClientModuleInit); module_exit(VNICClientModuleCleanUp); #ifdef MODULE_LICENSE MODULE_LICENSE("GPL"); #endif /* MODULE_LICENSE */