Skip to contentSkip to conversation

: hwmon - new chip driver for TI ADS7828 A-D

PATCH Steve Hardy 3 participants 5 messages Jan 4, 2008 – Jan 15, 2008 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Andrew/Jean,

Sorry for the delay - christmas & getting mutt working delayed my revised patch. Here is an updated patch against 2.6.24-rc6, which hopefully addresses all comments made so far.

Jean - you mentioned declaring the devices as platform data & writing a new-style I2C driver - are there any examples of this approach I can refer to? I simply copied what is/was currently in-tree for this driver, which seems to work well with the hardware I'm working with (a COTS CPCI carrier)

Since I've dropped Thunderbird I hope the patch mangling will be fixed.

Any problem, please let me know.

Regards,
Steve

Signed-Off by Steve Hardy <[email protected]>

---

Documentation/hwmon/ads7828 +37 -0
diff -uprN -X linux-2.6.24-rc6/Documentation/dontdiff linux-2.6.24-rc6/Documentation/hwmon/ads7828 linux-2.6.24-rc6-ads7828/Documentation/hwmon/ads7828
@@ -0,0 +1,38 @@
+Kernel driver ads7828
+==========+
+Supported chips:
+  * Texas Instruments/Burr-Brown ADS7828
+    Prefix: 'ads7828'
+    Addresses scanned: I2C 0x48, 0x49, 0x4a, 0x4b
+    Datasheet: Publicly available at the Texas Instruments website :
+               http://focus.ti.com/lit/ds/symlink/ads7828.pdf
+
+Authors:
+        Steve Hardy <[email protected]>
+
+Module Parameters
+-----------------
+
+* se_input: bool (default Y)
+  Single ended operation - set to N for differential mode
+* int_vref: bool (default Y)
+  Operate with the internal 2.5v reference - set to N for external reference
+* vref_mv: int (default 2500)
+  If using an external reference, set this to the reference voltage in mv
+
+Description
+-----------
+
+This driver implements support for the Texas Instruments ADS7828.
+
+This device is a 12bit 8ch A-D converter.
+
+It can operate in single ended mode (8 +ve inputs) or in differential mode,
+when 4 differential pairs can be measured.
+
+The chip also has the facility to use an external voltage reference.  This
+may be required if your hardware supplies the ADS7828 from a 5v supply, see
+the datasheet for more details.
+
+
drivers/hwmon/Kconfig +10 -0
diff -uprN -X linux-2.6.24-rc6/Documentation/dontdiff linux-2.6.24-rc6/drivers/hwmon/Kconfig linux-2.6.24-rc6-ads7828/drivers/hwmon/Kconfig
@@ -588,6 +588,16 @@ config SENSORS_SMSC47B397
 	  This driver can also be built as a module.  If so, the module
 	  will be called smsc47b397.
 
+config SENSORS_ADS7828
+	tristate "Texas Instruments ADS7828"
+	depends on I2C
+	help
+	If you say yes here you get support for Texas Instruments ADS7828
+	12-bit 8-channel ADC device.
+
+	This driver can also be built as a module.  If so, the module
+	will be called ads7828.
+
 config SENSORS_THMC50
 	tristate "Texas Instruments THMC50 / Analog Devices ADM1022"
 	depends on I2C && EXPERIMENTAL
drivers/hwmon/Makefile +1 -0
diff -uprN -X linux-2.6.24-rc6/Documentation/dontdiff linux-2.6.24-rc6/drivers/hwmon/Makefile linux-2.6.24-rc6-ads7828/drivers/hwmon/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_SENSORS_ADM1026)	+= adm1026
 obj-$(CONFIG_SENSORS_ADM1029)	+= adm1029.o
 obj-$(CONFIG_SENSORS_ADM1031)	+= adm1031.o
 obj-$(CONFIG_SENSORS_ADM9240)	+= adm9240.o
+obj-$(CONFIG_SENSORS_ADS7828)	+= ads7828.o
 obj-$(CONFIG_SENSORS_ADT7470)	+= adt7470.o
 obj-$(CONFIG_SENSORS_APPLESMC)	+= applesmc.o
 obj-$(CONFIG_SENSORS_AMS)	+= ams/
drivers/hwmon/ads7828.c +296 -0

296 lines not on this page · raw message

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#2 lore raw
Quoted 12 lines · On Fri, 4 Jan 2008 07:34:39 +0000 Steve Hardy <[email protected]> wrote:

Andrew/Jean,

