public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: guenter.roeck@ericsson.com
Cc: Jonathan Cameron <kernel@jic23.retrosnub.co.uk>,
	Hans de Goede <hdegoede@redhat.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Active DC  Output Controller/Monitor
Date: Sat, 19 Jun 2010 10:23:12 +0200	[thread overview]
Message-ID: <20100619102312.02f86e3b@hyperion.delvare> (raw)
In-Reply-To: <1276894613.2631.535.camel@groeck-laptop>

On Fri, 18 Jun 2010 13:56:53 -0700, Guenter Roeck wrote:
> [...]
> > > +             /*
> > > +              * Algorithm for reading ADC, per SMM665 datasheet
> > > +              *
> > > +              *  {[S][addr][W][Ack]} {[offset][Ack]} {[S][addr][R][Nack]}
> > > +              * [wait 70 uS]
> > > +              *  {[S][addr][R][Ack]} {[datahi][Ack]} {[datalo][Ack][P]}
> > > +              *
> > > +              * To implement the first part of this exchange,
> > > +              * do a full read transaction and expect a failure/Nack.
> > > +              * This sets up the address pointer on the SMM665
> > > +              * and starts the ADC conversion.
> > > +              * Then do a two-byte read transaction.
> > > +              */
> > Is there no better way of handling this? There are protocol mangling hacks
> > to tell the i2c core to ignore a NAKs under some circumstances.

This is only available on raw I2C messages, not on the higher-level
i2c_smbus_*() API. And not all bus drivers support it. And that's not
what is needed here anyway: ignoring the nack means we would continue
reading from the chip, while it really doesn't want to talk to us at
that time.

> > > +             rv = i2c_smbus_read_byte_data(client, adc << 3);
> > > +             if (rv >= 0) {

You should check for -ENXIO explicitly. According to
Documentation/i2c/fault-codes, this is the value bus drivers should
return on missing Ack.

> > > +                     /* No error, something is wrong. Retry. */
> > > +                     rv = -1;
> > > +                     continue;
> > > +             }
> 
> I looked through the core i2c code, but did not find anything I can
> use. 
> 
> Problem is that per smm665 specification, the first NACK is expected. So
> we do not just want to ignore this NACK, we want to actively check if
> the command "failed" as expected, and report an error if it did _not_
> fail.

Do you really have to trigger the Nack for the ADC conversion to start?
Can't you just use i2c_smbus_read_byte() (no _data) for the first part
of the transaction?

-- 
Jean Delvare

  parent reply	other threads:[~2010-06-19  8:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-18 16:06 [PATCH 0/3} hwmon: Driver for SMM665 Six-Channel Active DC Output Controller/Monitor Guenter Roeck
2010-06-18 16:06 ` [PATCH 1/3] " Guenter Roeck
2010-06-18 17:53   ` Jonathan Cameron
2010-06-18 18:10     ` [lm-sensors] " Jonathan Cameron
2010-06-18 19:13       ` Guenter Roeck
2010-06-19  8:27         ` Jean Delvare
2010-06-19 10:08           ` Jonathan Cameron
2010-06-18 20:56     ` Guenter Roeck
2010-06-18 21:37       ` [lm-sensors] " Jonathan Cameron
2010-06-18 21:54         ` Guenter Roeck
2010-06-19  8:23       ` Jean Delvare [this message]
2010-06-18 16:06 ` [PATCH 2/3] hwmon: SMM665 driver documentation Guenter Roeck
2010-06-18 16:06 ` [PATCH 3/3] hwmon: Update MAINTAINERS for smm665 driver Guenter Roeck

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=20100619102312.02f86e3b@hyperion.delvare \
    --to=khali@linux-fr.org \
    --cc=akpm@linux-foundation.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=guenter.roeck@ericsson.com \
    --cc=hdegoede@redhat.com \
    --cc=kernel@jic23.retrosnub.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.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