linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
To: "Jayachandran C."
	<jayachandranc-oSioyQM9ZPnuBjGU1YDckgC/G2K4zDHf@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"Ben Dooks (embedded platforms)"
	<ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>,
	"Jean Delvare (PC drivers,
	core)" <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>,
	ganesanr-oSioyQM9ZPnuBjGU1YDckgC/G2K4zDHf@public.gmane.org
Subject: Re: [RESEND] [PATCH] i2c: Support for Netlogic XLR/XLS on-chip I2C controller.
Date: Sat, 9 Jul 2011 10:37:42 +0100	[thread overview]
Message-ID: <20110709093742.GA9247@sirena.org.uk> (raw)
In-Reply-To: <20110623135057.GA26772-l4W0uAg2RDvWG0bvociYJ/An/qbn1+6FOui0OUZsNXA@public.gmane.org>

On Fri, Jul 08, 2011 at 03:42:04PM +0530, Jayachandran C. wrote:

>  arch/mips/configs/nlm_xlr_defconfig |    4 +
>  arch/mips/netlogic/xlr/platform.c   |   29 +++
>  drivers/i2c/busses/Kconfig          |   11 ++
>  drivers/i2c/busses/Makefile         |    1 +
>  drivers/i2c/busses/i2c-xlr.c        |  335 +++++++++++++++++++++++++++++++++++

Normally the arch/mips code would be split out from the driver patch.

> +config I2C_XLR
> +	tristate "XLR I2C support"
> +	depends on I2C && CPU_XLR

No need to depend on I2C in the I2C drivers directory.

> +struct xlr_i2c_private {
> +	struct i2c_adapter adap;
> +	u32 *iobase_i2c_regs;
> +};

Should there be an __iomem in there?

> +static struct xlr_i2c_private  xlr_i2c_priv;

This shouldn't be static data, it should be allocated per device.

> +u32 *get_i2c_base(unsigned short bus)
> +{
> +	nlm_reg_t *mmio = 0;
> +
> +	if (bus == 0)
> +		mmio = netlogic_io_mmio(NETLOGIC_IO_I2C_0_OFFSET);
> +	else
> +		mmio = netlogic_io_mmio(NETLOGIC_IO_I2C_1_OFFSET);
> +
> +	return (u32 *)mmio;

Functions like this should be static, though in this case the memory
region should be passed in as a resource rather than being embedded in
the driver.

> +	while (1) {
> +		i2c_status = xlr_i2c_read(priv->iobase_i2c_regs,
> +				XLR_I2C_STATUS);
> +
> +		if (i2c_status & XLR_I2C_SDOEMPTY) {
> +			pos++;
> +			nb = (pos < len) ? buf[pos] : 0;
> +			xlr_i2c_write(priv->iobase_i2c_regs, XLR_I2C_DATAOUT,
> +					nb);
> +		}
> +
> +		if (i2c_status & XLR_I2C_ARB_STARTERR)
> +			goto retry;
> +
> +		if (i2c_status & XLR_I2C_ACK_ERR) {
> +			dev_err(&priv->adap.dev, "ACK ERR\n");
> +			return -1;

Return a proper error code, not -1.

> +		}
> +
> +		if (i2c_status & XLR_I2C_BUS_BUSY)
> +			continue;

This is going to loop infinitely if the bus locks up for some reason.
There should be some limit on how long we try for.  It also looks like
we're busy waiting here which isn't terribly good.

> +static int __devinit xlr_i2c_probe(struct platform_device *pd)
> +{
> +	xlr_i2c_priv.iobase_i2c_regs = get_i2c_base(pd->id);
> +
> +	xlr_i2c_priv.adap.dev.parent = &pd->dev;
> +	if (xlr_i2c_add_bus(&xlr_i2c_priv) < 0) {
> +		dev_err(&xlr_i2c_priv.adap.dev, "Failed to add i2c bus\n");

You should return the error you get.

> +	} else
> +		dev_info(&xlr_i2c_priv.adap.dev, "Added I2C Bus.\n");

This seems needlessly chatty.

> +MODULE_AUTHOR("Netlogic Microsystems Inc.");

This should generally be a person.

  parent reply	other threads:[~2011-07-09  9:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-23 13:51 [PATCH] i2c: Support for Netlogic XLR/XLS on-chip I2C controller Jayachandran C.
     [not found] ` <20110623135057.GA26772-l4W0uAg2RDvWG0bvociYJ/An/qbn1+6FOui0OUZsNXA@public.gmane.org>
2011-07-09  9:37   ` Mark Brown [this message]
     [not found]     ` <20110709093742.GA9247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2011-07-11  7:02       ` [RESEND] " Jayachandran C.
     [not found]         ` <20110711070202.GB31303-l4W0uAg2RDvWG0bvociYJ/An/qbn1+6FOui0OUZsNXA@public.gmane.org>
2011-07-11  7:14           ` Mark Brown
2011-07-13 21:56   ` Ben Dooks

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=20110709093742.GA9247@sirena.org.uk \
    --to=broonie-yzvpicuk2aatku/dhu1wvuem+bqzidxxqq4iyu8u01e@public.gmane.org \
    --cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=ganesanr-oSioyQM9ZPnuBjGU1YDckgC/G2K4zDHf@public.gmane.org \
    --cc=jayachandranc-oSioyQM9ZPnuBjGU1YDckgC/G2K4zDHf@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).