Sorry for the delay - christmas & getting mutt working delayed my revised patch. Here is an updated patch against 2.6.24-rc6, which hopefully addresses all comments made so far.

Jean - you mentioned declaring the devices as platform data & writing a new-style I2C driver - are there any examples of this approach I can refer to? I simply copied what is/was currently in-tree for this driver, which seems to work well with the hardware I'm working with (a COTS CPCI carrier)

Quoted 5 lines

Since I've dropped Thunderbird I hope the patch mangling will be fixed.

Any problem, please let me know.

The above doesn't constitute a usable changelog. I guess we don't really need anything in this patch but please do remember that the changelog text should be included in each new rev of a patch.

Quoted 2 lines

Signed-Off by Steve Hardy <[email protected]>

"Signed-off-by:", please.

 Documentation/hwmon/ads7828 |   38 ++++
 drivers/hwmon/Kconfig       |   10 +
 drivers/hwmon/Makefile      |    1 
 drivers/hwmon/ads7828.c     |  296 ++++++++++++++++++++++++++++++++++
 4 files changed, 345 insertions(+)

I assumed that this is to be merged via Mark's git-hwmon tree.

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#3 lore raw
In reply to Steve Hardy

Hi Steve,

Quoted 5 lines · Steve Hardy

Jean - you mentioned declaring the devices as platform data & writing a new-style I2C driver - are there any examples of this approach I can refer to? I simply copied what is/was currently in-tree for this driver, which seems to work well with the hardware I'm working with (a COTS CPCI carrier)

In Linus' tree you can find the following new-style drivers:
drivers/rtc/rtc-ds1307.c
drivers/rtc/rtc-ds1374.c
drivers/rtc/rtc-m41t80.c
drivers/rtc/rtc-rs5c372.c

You may also take a look at one that was submitted for merge:
http://marc.info/?l=linux-kernel&m9956436514432&w=2

This doesn't have to be done now though, if you prefer to submit your driver as-is for now and convert it later, that's fine with me.

Quoted 2 lines

Since I've dropped Thunderbird I hope the patch mangling will be fixed.

Yes formatting looks OK this time.

Overall your driver looks good, I only have minor remarks:

Documentation/hwmon/ads7828 line 7

Quoted 11 lines

diff -uprN -X linux-2.6.24-rc6/Documentation/dontdiff linux-2.6.24-rc6/Documentation/hwmon/ads7828 linux-2.6.24-rc6-ads7828/Documentation/hwmon/ads7828

Documentation/hwmon/ads7828 +7 -0
@@ -0,0 +1,38 @@
+Kernel driver ads7828
+==========> +
+Supported chips:
+  * Texas Instruments/Burr-Brown ADS7828
+    Prefix: 'ads7828'
+    Addresses scanned: I2C 0x48, 0x49, 0x4a, 0x4b
+    Datasheet: Publicly available at the Texas Instruments website :

No space before colon.

Documentation/hwmon/ads7828 line 19

Quoted 12 lines
Documentation/hwmon/ads7828 +12 -0
+               http://focus.ti.com/lit/ds/symlink/ads7828.pdf
+
+Authors:
+        Steve Hardy <[email protected]>
+
+Module Parameters
+-----------------
+
+* se_input: bool (default Y)
+  Single ended operation - set to N for differential mode
+* int_vref: bool (default Y)
+  Operate with the internal 2.5v reference - set to N for external reference

2.5V

As far as I know boolean parameters take values 0 and 1, not N and Y.

Documentation/hwmon/ads7828 line 21

Quoted 2 lines
Documentation/hwmon/ads7828 +2 -0
+* vref_mv: int (default 2500)
+  If using an external reference, set this to the reference voltage in mv

Correct unit spelling is "mV".

Documentation/hwmon/ads7828 line 28

Quoted 7 lines
Documentation/hwmon/ads7828 +7 -0
+
+Description
+-----------
+
+This driver implements support for the Texas Instruments ADS7828.
+
+This device is a 12bit 8ch A-D converter.

12-bit 8-channel

Documentation/hwmon/ads7828 line 31

Quoted 3 lines
Documentation/hwmon/ads7828 +3 -0
+
+It can operate in single ended mode (8 +ve inputs) or in differential mode,
+when 4 differential pairs can be measured.

s/when/where/?

If there are only 4 measurement channels in differential mode, then ideally your driver should only create 4 sysfs files in this mode, and it should only read 4 values from the chip rather than 8 in the update function. I2C transactions aren't cheap.

Documentation/hwmon/ads7828 line 34

Quoted 3 lines
Documentation/hwmon/ads7828 +3 -0
+
+The chip also has the facility to use an external voltage reference.  This
+may be required if your hardware supplies the ADS7828 from a 5v supply, see

5V

Documentation/hwmon/ads7828 line 37

Quoted 3 lines
Documentation/hwmon/ads7828 +3 -0
+the datasheet for more details.
+
+

You can drop these extra blank lines.

Quoted 6 lines

diff -uprN -X linux-2.6.24-rc6/Documentation/dontdiff linux-2.6.24-rc6/drivers/hwmon/Kconfig linux-2.6.24-rc6-ads7828/drivers/hwmon/Kconfig

drivers/hwmon/Kconfig +0 -0
@@ -588,6 +588,16 @@ config SENSORS_SMSC47B397
 	  This driver can also be built as a module.  If so, the module
 	  will be called smsc47b397.

drivers/hwmon/Kconfig config SENSORS_SMSC47B397 · line 599

Quoted 10 lines
drivers/hwmon/Kconfig +9 -0
 
+config SENSORS_ADS7828
+	tristate "Texas Instruments ADS7828"
+	depends on I2C
+	help
+	If you say yes here you get support for Texas Instruments ADS7828
+	12-bit 8-channel ADC device.
+
+	This driver can also be built as a module.  If so, the module
+	will be called ads7828.

The help block is traditionally indented with two extra spaces.

Quoted 19 lines
drivers/hwmon/Kconfig +1 -0
+
 config SENSORS_THMC50
 	tristate "Texas Instruments THMC50 / Analog Devices ADM1022"
 	depends on I2C && EXPERIMENTAL

diff -uprN -X linux-2.6.24-rc6/Documentation/dontdiff linux-2.6.24-rc6/drivers/hwmon/Makefile linux-2.6.24-rc6-ads7828/drivers/hwmon/Makefile

drivers/hwmon/Makefile +1 -0
@@ -22,6 +22,7 @@ obj-$(CONFIG_SENSORS_ADM1026)	+= adm1026
 obj-$(CONFIG_SENSORS_ADM1029)	+= adm1029.o
 obj-$(CONFIG_SENSORS_ADM1031)	+= adm1031.o
 obj-$(CONFIG_SENSORS_ADM9240)	+= adm9240.o
+obj-$(CONFIG_SENSORS_ADS7828)	+= ads7828.o
 obj-$(CONFIG_SENSORS_ADT7470)	+= adt7470.o
 obj-$(CONFIG_SENSORS_APPLESMC)	+= applesmc.o
 obj-$(CONFIG_SENSORS_AMS)	+= ams/

diff -uprN -X linux-2.6.24-rc6/Documentation/dontdiff linux-2.6.24-rc6/drivers/hwmon/ads7828.c linux-2.6.24-rc6-ads7828/drivers/hwmon/ads7828.c

drivers/hwmon/ads7828.c line 9

Quoted 9 lines
drivers/hwmon/ads7828.c +9 -0
@@ -0,0 +1,296 @@
+/*
+	ads7828.c - lm_sensors driver for ads7828 12bit 8ch ADC
+	(C) 2007 EADS Astrium
+
+	This driver is based on the lm75 and other lm_sensors/hwmon drivers
+
+	Written by Steve Hardy <[email protected]>
+
+	Datasheet available at : http://focus.ti.com/lit/ds/symlink/ads7828.pdf

No space before colon.

Quoted 25 lines
drivers/hwmon/ads7828.c +25 -0
+
+	This program is free software; you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation; either version 2 of the License, or
+	(at your option) any later version.
+
+	This program is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+	GNU General Public License for more details.
+
+	You should have received a copy of the GNU General Public License
+	along with this program; if not, write to the Free Software
+	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/jiffies.h>
+#include <linux/i2c.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/err.h>
+#include <linux/mutex.h>

drivers/hwmon/ads7828.c line 44

Quoted 10 lines
drivers/hwmon/ads7828.c +10 -0
+
+/* The ADS7828 registers */
+#define ADS7828_NCH 8 /* 8 channels of 12bit A-D supported */
+#define ADS7828_CMD_SD_SE 0x80 /* Single ended inputs */
+#define ADS7828_CMD_SD_DIFF 0x00 /* Differential inputs */
+#define ADS7828_CMD_PD0 0x0 /* Power Down between A-D conversions */
+#define ADS7828_CMD_PD1 0x04 /* Internal ref OFF && A-D ON */
+#define ADS7828_CMD_PD2 0x08 /* Internal ref ON && A-D OFF */
+#define ADS7828_CMD_PD3 0x0C /* Internal ref ON && A-D ON */
+#define ADS7828_INT_VREF_MV 2500 /* Internal vref is 2.5v, 2500mV */

