[U-Boot] [PATCH-OMAP3] OMAP3: Convert readl/writel and replace hardcoded values

Wolfgang Denk wd at denx.de
Sun Nov 23 16:16:44 CET 2008


Dear Dirk,

In message <1227445293-23887-1-git-send-email-dirk.behme at googlemail.com> you wrote:
> Convert readl/writel to base + offset style. Replace hardcoded values with
> macros.

I think repeating the sequence "base + offset(foo)" again  and  again
is not exactly nice or easy to read.

> -	writel((a_add_high | a_add_low), SDRC_CS_CFG);
> +	writel((a_add_high | a_add_low), sdrc_base + OFFS(SDRC_CS_CFG));

I find this new code is even less readable.

At this point I was tempted to compain that you should not re-invent
the offsetof() macro when I realized that the actual definition of
OFFS is

	#define OFFS(x)    ((x) >> 2)

Argh... that's awfully error prone. So you rely  on  havnig  to  deal
with  32  bit  register  accesses  only,  without any way of compiler
supported type checking?

That's awful.

I am aware that many areas of ARM code use such a  horrible  program-
ming  syle  of  defining only register offsets instead of proper data
structures like for example PowerPC has been doing for ages.

Do you see a chance to convert the OMAP3 code to use data  structures
instead of offset definitions to describe the processor registers and
peripherals?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Nearly everyone is in favor of going  to  heaven  but  too  many  are
hoping  they'll  live  long  enough  to see an easing of the entrance
requirements. Never appeal to a man's "better nature." he  might  not
have one.


More information about the U-Boot mailing list