我必须在初始化接口时从EEPROM读取MAC地址并将其设置为网络接口。
然后,我按照Read EEPROM entry from linux module的注释通过sysfs读取EEPROM。但是结果失败了。
当我通过filp_open()打开EEPROM文件时,它总是返回带有-EACCESS的错误指针。
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 and filp value with -13, aka -EACCESS, aka Permission denied
}
有什么想法吗?
[更新]
-处理器:AST2500(ARMv6)
-内核版本:4.19
-EEPROM:at24c64