IO, ANSI vs GCC structs
Wolfgang Denk
wd at denx.de
Sat Jul 26 05:22:47 EST 2003
In message <20030725134734.J29161 at borg.org> you wrote:
>
> How important is it to the kernel coding style that hardware be
I cannot speak for the powers that be, but...
> accessed through a structure? Is it acceptable to do:
>
> #define MYHW (MY_MBAR+42)
>
> ...
>
> out_be32(MYHW, 0xco1df00d);
...I would not accept such code.
There is one fundamental difference: a field in a struct has a type,
i. e. the compiler "knows" how big it is (8, 16, 32, ... bits), if
special attributes apply (volatile), etc.
There is no such information with a #define like yours above.
OK, you can write
#define FOO ((volatile uint32_t *)(FOO_BASE+FOO_OFFSET))
but this isn't really readable, is it?
Just my $0.02
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de
They say a little knowledge is a dangerous thing, but it is not one
half so bad as a lot of ignorance. - Terry Pratchett, _Equal Rites_
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
More information about the Linuxppc-embedded
mailing list