I have to read MAC address from EEPROM and set it to the network interface while the interface is initializing.
And I followed the comment from Read EEPROM entry from linux module to read EEPROM through sysfs. But the result is failed.
When I opened the EEPROM file through filp_open(), it always return error pointer with -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
}
Have any ideas?
[Updated]
- Processor: AST2500 (ARMv6)
- Kernel version: 4.19
- EEPROM: at24c64