From: Vitaly Wool <vitalywool@gmail.com>
To: Ben Dooks <ben-linux@fluff.org>
Cc: i2c@lm-sensors.org, linux-arm-kernel@lists.arm.linux.org.uk,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] I2C bus driver for Philips ARM boards
Date: Thu, 22 Jun 2006 16:08:36 +0400 [thread overview]
Message-ID: <20060622160836.9c0640e6.vitalywool@gmail.com> (raw)
In-Reply-To: <20060622114506.GF2028@trinity.fluff.org>
On Thu, 22 Jun 2006 12:45:06 +0100
Ben Dooks <ben-linux@fluff.org> wrote:
> > +
> > + pr_debug("%s: Timer armed at %lu plus %u jiffies.\n",
> > + __FUNCTION__, jiffies, TIMEOUT);
> how about using the dev_dbg() macros?
Okay.
> > +struct i2c_regs {
> > + /* LSB */
> > + union {
> > + const u32 rx; /* Receive FIFO Register - Read Only */
> > + u32 tx; /* Transmit FIFO Register - Write Only */
> > + } fifo;
> > + u32 sts; /* Status Register - Read Only */
> > + u32 ctl; /* Control Register - Read/Write */
> > + u32 ckl; /* Clock divider low - Read/Write */
> > + u32 ckh; /* Clock divider high - Read/Write */
> > + u32 adr; /* I2C address (optional) - Read/Write */
> > + const u32 rfl; /* Rx FIFO level (optional) - Read Only */
> > + const u32 _unused; /* Tx FIFO level (optional) - Read Only */
> > + const u32 rxb; /* Number of bytes received (opt.) - Read Only */
> > + const u32 txb; /* Number of bytes transmitted (opt.) - Read Only */
> > + u32 txs; /* Tx Slave FIFO register - Write Only */
> > + const u32 stfl; /* Tx Slave FIFO level - Read Only */
> > + /* MSB */
> > +};
>
> ARGH, using structs to represent register sets is not good
> practice, and worse, you've marked items in there const, so god
> knows wether the compiler is going to cache results in the
> cpu registers.
The structure is used as volatile throughout.
I personally didn't ever like to use structures for registers, but this is actually an old driver written first at the time ARM compilers produced more optimal code when the registers were accessed through structures.
> > + sprintf(name, "i2c%d_ck", pdev->id);
>
> abuse of the clock system, you should pass the device as the first
> argument, so the clk_get() implementor can differentiate between
> different device's clocks of the same name!
>
> ie:
> clk_get(&pdev->dev, "i2c");
Agreed.
> > +
> > + sprintf(name, "i2c%d_ck", pdev->id);
> > + clk = clk_get(0, name);
>
> why not keep the struct clk with your adapter? this seems to
> get re-used in several places, so keep the `struct clk *` since
> you've got an implicit ref-lock on it by calling clk_get() it
> isn't going anywhere!
The reason behind that is that the other target which has this bus has absolutely different clock layout so it's hard to combine those. Therefore clock stuff was pus into arch-specific part.
> > + if (!IS_ERR(clk)) {
> > + clk_set_rate(clk, 1);
> > + clk_put(clk);
> > + } else
> > + retval = -ENOENT;
> > +#endif
> > + return retval;
> > +}
> > +
>
> These could have easily gone into the main driver, any
> reason for keeping them seperate?
Well, the reason is the same as mentioned above.
Vitaly
next prev parent reply other threads:[~2006-06-22 12:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-22 11:31 [PATCH] I2C bus driver for Philips ARM boards Vitaly Wool
2006-06-22 11:45 ` Ben Dooks
2006-06-22 12:08 ` Vitaly Wool [this message]
2006-06-22 18:39 ` [i2c] " Greg KH
[not found] ` <acd2a5930606221317w6432aefcsf4569fca3b59ebcd@mail.gmail.com>
2006-06-22 20:35 ` Greg KH
2006-06-22 22:26 ` Mark Underwood
2006-06-23 9:38 ` Vitaly Wool
2006-06-23 12:16 ` Mark Underwood
-- strict thread matches above, loose matches on Subject: below --
2006-06-23 9:48 Vitaly Wool
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=20060622160836.9c0640e6.vitalywool@gmail.com \
--to=vitalywool@gmail.com \
--cc=ben-linux@fluff.org \
--cc=i2c@lm-sensors.org \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
/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