I have a peice of hardware I am writing a driver for. And I've seen several implementations of how to write to driver registers, but I'm not sure which is the 'correct' or 'least messy' version One option is to make a struct that directly maps out the memory locations of the register, for example: struct foo { u32 foo; u32 offset[6]; u32 bar; }; then set the struct to the base memory address of the hardware and control it by writing directly by: foo->bar = 0x0f; foo->foo = foo->bar; Or i could create my own struct and map the pointers to the memory locations of the registers i want regarless of where they are: struct foo { u32 *foo; u32 *bar; }; foo->foo = (mem address); foo->bar = (mem address); then write to the register via those pointers to them mmio. So what generally is the best option ? Dave
Attachment:
pgp00406.pgp
Description: PGP signature