mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Jochen Friedrich <jochen@scram.de>
Cc: Jon Smirl <jonsmirl@gmail.com>, Jean Delvare <khali@linux-fr.org>,
	linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org,
	Scott Wood <scottwood@freescale.com>
Subject: Re: [PATCHv2] i2c: adds support for i2c bus on Frescale CPM1/CPM2 controllers
Date: Thu, 3 Jan 2008 10:41:21 +1100	[thread overview]
Message-ID: <20080103104121.58697148.sfr@canb.auug.org.au> (raw)
In-Reply-To: <477BEB60.4070703@scram.de>

[-- Attachment #1: Type: text/plain, Size: 2439 bytes --]

Hi Jochen,

Just a few trivial things.

On Wed, 02 Jan 2008 20:52:00 +0100 Jochen Friedrich <jochen@scram.de> wrote:
>
> +++ b/drivers/i2c/busses/i2c-cpm.c
> +
> +static irqreturn_t cpm_i2c_interrupt(int irq, void *dev_id)
> +{
> +	struct i2c_adapter *adap;
> +	struct cpm_i2c *cpm;
> +	struct i2c_reg __iomem *i2c_reg;
> +	int i;
> +
> +	adap = (struct i2c_adapter *) dev_id;

This cast is unnecessary. In fact, you could just pass dev_id to the
following call to i2c_get_adapdata() and eliminate adap completely.

> +	/* Get 'me going again.
> +	 */

For short comments, just make them one line.  Similarly later as well.

> +	/* This chip can't do zero length writes. However, the i2c core uses
> +	   them to scan for devices. The best we can do is to convert them
> +	   into 1 byte reads */

For multiline comments, we normally do
/*
 * blah ...
 * more blah
 */

> +static int cpm_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
> +{
> +
> +	while (tptr < num) {
> +		/* Check for outstanding messages */
> +		dev_dbg(&adap->dev, "test ready.\n");
> +		if (!(tbdf[tptr].cbd_sc & BD_SC_READY)) {
> +			dev_dbg(&adap->dev, "ready.\n");
> +			rmsg = &msgs[tptr];
> +			ret = cpm_i2c_check_message(adap, rmsg, tptr, rptr);
> +			tptr++;
> +			if (rmsg->flags & I2C_M_RD)
> +				rptr++;
> +			if (ret) {
> +				cpm_i2c_force_close(adap);
> +				mutex_unlock(&cpm->i2c_mutex);
> +				return ret;
> +			}
> +		} else {
> +			dev_dbg(&adap->dev, "not ready.\n");
> +			ret = wait_event_interruptible_timeout(cpm->i2c_wait,
> +				!(tbdf[tptr].cbd_sc & BD_SC_READY), 1 * HZ);
> +			if (ret == 0) {
> +				cpm_i2c_force_close(adap);
> +				dev_dbg(&adap->dev, "I2C read: timeout!\n");
> +				mutex_unlock(&cpm->i2c_mutex);
> +				return -EREMOTEIO;
> +			}

You might want to consolidate the two error paths above using gotos to an
error return section below.

> +static void of_register_i2c_devices(struct i2c_adapter *adap,
> +				    struct device_node *adap_node)
> +{
> +	struct device_node *node = NULL;
> +
> +	while ((node = of_get_next_child(adap_node, node))) {

Use
	for_each_child_of_node(adap_node, node) {
instead and you don't need to initialise "node" above.

> +static struct of_device_id cpm_i2c_match[] = {

const?

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2008-01-02 23:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-02 19:52 Jochen Friedrich
2008-01-02 23:41 ` Stephen Rothwell [this message]
2008-01-23 10:29   ` Jean Delvare
2008-01-23 11:23     ` Jochen Friedrich
2008-01-23 13:02       ` Jean Delvare
2008-01-23 14:28         ` Jon Smirl

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=20080103104121.58697148.sfr@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=jochen@scram.de \
    --cc=jonsmirl@gmail.com \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=scottwood@freescale.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

all inboxes | Powered by JetHome®