1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #include <linux/init.h>
- #include <linux/module.h>
- #include <linux/device.h>
- #include <linux/types.h>
- #include <linux/cdev.h>
- #include <linux/fs.h>
- #include <linux/slab.h>
- #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;
- }
|