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] [PATCH] 6/12 Multiadapter/multibus I2C, drivers part 3
Date: Mon, 16 Feb 2009 22:55:46 +0100	[thread overview]
Message-ID: <20090216215546.DCF04832E893@gemini.denx.de> (raw)
In-Reply-To: <Pine.LNX.4.64ksi.0902121420120.21067@home-gw.koi8.net>

Dear ksi at koi8.net,

In message <Pine.LNX.4.64ksi.0902121420120.21067@home-gw.koi8.net> you wrote:
...
> +/* I2C registers field definitions */
> +/* --------------------------------*/
> +/* I2C_CONTROL (R/W) */

Incorrect multi-line comment style. Please fix.

> +#define SM501_CHECK_NACK() \
> +	do {\
> +		if (tmp & (SM501_I2C_NACK | SM501_I2C_BUS_ERROR)) {\
> +			tmp = read_i2c_reg(SM501_I2C_CONTROL) & SM501_I2C_SPEED;\
> +			write_i2c_reg(SM501_I2C_CONTROL, tmp);\
> +			return(1);\
> +		}\
> +	} while (0)

Macros with magic side effects (here on the variable "tmp" are stronly
deprecated. Please fix this.

> +static __inline__ void write_i2c_reg(unsigned long offset, u_int8_t data)
> +{
> +	writeb(data, sm501_iomem_base + SM501_I2C + offset);
> +	__asm__("sync;isync;msync");

Are you sure the "sync;isync;msync" is needed? The accessor functions
should make sure this is not necessary.

Also, instead of register offsets ("...base + SM501_I2C") please use
a proper data structure.


> +	do {
> +		stat = read_i2c_reg(SM501_I2C_STATUS);
> +		if (stat & mask) {
> +			return(stat);
> +		}

No curly braces for single line statements. Same goes everywhere esle,
too.

And "return" is not a function - please omit the parens (here and
elsewhere).

> +	while ((read_i2c_reg(SM501_I2C_STATUS) & SM501_I2C_BUS_BUSY) && timeout--) {
...
> diff -purN u-boot-i2c.orig/include/sm501-regs.h u-boot-i2c/include/sm501-regs.h
> --- u-boot-i2c.orig/include/sm501-regs.h	1969-12-31 16:00:00.000000000 -0800
> +++ u-boot-i2c/include/sm501-regs.h	2009-02-12 10:46:00.000000000 -0800
> @@ -0,0 +1,394 @@
> +/* sm501-regs.h

Incorrect multiline comment style.

...
> +#define SM501_GPIO31_0_CONTROL		(0x000008)
> +#define SM501_GPIO63_32_CONTROL		(0x00000C)
> +#define SM501_DRAM_CONTROL		(0x000010)
> +
> +/* command list */
> +#define SM501_ARBTRTN_CONTROL		(0x000014)
> +
> +/* command list */
> +#define SM501_COMMAND_LIST_STATUS	(0x000024)
> +
> +/* interrupt debug */
> +#define SM501_RAW_IRQ_STATUS		(0x000028)
> +#define SM501_RAW_IRQ_CLEAR		(0x000028)
> +#define SM501_IRQ_STATUS		(0x00002C)
> +#define SM501_IRQ_MASK			(0x000030)
> +#define SM501_DEBUG_CONTROL		(0x000034)

Please do not use register offsets, define a C structure instead.


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
Fantasy is like alcohol - too much is bad for you, a little bit makes
the world a better place. Like  an  exercise  bicycle  it  takes  you
nowhere, but it just might tone up the muscles that will. Daydreaming
got  us  where we are today; early in our evolution we learned to let
our minds wander so well that they started coming  back  with  souve-
nirs.   - Terry Pratchett & Stephen Briggs, _The Discworld Companion_

  parent reply	other threads:[~2009-02-16 21:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-12 22:21 [U-Boot] [PATCH] 6/12 Multiadapter/multibus I2C, drivers part 3 ksi at koi8.net
2009-02-13  8:05 ` Heiko Schocher
2009-02-16 21:55 ` Wolfgang Denk [this message]
2009-02-17 19:54   ` ksi at koi8.net
2009-02-19 20:35     ` Wolfgang Denk
2009-02-19 21:56       ` ksi at koi8.net

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=20090216215546.DCF04832E893@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