2.5V

drivers/hwmon/ads7828.c line 56

Quoted 12 lines
drivers/hwmon/ads7828.c +12 -0
+
+/* Addresses to scan */
+static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
+	I2C_CLIENT_END };
+
+/* Insmod parameters */
+I2C_CLIENT_INSMOD_1(ads7828);
+
+/* Other module parameters */
+static int se_input = 1; /* Default is SE, 0 = diff */
+static int int_vref = 1; /* Default is internal ref ON */
+static int vref_mv = ADS7828_INT_VREF_MV; /* set if vref != 2.5v */

2.5V

Quoted 6 lines
drivers/hwmon/ads7828.c +6 -0
+module_param(se_input, bool, S_IRUGO);
+module_param(int_vref, bool, S_IRUGO);
+module_param(vref_mv, int, S_IRUGO);
+
+/* Global Variables */
+static u8 ads7828_cmd_byte; /* cmd byte without channel bits */

drivers/hwmon/ads7828.c line 72

Quoted 10 lines
drivers/hwmon/ads7828.c +10 -0
+static unsigned int ads7828_lsb_resol; /* resolution of the ADC sample lsb */
+
+/* Each client has this additional data */
+struct ads7828_data {
+	struct i2c_client client;
+	struct device *hwmon_dev;
+	struct mutex update_lock; /* mutex protect updates */
+	char valid; /* !=0 if following fields are valid */
+	unsigned long last_updated; /* In jiffies */
+	u16 adc_input[ADS7828_NCH]; /* ADS7828_NCH 12bit samples */

12-bit

drivers/hwmon/ads7828.c line 75

Quoted 3 lines
drivers/hwmon/ads7828.c +3 -0
+};
+
+/* Function declaration - neccesary due to function dependencies */

Spelling: necessary.

Quoted 17 lines
drivers/hwmon/ads7828.c +17 -0
+static int ads7828_detect(struct i2c_adapter *adapter, int address, int kind);
+
+/* The ADS7828 returns the 12bit sample in two bytes,
+	these are read as a word then byte-swapped */
+static u16 ads7828_read_value(struct i2c_client *client, u8 reg)
+{
+	return swab16(i2c_smbus_read_word_data(client, reg));
+}
+
+static inline u8 channel_cmd_byte(int ch)
+{
+	/* cmd byte C2,C1,C0 - see datasheet */
+	u8 cmd = (((ch>>1) | (ch&0x01)<<2)<<4);
+	cmd |= ads7828_cmd_byte;
+	return cmd;
+}
+

drivers/hwmon/ads7828.c line 102

Quoted 10 lines
drivers/hwmon/ads7828.c +10 -0
+/* Update data for the device (all 8 channels) */
+static struct ads7828_data *ads7828_update_device(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct ads7828_data *data = i2c_get_clientdata(client);
+
+	mutex_lock(&data->update_lock);
+
+	if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
+			|| !data->valid) {

Note: depending on your application, this caching behavior may or may not be desirable. It's convenient for PC drivers to prevent users from saturating the SMBus, but for embedded designs it might cause trouble. You might want to lower the cache lifetime or even disable the caching behavior to always get real-time measurements.

Quoted 13 lines
drivers/hwmon/ads7828.c +13 -0
+		unsigned int ch;
+		dev_dbg(&client->dev, "Starting ads7828 update\n");
+
+		for (ch = 0; ch < ADS7828_NCH; ch++) {
+			u8 cmd = channel_cmd_byte(ch);
+			data->adc_input[ch] = ads7828_read_value(client, cmd);
+		}
+		data->last_updated = jiffies;
+		data->valid = 1;
+	}
+
+	mutex_unlock(&data->update_lock);
+

drivers/hwmon/ads7828.c line 125

Quoted 10 lines
drivers/hwmon/ads7828.c +10 -0
+	return data;
+}
+
+/* sysfs callback function */
+static ssize_t show_in(struct device *dev, struct device_attribute *da,
+	char *buf)
+{
+	struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
+	struct ads7828_data *data = ads7828_update_device(dev);
+	/* Print value (in mv as specified in sysfs-interface documentation) */

mV

drivers/hwmon/ads7828.c line 132

Quoted 7 lines
drivers/hwmon/ads7828.c +7 -0
+	return sprintf(buf, "%d\n", (data->adc_input[attr->index] *
+		ads7828_lsb_resol)/1000);
+}
+
+#define in_reg(offset)\
+static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in,\
+	NULL, offset);

