All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <guenter.roeck@ericsson.com>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel
Date: Sat, 19 Jun 2010 14:36:56 +0000	[thread overview]
Message-ID: <20100619143656.GA2038@ericsson.com> (raw)
In-Reply-To: <1276877194-28214-2-git-send-email-guenter.roeck@ericsson.com>

On Sat, Jun 19, 2010 at 04:23:12AM -0400, Jean Delvare wrote:
> 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.
> 
Ok, I'll do that. I'll submit a separate patch for the sibyte
i2c bus driver since it returns -1 - which is wrong anyway.

> > > > +                     /* 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?
> 
Unfortunately, yes. It is the only command that works.

Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2010-06-19 14:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-18 16:06 [lm-sensors] [PATCH 0/3} hwmon: Driver for SMM665 Six-Channel Guenter Roeck
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 ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Guenter Roeck
2010-06-18 16:06   ` [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Active DC Output Controller/Monitor Guenter Roeck
2010-06-18 17:53   ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Jonathan Cameron
2010-06-18 17:53     ` [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Active DC Output Controller/Monitor Jonathan Cameron
2010-06-18 18:10     ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Jonathan Cameron
2010-06-18 18:10       ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Active DC Output Controller/Monitor Jonathan Cameron
2010-06-18 19:13       ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Guenter Roeck
2010-06-18 19:13         ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Active DC Output Controller/Monitor Guenter Roeck
2010-06-19  8:27         ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Jean Delvare
2010-06-19  8:27           ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Active DC Output Controller/Monitor Jean Delvare
2010-06-19 10:08           ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Jonathan Cameron
2010-06-19 10:08             ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Active DC Output Controller/Monitor Jonathan Cameron
2010-06-18 20:56     ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Guenter Roeck
2010-06-18 20:56       ` [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Active DC Output Controller/Monitor Guenter Roeck
2010-06-18 21:37       ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Jonathan Cameron
2010-06-18 21:37         ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Active DC Output Controller/Monitor Jonathan Cameron
2010-06-18 21:54         ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Guenter Roeck
2010-06-18 21:54           ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Active DC Output Controller/Monitor Guenter Roeck
2010-06-19  8:23       ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Jean Delvare
2010-06-19  8:23         ` [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Active DC Output Controller/Monitor Jean Delvare
2010-06-18 19:31   ` [lm-sensors] [PATCH 1/3] hwmon: Driver for SMM665 Six-Channel Guenter Roeck
2010-06-19 14:36   ` Guenter Roeck [this message]
2010-06-18 16:06 ` [lm-sensors] [PATCH 2/3] hwmon: SMM665 driver documentation Guenter Roeck
2010-06-18 16:06   ` Guenter Roeck
2010-06-18 16:06 ` [lm-sensors] [PATCH 3/3] hwmon: Update MAINTAINERS for smm665 driver Guenter Roeck
2010-06-18 16:06   ` 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=20100619143656.GA2038@ericsson.com \
    --to=guenter.roeck@ericsson.com \
    --cc=lm-sensors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.