Linux Kernel
3.7.1
|
#include <at24.h>
Data Fields | |
u32 | byte_len |
u16 | page_size |
u8 | flags |
void(* | setup )(struct memory_accessor *, void *context) |
void * | context |
struct at24_platform_data - data to set up at24 (generic eeprom) driver : size of eeprom in byte : number of byte which can be written in one go : tunable options, check AT24_FLAG_* defines : an optional callback invoked after eeprom is probed; enables kernel code to access eeprom via memory_accessor, see example : optional parameter passed to setup()
If you set up a custom eeprom type, please double-check the parameters. Especially page_size needs extra care, as you risk data loss if your value is bigger than what the chip actually supports!
An example in pseudo code for a setup() callback:
void get_mac_addr(struct memory_accessor *mem_acc, void *context) { u8 *mac_addr = ethernet_pdata->mac_addr; off_t offset = context;
// Read MAC addr from EEPROM if (mem_acc->read(mem_acc, mac_addr, offset, ETH_ALEN) == ETH_ALEN) pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr); }
This function pointer and context can now be set up in at24_platform_data.