The current eth_device leaves a 2 byte hole after "enetaddr" and before "iobase". Since the enetaddr member has to be 6 bytes, we might as well fill that 2 byte hole with something useful.
Further, most device drivers want to load enetaddr from memory into the hardware as 1 32bit value and 1 16bit value. So re-arrange the structure slightly, and add an anonymous union to make eth_device even better: - expand the name field to fill the 2 byte hole - make sure enetaddr is aligned, and provides 32bit/16bit members Now device driver code can simply use "dev->enetaddr32" and "dev->enetaddr16[2]" to access the values without having to manually shift the bytes out of dev->enetaddr. Signed-off-by: Mike Frysinger <vap...@gentoo.org> --- include/net.h | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/net.h b/include/net.h index b4acd8f..e8c12d9 100644 --- a/include/net.h +++ b/include/net.h @@ -73,8 +73,17 @@ enum eth_state_t { }; struct eth_device { - char name[16]; - unsigned char enetaddr[6]; + /* Keep enetaddr at start so it is guaranteed aligned */ + union { + u32 enetaddr32; + u16 enetaddr16[3]; + unsigned char enetaddr[6]; + }; + /* + * Note: name size is picked to fill the holes in memory after + * enetaddr, and to match up to alignment for following "int". + */ + char name[18]; int iobase; int state; -- 1.7.6.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot