Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct file *kernel_open(const char *filename, int flags, umode_t mode) {
- struct file *filp = NULL;
- mm_segment_t oldfs = get_fs();
- set_fs(get_ds());
- filp = filp_open(filename, flags, mode);
- set_fs(oldfs);
- return filp;
- }
- const char *filename = "/sys/bus/i2c/devices/6-0054/eeprom";
- struct file filp = kernel_open(filename, O_RDONLY, 0);
- if (IS_ERR(filp)) {
- printk(KERN_ERR "Failed to open file (code: %d)n", PTR_ERR(filp));
- return; <-- always return here
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement