#include #include #include #include #include #include #include #include "mod.h" #include "dev.h" #include "debug.h" #define sysfs_attr(name) do { \ if (device_create_file(dev->dev, &dev_attr_##name) != 0) \ goto probe_device_create_fail; \ } while (0) int test_device_open(struct inode *inode, struct file *filp) { test_dev_t *test; test = container_of( inode->i_cdev, test_dev_t, cdev); filp->private_data = test; mod_info("open\n"); return 0; } int test_device_release(struct inode *inode, struct file *filp) { test_dev_t *test = (test_dev_t*)filp->private_data; mod_info("close\n"); return 0; } static struct file_operations test_fops = { .owner = THIS_MODULE, // .unlocked_ioctl = pcidriver_ioctl, // .mmap = pcidriver_mmap, .open = test_device_open, .release = test_device_release, }; const struct file_operations *test_get_fops(void) { return &test_fops; }