/*--------------------*/ /*board-dm646x-evm.c*/ int your_cpld_action() { Use global cpld_reg0_client and cpld_client to calls to I2C library. } /*--------------------*/ /* your_driver.c*/ static int your_open(...) { } static int your_ioctl(..., args) { your_cpld_action() } static int your_close(...) { } struct file_operations your_ops= { .open = your_open, .unlocked_ioctl = your_ioctl, .release = your_close, } MODULE_DESCRIPTION("CPLD Device Driver") static int __init Init(void) { class_create(...) alloc_chrdev_region(...) device_create(..., "cpld") <--- "/dev/cpld" created here cdev_init(..., your_ops) <--- your ops registered here } module_init(init); static int __exit cleanup(void) { cdev_del() device_destory(...) unregister_chrdev_region(...) class_destroy(...) } module_init(init); /*--------------------*/ /* your_app.c */ int main(...) { int fd; fd = open("/dev/cpld") ioctl(fd, args); close(fd); } Example above is derived from "drivers/usb/gadget/printer.c".