Devicetree
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: robh+dt@kernel.org, afaerber@suse.de, linus.walleij@linaro.org,
	linux-i2c@vger.kernel.org, liuwei@actions-semi.com,
	mp-cs@actions-semi.com, 96boards@ucrobotics.com,
	devicetree@vger.kernel.org, andy.shevchenko@gmail.com,
	daniel.thompson@linaro.org, amit.kucheria@linaro.org,
	linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org, hzhang@ucrobotics.com,
	bdong@ucrobotics.com, manivannanece23@gmail.com,
	thomas.liau@actions-semi.com, jeff.chen@actions-semi.com
Subject: Re: [PATCH v7 5/6] i2c: Add Actions Semiconductor Owl family S900 I2C driver
Date: Wed, 1 Aug 2018 10:26:39 +0530	[thread overview]
Message-ID: <20180801045639.GB15529@Mani-XPS-13-9360> (raw)
In-Reply-To: <20180731200932.n7djds2rmqhclit5@ninjato>

Hi Wolfram,

On Tue, Jul 31, 2018 at 10:09:32PM +0200, Wolfram Sang wrote:
> Hi Manivannan,
> 
> On Thu, Jul 26, 2018 at 09:16:02PM +0530, Manivannan Sadhasivam wrote:
> > Add Actions Semiconductor Owl family S900 I2C driver.
> > 
> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > Acked-by: Peter Rosin <peda@axentia.se>
> 
> Looks mostly good already. Thanks Peter for the initial review!
> 

Thanks to Andy also :)

> > +static irqreturn_t owl_i2c_interrupt(int irq, void *_dev)
> > +{
> > +	struct owl_i2c_dev *i2c_dev = _dev;
> > +	struct i2c_msg *msg = i2c_dev->msg;
> > +	unsigned long flags;
> > +	unsigned int stat, fifostat;
> > +
> > +	spin_lock_irqsave(&i2c_dev->lock, flags);
> > +
> > +	fifostat = readl(i2c_dev->base + OWL_I2C_REG_FIFOSTAT);
> > +	if (fifostat & OWL_I2C_FIFOSTAT_RNB) {
> > +		dev_dbg(&i2c_dev->adap.dev, "received NACK from device\n");
> > +		goto stop;
> > +	}
> > +
> > +	stat = readl(i2c_dev->base + OWL_I2C_REG_STAT);
> > +	if (stat & OWL_I2C_STAT_BEB) {
> > +		dev_dbg(&i2c_dev->adap.dev, "bus error\n");
> > +		goto stop;
> > +	}
> 
> I wonder if you can't pass back the different errors to the upper
> layers? Like -ENXIO for NACK and -EIO for bus error? We have a
> convention for that and it seems your HW can support it. The different
> error codes would then maybe also make the debug outputs obsolete.
> 
> 

Sure, will catch the errors using an i2c_dev member and pass it to upper
layers in owl_i2c_master_xfer.

> > +	/*
> > +	 * Here, -ENXIO will be returned if interrupt occurred but no
> > +	 * read or write happened. Else if msg_ptr equals to message length,
> > +	 * message count will be returned.
> > +	 */
> > +	ret = i2c_dev->msg_ptr == msg->len ? num : -ENXIO;
> 
> I'd think this kinda unusual construct could go then as well by just
> returning the error code derived from the interrupt handler above.
> 

Makes sense! It will become:

ret = i2c_dev->err < 0 ? i2c_dev->err : num;

Thanks,
Mani

> > +static const struct i2c_adapter_quirks owl_i2c_quirks = {
> > +	.flags		= I2C_AQ_COMB | I2C_AQ_COMB_WRITE_FIRST,
> > +	.max_read_len   = 240,
> > +	.max_write_len  = 240,
> > +	.max_comb_1st_msg_len = 6,
> > +	.max_comb_2nd_msg_len = 240,
> > +};
> 
> Yay! Good use of the i2c_adapter_quirks struct :)
> 
> Regards,
> 
>    Wolfram
> 

  reply	other threads:[~2018-08-01  4:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-26 15:45 [PATCH v7 0/6] Add Actions Semiconductor Owl S900 I2C support Manivannan Sadhasivam
2018-07-26 15:45 ` [PATCH v7 1/6] dt-bindings: i2c: Add binding for Actions Semiconductor Owl I2C controller Manivannan Sadhasivam
2018-07-26 15:45 ` [PATCH v7 2/6] arm64: dts: actions: Add pinctrl definition for S900 " Manivannan Sadhasivam
2018-07-26 15:46 ` [PATCH v7 3/6] arm64: dts: actions: Add Actions Semiconductor S900 I2C controller nodes Manivannan Sadhasivam
2018-07-26 15:46 ` [PATCH v7 4/6] arm64: dts: actions: Enable I2C1 and I2C2 in Bubblegum-96 board Manivannan Sadhasivam
2018-07-26 15:46 ` [PATCH v7 5/6] i2c: Add Actions Semiconductor Owl family S900 I2C driver Manivannan Sadhasivam
2018-07-31 20:09   ` Wolfram Sang
2018-08-01  4:56     ` Manivannan Sadhasivam [this message]
2018-07-26 15:46 ` [PATCH v7 6/6] MAINTAINERS: Add entry for Actions Semiconductor Owl " Manivannan Sadhasivam
2018-07-30 17:07 ` [PATCH v7 0/6] Add Actions Semiconductor Owl S900 I2C support Manivannan Sadhasivam

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=20180801045639.GB15529@Mani-XPS-13-9360 \
    --to=manivannan.sadhasivam@linaro.org \
    --cc=96boards@ucrobotics.com \
    --cc=afaerber@suse.de \
    --cc=amit.kucheria@linaro.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=bdong@ucrobotics.com \
    --cc=daniel.thompson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hzhang@ucrobotics.com \
    --cc=jeff.chen@actions-semi.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuwei@actions-semi.com \
    --cc=manivannanece23@gmail.com \
    --cc=mp-cs@actions-semi.com \
    --cc=robh+dt@kernel.org \
    --cc=thomas.liau@actions-semi.com \
    --cc=wsa@the-dreams.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