From: David Brownell <david-b@pacbell.net>
To: Felipe Balbi <me@felipebalbi.com>
Cc: linux-omap@vger.kernel.org,
linux-omap-open-source <linux-omap-open-source@linux.omap.com>
Subject: Re: [PATCH 2/3] ARM: OMAP: Add support for TWL4030 USB Transceiver on OMAP34xx
Date: Wed, 5 Dec 2007 11:46:33 -0800 [thread overview]
Message-ID: <200712051146.34224.david-b@pacbell.net> (raw)
In-Reply-To: <7820275afb3274d87dac374fcf7e7484@felipebalbi.com>
On Wednesday 05 December 2007, Felipe Balbi wrote:
> I think this twl4030_usb.c driver should move to new style I2C. I'm adding
> David Brownell on the loop as he has moved isp1301 to new style i2c driver.
>
> Dave, do you have any comments, here ?
Yes, make it a new-style I2C driver. :)
And pass the IRQ in from board-specific data.
I don't know the twl4030 but I suspect it should be plugging
itself into an otg_transceiver structure instead of exporting
global functions like this ...
Also:
> +#define FUNC_CTRL (0x04)
is bad style; drop the pointless parenthesis. Another bit of bad
style (well, maybe just not-good style) is that the register fields
aren't associated with the register ... e.g. it looks like
> +#define FUNC_CTRL (0x04)
> +#define FUNC_CTRL_SET (0x05)
> +#define FUNC_CTRL_CLR (0x06)
> +#define SUSPENDM (1 << 6)
> +#define RESET (1 << 5)
> +#define OPMODE_MASK (3 << 3) /* bits 3 and 4 */
> +#define OPMODE_NORMAL (0 << 3)
> +#define OPMODE_NONDRIVING (1 << 3)
> +#define OPMODE_DISABLE_BIT_NRZI (2 << 3)
> +#define TERMSELECT (1 << 2)
> +#define XCVRSELECT_MASK (3 << 0) /* bits 0 and 1 */
> +#define XCVRSELECT_HS (0 << 0)
> +#define XCVRSELECT_FS (1 << 0)
> +#define XCVRSELECT_LS (2 << 0)
> +#define XCVRSELECT_FS4LS (3 << 0)
most of these masks are valid for the "control" register, but I
can't tell. And if I were to look at a line of code masking those
together with AUTORESUME, the bug (bitfield from wrong register)
would be almost impossible to discover. In those case a better
convention is to use FN_CTRL_SUSPENDM and IF_CTRL_AUTORESUME,
or something simmilar.
(And a minor nit: "#define<TAB>..." makes trouble reading diffs,
as lines stretch and sometimes wrap; "#define<SPACE>" doesn't.
Either is correct, but the former can be a bit annoying.)
> +#define twl4030_i2c_write_u8_verify(module, data, address) \
> +do { \
> + u8 check; \
> + if (!((twl4030_i2c_write_u8((module), (data), (address)) >= 0) && \
> + (twl4030_i2c_read_u8((module), &check, (address)) >= 0) && \
> + (check == data)) && \
> + !((twl4030_i2c_write_u8((module), (data), (address)) >= 0) && \
> + (twl4030_i2c_read_u8((module), &check, (address)) >= 0) && \
> + (check == (data)))) { \
> + printk(KERN_ERR "twl4030_usb: i2c write failed, \
> + line %d\n", __LINE__); \
> + goto i2c_failed; \
> + } \
> +} while (0)
Good example of something too big for a #define. Make it a function.
No comments about the rest.
- Dave
_______________________________________________
Linux-omap-open-source mailing list
Linux-omap-open-source@linux.omap.com
http://linux.omap.com/mailman/listinfo/linux-omap-open-source
next prev parent reply other threads:[~2007-12-05 19:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-05 13:10 [PATCH 2/3] ARM: OMAP: Add support for TWL4030 USB Transceiver on OMAP34xx Gadiyar, Anand
[not found] ` <7820275afb3274d87dac374fcf7e7484@felipebalbi.com>
2007-12-05 19:46 ` David Brownell [this message]
2007-12-12 11:37 ` Gadiyar, Anand
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=200712051146.34224.david-b@pacbell.net \
--to=david-b@pacbell.net \
--cc=linux-omap-open-source@linux.omap.com \
--cc=linux-omap@vger.kernel.org \
--cc=me@felipebalbi.com \
/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