public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH 1/3] Apollon BSP support
Date: Fri, 14 Sep 2007 10:52:15 +0200	[thread overview]
Message-ID: <20070914085215.B40C8247D2@gemini.denx.de> (raw)
In-Reply-To: Your message of "Fri, 14 Sep 2007 09:51:31 +0900." <20070914005131.GA14660@party>

In message <20070914005131.GA14660@party> you wrote:
> Apollon BSP support
> 
> The Apollon based on OMAP2420 is designed for OneNAND development.
> It's similar with OMAP2420 H4 except some peripherals.
...
...
> +	MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_PUEN;
> +	*MuxConfigReg &= (uint8) (~0x1F);
> +
> +	MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_VP;
> +	*MuxConfigReg &= (uint8) (~0x1F);
> +
> +	MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_VM;
> +	*MuxConfigReg &= (uint8) (~0x1F);
> +
> +	MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_RCV;
> +	*MuxConfigReg &= (uint8) (~0x1F);
> +
> +	MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_TXEN;
> +	*MuxConfigReg &= (uint8) (~0x1F);
> +
> +	MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_SE0;
> +	*MuxConfigReg &= (uint8) (~0x1F);
> +
> +	MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_DAT;
> +	*MuxConfigReg &= (uint8) (~0x1F);
...

You use this sequence extensively. In the current form, it's extremly
lengthy, difficult to read and difficult to maintain.

Please define an (inline?) fintion which performs the actions and
allows you to change (for example)

> +	/* V19 */
> +	MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB1_RCV;
> +	*MuxConfigReg = 1;
> +	/* W20 */
> +	MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB1_TXEN;
> +	*MuxConfigReg = 1;
> +	/* N14 */
> +	MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPIO69;
> +	*MuxConfigReg = 3;
> +	/* P15 */
> +	MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPIO70;
> +	*MuxConfigReg = 3;

into

	write_config_reg (CONTROL_PADCONF_USB1_RCV, 1);		/* V19 */
	write_config_reg (CONTROL_PADCONF_USB1_TXEN, 1);	/* W20 */
	write_config_reg (CONTROL_PADCONF_GPIO69, 3);		/* N14 */
	write_config_reg (CONTROL_PADCONF_GPIO70, 3);		/* P15 */

This is IMO *much* easier to read and understand.

Please  also  note  that  identifiers  like  "MuxConfigReg"  are   in
violation with the Coding Style:

    C is a Spartan language, and so should your naming be.  Unlike Modula-2
    and Pascal programmers, C programmers do not use cute names like
    ThisVariableIsATemporaryCounter.  A C programmer would call that
    variable "tmp", which is much easier to write, and not the least more
    difficult to understand.


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
"Virtual" means never knowing where your next byte is coming from.

  reply	other threads:[~2007-09-14  8:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-14  0:51 [U-Boot-Users] [PATCH 1/3] Apollon BSP support Kyungmin Park
2007-09-14  8:52 ` Wolfgang Denk [this message]
2007-09-15  2:08   ` Kyungmin Park
2007-09-15 19:01     ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070914085215.B40C8247D2@gemini.denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox