All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean MacLennan <seanm@seanm.ca>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] ad7414 driver
Date: Thu, 19 Jun 2008 16:37:04 +0000	[thread overview]
Message-ID: <20080619123704.773d3930@lappy.seanm.ca> (raw)
In-Reply-To: <20080613221221.50c642ee@lappy.seanm.ca>

On Thu, 19 Jun 2008 12:46:50 +0200
Jean Delvare <khali@linux-fr.org> wrote:

> Hi Sean,
> > +static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input,
> > NULL, 0);
> 
> Note that you don't really need to use SENSOR_DEVICE_ATTR for this
> one, as you make no use of the index value. No big deal either though.

Agreed, but I thought it *looked* better if they all used
SENSOR_DEVICE_ATTR than a mix of SENSOR_DEVICE and DEVICE.

> > +	/* Put the chip in the default power up state. */
> > +	i2c_smbus_write_byte_data(client, AD7414_REG_CONF, 0x40);
> 
> This is overwriting _all_ the bits of the configuration file,
> including changes that could have been done by the the BIOS or
> firmware or whatever. That's not OK! You must read the configuration
> register value, check bit 2, and if it's set, write the value back
> with just bit 2 cleared.

I work with, what we call, "board drivers" too much. We always reset
everything to a know state ;)

We don't need to worry about bit 2. The chip always runs in continuous
conversion mode unless it is powered down. The one shot just *forces*
an immediate conversion rather than waiting 800ms.

The one shot is really more useful in the powered down mode.

All we have to guarantee is that the chip is powered up. Below is the
new code:

	/* Make sure the chip is powered up. */
	conf = i2c_smbus_read_byte_data(client, AD7414_REG_CONF);
	if (conf < 0)
		printk(KERN_WARNING
		       "ad7414_probe unable to read config register.\n");
	else {
		conf &= ~(1 << 7);
		i2c_smbus_write_byte_data(client, AD7414_REG_CONF, conf);
	}

I do not fail the driver if the config read fails. The ad7414 is very
important for our board and will always come up with the reset
value. So the above code is really a NOP for us. I would hate to fail
the driver due to an i2c bus glitch.

If we can agree on the above patch, I can submit a patch with the code
changes.

I also added the AD7414_REG_LIMIT array and the round off change.

Cheers,
   Sean

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

  parent reply	other threads:[~2008-06-19 16:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-14  2:12 [lm-sensors] [PATCH] ad7414 driver Sean MacLennan
2008-06-15  8:09 ` Jean Delvare
2008-06-15 17:13 ` Sean MacLennan
2008-06-15 21:11 ` Jean Delvare
2008-06-15 22:07 ` Sean MacLennan
2008-06-16  6:36 ` Jean Delvare
2008-06-16 23:11 ` Sean MacLennan
2008-06-19 10:46 ` Jean Delvare
2008-06-19 16:37 ` Sean MacLennan [this message]
2008-06-19 17:45 ` Jean Delvare
2008-06-19 18:02 ` Sean MacLennan
2008-06-23 12:33 ` Jean Delvare
2008-08-02  3:52 ` Sean MacLennan
2008-08-08  9:06 ` Jean Delvare

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=20080619123704.773d3930@lappy.seanm.ca \
    --to=seanm@seanm.ca \
    --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.