Trailing semi-colon is not needed.

Quoted 43 lines
drivers/hwmon/ads7828.c +43 -0
+
+in_reg(0);
+in_reg(1);
+in_reg(2);
+in_reg(3);
+in_reg(4);
+in_reg(5);
+in_reg(6);
+in_reg(7);
+
+static struct attribute *ads7828_attributes[] = {
+	&sensor_dev_attr_in0_input.dev_attr.attr,
+	&sensor_dev_attr_in1_input.dev_attr.attr,
+	&sensor_dev_attr_in2_input.dev_attr.attr,
+	&sensor_dev_attr_in3_input.dev_attr.attr,
+	&sensor_dev_attr_in4_input.dev_attr.attr,
+	&sensor_dev_attr_in5_input.dev_attr.attr,
+	&sensor_dev_attr_in6_input.dev_attr.attr,
+	&sensor_dev_attr_in7_input.dev_attr.attr,
+	NULL
+};
+
+static const struct attribute_group ads7828_group = {
+	.attrs = ads7828_attributes,
+};
+
+static int ads7828_attach_adapter(struct i2c_adapter *adapter)
+{
+	if (!(adapter->class & I2C_CLASS_HWMON))
+		return 0;
+	return i2c_probe(adapter, &addr_data, ads7828_detect);
+}
+
+static int ads7828_detach_client(struct i2c_client *client)
+{
+	struct ads7828_data *data = i2c_get_clientdata(client);
+	hwmon_device_unregister(data->hwmon_dev);
+	sysfs_remove_group(&client->dev.kobj, &ads7828_group);
+	i2c_detach_client(client);
+	kfree(i2c_get_clientdata(client));
+	return 0;
+}
+

drivers/hwmon/ads7828.c line 185

Quoted 10 lines
drivers/hwmon/ads7828.c +10 -0
+/* This is the driver that will be inserted */
+static struct i2c_driver ads7828_driver = {
+	.driver = {
+		.name = "ads7828",
+	},
+	.attach_adapter = ads7828_attach_adapter,
+	.detach_client = ads7828_detach_client,
+};
+
+/* This function is called by i2c_detect */

Actually not, it's called by i2c_probe.

Quoted 4 lines
drivers/hwmon/ads7828.c +4 -0
+static int ads7828_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+	struct i2c_client *client;
+	struct ads7828_data *data;

drivers/hwmon/ads7828.c line 199

Quoted 10 lines
drivers/hwmon/ads7828.c +10 -0
+	int err=0;
+	const char *name = "";
+
+	/* Check we have a valid client */
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_WORD_DATA))
+		goto exit;
+
+	/* OK. For now, we presume we have a valid client. We now create the
+		 client structure, even though we cannot fill it completely yet.
+		 But it allows us to access ads7828_read_value. */

Strange indentation...

Quoted 65 lines
drivers/hwmon/ads7828.c +65 -0
+	data = kzalloc(sizeof(struct ads7828_data), GFP_KERNEL);
+	if (!data) {
+		err = -ENOMEM;
+		goto exit;
+	}
+
+	client = &data->client;
+	i2c_set_clientdata(client, data);
+	client->addr = address;
+	client->adapter = adapter;
+	client->driver = &ads7828_driver;
+
+	/* Now, we do the remaining detection. There is no identification
+	dedicated register so attempt to sanity check using knowledge of the chip
+	- Read from the 8 channel addresses
+	- Check the top 4 bits of each result are not set (12 data bits)
+	*/
+	if (kind < 0) {
+		int ch;
+		for (ch = 0; ch < ADS7828_NCH; ch++) {
+			u16 in_data;
+			u8 cmd = channel_cmd_byte(ch);
+			in_data = ads7828_read_value(client, cmd);
+			if (in_data & 0xF000) {
+				printk(KERN_DEBUG 
+				"%s : Doesn't look like an ads7828 device\n",
+				__FUNCTION__);
+				goto exit_free;
+			}
+		}
+	}
+
+	/* Determine the chip type - only one kind supported! */
+	if (kind <= 0)
+		kind = ads7828;
+
+	if (kind = ads7828)
+		name = "ads7828";
+
+	/* Fill in the remaining client fields, put it into the global list */
+	strlcpy(client->name, name, I2C_NAME_SIZE);
+
+	mutex_init(&data->update_lock);
+
+	/* Tell the I2C layer a new client has arrived */
+	err = i2c_attach_client(client);
+	if (err)
+		goto exit_free;
+
+	/* Register sysfs hooks */
+	err = sysfs_create_group(&client->dev.kobj, &ads7828_group);
+	if (err)
+		goto exit_detach;
+
+	data->hwmon_dev = hwmon_device_register(&client->dev);
+	if (IS_ERR(data->hwmon_dev)) {
+		err = PTR_ERR(data->hwmon_dev);
+		goto exit_remove;
+	}
+
+	return 0;
+
+exit_remove:
+	sysfs_remove_group(&client->dev.kobj, &ads7828_group);
+exit_detach:

