[U-Boot] structure usage for peripheral registers

hi,
The u-boot source has been following a strict rule to use structures to define peripheral registers for some time now
I was wondering if there really is an advantage over the macro definitions which is being used in Linux until today or this is just a coding guideline to maintain consistency in the code
Thanks and Regards Vipin

Dear Vipin Kumar,
In message AANLkTilwwiY7k1ZH5oPYukIiY9updRtHgFpGivEhgTgV@mail.gmail.com you wrote:
The u-boot source has been following a strict rule to use structures to define peripheral registers for some time now
I was wondering if there really is an advantage over the macro definitions which is being used in Linux until today or this is just a coding guideline to maintain consistency in the code
The advantage is that the compiler can perform strict type checking (assuming a proper set of accessor functions is available); using base address + offset notation you will not get any compile time warnings when trying to access - say - a 16 bit wide register in 32 bit mode, etc.
Best regards,
Wolfgang Denk
participants (2)
-
Vipin Kumar
-
Wolfgang Denk