drivers/hwmon/ads7828.c line 274

Quoted 10 lines
drivers/hwmon/ads7828.c +10 -0
+	i2c_detach_client(client);
+exit_free:
+	kfree(data);
+exit:
+	return err;
+}
+
+static int __init sensors_ads7828_init(void)
+{
+	/* Initialise the command byte according to module parameters */

Spelling: Initialize.

Quoted 12 lines
drivers/hwmon/ads7828.c +12 -0
+	ads7828_cmd_byte = se_input ?
+		ADS7828_CMD_SD_SE : ADS7828_CMD_SD_DIFF;
+	ads7828_cmd_byte |= int_vref ?
+		ADS7828_CMD_PD3 : ADS7828_CMD_PD1;
+
+	/* Calculate the LSB resolution */
+	ads7828_lsb_resol = (vref_mv*1000)/4096;
+
+	return i2c_add_driver(&ads7828_driver);
+}
+
+static void __exit sensors_ads7828_exit(void)

drivers/hwmon/ads7828.c line 296

Quoted 10 lines
drivers/hwmon/ads7828.c +10 -0
+{
+	i2c_del_driver(&ads7828_driver);
+}
+
+MODULE_AUTHOR("Steve Hardy <[email protected]>");
+MODULE_DESCRIPTION("ADS7828 driver");
+MODULE_LICENSE("GPL");
+
+module_init(sensors_ads7828_init);
+module_exit(sensors_ads7828_exit);

The rest looks OK to me. I suggest that you give a try to lm-sensors 3.0.0 with this driver, that's the best way to ensure that your sysfs interface is properly implemented.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#4 lore raw
Quoted 2 lines

As far as I know boolean parameters take values 0 and 1, not N and Y.

Not on the systems I am testing on (2.6.24-rc6) - the sysfs interface displays boolean parameters as Y/N, and will accept boot parameters as either Y/N or 0/1. Below is a snippet from a test proving this point :

test@shtest:~$ cat /sys/module/ads7828/parameters/se_input
Y
test@shtest:~$ cat /sys/module/ads7828/parameters/int_vref
Y

after appending the ads7828.int_vref=N parameter to the kernel command-line :

Linux 2.6.24-rc6 (shtest) (16:53 on Saturday, 05 January 2002)

login: test

test@shtest:~$ cat /sys/module/ads7828/parameters/int_vref
N

Is it more "correct" to refer to 1/0 in the documentation? I just naturally used the same syntax provided by the sysfs nodes

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#5 lore raw

Hi Steve,

Quoted 11 lines · Steve Hardy
Quoted 1 line

As far as I know boolean parameters take values 0 and 1, not N and Y.

Not on the systems I am testing on (2.6.24-rc6) - the sysfs interface displays boolean parameters as Y/N, and will accept boot parameters as either Y/N or 0/1. Below is a snippet from a test proving this point :

test@shtest:~$ cat /sys/module/ads7828/parameters/se_input
Y
test@shtest:~$ cat /sys/module/ads7828/parameters/int_vref
Y
Quoted 8 lines

after appending the ads7828.int_vref=N parameter to the kernel command-line :

Linux 2.6.24-rc6 (shtest) (16:53 on Saturday, 05 January 2002)

login: test

test@shtest:~$ cat /sys/module/ads7828/parameters/int_vref
N

Oh. This is news to me, thanks for the information.

Quoted 2 lines

Is it more "correct" to refer to 1/0 in the documentation? I just naturally used the same syntax provided by the sysfs nodes

Nah, just scratch this comment of mine, I just didn't know that Y/N was working for booleans. If you prefer that to document that form that's alright with me.

(I do believe that it was a mistake to allow two different ways to do the same thing, but that's a different issue.)

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors