linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BK PATCH] i2c driver fixes for 2.6.0
@ 2003-12-30 22:02 Greg KH
  2003-12-30 22:06 ` [PATCH] " Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:02 UTC (permalink / raw)
  To: torvalds, akpm; +Cc: linux-kernel, sensors

Hi,

Here are some i2c driver fixes and updates for 2.6.0.  There are a
number of bug fixes here, a big documentation update, and a new i2c chip
driver was added.

Please pull from:  bk://linuxusb.bkbits.net/i2c-devel-2.6

Individual patches will follow, sent to the sensors and linux-kernel
lists.

thanks,

greg k-h

 Documentation/i2c/i2c-velleman    |   16 -
 Documentation/i2c/porting-clients |  121 ++++++++++
 Documentation/i2c/summary         |    2 
 Documentation/i2c/sysfs-interface |   33 +-
 Documentation/i2c/writing-clients |   57 ----
 drivers/i2c/algos/i2c-algo-bit.c  |   96 ++++----
 drivers/i2c/algos/i2c-algo-ite.c  |   36 ---
 drivers/i2c/busses/Kconfig        |   12 -
 drivers/i2c/busses/i2c-amd756.c   |   35 +-
 drivers/i2c/busses/i2c-amd8111.c  |    2 
 drivers/i2c/busses/i2c-ibm_iic.c  |   34 --
 drivers/i2c/busses/i2c-piix4.c    |   39 ++-
 drivers/i2c/busses/i2c-savage4.c  |   12 -
 drivers/i2c/busses/i2c-velleman.c |    2 
 drivers/i2c/busses/i2c-viapro.c   |    8 
 drivers/i2c/chips/Kconfig         |   27 +-
 drivers/i2c/chips/Makefile        |    1 
 drivers/i2c/chips/it87.c          |   11 
 drivers/i2c/chips/lm75.c          |   40 ---
 drivers/i2c/chips/lm75.h          |   49 ++++
 drivers/i2c/chips/lm78.c          |    4 
 drivers/i2c/chips/lm83.c          |  450 +++++++++++++++++++++++++++++++++++---
 drivers/i2c/chips/via686a.c       |   46 +--
 drivers/i2c/chips/w83781d.c       |  221 ++----------------
 drivers/pcmcia/sa1100_stork.c     |    1 
 include/linux/i2c-id.h            |    2 
 26 files changed, 845 insertions(+), 512 deletions(-)
-----

Greg Kroah-Hartman:
  o I2C: removed #include <linux/i2c.h> from sa1100_stork.c as it's not needed

Jean Delvare:
  o I2C: lm83 driver updates
  o I2C: velleman typo
  o I2C: Fix SCx200 dependancies
  o I2C: remove bus scan logic from i2c chip drivers
  o I2C: restore support for AMD8111 in i2c-amd756 driver
  o I2C: fix i2c-amd8111 driver
  o I2C: it87 and via686a alarms
  o I2C: add KT600 support to i2c-viapro driver
  o I2C: add Serverworks CSB6 support to i2c-piix4
  o I2C: fix author of i2c-savage4.c driver
  o I2C: make I2C chipset drivers use temp_hyst[1-3]
  o I2C: sysfs interface documentation
  o I2C: Fix i2c-algo-bit for adapers that cannot read SCL back
  o I2C: i2c documentation (2 of 2)
  o I2C: i2c documentation (1 of 2)
  o I2C: Add lm83 chip driver

Mark D. Studebaker:
  o I2C: fix amd756 byte writes

Mark M. Hoffman:
  o I2C: lm75 chip driver conversion routine fixes
  o I2C: remove initialization of limits by lm75 driver
  o I2C: remove initialization of limits by w83781d driver
  o I2C: improve chip detection in w83781d.c driver

Tom Rini:
  o I2C: make i2c-piix4 fix optional


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:02 [BK PATCH] i2c driver fixes for 2.6.0 Greg KH
@ 2003-12-30 22:06 ` Greg KH
  2003-12-30 22:06   ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1337.6.1, 2003/10/09 13:40:07-07:00, khali@linux-fr.org

[PATCH] I2C: Add lm83 chip driver


 drivers/i2c/chips/Kconfig  |   11 +
 drivers/i2c/chips/Makefile |    1 
 drivers/i2c/chips/lm83.c   |  413 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/i2c-id.h     |    1 
 4 files changed, 426 insertions(+)


diff -Nru a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
--- a/drivers/i2c/chips/Kconfig	Tue Dec 30 12:33:21 2003
+++ b/drivers/i2c/chips/Kconfig	Tue Dec 30 12:33:21 2003
@@ -68,6 +68,17 @@
 	  This driver can also be built as a module.  If so, the module
 	  will be called lm78.
 
+config SENSORS_LM83
+	tristate "National Semiconductor LM83"
+	depends on I2C && EXPERIMENTAL
+	select I2C_SENSOR
+	help
+	  If you say yes here you get support for National Semiconductor
+	  LM83 sensor chips.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called lm83.
+
 config SENSORS_LM85
 	tristate "National Semiconductors LM85 and compatibles"
 	depends on I2C && EXPERIMENTAL
diff -Nru a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
--- a/drivers/i2c/chips/Makefile	Tue Dec 30 12:33:21 2003
+++ b/drivers/i2c/chips/Makefile	Tue Dec 30 12:33:21 2003
@@ -10,5 +10,6 @@
 obj-$(CONFIG_SENSORS_IT87)	+= it87.o
 obj-$(CONFIG_SENSORS_LM75)	+= lm75.o
 obj-$(CONFIG_SENSORS_LM78)	+= lm78.o
+obj-$(CONFIG_SENSORS_LM83)	+= lm83.o
 obj-$(CONFIG_SENSORS_LM85)	+= lm85.o
 obj-$(CONFIG_SENSORS_VIA686A)	+= via686a.o
diff -Nru a/drivers/i2c/chips/lm83.c b/drivers/i2c/chips/lm83.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/i2c/chips/lm83.c	Tue Dec 30 12:33:21 2003
@@ -0,0 +1,413 @@
+/*
+ * lm83.c - Part of lm_sensors, Linux kernel modules for hardware
+ *          monitoring
+ * Copyright (C) 2003  Jean Delvare <khali@linux-fr.org>
+ *
+ * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is
+ * a sensor chip made by National Semiconductor. It reports up to four
+ * temperatures (its own plus up to three external ones) with a 1 deg
+ * resolution and a 3-4 deg accuracy. Complete datasheet can be obtained
+ * from National's website at:
+ *   http://www.national.com/pf/LM/LM83.html
+ * Since the datasheet omits to give the chip stepping code, I give it
+ * here: 0x03 (at register 0xff).
+ *
+ * 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/i2c.h>
+#include <linux/i2c-sensor.h>
+
+/*
+ * Addresses to scan
+ * Address is selected using 2 three-level pins, resulting in 9 possible
+ * addresses.
+ */
+
+static unsigned short normal_i2c[] = { I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { 0x18, 0x1a, 0x29, 0x2b,
+    0x4c, 0x4e, I2C_CLIENT_END };
+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
+static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
+
+/*
+ * Insmod parameters
+ */
+
+SENSORS_INSMOD_1(lm83);
+
+/*
+ * The LM83 registers
+ * Manufacturer ID is 0x01 for National Semiconductor.
+ */
+
+#define LM83_REG_R_MAN_ID		0xFE
+#define LM83_REG_R_CHIP_ID		0xFF
+#define LM83_REG_R_CONFIG		0x03
+#define LM83_REG_W_CONFIG		0x09
+#define LM83_REG_R_STATUS1		0x02
+#define LM83_REG_R_STATUS2		0x35
+#define LM83_REG_R_LOCAL_TEMP		0x00
+#define LM83_REG_R_LOCAL_HIGH		0x05
+#define LM83_REG_W_LOCAL_HIGH		0x0B
+#define LM83_REG_R_REMOTE1_TEMP		0x30
+#define LM83_REG_R_REMOTE1_HIGH		0x38
+#define LM83_REG_W_REMOTE1_HIGH		0x50
+#define LM83_REG_R_REMOTE2_TEMP		0x01
+#define LM83_REG_R_REMOTE2_HIGH		0x07
+#define LM83_REG_W_REMOTE2_HIGH		0x0D
+#define LM83_REG_R_REMOTE3_TEMP		0x31
+#define LM83_REG_R_REMOTE3_HIGH		0x3A
+#define LM83_REG_W_REMOTE3_HIGH		0x52
+#define LM83_REG_R_TCRIT		0x42
+#define LM83_REG_W_TCRIT		0x5A
+
+/*
+ * Conversions, initial values and various macros
+ * The LM83 uses signed 8-bit values.
+ */
+
+#define TEMP_FROM_REG(val)	((val > 127 ? val-256 : val) * 1000)
+#define TEMP_TO_REG(val)	((val < 0 ? val+256 : val) / 1000)
+
+#define LM83_INIT_HIGH		100
+#define LM83_INIT_CRIT		120
+
+static const u8 LM83_REG_R_TEMP[] = {
+	LM83_REG_R_LOCAL_TEMP,
+	LM83_REG_R_REMOTE1_TEMP,
+	LM83_REG_R_REMOTE2_TEMP,
+	LM83_REG_R_REMOTE3_TEMP
+};
+
+static const u8 LM83_REG_R_HIGH[] = {
+	LM83_REG_R_LOCAL_HIGH,
+	LM83_REG_R_REMOTE1_HIGH,
+	LM83_REG_R_REMOTE2_HIGH,
+	LM83_REG_R_REMOTE3_HIGH
+};
+
+static const u8 LM83_REG_W_HIGH[] = {
+	LM83_REG_W_LOCAL_HIGH,
+	LM83_REG_W_REMOTE1_HIGH,
+	LM83_REG_W_REMOTE2_HIGH,
+	LM83_REG_W_REMOTE3_HIGH
+};
+
+/*
+ * Functions declaration
+ */
+
+static int lm83_attach_adapter(struct i2c_adapter *adapter);
+static int lm83_detect(struct i2c_adapter *adapter, int address,
+    int kind);
+static void lm83_init_client(struct i2c_client *client);
+static int lm83_detach_client(struct i2c_client *client);
+static void lm83_update_client(struct i2c_client *client);
+
+/*
+ * Driver data (common to all clients)
+ */
+ 
+static struct i2c_driver lm83_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "lm83",
+	.id		= I2C_DRIVERID_LM83,
+	.flags		= I2C_DF_NOTIFY,
+	.attach_adapter	= lm83_attach_adapter,
+	.detach_client	= lm83_detach_client,
+};
+
+/*
+ * Client data (each client gets its own)
+ */
+
+struct lm83_data
+{
+	struct semaphore update_lock;
+	char valid; /* zero until following fields are valid */
+	unsigned long last_updated; /* in jiffies */
+
+	/* registers values */
+	u8 temp_input[4];
+	u8 temp_high[4];
+	u8 temp_crit;
+	u16 alarms; /* bitvector, combined */
+};
+
+/*
+ * Internal variables
+ */
+
+static int lm83_id = 0;
+
+/*
+ * Sysfs stuff
+ */
+
+#define show_temp(suffix, value) \
+static ssize_t show_temp_##suffix(struct device *dev, char *buf) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct lm83_data *data = i2c_get_clientdata(client); \
+	lm83_update_client(client); \
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \
+}
+show_temp(input1, temp_input[0]);
+show_temp(input2, temp_input[1]);
+show_temp(input3, temp_input[2]);
+show_temp(input4, temp_input[3]);
+show_temp(high1, temp_high[0]);
+show_temp(high2, temp_high[1]);
+show_temp(high3, temp_high[2]);
+show_temp(high4, temp_high[3]);
+show_temp(crit, temp_crit);
+
+#define set_temp(suffix, value, reg) \
+static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct lm83_data *data = i2c_get_clientdata(client); \
+	data->value = TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \
+	i2c_smbus_write_byte_data(client, reg, data->value); \
+	return count; \
+}
+set_temp(high1, temp_high[0], LM83_REG_W_LOCAL_HIGH);
+set_temp(high2, temp_high[1], LM83_REG_W_REMOTE1_HIGH);
+set_temp(high3, temp_high[2], LM83_REG_W_REMOTE2_HIGH);
+set_temp(high4, temp_high[3], LM83_REG_W_REMOTE3_HIGH);
+set_temp(crit, temp_crit, LM83_REG_W_TCRIT);
+
+static ssize_t show_alarms(struct device *dev, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm83_data *data = i2c_get_clientdata(client);
+	lm83_update_client(client);
+	return sprintf(buf, "%d\n", data->alarms);
+}
+
+static DEVICE_ATTR(temp_input1, S_IRUGO, show_temp_input1, NULL);
+static DEVICE_ATTR(temp_input2, S_IRUGO, show_temp_input2, NULL);
+static DEVICE_ATTR(temp_input3, S_IRUGO, show_temp_input3, NULL);
+static DEVICE_ATTR(temp_input4, S_IRUGO, show_temp_input4, NULL);
+static DEVICE_ATTR(temp_max1, S_IWUSR | S_IRUGO, show_temp_high1,
+    set_temp_high1);
+static DEVICE_ATTR(temp_max2, S_IWUSR | S_IRUGO, show_temp_high2,
+    set_temp_high2);
+static DEVICE_ATTR(temp_max3, S_IWUSR | S_IRUGO, show_temp_high3,
+    set_temp_high3);
+static DEVICE_ATTR(temp_max4, S_IWUSR | S_IRUGO, show_temp_high4,
+    set_temp_high4);
+static DEVICE_ATTR(temp_crit, S_IWUSR | S_IRUGO, show_temp_crit,
+    set_temp_crit);
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
+
+/*
+ * Real code
+ */
+
+static int lm83_attach_adapter(struct i2c_adapter *adapter)
+{
+	if (!(adapter->class & I2C_ADAP_CLASS_SMBUS))
+		return 0;
+	return i2c_detect(adapter, &addr_data, lm83_detect);
+}
+
+/*
+ * The following function does more than just detection. If detection
+ * succeeds, it also registers the new chip.
+ */
+static int lm83_detect(struct i2c_adapter *adapter, int address,
+    int kind)
+{
+	struct i2c_client *new_client;
+	struct lm83_data *data;
+	int err = 0;
+	const char *name = "";
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+		goto exit;
+
+	if (!(new_client = kmalloc(sizeof(struct i2c_client) +
+	    sizeof(struct lm83_data), GFP_KERNEL))) {
+		err = -ENOMEM;
+		goto exit;
+	}
+	memset(new_client, 0x00, sizeof(struct i2c_client) +
+	    sizeof(struct lm83_data));
+
+	/* The LM83-specific data is placed right after the common I2C
+	 * client data. */
+	data = (struct lm83_data *) (new_client + 1);
+	i2c_set_clientdata(new_client, data);
+	new_client->addr = address;
+	new_client->adapter = adapter;
+	new_client->driver = &lm83_driver;
+	new_client->flags = 0;
+
+	/* Now we do the detection and identification. A negative kind
+	 * means that the driver was loaded with no force parameter
+	 * (default), so we must both detect and identify the chip
+	 * (actually there is only one possible kind of chip for now, LM83).
+	 * A zero kind means that the driver was loaded with the force
+	 * parameter, the detection step shall be skipped. A positive kind
+	 * means that the driver was loaded with the force parameter and a
+	 * given kind of chip is requested, so both the detection and the
+	 * identification steps are skipped. */
+	if (kind < 0) { /* detection */
+		if (((i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS1)
+		    & 0xA8) != 0x00) ||
+		    ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS2)
+		    & 0x48) != 0x00) ||
+		    ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_CONFIG)
+		    & 0x41) != 0x00)) {
+			dev_dbg(&client->dev,
+			    "LM83 detection failed at 0x%02x.\n", address);
+			goto exit_free;
+		}
+	}
+
+	if (kind <= 0) { /* identification */
+		u8 man_id, chip_id;
+
+		man_id = i2c_smbus_read_byte_data(new_client,
+		    LM83_REG_R_MAN_ID);
+		chip_id = i2c_smbus_read_byte_data(new_client,
+		    LM83_REG_R_CHIP_ID);
+		if (man_id == 0x01) { /* National Semiconductor */
+			if (chip_id == 0x03) {
+				kind = lm83;
+				name = "lm83";
+			}
+		}
+
+		if (kind <= 0) { /* identification failed */
+			dev_info(&adapter->dev,
+			    "Unsupported chip (man_id=0x%02X, "
+			    "chip_id=0x%02X).\n", man_id, chip_id);
+			goto exit_free;
+		}
+	}
+
+	/* We can fill in the remaining client fields */
+	strlcpy(new_client->name, name, I2C_NAME_SIZE);
+	new_client->id = lm83_id++;
+	data->valid = 0;
+	init_MUTEX(&data->update_lock);
+
+	/* Tell the I2C layer a new client has arrived */
+	if ((err = i2c_attach_client(new_client)))
+		goto exit_free;
+
+	/* Initialize the LM83 chip */
+	lm83_init_client(new_client);
+
+	/* Register sysfs hooks */
+	device_create_file(&new_client->dev, &dev_attr_temp_input1);
+	device_create_file(&new_client->dev, &dev_attr_temp_input2);
+	device_create_file(&new_client->dev, &dev_attr_temp_input3);
+	device_create_file(&new_client->dev, &dev_attr_temp_input4);
+	device_create_file(&new_client->dev, &dev_attr_temp_max1);
+	device_create_file(&new_client->dev, &dev_attr_temp_max2);
+	device_create_file(&new_client->dev, &dev_attr_temp_max3);
+	device_create_file(&new_client->dev, &dev_attr_temp_max4);
+	device_create_file(&new_client->dev, &dev_attr_temp_crit);
+	device_create_file(&new_client->dev, &dev_attr_alarms);
+
+	return 0;
+
+exit_free:
+	kfree(new_client);
+exit:
+	return err;
+}
+
+static void lm83_init_client(struct i2c_client *client)
+{
+	int nr;
+
+	for (nr = 0; nr < 4; nr++)
+		i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr],
+	            TEMP_TO_REG(LM83_INIT_HIGH));
+	i2c_smbus_write_byte_data(client, LM83_REG_W_TCRIT,
+	    TEMP_TO_REG(LM83_INIT_CRIT));
+}
+
+static int lm83_detach_client(struct i2c_client *client)
+{
+	int err;
+
+	if ((err = i2c_detach_client(client))) {
+		dev_err(&client->dev,
+		    "Client deregistration failed, client not detached.\n");
+		return err;
+	}
+
+	kfree(client);
+	return 0;
+}
+
+static void lm83_update_client(struct i2c_client *client)
+{
+	struct lm83_data *data = i2c_get_clientdata(client);
+
+	down(&data->update_lock);
+
+	if ((jiffies - data->last_updated > HZ * 2) ||
+	    (jiffies < data->last_updated) ||
+	    !data->valid) {
+		int nr;
+		dev_dbg(&client->dev, "Updating lm83 data.\n");
+		for (nr = 0; nr < 4 ; nr++) {
+			data->temp_input[nr] =
+			    i2c_smbus_read_byte_data(client,
+			    LM83_REG_R_TEMP[nr]);
+			data->temp_high[nr] =
+			    i2c_smbus_read_byte_data(client,
+			    LM83_REG_R_HIGH[nr]);
+		}
+		data->temp_crit =
+		    i2c_smbus_read_byte_data(client, LM83_REG_R_TCRIT);
+		data->alarms =
+		    i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1)
+		    + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2)
+		    << 8);
+		data->last_updated = jiffies;
+		data->valid = 1;
+	}
+
+	up(&data->update_lock);
+}
+
+static int __init sensors_lm83_init(void)
+{
+	return i2c_add_driver(&lm83_driver);
+}
+
+static void __exit sensors_lm83_exit(void)
+{
+	i2c_del_driver(&lm83_driver);
+}
+
+MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
+MODULE_DESCRIPTION("LM83 driver");
+MODULE_LICENSE("GPL");
+
+module_init(sensors_lm83_init);
+module_exit(sensors_lm83_exit);
diff -Nru a/include/linux/i2c-id.h b/include/linux/i2c-id.h
--- a/include/linux/i2c-id.h	Tue Dec 30 12:33:21 2003
+++ b/include/linux/i2c-id.h	Tue Dec 30 12:33:21 2003
@@ -153,6 +153,7 @@
 #define I2C_DRIVERID_FS451 1037
 #define I2C_DRIVERID_W83627HF 1038
 #define I2C_DRIVERID_LM85 1039
+#define I2C_DRIVERID_LM83 1040
 
 /*
  * ---- Adapter types ----------------------------------------------------


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06       ` Greg KH
@ 2003-12-30 22:06         ` Greg KH
  2003-12-30 22:06           ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.6.2, 2003/12/04 00:43:55-08:00, khali@linux-fr.org

[PATCH] I2C: i2c documentation (1 of 2)

This is the document I wrote (and you reviewed) about porting client
drivers to Linux 2.6. The retained name is "porting-clients" (in line
with writing-clients). I won't commit it to i2c/lm_sensors2 CVS, since
that document is of no use outside of the 2.6 kernel (and I'm bored
keeping files in sync).


 Documentation/i2c/porting-clients |  121 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 121 insertions(+)


diff -Nru a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/Documentation/i2c/porting-clients	Tue Dec 30 12:32:57 2003
@@ -0,0 +1,121 @@
+Revision 3, 2003-10-04
+Jean Delvare <khali@linux-fr.org>
+Greg KH <greg@kroah.com>
+
+This is a guide on how to convert I2C chip drivers from Linux 2.4 to
+Linux 2.6. I have been using existing drivers (lm75, lm78) as examples.
+Then I converted a driver myself (lm83) and updated this document.
+
+There are two sets of points below. The first set concerns technical
+changes. The second set concerns coding policy. Both are mandatory.
+
+Although reading this guide will help you porting drivers, I suggest
+you keep an eye on an already ported driver while porting your own
+driver. This will help you a lot understanding what this guide
+exactly means. Choose the chip driver that is the more similar to
+yours for best results.
+
+Technical changes:
+
+* [Includes] Get rid of "version.h". Replace <linux/i2c-proc.h> with
+  <linux/i2c-sensor.h>. Includes typically look like that:
+  #include <linux/module.h>
+  #include <linux/init.h>
+  #include <linux/slab.h>
+  #include <linux/i2c.h>
+  #include <linux/i2c-sensor.h>
+  #include <linux/i2c-vid.h>     /* if you need VRM support */
+  #include <asm/io.h>            /* if you have I/O operations */
+  Some extra headers may be required for a given driver.
+
+* [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, SENSORS_ISA_END
+  becomes I2C_CLIENT_ISA_END.
+
+* [Client data] Get rid of sysctl_id. Try using standard names for
+  register values (for example, temp_os becomes temp_max). You're
+  still relatively free here, but you *have* to follow the standard
+  names for sysfs files (see the Sysctl section below).
+
+* [Function prototypes] The detect functions loses its flags
+  parameter. Sysctl (e.g. lm75_temp) and miscellaneous (e.g.
+  swap_bytes) functions are off the list of prototypes. This
+  usually leaves five prototypes:
+  static int lm75_attach_adapter(struct i2c_adapter *adapter);
+  static int lm75_detect(struct i2c_adapter *adapter, int address,
+      int kind);
+  static void lm75_init_client(struct i2c_client *client);
+  static int lm75_detach_client(struct i2c_client *client);
+  static void lm75_update_client(struct i2c_client *client);
+
+* [Sysctl] All sysctl stuff is of course gone (defines, ctl_table
+  and functions). Instead, right after the static id definition
+  line, you have to define show and set functions for each sysfs
+  file. Only define set for writable values. Take a look at an
+  existing 2.6 driver for details (lm78 for example). Don't forget
+  to define the attributes for each file (this is that step that
+  links callback functions). Use the file names specified in
+  Documentation/i2c/sysfs-interface for the individual files. Also
+  convert the units these files read and write to the specified ones.
+  If you need to add a new type of file, please discuss it on the
+  sensors mailing list <sensors@stimpy.netroedge.com> by providing a
+  patch to the Documentation/i2c/sysfs-interface file.
+
+* [Attach] For I2C drivers, the attach function should make sure
+  that the adapter's class has I2C_ADAP_CLASS_SMBUS, using the
+  following construct:
+  if (!(adapter->class & I2C_ADAP_CLASS_SMBUS))
+          return 0;
+  ISA-only drivers of course don't need this.
+
+* [Detect] As mentioned earlier, the flags parameter is gone.
+  The type_name and client_name strings are replaced by a single
+  name string, which will be filled with a lowercase, short string
+  (typically the driver name, e.g. "lm75"). The errorN labels are
+  reduced to the number needed. If that number is 2 (i2c-only
+  drivers), it is advised that the labels are named exit and
+  exit_free. For i2c+isa drivers, labels should be named ERROR0,
+  ERROR1 and ERROR2. Don't forget to properly set err before
+  jumping to error labels. By the way, labels should be
+  left-aligned.
+  Use memset to fill the client and data area with 0x00.
+  Use i2c_set_clientdata to set the client data (as opposed to
+  a direct access to client->data).
+  Use strlcpy instead of strcpy to copy the client name.
+  Replace the sysctl directory registration by calls to
+  device_create_file. Move the driver initialization before any
+  sysfs file creation.
+
+* [Detach] Get rid of data, remove the call to
+  i2c_deregister_entry.
+
+* [Update] Don't access client->data directly, use
+  i2c_get_clientdata(client) instead.
+
+* [Interface] Init function should not print anything. Make sure
+  there is a MODULE_LICENSE() line.
+
+Coding policy:
+
+* [Copyright] Use (C), not (c), for copyright.
+
+* [Debug/log] Get rid of #ifdef DEBUG/#endif constructs whenever you
+  can. Calls to printk/pr_debug for debugging purposes are replaced
+  by calls to dev_dbg. Here is an example on how to call it (taken
+  from lm75_detect):
+  dev_dbg(&adapter->dev,
+          "lm75_detect called for an ISA bus adapter?!?\n");
+  Replace other printk calls with the dev_info, dev_err or dev_warn
+  function, as appropriate.
+
+* [Constants] Constants defines (registers, conversions, initial
+  values) should be aligned. This greatly improves readability.
+  Same goes for variables declarations. Alignments are achieved by the
+  means of tabs, not spaces. Remember that tabs are set to 8 in the
+  Linux kernel code.
+
+* [Structure definition] The name field should be standardized. All
+  lowercase and as simple as the driver name itself (e.g. "lm75").
+
+* [Layout] Avoid extra empty lines between comments and what they
+  comment. Respect the coding style (see Documentation/CodingStyle),
+  in particular when it comes to placing curly braces.


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06     ` Greg KH
@ 2003-12-30 22:06       ` Greg KH
  2003-12-30 22:06         ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.23.2, 2003/12/19 11:37:00-08:00, trini@kernel.crashing.org

[PATCH] I2C: make i2c-piix4 fix optional

On Thu, Dec 18, 2003 at 10:26:40AM -0800, Greg KH wrote:


 drivers/i2c/busses/i2c-piix4.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)


diff -Nru a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
--- a/drivers/i2c/busses/i2c-piix4.c	Tue Dec 30 12:29:37 2003
+++ b/drivers/i2c/busses/i2c-piix4.c	Tue Dec 30 12:29:37 2003
@@ -99,6 +99,13 @@
 		 "Forcibly enable the PIIX4 at the given address. "
 		 "EXTREMELY DANGEROUS!");
 
+/* If fix_hstcfg is set to anything different from 0, we reset one of the
+   registers to be a valid value. */
+static int fix_hstcfg = 0;
+MODULE_PARM(fix_hstcfg, "i");
+MODULE_PARM_DESC(fix_hstcfg,
+		"Fix config register. Needed on some boards (Force CPCI735).");
+
 static int piix4_transaction(void);
 
 
@@ -164,9 +171,17 @@
 	/* Some BIOS will set up the chipset incorrectly and leave a register
 	   in an undefined state (causing I2C to act very strangely). */
 	if (temp & 0x02) {
-		dev_info(&PIIX4_dev->dev, "Worked around buggy BIOS (I2C)\n");
-		temp = temp & 0xfd;
-		pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp);
+		if (fix_hstcfg) {
+			dev_info(&PIIX4_dev->dev, "Working around buggy BIOS "
+					"(I2C)\n");
+			temp &= 0xfd;
+			pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp);
+		} else {
+			dev_info(&PIIX4_dev->dev, "Unusual config register "
+					"value\n");
+			dev_info(&PIIX4_dev->dev, "Try using fix_hstcfg=1 if "
+					"you experience problems\n");
+		}
 	}
  
 	/* If force_addr is set, we program the new address here. Just to make


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06 ` [PATCH] " Greg KH
@ 2003-12-30 22:06   ` Greg KH
  2003-12-30 22:06     ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.20.1, 2003/12/17 15:44:31-08:00, khali@linux-fr.org

[PATCH] I2C: fix i2c-amd8111 driver.

This patch fixes i2c_smbus_write_byte() being broken for i2c-amd8111.
This causes trouble when that module is used together with eeprom (which
is also in 2.6). We have had no report so far, but the problem is
similar to the one addressed by a recent patch to i2c-nforce2.

Credits go to Hans-Frieder Vogt for finding and fixing the problem. Mark
D. Studebaker found and fixed the original problem in i2c-nforce2.

This is a serious bug fix, and I believe you shouldn't wait too long
before applying it.


 drivers/i2c/busses/i2c-amd8111.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


diff -Nru a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
--- a/drivers/i2c/busses/i2c-amd8111.c	Tue Dec 30 12:31:03 2003
+++ b/drivers/i2c/busses/i2c-amd8111.c	Tue Dec 30 12:31:03 2003
@@ -192,7 +192,7 @@
 
 		case I2C_SMBUS_BYTE:
 			if (read_write == I2C_SMBUS_WRITE)
-				amd_ec_write(smbus, AMD_SMB_DATA, data->byte);
+				amd_ec_write(smbus, AMD_SMB_CMD, command);
 			protocol |= AMD_SMB_PRTCL_BYTE;
 			break;
 


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06   ` Greg KH
@ 2003-12-30 22:06     ` Greg KH
  2003-12-30 22:06       ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.20.2, 2003/12/19 10:47:09-08:00, mds@paradyne.com

[PATCH] I2C: fix amd756 byte writes

This fixes byte writes (used by the eeprom driver) in the i2c-amd756
driver.  It is similar to recent fixes for the i2c-amd8111 and
i2c-nforce2 drivers.

Tested by me.


 drivers/i2c/busses/i2c-amd756.c |    3 +--
 1 files changed, 1 insertion(+), 2 deletions(-)


diff -Nru a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
--- a/drivers/i2c/busses/i2c-amd756.c	Tue Dec 30 12:29:49 2003
+++ b/drivers/i2c/busses/i2c-amd756.c	Tue Dec 30 12:29:49 2003
@@ -213,9 +213,8 @@
 	case I2C_SMBUS_BYTE:
 		outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
 		       SMB_HOST_ADDRESS);
-		/* TODO: Why only during write? */
 		if (read_write == I2C_SMBUS_WRITE)
-			outb_p(command, SMB_HOST_COMMAND);
+			outb_p(command, SMB_HOST_DATA);
 		size = AMD756_BYTE;
 		break;
 	case I2C_SMBUS_BYTE_DATA:


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06             ` Greg KH
@ 2003-12-30 22:06               ` Greg KH
  2003-12-30 22:06                 ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.8.31, 2003/12/17 16:04:10-08:00, mhoffman@lightlink.com

[PATCH] I2C: improve chip detection in w83781d.c driver

This patch improves chip detection.  It was forward ported from the
lm_sensors project CVS, from these revisions:

	1.104 (Khali) Enhance chip detection (stricter).
	1.108 (Khali) Fix W83627HF detection.


 drivers/i2c/chips/w83781d.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)


diff -Nru a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c
--- a/drivers/i2c/chips/w83781d.c	Tue Dec 30 12:30:38 2003
+++ b/drivers/i2c/chips/w83781d.c	Tue Dec 30 12:30:38 2003
@@ -24,10 +24,11 @@
     Supports following chips:
 
     Chip	#vin	#fanin	#pwm	#temp	wchipid	vendid	i2c	ISA
-    as99127f	7	3	1?	3	0x30	0x12c3	yes	no
-    asb100 "bach" (type_name = as99127f)	0x30	0x0694	yes	no
-    w83781d	7	3	0	3	0x10	0x5ca3	yes	yes
-    w83627hf	9	3	2	3	0x20	0x5ca3	yes	yes(LPC)
+    as99127f	7	3	1?	3	0x31	0x12c3	yes	no
+    as99127f rev.2 (type_name = 1299127f)	0x31	0x5ca3	yes	no
+    asb100 "bach" (type_name = as99127f)	0x31	0x0694	yes	no
+    w83781d	7	3	0	3	0x10-1	0x5ca3	yes	yes
+    w83627hf	9	3	2	3	0x21	0x5ca3	yes	yes(LPC)
     w83627thf	9	3	2	3	0x90	0x5ca3	no	yes(LPC)
     w83782d	9	3	2-4	3	0x30	0x5ca3	yes	yes
     w83783s	5-6	3	2	1-2	0x40	0x5ca3	yes	no
@@ -1264,7 +1265,7 @@
 			goto ERROR2;
 		}
 		/* If Winbond SMBus, check address at 0x48.
-		   Asus doesn't support */
+		   Asus doesn't support, except for as99127f rev.2 */
 		if ((!is_isa) && (((!(val1 & 0x80)) && (val2 == 0xa3)) ||
 				  ((val1 & 0x80) && (val2 == 0x5c)))) {
 			if (w83781d_read_value
@@ -1295,18 +1296,17 @@
 			goto ERROR2;
 		}
 
-		/* mask off lower bit, not reliable */
-		val1 =
-		    w83781d_read_value(new_client, W83781D_REG_WCHIPID) & 0xfe;
-		if (val1 == 0x10 && vendid == winbond)
+		val1 = w83781d_read_value(new_client, W83781D_REG_WCHIPID);
+		if ((val1 == 0x10 || val1 == 0x11) && vendid == winbond)
 			kind = w83781d;
 		else if (val1 == 0x30 && vendid == winbond)
 			kind = w83782d;
-		else if (val1 == 0x40 && vendid == winbond && !is_isa)
+		else if (val1 == 0x40 && vendid == winbond && !is_isa
+				&& address == 0x2d)
 			kind = w83783s;
-		else if ((val1 == 0x20 || val1 == 0x90) && vendid == winbond)
+		else if ((val1 == 0x21 || val1 == 0x90) && vendid == winbond)
 			kind = w83627hf;
-		else if (val1 == 0x30 && vendid == asus && !is_isa)
+		else if (val1 == 0x31 && !is_isa && address >= 0x28)
 			kind = as99127f;
 		else if (val1 == 0x60 && vendid == winbond && is_isa)
 			kind = w83697hf;


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06           ` Greg KH
@ 2003-12-30 22:06             ` Greg KH
  2003-12-30 22:06               ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.8.30, 2003/12/17 15:52:23-08:00, khali@linux-fr.org

[PATCH] I2C: restore support for AMD8111 in i2c-amd756 driver

This patch restores support for the AMD8111 in the i2c-amd756 driver.

Credits go to Philip Pokorny for the original patch. I tweaked it a bit.

This isn't a bug fix and can be delayed until after 2.6.0 if you want.


 drivers/i2c/busses/i2c-amd756.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)


diff -Nru a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
--- a/drivers/i2c/busses/i2c-amd756.c	Tue Dec 30 12:30:50 2003
+++ b/drivers/i2c/busses/i2c-amd756.c	Tue Dec 30 12:30:50 2003
@@ -28,10 +28,12 @@
     2002-04-08: Added nForce support. (Csaba Halasz)
     2002-10-03: Fixed nForce PnP I/O port. (Michael Steil)
     2002-12-28: Rewritten into something that resembles a Linux driver (hch)
+    2003-11-29: Added back AMD8111 removed by the previous rewrite.
+                (Philip Pokorny)
 */
 
 /*
-   Supports AMD756, AMD766, AMD768 and nVidia nForce
+   Supports AMD756, AMD766, AMD768, AMD8111 and nVidia nForce
    Note: we assume there can only be one device, with one SMBus interface.
 */
 
@@ -308,12 +310,13 @@
 	.name		= "unset",
 };
 
-enum chiptype { AMD756, AMD766, AMD768, NFORCE };
+enum chiptype { AMD756, AMD766, AMD768, NFORCE, AMD8111 };
 
 static struct pci_device_id amd756_ids[] = {
 	{PCI_VENDOR_ID_AMD, 0x740B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD756 },
 	{PCI_VENDOR_ID_AMD, 0x7413, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD766 },
 	{PCI_VENDOR_ID_AMD, 0x7443, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD768 },
+	{PCI_VENDOR_ID_AMD, 0x746B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD8111 },
 	{PCI_VENDOR_ID_NVIDIA, 0x01B4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE },
 	{ 0, }
 };
@@ -321,7 +324,8 @@
 static int __devinit amd756_probe(struct pci_dev *pdev,
 				  const struct pci_device_id *id)
 {
-	int nforce = (id->driver_data == NFORCE), error;
+	int nforce = (id->driver_data == NFORCE);
+	int error;
 	u8 temp;
 	
 	if (amd756_ioport) {
@@ -368,7 +372,7 @@
 	amd756_adapter.dev.parent = &pdev->dev;
 
 	snprintf(amd756_adapter.name, I2C_NAME_SIZE,
-		"SMBus AMD75x adapter at %04x", amd756_ioport);
+		"SMBus AMD756 adapter at %04x", amd756_ioport);
 
 	error = i2c_add_adapter(&amd756_adapter);
 	if (error) {
@@ -391,7 +395,7 @@
 }
 
 static struct pci_driver amd756_driver = {
-	.name		= "amd75x smbus",
+	.name		= "amd756 smbus",
 	.id_table	= amd756_ids,
 	.probe		= amd756_probe,
 	.remove		= __devexit_p(amd756_remove),
@@ -408,7 +412,7 @@
 }
 
 MODULE_AUTHOR("Merlin Hughes <merlin@merlin.org>");
-MODULE_DESCRIPTION("AMD756/766/768/nVidia nForce SMBus driver");
+MODULE_DESCRIPTION("AMD756/766/768/8111 and nVidia nForce SMBus driver");
 MODULE_LICENSE("GPL");
 
 module_init(amd756_init)


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06         ` Greg KH
@ 2003-12-30 22:06           ` Greg KH
  2003-12-30 22:06             ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.6.3, 2003/12/04 00:44:29-08:00, khali@linux-fr.org

[PATCH] I2C: i2c documentation (2 of 2)

This is a patch to writing-clients. The current version in Linux 2.6
still mentions the old module reference counting mechanism. The patch
brings it to the same version we have in i2c CVS, where that section has
been updated.


 Documentation/i2c/writing-clients |   57 ++++++--------------------------------
 1 files changed, 10 insertions(+), 47 deletions(-)


diff -Nru a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
--- a/Documentation/i2c/writing-clients	Tue Dec 30 12:32:43 2003
+++ b/Documentation/i2c/writing-clients	Tue Dec 30 12:32:43 2003
@@ -24,16 +24,14 @@
 routines, a client structure specific information like the actual I2C
 address.
 
-  struct i2c_driver foo_driver
-  {  
-    /* name           */  "Foo version 2.3 and later driver",
-    /* id             */  I2C_DRIVERID_FOO,
-    /* flags          */  I2C_DF_NOTIFY,
-    /* attach_adapter */  &foo_attach_adapter,
-    /* detach_client  */  &foo_detach_client,
-    /* command        */  &foo_command,   /* May be NULL */
-    /* inc_use        */  &foo_inc_use,   /* May be NULL */
-    /* dec_use        */  &foo_dec_use    /* May be NULL */
+  static struct i2c_driver foo_driver = {
+    .owner          = THIS_MODULE,
+    .name           = "Foo version 2.3 driver",
+    .id             = I2C_DRIVERID_FOO, /* usually from i2c-id.h */
+    .flags          = I2C_DF_NOTIFY,
+    .attach_adapter = &foo_attach_adapter,
+    .detach_client  = &foo_detach_client,
+    .command        = &foo_command /* may be NULL */
   }
  
 The name can be chosen freely, and may be upto 40 characters long. Please
@@ -50,43 +48,8 @@
 All other fields are for call-back functions which will be explained 
 below.
 
-
-Module usage count
-==================
-
-If your driver can also be compiled as a module, there are moments at 
-which the module can not be removed from memory. For example, when you
-are doing a lengthy transaction, or when you create a /proc directory,
-and some process has entered that directory (this last case is the
-main reason why these call-backs were introduced).
-
-To increase or decrease the module usage count, you can use the
-MOD_{INC,DEC}_USE_COUNT macros. They must be called from the module
-which needs to get its usage count changed; that is why each driver
-module has to implement its own callback.
-
-  void foo_inc_use (struct i2c_client *client)
-  {
-  #ifdef MODULE
-    MOD_INC_USE_COUNT;
-  #endif
-  }
-
-  void foo_dec_use (struct i2c_client *client)
-  {
-  #ifdef MODULE
-    MOD_DEC_USE_COUNT;
-  #endif
-  }
-
-Do not call these call-back functions directly; instead, use one of the
-following functions defined in i2c.h:
-  void i2c_inc_use_client(struct i2c_client *);
-  void i2c_dec_use_client(struct i2c_client *);
-
-You should *not* increase the module count just because a device is
-detected and a client created. This would make it impossible to remove
-an adapter driver! 
+There use to be two additional fields in this structure, inc_use et dec_use,
+for module usage count, but these fields were obsoleted and removed.
 
 
 Extra client data


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06               ` Greg KH
@ 2003-12-30 22:06                 ` Greg KH
  2003-12-30 22:06                   ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.8.32, 2003/12/17 16:04:29-08:00, mhoffman@lightlink.com

[PATCH] I2C: remove initialization of limits by w83781d driver

This patch is from the lm_sensors project CVS, from this revision:

	1.111 (mds) remove initialization of limits by driver

It is better to set these limits by a combination of /etc/sensors.conf
and 'sensors -s'; "mechanism not policy." And what's not to like about
a patch that removes 163 lines?


 drivers/i2c/chips/w83781d.c |  173 --------------------------------------------
 1 files changed, 173 deletions(-)


diff -Nru a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c
--- a/drivers/i2c/chips/w83781d.c	Tue Dec 30 12:30:26 2003
+++ b/drivers/i2c/chips/w83781d.c	Tue Dec 30 12:30:26 2003
@@ -208,72 +208,6 @@
 	return ((u8) i);
 }
 
-/* Initial limits */
-#define W83781D_INIT_IN_0		(vid == 3500 ? 280 : vid / 10)
-#define W83781D_INIT_IN_1		(vid == 3500 ? 280 : vid / 10)
-#define W83781D_INIT_IN_2		330
-#define W83781D_INIT_IN_3		(((500)   * 100) / 168)
-#define W83781D_INIT_IN_4		(((1200)  * 10) / 38)
-#define W83781D_INIT_IN_5		(((-1200) * -604) / 2100)
-#define W83781D_INIT_IN_6		(((-500)  * -604) / 909)
-#define W83781D_INIT_IN_7		(((500)   * 100) / 168)
-#define W83781D_INIT_IN_8		300
-/* Initial limits for 782d/783s negative voltages */
-/* Note level shift. Change min/max below if you change these. */
-#define W83782D_INIT_IN_5		((((-1200) + 1491) * 100)/514)
-#define W83782D_INIT_IN_6		((( (-500)  + 771) * 100)/314)
-
-#define W83781D_INIT_IN_PERCENTAGE	10
-#define W83781D_INIT_IN_MIN(val)	(val - val * W83781D_INIT_IN_PERCENTAGE / 100)
-#define W83781D_INIT_IN_MAX(val)	(val + val * W83781D_INIT_IN_PERCENTAGE / 100)
-
-#define W83781D_INIT_IN_MIN_0		W83781D_INIT_IN_MIN(W83781D_INIT_IN_0)
-#define W83781D_INIT_IN_MAX_0		W83781D_INIT_IN_MAX(W83781D_INIT_IN_0)
-#define W83781D_INIT_IN_MIN_1		W83781D_INIT_IN_MIN(W83781D_INIT_IN_1)
-#define W83781D_INIT_IN_MAX_1		W83781D_INIT_IN_MAX(W83781D_INIT_IN_1)
-#define W83781D_INIT_IN_MIN_2		W83781D_INIT_IN_MIN(W83781D_INIT_IN_2)
-#define W83781D_INIT_IN_MAX_2		W83781D_INIT_IN_MAX(W83781D_INIT_IN_2)
-#define W83781D_INIT_IN_MIN_3		W83781D_INIT_IN_MIN(W83781D_INIT_IN_3)
-#define W83781D_INIT_IN_MAX_3		W83781D_INIT_IN_MAX(W83781D_INIT_IN_3)
-#define W83781D_INIT_IN_MIN_4		W83781D_INIT_IN_MIN(W83781D_INIT_IN_4)
-#define W83781D_INIT_IN_MAX_4		W83781D_INIT_IN_MAX(W83781D_INIT_IN_4)
-#define W83781D_INIT_IN_MIN_5		W83781D_INIT_IN_MIN(W83781D_INIT_IN_5)
-#define W83781D_INIT_IN_MAX_5		W83781D_INIT_IN_MAX(W83781D_INIT_IN_5)
-#define W83781D_INIT_IN_MIN_6		W83781D_INIT_IN_MIN(W83781D_INIT_IN_6)
-#define W83781D_INIT_IN_MAX_6		W83781D_INIT_IN_MAX(W83781D_INIT_IN_6)
-#define W83781D_INIT_IN_MIN_7		W83781D_INIT_IN_MIN(W83781D_INIT_IN_7)
-#define W83781D_INIT_IN_MAX_7		W83781D_INIT_IN_MAX(W83781D_INIT_IN_7)
-#define W83781D_INIT_IN_MIN_8		W83781D_INIT_IN_MIN(W83781D_INIT_IN_8)
-#define W83781D_INIT_IN_MAX_8		W83781D_INIT_IN_MAX(W83781D_INIT_IN_8)
-
-/* Initial limits for 782d/783s negative voltages */
-/* These aren't direct multiples because of level shift */
-/* Beware going negative - check */
-#define W83782D_INIT_IN_MIN_5_TMP \
-	(((-1200 * (100 + W83781D_INIT_IN_PERCENTAGE)) + (1491 * 100))/514)
-#define W83782D_INIT_IN_MIN_5 \
-	((W83782D_INIT_IN_MIN_5_TMP > 0) ? W83782D_INIT_IN_MIN_5_TMP : 0)
-#define W83782D_INIT_IN_MAX_5 \
-	(((-1200 * (100 - W83781D_INIT_IN_PERCENTAGE)) + (1491 * 100))/514)
-#define W83782D_INIT_IN_MIN_6_TMP \
-	((( -500 * (100 + W83781D_INIT_IN_PERCENTAGE)) +  (771 * 100))/314)
-#define W83782D_INIT_IN_MIN_6 \
-	((W83782D_INIT_IN_MIN_6_TMP > 0) ? W83782D_INIT_IN_MIN_6_TMP : 0)
-#define W83782D_INIT_IN_MAX_6 \
-	((( -500 * (100 - W83781D_INIT_IN_PERCENTAGE)) +  (771 * 100))/314)
-
-#define W83781D_INIT_FAN_MIN_1		3000
-#define W83781D_INIT_FAN_MIN_2		3000
-#define W83781D_INIT_FAN_MIN_3		3000
-
-/* temp = value / 100 */
-#define W83781D_INIT_TEMP_OVER		6000
-#define W83781D_INIT_TEMP_HYST		12700	/* must be 127 for ALARM to work */
-#define W83781D_INIT_TEMP2_OVER		6000
-#define W83781D_INIT_TEMP2_HYST		5000
-#define W83781D_INIT_TEMP3_OVER		6000
-#define W83781D_INIT_TEMP3_HYST		5000
-
 /* There are some complications in a module like this. First off, W83781D chips
    may be both present on the SMBus and the ISA bus, and we have to handle
    those cases separately at some places. Second, there might be several
@@ -1688,113 +1622,6 @@
 #endif				/* W83781D_RT */
 
 	if (init) {
-		w83781d_write_value(client, W83781D_REG_IN_MIN(0),
-				    IN_TO_REG(W83781D_INIT_IN_MIN_0));
-		w83781d_write_value(client, W83781D_REG_IN_MAX(0),
-				    IN_TO_REG(W83781D_INIT_IN_MAX_0));
-		if (type != w83783s && type != w83697hf) {
-			w83781d_write_value(client, W83781D_REG_IN_MIN(1),
-					    IN_TO_REG(W83781D_INIT_IN_MIN_1));
-			w83781d_write_value(client, W83781D_REG_IN_MAX(1),
-					    IN_TO_REG(W83781D_INIT_IN_MAX_1));
-		}
-
-		w83781d_write_value(client, W83781D_REG_IN_MIN(2),
-				    IN_TO_REG(W83781D_INIT_IN_MIN_2));
-		w83781d_write_value(client, W83781D_REG_IN_MAX(2),
-				    IN_TO_REG(W83781D_INIT_IN_MAX_2));
-		w83781d_write_value(client, W83781D_REG_IN_MIN(3),
-				    IN_TO_REG(W83781D_INIT_IN_MIN_3));
-		w83781d_write_value(client, W83781D_REG_IN_MAX(3),
-				    IN_TO_REG(W83781D_INIT_IN_MAX_3));
-		w83781d_write_value(client, W83781D_REG_IN_MIN(4),
-				    IN_TO_REG(W83781D_INIT_IN_MIN_4));
-		w83781d_write_value(client, W83781D_REG_IN_MAX(4),
-				    IN_TO_REG(W83781D_INIT_IN_MAX_4));
-		if (type == w83781d || type == as99127f) {
-			w83781d_write_value(client, W83781D_REG_IN_MIN(5),
-					    IN_TO_REG(W83781D_INIT_IN_MIN_5));
-			w83781d_write_value(client, W83781D_REG_IN_MAX(5),
-					    IN_TO_REG(W83781D_INIT_IN_MAX_5));
-		} else {
-			w83781d_write_value(client, W83781D_REG_IN_MIN(5),
-					    IN_TO_REG(W83782D_INIT_IN_MIN_5));
-			w83781d_write_value(client, W83781D_REG_IN_MAX(5),
-					    IN_TO_REG(W83782D_INIT_IN_MAX_5));
-		}
-		if (type == w83781d || type == as99127f) {
-			w83781d_write_value(client, W83781D_REG_IN_MIN(6),
-					    IN_TO_REG(W83781D_INIT_IN_MIN_6));
-			w83781d_write_value(client, W83781D_REG_IN_MAX(6),
-					    IN_TO_REG(W83781D_INIT_IN_MAX_6));
-		} else {
-			w83781d_write_value(client, W83781D_REG_IN_MIN(6),
-					    IN_TO_REG(W83782D_INIT_IN_MIN_6));
-			w83781d_write_value(client, W83781D_REG_IN_MAX(6),
-					    IN_TO_REG(W83782D_INIT_IN_MAX_6));
-		}
-		if ((type == w83782d) || (type == w83627hf) ||
-		    (type == w83697hf)) {
-			w83781d_write_value(client, W83781D_REG_IN_MIN(7),
-					    IN_TO_REG(W83781D_INIT_IN_MIN_7));
-			w83781d_write_value(client, W83781D_REG_IN_MAX(7),
-					    IN_TO_REG(W83781D_INIT_IN_MAX_7));
-			w83781d_write_value(client, W83781D_REG_IN_MIN(8),
-					    IN_TO_REG(W83781D_INIT_IN_MIN_8));
-			w83781d_write_value(client, W83781D_REG_IN_MAX(8),
-					    IN_TO_REG(W83781D_INIT_IN_MAX_8));
-			w83781d_write_value(client, W83781D_REG_VBAT,
-					    (w83781d_read_value
-					     (client,
-					      W83781D_REG_VBAT) | 0x01));
-		}
-		w83781d_write_value(client, W83781D_REG_FAN_MIN(1),
-				    FAN_TO_REG(W83781D_INIT_FAN_MIN_1, 2));
-		w83781d_write_value(client, W83781D_REG_FAN_MIN(2),
-				    FAN_TO_REG(W83781D_INIT_FAN_MIN_2, 2));
-		if (type != w83697hf) {
-			w83781d_write_value(client, W83781D_REG_FAN_MIN(3),
-					    FAN_TO_REG(W83781D_INIT_FAN_MIN_3,
-						       2));
-		}
-
-		w83781d_write_value(client, W83781D_REG_TEMP_OVER(1),
-				    TEMP_TO_REG(W83781D_INIT_TEMP_OVER));
-		w83781d_write_value(client, W83781D_REG_TEMP_HYST(1),
-				    TEMP_TO_REG(W83781D_INIT_TEMP_HYST));
-
-		if (type == as99127f) {
-			w83781d_write_value(client, W83781D_REG_TEMP_OVER(2),
-					    AS99127_TEMP_ADD_TO_REG
-					    (W83781D_INIT_TEMP2_OVER));
-			w83781d_write_value(client, W83781D_REG_TEMP_HYST(2),
-					    AS99127_TEMP_ADD_TO_REG
-					    (W83781D_INIT_TEMP2_HYST));
-		} else {
-			w83781d_write_value(client, W83781D_REG_TEMP_OVER(2),
-					    TEMP_ADD_TO_REG
-					    (W83781D_INIT_TEMP2_OVER));
-			w83781d_write_value(client, W83781D_REG_TEMP_HYST(2),
-					    TEMP_ADD_TO_REG
-					    (W83781D_INIT_TEMP2_HYST));
-		}
-		w83781d_write_value(client, W83781D_REG_TEMP2_CONFIG, 0x00);
-
-		if (type == as99127f) {
-			w83781d_write_value(client, W83781D_REG_TEMP_OVER(3),
-					    AS99127_TEMP_ADD_TO_REG
-					    (W83781D_INIT_TEMP3_OVER));
-			w83781d_write_value(client, W83781D_REG_TEMP_HYST(3),
-					    AS99127_TEMP_ADD_TO_REG
-					    (W83781D_INIT_TEMP3_HYST));
-		} else if (type != w83783s && type != w83697hf) {
-			w83781d_write_value(client, W83781D_REG_TEMP_OVER(3),
-					    TEMP_ADD_TO_REG
-					    (W83781D_INIT_TEMP3_OVER));
-			w83781d_write_value(client, W83781D_REG_TEMP_HYST(3),
-					    TEMP_ADD_TO_REG
-					    (W83781D_INIT_TEMP3_HYST));
-		}
 		if (type != w83783s && type != w83697hf) {
 			w83781d_write_value(client, W83781D_REG_TEMP3_CONFIG,
 					    0x00);


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                   ` Greg KH
@ 2003-12-30 22:06                     ` Greg KH
  2003-12-30 22:06                       ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.8.34, 2003/12/17 16:06:50-08:00, mhoffman@lightlink.com

[PATCH] I2C: lm75 chip driver conversion routine fixes

This patch is based on the lm_sensors project CVS, from revisions 1.45 and 1.1
of lm75.c and lm75.h, respectively.

The patch fixes the conversion routines (according to datasheet) and moves
them into a header file - as these conversions can be used by several drivers
which emulate LM75s as subclients.  Also, temps are now reported in 1/1000 C
in sysfs as per documentation.


 drivers/i2c/chips/lm75.c |   28 ++++++++------------------
 drivers/i2c/chips/lm75.h |   49 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 19 deletions(-)


diff -Nru a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c
--- a/drivers/i2c/chips/lm75.c	Tue Dec 30 12:30:01 2003
+++ b/drivers/i2c/chips/lm75.c	Tue Dec 30 12:30:01 2003
@@ -25,6 +25,7 @@
 #include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/i2c-sensor.h>
+#include "lm75.h"
 
 
 /* Addresses to scan */
@@ -44,13 +45,6 @@
 #define LM75_REG_TEMP_HYST	0x02
 #define LM75_REG_TEMP_OS	0x03
 
-/* Conversions. Rounding and limit checking is only done on the TO_REG
-   variants. Note that you should be a bit careful with which arguments
-   these macros are called: arguments may be evaluated more than once.
-   Fixing this is just not worth it. */
-#define TEMP_FROM_REG(val)	((((val & 0x7fff) >> 7) * 5) | ((val & 0x8000)?-256:0))
-#define TEMP_TO_REG(val)	(SENSORS_LIMIT((val<0?(0x200+((val)/5))<<7:(((val) + 2) / 5) << 7),0,0xffff))
-
 /* Each client has this additional data */
 struct lm75_data {
 	struct semaphore	update_lock;
@@ -83,15 +77,12 @@
 static int lm75_id = 0;
 
 #define show(value)	\
-static ssize_t show_##value(struct device *dev, char *buf)	\
-{								\
-	struct i2c_client *client = to_i2c_client(dev);		\
-	struct lm75_data *data = i2c_get_clientdata(client);	\
-	int temp;						\
-								\
-	lm75_update_client(client);				\
-	temp = TEMP_FROM_REG(data->value);			\
-	return sprintf(buf, "%d\n", temp * 100);		\
+static ssize_t show_##value(struct device *dev, char *buf)		\
+{									\
+	struct i2c_client *client = to_i2c_client(dev);			\
+	struct lm75_data *data = i2c_get_clientdata(client);		\
+	lm75_update_client(client);					\
+	return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->value));	\
 }
 show(temp_max);
 show(temp_hyst);
@@ -102,9 +93,8 @@
 {								\
 	struct i2c_client *client = to_i2c_client(dev);		\
 	struct lm75_data *data = i2c_get_clientdata(client);	\
-	int temp = simple_strtoul(buf, NULL, 10) / 100;		\
-								\
-	data->value = TEMP_TO_REG(temp);			\
+	int temp = simple_strtoul(buf, NULL, 10);		\
+	data->value = LM75_TEMP_TO_REG(temp);			\
 	lm75_write_value(client, reg, data->value);		\
 	return count;						\
 }
diff -Nru a/drivers/i2c/chips/lm75.h b/drivers/i2c/chips/lm75.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/i2c/chips/lm75.h	Tue Dec 30 12:30:01 2003
@@ -0,0 +1,49 @@
+/*
+    lm75.h - Part of lm_sensors, Linux kernel modules for hardware
+             monitoring
+    Copyright (c) 2003 Mark M. Hoffman <mhoffman@lightlink.com>
+
+    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.
+*/
+
+/*
+    This file contains common code for encoding/decoding LM75 type
+    temperature readings, which are emulated by many of the chips
+    we support.  As the user is unlikely to load more than one driver
+    which contains this code, we don't worry about the wasted space.
+*/
+
+#include <linux/i2c-sensor.h>
+
+/* straight from the datasheet */
+#define LM75_TEMP_MIN (-55000)
+#define LM75_TEMP_MAX 125000
+
+/* TEMP: 0.001C/bit (-55C to +125C)
+   REG: (0.5C/bit, two's complement) << 7 */
+static inline u16 LM75_TEMP_TO_REG(int temp)
+{
+	int ntemp = SENSORS_LIMIT(temp, LM75_TEMP_MIN, LM75_TEMP_MAX);
+	ntemp += (ntemp<0 ? -250 : 250);
+	return (u16)((ntemp / 500) << 7);
+}
+
+static inline int LM75_TEMP_FROM_REG(u16 reg)
+{
+	/* use integer division instead of equivalent right shift to
+	   guarantee arithmetic shift and preserve the sign */
+	return ((s16)reg / 128) * 500;
+}
+


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                 ` Greg KH
@ 2003-12-30 22:06                   ` Greg KH
  2003-12-30 22:06                     ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.8.33, 2003/12/17 16:06:23-08:00, mhoffman@lightlink.com

[PATCH] I2C: remove initialization of limits by lm75 driver

This patch is from the lm_sensors project CVS, from this revision:

	1.44 (mds) remove initialization of limits by driver

It is better to set these limits by a combination of /etc/sensors.conf
and 'sensors -s'; "mechanism not policy."


 drivers/i2c/chips/lm75.c |    8 --------
 1 files changed, 8 deletions(-)


diff -Nru a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c
--- a/drivers/i2c/chips/lm75.c	Tue Dec 30 12:30:13 2003
+++ b/drivers/i2c/chips/lm75.c	Tue Dec 30 12:30:13 2003
@@ -51,10 +51,6 @@
 #define TEMP_FROM_REG(val)	((((val & 0x7fff) >> 7) * 5) | ((val & 0x8000)?-256:0))
 #define TEMP_TO_REG(val)	(SENSORS_LIMIT((val<0?(0x200+((val)/5))<<7:(((val) + 2) / 5) << 7),0,0xffff))
 
-/* Initial values */
-#define LM75_INIT_TEMP_OS	600
-#define LM75_INIT_TEMP_HYST	500
-
 /* Each client has this additional data */
 struct lm75_data {
 	struct semaphore	update_lock;
@@ -258,10 +254,6 @@
 static void lm75_init_client(struct i2c_client *client)
 {
 	/* Initialize the LM75 chip */
-	lm75_write_value(client, LM75_REG_TEMP_OS,
-			 TEMP_TO_REG(LM75_INIT_TEMP_OS));
-	lm75_write_value(client, LM75_REG_TEMP_HYST,
-			 TEMP_TO_REG(LM75_INIT_TEMP_HYST));
 	lm75_write_value(client, LM75_REG_CONF, 0);
 }
 


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                     ` Greg KH
@ 2003-12-30 22:06                       ` Greg KH
  2003-12-30 22:06                         ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.8.35, 2003/12/19 11:49:32-08:00, greg@kroah.com

[PATCH] I2C: removed #include <linux/i2c.h> from sa1100_stork.c as it's not needed.

Thanks to Jean Delvare <khali@linux-fr.org> for pointing it out.


 drivers/pcmcia/sa1100_stork.c |    1 -
 1 files changed, 1 deletion(-)


diff -Nru a/drivers/pcmcia/sa1100_stork.c b/drivers/pcmcia/sa1100_stork.c
--- a/drivers/pcmcia/sa1100_stork.c	Tue Dec 30 12:29:25 2003
+++ b/drivers/pcmcia/sa1100_stork.c	Tue Dec 30 12:29:25 2003
@@ -23,7 +23,6 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/device.h>
-#include <linux/i2c.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                       ` Greg KH
@ 2003-12-30 22:06                         ` Greg KH
  2003-12-30 22:06                           ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.8.37, 2003/12/30 12:09:49-08:00, khali@linux-fr.org

[PATCH] I2C: remove bus scan logic from i2c chip drivers

This patch drops bus scan from i2c-algo-ite and i2c-ibm_iic. It also
removes the incomplete and broken SLO_IO stuff from i2c-algo-ite.


 drivers/i2c/algos/i2c-algo-ite.c |   36 ------------------------------------
 drivers/i2c/busses/i2c-ibm_iic.c |   34 ----------------------------------
 2 files changed, 70 deletions(-)


diff -Nru a/drivers/i2c/algos/i2c-algo-ite.c b/drivers/i2c/algos/i2c-algo-ite.c
--- a/drivers/i2c/algos/i2c-algo-ite.c	Tue Dec 30 12:28:59 2003
+++ b/drivers/i2c/algos/i2c-algo-ite.c	Tue Dec 30 12:28:59 2003
@@ -60,27 +60,13 @@
  	/* debug the protocol by showing transferred bits */
 #define DEF_TIMEOUT 16
 
-/* debugging - slow down transfer to have a look at the data .. 	*/
-/* I use this with two leds&resistors, each one connected to sda,scl 	*/
-/* respectively. This makes sure that the algorithm works. Some chips   */
-/* might not like this, as they have an internal timeout of some mils	*/
-/*
-#define SLO_IO      jif=jiffies;while(jiffies<=jif+i2c_table[minor].veryslow)\
-                        cond_resched();
-*/
-
 
 /* ----- global variables ---------------------------------------------	*/
 
-#ifdef SLO_IO
-	int jif;
-#endif
-
 /* module parameters:
  */
 static int i2c_debug=1;
 static int iic_test=0;	/* see if the line-setting functions work	*/
-static int iic_scan=0;	/* have a look at what's hanging 'round		*/
 
 /* --- setting states on the bus with the right timing: ---------------	*/
 
@@ -757,8 +743,6 @@
  */
 int i2c_iic_add_bus(struct i2c_adapter *adap)
 {
-	int i;
-	short status;
 	struct i2c_algo_iic_data *iic_adap = adap->algo_data;
 
 	if (iic_test) {
@@ -782,24 +766,6 @@
 	i2c_add_adapter(adap);
 	iic_init(iic_adap);
 
-	/* scan bus */
-	/* By default scanning the bus is turned off. */
-	if (iic_scan) {
-		printk(KERN_INFO " i2c-algo-ite: scanning bus %s.\n",
-		       adap->name);
-		for (i = 0x00; i < 0xff; i+=2) {
-			iic_outw(iic_adap, ITE_I2CSAR, i);
-			iic_start(iic_adap);
-			if ( (wait_for_pin(iic_adap, &status) == 0) && 
-			    ((status & ITE_I2CHSR_DNE) == 0) ) { 
-				printk(KERN_INFO "\n(%02x)\n",i>>1); 
-			} else {
-				printk(KERN_INFO "."); 
-				iic_reset(iic_adap);
-			}
-			udelay(iic_adap->udelay);
-		}
-	}
 	return 0;
 }
 
@@ -839,11 +805,9 @@
 MODULE_LICENSE("GPL");
 
 MODULE_PARM(iic_test, "i");
-MODULE_PARM(iic_scan, "i");
 MODULE_PARM(i2c_debug,"i");
 
 MODULE_PARM_DESC(iic_test, "Test if the I2C bus is available");
-MODULE_PARM_DESC(iic_scan, "Scan for active chips on the bus");
 MODULE_PARM_DESC(i2c_debug,
         "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol");
 
diff -Nru a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
--- a/drivers/i2c/busses/i2c-ibm_iic.c	Tue Dec 30 12:28:59 2003
+++ b/drivers/i2c/busses/i2c-ibm_iic.c	Tue Dec 30 12:28:59 2003
@@ -48,10 +48,6 @@
 MODULE_DESCRIPTION("IBM IIC driver v" DRIVER_VERSION);
 MODULE_LICENSE("GPL");
 
-static int iic_scan = 0;
-MODULE_PARM(iic_scan, "i");
-MODULE_PARM_DESC(iic_scan, "Scan for active chips on the bus");
-
 static int iic_force_poll = 0;
 MODULE_PARM(iic_force_poll, "i");
 MODULE_PARM_DESC(iic_force_poll, "Force polling mode");
@@ -518,32 +514,6 @@
 };
 
 /*
- * Scan bus for valid 7-bit addresses (ie things that ACK on 1 byte read)
- * We only scan range [0x08 - 0x77], all other addresses are reserved anyway
- */
-static void __devinit iic_scan_bus(struct ibm_iic_private* dev)
-{
-	int found = 0;
-	char dummy;
-	struct i2c_msg msg = {
-		.buf   = &dummy,
-		.len   = sizeof(dummy),
-		.flags = I2C_M_RD
-	};
-	
-	printk(KERN_INFO "ibm-iic%d: scanning bus...\n" KERN_INFO, dev->idx);
-	
-	for (msg.addr = 8; msg.addr < 0x78; ++msg.addr)
-		if (iic_xfer(&dev->adap, &msg, 1) == 1){
-			++found;
-			printk(" 0x%02x", msg.addr);
-		}
-
-	printk("%sibm-iic%d: %d device(s) detected\n", 
-		found ? "\n" KERN_INFO : "", dev->idx, found);
-}
-
-/*
  * Calculates IICx_CLCKDIV value for a specific OPB clock frequency
  */
 static inline u8 iic_clckdiv(unsigned int opb)
@@ -648,10 +618,6 @@
 	
 	printk(KERN_INFO "ibm-iic%d: using %s mode\n", dev->idx,
 		dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
-
-	/* Scan bus if requested by user */
-	if (iic_scan)
-		iic_scan_bus(dev);
 
 	return 0;
 


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                           ` Greg KH
@ 2003-12-30 22:06                             ` Greg KH
  2003-12-30 22:06                               ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.8.39, 2003/12/30 12:10:24-08:00, khali@linux-fr.org

[PATCH] I2C: velleman typo

This patch replaces "K9000" with "K8000" everywhere (5 occurences) since
it seems that the "K9000" was a typo in the first place. It also rewords
the i2c-velleman doc. I have fixed it in our CVS repository too, and
have been sending a similar patch to Marcelo for Linux 2.4.


 Documentation/i2c/i2c-velleman    |   16 ++++++----------
 Documentation/i2c/summary         |    2 +-
 drivers/i2c/busses/Kconfig        |    4 ++--
 drivers/i2c/busses/i2c-velleman.c |    2 +-
 4 files changed, 10 insertions(+), 14 deletions(-)


diff -Nru a/Documentation/i2c/i2c-velleman b/Documentation/i2c/i2c-velleman
--- a/Documentation/i2c/i2c-velleman	Tue Dec 30 12:28:12 2003
+++ b/Documentation/i2c/i2c-velleman	Tue Dec 30 12:28:12 2003
@@ -1,6 +1,6 @@
 i2c-velleman driver
 -------------------
-This is a driver for i2c-hw access for Velleman K9000 and other adapters.
+This is a driver for i2c-hw access for Velleman K8000 and other adapters.
 
 Useful links
 ------------
@@ -10,18 +10,14 @@
 Velleman K8000 Howto:
 	http://howto.htlw16.ac.at/k8000-howto.html
 
-
 K8000 and K8005 libraries
 -------------------------
-The project has lead to new libs for the Velleman K8000 and K8005..
+The project has lead to new libs for the Velleman K8000 and K8005:
 LIBK8000 v1.99.1 and LIBK8005 v0.21
 
-With these libs you can control the K8000 and K8005 with the original
-simple commands which are in the original Velleman software.
-Like SetIOchannel, ReadADchannel, SendStepCCWFull and many more.
-Via i2c kernel device /dev/velleman
+With these libs, you can control the K8000 interface card and the K8005
+stepper motor card with the simple commands which are in the original
+Velleman software, like SetIOchannel, ReadADchannel, SendStepCCWFull and
+many more, using /dev/velleman.
 
 The libs can be found on http://groups.yahoo.com/group/k8000/files/linux/
-
-The Velleman K8000 interface card on http://www.velleman.be/kits/k8000.htm
-The Velleman K8005 steppermotorcard on http://www.velleman.be/kits/k8005.htm
diff -Nru a/Documentation/i2c/summary b/Documentation/i2c/summary
--- a/Documentation/i2c/summary	Tue Dec 30 12:28:12 2003
+++ b/Documentation/i2c/summary	Tue Dec 30 12:28:12 2003
@@ -71,5 +71,5 @@
 i2c-adap-ibm_ocp: IBM 4xx processor I2C device (uses i2c-algo-ibm_ocp) (NOT BUILT BY DEFAULT)
 i2c-pport:       Primitive parallel port adapter (uses i2c-algo-bit)
 i2c-rpx:         RPX board Motorola 8xx I2C device (uses i2c-algo-8xx) (NOT BUILT BY DEFAULT)
-i2c-velleman:    Velleman K9000 parallel port adapter (uses i2c-algo-bit)
+i2c-velleman:    Velleman K8000 parallel port adapter (uses i2c-algo-bit)
 
diff -Nru a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
--- a/drivers/i2c/busses/Kconfig	Tue Dec 30 12:28:12 2003
+++ b/drivers/i2c/busses/Kconfig	Tue Dec 30 12:28:12 2003
@@ -276,10 +276,10 @@
 	  will be called i2c-sis96x.
 
 config I2C_VELLEMAN
-	tristate "Velleman K9000 adapter"
+	tristate "Velleman K8000 adapter"
 	depends on I2C_ALGOBIT && ISA
 	help
-	  This supports the Velleman K9000 parallel-port I2C adapter.  Say Y
+	  This supports the Velleman K8000 parallel-port I2C adapter.  Say Y
 	  if you own such an adapter.
 
 	  This support is also available as a module.  If so, the module 
diff -Nru a/drivers/i2c/busses/i2c-velleman.c b/drivers/i2c/busses/i2c-velleman.c
--- a/drivers/i2c/busses/i2c-velleman.c	Tue Dec 30 12:28:12 2003
+++ b/drivers/i2c/busses/i2c-velleman.c	Tue Dec 30 12:28:12 2003
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------------- */
-/* i2c-velleman.c i2c-hw access for Velleman K9000 adapters		     */
+/* i2c-velleman.c i2c-hw access for Velleman K8000 adapters		     */
 /* ------------------------------------------------------------------------- */
 /*   Copyright (C) 1995-96, 2000 Simon G. Vogl
 


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                         ` Greg KH
@ 2003-12-30 22:06                           ` Greg KH
  2003-12-30 22:06                             ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.8.38, 2003/12/30 12:10:08-08:00, khali@linux-fr.org

[PATCH] I2C: Fix SCx200 dependancies

The following patch fixes incorrect dependencies (as far as I can see)
for the SCx200 modules. A similar patch (with even more fixes) is also
needed for Linux 2.4, and will be part of my next wave to Marcelo. Note
that I don't have the necessary hardware to actually test anything, but
a quick look at the code doesn't leave much place for doubt IMHO.


 drivers/i2c/busses/Kconfig |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


diff -Nru a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
--- a/drivers/i2c/busses/Kconfig	Tue Dec 30 12:28:44 2003
+++ b/drivers/i2c/busses/Kconfig	Tue Dec 30 12:28:44 2003
@@ -202,7 +202,7 @@
 
 config SCx200_I2C
 	tristate "NatSemi SCx200 I2C using GPIO pins"
-	depends on SCx200 && I2C_ALGOBIT
+	depends on SCx200_GPIO && I2C_ALGOBIT
 	help
 	  Enable the use of two GPIO pins of a SCx200 processor as an I2C bus.
 
@@ -229,7 +229,7 @@
 
 config SCx200_ACB
 	tristate "NatSemi SCx200 ACCESS.bus"
-	depends on I2C_ALGOBIT!=n && I2C
+	depends on I2C
 	help
 	  Enable the use of the ACCESS.bus controllers of a SCx200 processor.
 


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                             ` Greg KH
@ 2003-12-30 22:06                               ` Greg KH
  2003-12-30 22:06                                 ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.8.40, 2003/12/30 12:10:39-08:00, khali@linux-fr.org

[PATCH] I2C: lm83 driver updates

Here is a patch for the lm83 driver, to be applied on top of your
pending patches stack. What it does:
* Remove limit initialisation by the driver. This is a backport from
  CVS.
* A few whitespace changes inspired by my recent porting of the lm90
  driver.


 drivers/i2c/chips/lm83.c |   37 ++++++++++++-------------------------
 1 files changed, 12 insertions(+), 25 deletions(-)


diff -Nru a/drivers/i2c/chips/lm83.c b/drivers/i2c/chips/lm83.c
--- a/drivers/i2c/chips/lm83.c	Tue Dec 30 12:27:57 2003
+++ b/drivers/i2c/chips/lm83.c	Tue Dec 30 12:27:57 2003
@@ -41,7 +41,7 @@
 
 static unsigned short normal_i2c[] = { I2C_CLIENT_END };
 static unsigned short normal_i2c_range[] = { 0x18, 0x1a, 0x29, 0x2b,
-    0x4c, 0x4e, I2C_CLIENT_END };
+	0x4c, 0x4e, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
@@ -78,16 +78,13 @@
 #define LM83_REG_W_TCRIT		0x5A
 
 /*
- * Conversions, initial values and various macros
+ * Conversions and various macros
  * The LM83 uses signed 8-bit values.
  */
 
 #define TEMP_FROM_REG(val)	((val > 127 ? val-256 : val) * 1000)
 #define TEMP_TO_REG(val)	((val < 0 ? val+256 : val) / 1000)
 
-#define LM83_INIT_HIGH		100
-#define LM83_INIT_CRIT		120
-
 static const u8 LM83_REG_R_TEMP[] = {
 	LM83_REG_R_LOCAL_TEMP,
 	LM83_REG_R_REMOTE1_TEMP,
@@ -114,9 +111,7 @@
  */
 
 static int lm83_attach_adapter(struct i2c_adapter *adapter);
-static int lm83_detect(struct i2c_adapter *adapter, int address,
-    int kind);
-static void lm83_init_client(struct i2c_client *client);
+static int lm83_detect(struct i2c_adapter *adapter, int address, int kind);
 static int lm83_detach_client(struct i2c_client *client);
 static void lm83_update_client(struct i2c_client *client);
 
@@ -137,8 +132,7 @@
  * Client data (each client gets its own)
  */
 
-struct lm83_data
-{
+struct lm83_data {
 	struct semaphore update_lock;
 	char valid; /* zero until following fields are valid */
 	unsigned long last_updated; /* in jiffies */
@@ -233,8 +227,7 @@
  * The following function does more than just detection. If detection
  * succeeds, it also registers the new chip.
  */
-static int lm83_detect(struct i2c_adapter *adapter, int address,
-    int kind)
+static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
 {
 	struct i2c_client *new_client;
 	struct lm83_data *data;
@@ -290,6 +283,7 @@
 		    LM83_REG_R_MAN_ID);
 		chip_id = i2c_smbus_read_byte_data(new_client,
 		    LM83_REG_R_CHIP_ID);
+
 		if (man_id == 0x01) { /* National Semiconductor */
 			if (chip_id == 0x03) {
 				kind = lm83;
@@ -315,8 +309,10 @@
 	if ((err = i2c_attach_client(new_client)))
 		goto exit_free;
 
-	/* Initialize the LM83 chip */
-	lm83_init_client(new_client);
+	/*
+	 * Initialize the LM83 chip
+	 * (Nothing to do for this one.)
+	 */
 
 	/* Register sysfs hooks */
 	device_create_file(&new_client->dev, &dev_attr_temp_input1);
@@ -338,17 +334,6 @@
 	return err;
 }
 
-static void lm83_init_client(struct i2c_client *client)
-{
-	int nr;
-
-	for (nr = 0; nr < 4; nr++)
-		i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr],
-	            TEMP_TO_REG(LM83_INIT_HIGH));
-	i2c_smbus_write_byte_data(client, LM83_REG_W_TCRIT,
-	    TEMP_TO_REG(LM83_INIT_CRIT));
-}
-
 static int lm83_detach_client(struct i2c_client *client)
 {
 	int err;
@@ -373,6 +358,7 @@
 	    (jiffies < data->last_updated) ||
 	    !data->valid) {
 		int nr;
+
 		dev_dbg(&client->dev, "Updating lm83 data.\n");
 		for (nr = 0; nr < 4 ; nr++) {
 			data->temp_input[nr] =
@@ -388,6 +374,7 @@
 		    i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1)
 		    + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2)
 		    << 8);
+
 		data->last_updated = jiffies;
 		data->valid = 1;
 	}


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                               ` Greg KH
@ 2003-12-30 22:06                                 ` Greg KH
  2003-12-30 22:06                                   ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.9.2, 2003/12/04 13:35:42-08:00, khali@linux-fr.org

[PATCH] I2C: Fix i2c-algo-bit for adapers that cannot read SCL back

Here follows a patch to i2c-algo-bit.c as found in linux-2.6.0-test9,
with two fixes for adapters that cannot read SCL back. Althouth real
adapters should be able to read SCL back, there are some that
cannot, for example the ADM1032 evaluation board I am using. Such
adapters where supposed to be already supported, but I found a probable
bug and improved support.

These changes were applied to our i2c CVS repository two weeks ago and
have been reviewed by Mark D. Studebaker.

List of changes:

* Fix sclhi() for adapters that do not have getscl().
* Enable bit_test for adapters that do not have getscl().
* Mostly rewrite test_bus(), cleaner and probably faster.


 drivers/i2c/algos/i2c-algo-bit.c |   96 ++++++++++++++++++++-------------------
 1 files changed, 50 insertions(+), 46 deletions(-)


diff -Nru a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
--- a/drivers/i2c/algos/i2c-algo-bit.c	Tue Dec 30 12:32:32 2003
+++ b/drivers/i2c/algos/i2c-algo-bit.c	Tue Dec 30 12:32:32 2003
@@ -18,10 +18,8 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.		     */
 /* ------------------------------------------------------------------------- */
 
-/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
-   Frodo Looijaard <frodol@dds.nl> */
-
-/* $Id: i2c-algo-bit.c,v 1.44 2003/01/21 08:08:16 kmalkki Exp $ */
+/* With some changes from Frodo Looijaard <frodol@dds.nl>, Kyösti Mälkki
+   <kmalkki@cc.hut.fi> and Jean Delvare <khali@linux-fr.org> */
 
 /* #define DEBUG 1 */
 
@@ -87,8 +85,10 @@
 	setscl(adap,1);
 
 	/* Not all adapters have scl sense line... */
-	if (adap->getscl == NULL )
+	if (adap->getscl == NULL ) {
+		udelay(adap->udelay);
 		return 0;
+	}
 
 	start=jiffies;
 	while (! getscl(adap) ) {	
@@ -222,68 +222,72 @@
  */
 static int test_bus(struct i2c_algo_bit_data *adap, char* name) {
 	int scl,sda;
+
+	if (adap->getscl==NULL)
+		printk(KERN_INFO "i2c-algo-bit.o: Testing SDA only, "
+			"SCL is not readable.\n");
+
 	sda=getsda(adap);
-	if (adap->getscl==NULL) {
-		printk(KERN_WARNING "i2c-algo-bit.o: Warning: Adapter can't read from clock line - skipping test.\n");
-		return 0;		
-	}
-	scl=getscl(adap);
-	printk(KERN_INFO "i2c-algo-bit.o: Adapter: %s scl: %d  sda: %d -- testing...\n",
-	       name,getscl(adap),getsda(adap));
+	scl=(adap->getscl==NULL?1:getscl(adap));
+	printk(KERN_DEBUG "i2c-algo-bit.o: (0) scl=%d, sda=%d\n",scl,sda);
 	if (!scl || !sda ) {
-		printk(KERN_INFO " i2c-algo-bit.o: %s seems to be busy.\n",name);
+		printk(KERN_WARNING "i2c-algo-bit.o: %s seems to be busy.\n", name);
 		goto bailout;
 	}
+
 	sdalo(adap);
-	printk(KERN_DEBUG "i2c-algo-bit.o:1 scl: %d  sda: %d \n",getscl(adap),
-	       getsda(adap));
-	if ( 0 != getsda(adap) ) {
-		printk(KERN_WARNING "i2c-algo-bit.o: %s SDA stuck high!\n",name);
-		sdahi(adap);
+	sda=getsda(adap);
+	scl=(adap->getscl==NULL?1:getscl(adap));
+	printk(KERN_DEBUG "i2c-algo-bit.o: (1) scl=%d, sda=%d\n",scl,sda);
+	if ( 0 != sda ) {
+		printk(KERN_WARNING "i2c-algo-bit.o: SDA stuck high!\n");
 		goto bailout;
 	}
-	if ( 0 == getscl(adap) ) {
-		printk(KERN_WARNING "i2c-algo-bit.o: %s SCL unexpected low while pulling SDA low!\n",
-			name);
+	if ( 0 == scl ) {
+		printk(KERN_WARNING "i2c-algo-bit.o: SCL unexpected low "
+			"while pulling SDA low!\n");
 		goto bailout;
 	}		
+
 	sdahi(adap);
-	printk(KERN_DEBUG "i2c-algo-bit.o:2 scl: %d  sda: %d \n",getscl(adap),
-	       getsda(adap));
-	if ( 0 == getsda(adap) ) {
-		printk(KERN_WARNING "i2c-algo-bit.o: %s SDA stuck low!\n",name);
-		sdahi(adap);
+	sda=getsda(adap);
+	scl=(adap->getscl==NULL?1:getscl(adap));
+	printk(KERN_DEBUG "i2c-algo-bit.o: (2) scl=%d, sda=%d\n",scl,sda);
+	if ( 0 == sda ) {
+		printk(KERN_WARNING "i2c-algo-bit.o: SDA stuck low!\n");
 		goto bailout;
 	}
-	if ( 0 == getscl(adap) ) {
-		printk(KERN_WARNING "i2c-algo-bit.o: %s SCL unexpected low while SDA high!\n",
-		       name);
-	goto bailout;
+	if ( 0 == scl ) {
+		printk(KERN_WARNING "i2c-algo-bit.o: SCL unexpected low "
+			"while pulling SDA high!\n");
+		goto bailout;
 	}
+
 	scllo(adap);
-	printk(KERN_DEBUG "i2c-algo-bit.o:3 scl: %d  sda: %d \n",getscl(adap),
-	       getsda(adap));
-	if ( 0 != getscl(adap) ) {
-		printk(KERN_WARNING "i2c-algo-bit.o: %s SCL stuck high!\n",name);
-		sclhi(adap);
+	sda=getsda(adap);
+	scl=(adap->getscl==NULL?0:getscl(adap));
+	printk(KERN_DEBUG "i2c-algo-bit.o: (3) scl=%d, sda=%d\n",scl,sda);
+	if ( 0 != scl ) {
+		printk(KERN_WARNING "i2c-algo-bit.o: SCL stuck high!\n");
 		goto bailout;
 	}
-	if ( 0 == getsda(adap) ) {
-		printk(KERN_WARNING "i2c-algo-bit.o: %s SDA unexpected low while pulling SCL low!\n",
-			name);
+	if ( 0 == sda ) {
+		printk(KERN_WARNING "i2c-algo-bit.o: SDA unexpected low "
+			"while pulling SCL low!\n");
 		goto bailout;
 	}
+	
 	sclhi(adap);
-	printk(KERN_DEBUG "i2c-algo-bit.o:4 scl: %d  sda: %d \n",getscl(adap),
-	       getsda(adap));
-	if ( 0 == getscl(adap) ) {
-		printk(KERN_WARNING "i2c-algo-bit.o: %s SCL stuck low!\n",name);
-		sclhi(adap);
+	sda=getsda(adap);
+	scl=(adap->getscl==NULL?1:getscl(adap));
+	printk(KERN_DEBUG "i2c-algo-bit.o: (4) scl=%d, sda=%d\n",scl,sda);
+	if ( 0 == scl ) {
+		printk(KERN_WARNING "i2c-algo-bit.o: SCL stuck low!\n");
 		goto bailout;
 	}
-	if ( 0 == getsda(adap) ) {
-		printk(KERN_WARNING "i2c-algo-bit.o: %s SDA unexpected low while SCL high!\n",
-			name);
+	if ( 0 == sda ) {
+		printk(KERN_WARNING "i2c-algo-bit.o: SDA unexpected low "
+			"while pulling SCL high!\n");
 		goto bailout;
 	}
 	printk(KERN_INFO "i2c-algo-bit.o: %s passed test.\n",name);


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                                 ` Greg KH
@ 2003-12-30 22:06                                   ` Greg KH
  2003-12-30 22:06                                     ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.9.3, 2003/12/04 13:41:40-08:00, khali@linux-fr.org

[PATCH] I2C: sysfs interface documentation

1* No more current hysteresis value. I don't think we ever saw a chip
   which monitors current, and if we ever do, I would be very, very
   surprised if it would have an hysteresis value.
2* Temperature input and max can have 4 values. [from the previous
   patch]
3* Split temperature min and hysteresis into two separate files.
4* New file temp_crit. [from previous patch]

The new file temp_crit is subject to change later as we decide more
precisely how we want to handle values that are common to more than one
temperature channels.


 Documentation/i2c/sysfs-interface |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)


diff -Nru a/Documentation/i2c/sysfs-interface b/Documentation/i2c/sysfs-interface
--- a/Documentation/i2c/sysfs-interface	Tue Dec 30 12:32:18 2003
+++ b/Documentation/i2c/sysfs-interface	Tue Dec 30 12:32:18 2003
@@ -68,9 +68,7 @@
 		Fixed point XXXXX, divide by 1000 to get Amps.
 		Read/Write.
 
-curr_min[1-n]	Current min or hysteresis value.
-		Preferably a hysteresis value, reported as a absolute
-		current, NOT a delta from the max value.
+curr_min[1-n]	Current min value.
 		Fixed point XXXXX, divide by 1000 to get Amps.
 		Read/Write.
 
@@ -144,25 +142,38 @@
 		Integers 1,2,3, or thermistor Beta value (3435)
 		Read/Write.
 
-temp_max[1-3]	Temperature max value.
+temp_max[1-4]	Temperature max value.
 		Fixed point value in form XXXXX and should be divided by
 		1000 to get degrees Celsius.
 		Read/Write value.
 
-temp_min[1-3]	Temperature min or hysteresis value.
+temp_min[1-3]	Temperature min value.
 		Fixed point value in form XXXXX and should be divided by
-		1000 to get degrees Celsius.  This is preferably a
-		hysteresis value, reported as a absolute temperature,
-		NOT a delta from the max value.
+		1000 to get degrees Celsius.
 		Read/Write value.
 
-temp_input[1-3] Temperature input value.
+temp_hyst[1-3]	Temperature hysteresis value.
+		Fixed point value in form XXXXX and should be divided by
+		1000 to get degrees Celsius.  Must be reported as an
+		absolute temperature, NOT a delta from the max value.
+		Read/Write value.
+
+temp_input[1-4] Temperature input value.
+		Fixed point value in form XXXXX and should be divided by
+		1000 to get degrees Celsius.
 		Read only value.
 
+temp_crit	Temperature critical value, typically greater than all
+		temp_max values.
+		Fixed point value in form XXXXX and should be divided by
+		1000 to get degrees Celsius.
+		Common to all temperature channels.
+		Read/Write value.
+
 		If there are multiple temperature sensors, temp_*1 is
 		generally the sensor inside the chip itself, generally
-		reported as "motherboard temperature".  temp_*2 and
-		temp_*3 are generally sensors external to the chip
+		reported as "motherboard temperature".  temp_*2 to
+		temp_*4 are generally sensors external to the chip
 		itself, for example the thermal diode inside the CPU or
 		a thermistor nearby.
 


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                                     ` Greg KH
@ 2003-12-30 22:06                                       ` Greg KH
  2003-12-30 22:06                                         ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.9.5, 2003/12/04 13:53:21-08:00, khali@linux-fr.org

[PATCH] I2C: fix author of i2c-savage4.c driver

This patch rehabilitates Alexander Wold as the author of the i2c-savage4
driver. For some reason, his name was not mentioned anywhere in the
first place.

The change was requested by Alexander Wold himself.


 drivers/i2c/busses/i2c-savage4.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)


diff -Nru a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c
--- a/drivers/i2c/busses/i2c-savage4.c	Tue Dec 30 12:31:52 2003
+++ b/drivers/i2c/busses/i2c-savage4.c	Tue Dec 30 12:31:52 2003
@@ -1,13 +1,11 @@
 /*
     i2c-savage4.c - Part of lm_sensors, Linux kernel modules for hardware
               monitoring
-    Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>,
-    Philip Edelbrock <phil@netroedge.com>,
-    Ralph Metzler <rjkm@thp.uni-koeln.de>, and
+    Copyright (C) 1998-2003  The LM Sensors Team
+    Alexander Wold <awold@bigfoot.com>
     Mark D. Studebaker <mdsxyz123@yahoo.com>
     
-    Based on code written by Ralph Metzler <rjkm@thp.uni-koeln.de> and
-    Simon Vogl
+    Based on i2c-voodoo3.c.
 
     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
@@ -195,9 +193,7 @@
 	pci_unregister_driver(&savage4_driver);
 }
 
-MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
-		"Philip Edelbrock <phil@netroedge.com>, "
-		"Ralph Metzler <rjkm@thp.uni-koeln.de>, "
+MODULE_AUTHOR("Alexander Wold <awold@bigfoot.com> "
 		"and Mark D. Studebaker <mdsxyz123@yahoo.com>");
 MODULE_DESCRIPTION("Savage4 I2C/SMBus driver");
 MODULE_LICENSE("GPL");


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                                   ` Greg KH
@ 2003-12-30 22:06                                     ` Greg KH
  2003-12-30 22:06                                       ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.9.4, 2003/12/04 13:43:05-08:00, khali@linux-fr.org

[PATCH] I2C: make I2C chipset drivers use temp_hyst[1-3]

Summary of the changes:
adm1021.c: No changes, that chipset uses a real min/max model.
eeeprom.c: No changes (obviously).
it87.c:    Remove buggy comments (obviously taken from via686a) about
           max and min temperature limits being over and hyst. This
           isn't the case for this driver (min/max model).
lm75.c:    Simple sysfs file name change (temp_min to temp_hyst).
lm78.c:    Simple sysfs file name change (temp_min to temp_hyst).
lm85.c:    No changes needed (min/max model).
via686a.c: Rename functions and macros from min/max to hyst/over, what
           it really is. Remove unnecessary comments. Rename sysfs
           files from temp_min[1-3] to temp_hyst[1-3].
w83781d.c: Rename variables from temp_min* to temp_hyst* (needed so
           that the macros keep working). Update macro calls
           accordingly. Fix writing temp to max and hyst being
           swapped.

Additional remarks:

The lm75 and lm78 having a single temperature channel, there is no
number appended to the file names. Shouldn't a "1" be appended in this
case? I think it would make it easier for the future library to catch
all the files.

I made sure the drivers would still compile after the changes, but did
not test them otherwise (no working 2.6.0 kernel here, and not all the
hardware anyway).


 drivers/i2c/chips/it87.c    |    2 --
 drivers/i2c/chips/lm75.c    |    4 ++--
 drivers/i2c/chips/lm78.c    |    4 ++--
 drivers/i2c/chips/via686a.c |   38 ++++++++++++++++++--------------------
 drivers/i2c/chips/w83781d.c |   24 ++++++++++++------------
 5 files changed, 34 insertions(+), 38 deletions(-)


diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
--- a/drivers/i2c/chips/it87.c	Tue Dec 30 12:32:05 2003
+++ b/drivers/i2c/chips/it87.c	Tue Dec 30 12:32:05 2003
@@ -343,7 +343,6 @@
 	it87_update_client(client);
 	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])*100 );
 }
-/* more like overshoot temperature */
 static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -351,7 +350,6 @@
 	it87_update_client(client);
 	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])*100);
 }
-/* more like hysteresis temperature */
 static ssize_t show_temp_min(struct device *dev, char *buf, int nr)
 {
 	struct i2c_client *client = to_i2c_client(dev);
diff -Nru a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c
--- a/drivers/i2c/chips/lm75.c	Tue Dec 30 12:32:05 2003
+++ b/drivers/i2c/chips/lm75.c	Tue Dec 30 12:32:05 2003
@@ -116,7 +116,7 @@
 set(temp_hyst, LM75_REG_TEMP_HYST);
 
 static DEVICE_ATTR(temp_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max);
-static DEVICE_ATTR(temp_min, S_IWUSR | S_IRUGO, show_temp_hyst, set_temp_hyst);
+static DEVICE_ATTR(temp_hyst, S_IWUSR | S_IRUGO, show_temp_hyst, set_temp_hyst);
 static DEVICE_ATTR(temp_input, S_IRUGO, show_temp_input, NULL);
 
 static int lm75_attach_adapter(struct i2c_adapter *adapter)
@@ -209,7 +209,7 @@
 	
 	/* Register sysfs hooks */
 	device_create_file(&new_client->dev, &dev_attr_temp_max);
-	device_create_file(&new_client->dev, &dev_attr_temp_min);
+	device_create_file(&new_client->dev, &dev_attr_temp_hyst);
 	device_create_file(&new_client->dev, &dev_attr_temp_input);
 
 	return 0;
diff -Nru a/drivers/i2c/chips/lm78.c b/drivers/i2c/chips/lm78.c
--- a/drivers/i2c/chips/lm78.c	Tue Dec 30 12:32:05 2003
+++ b/drivers/i2c/chips/lm78.c	Tue Dec 30 12:32:05 2003
@@ -367,7 +367,7 @@
 static DEVICE_ATTR(temp_input, S_IRUGO, show_temp, NULL)
 static DEVICE_ATTR(temp_max, S_IRUGO | S_IWUSR,
 		show_temp_over, set_temp_over)
-static DEVICE_ATTR(temp_min, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(temp_hyst, S_IRUGO | S_IWUSR,
 		show_temp_hyst, set_temp_hyst)
 
 /* 3 Fans */
@@ -674,8 +674,8 @@
 	device_create_file(&new_client->dev, &dev_attr_in_min6);
 	device_create_file(&new_client->dev, &dev_attr_in_max6);
 	device_create_file(&new_client->dev, &dev_attr_temp_input);
-	device_create_file(&new_client->dev, &dev_attr_temp_min);
 	device_create_file(&new_client->dev, &dev_attr_temp_max);
+	device_create_file(&new_client->dev, &dev_attr_temp_hyst);
 	device_create_file(&new_client->dev, &dev_attr_fan_input1);
 	device_create_file(&new_client->dev, &dev_attr_fan_min1);
 	device_create_file(&new_client->dev, &dev_attr_fan_div1);
diff -Nru a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c
--- a/drivers/i2c/chips/via686a.c	Tue Dec 30 12:32:05 2003
+++ b/drivers/i2c/chips/via686a.c	Tue Dec 30 12:32:05 2003
@@ -496,21 +496,19 @@
 	via686a_update_client(client);
 	return sprintf(buf, "%ld\n", TEMP_FROM_REG10(data->temp[nr])*100 );
 }
-/* more like overshoot temperature */
-static ssize_t show_temp_max(struct device *dev, char *buf, int nr) {
+static ssize_t show_temp_over(struct device *dev, char *buf, int nr) {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct via686a_data *data = i2c_get_clientdata(client);
 	via686a_update_client(client);
 	return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp_over[nr])*100);
 }
-/* more like hysteresis temperature */
-static ssize_t show_temp_min(struct device *dev, char *buf, int nr) {
+static ssize_t show_temp_hyst(struct device *dev, char *buf, int nr) {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct via686a_data *data = i2c_get_clientdata(client);
 	via686a_update_client(client);
 	return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp_hyst[nr])*100);
 }
-static ssize_t set_temp_max(struct device *dev, const char *buf, 
+static ssize_t set_temp_over(struct device *dev, const char *buf, 
 		size_t count, int nr) {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct via686a_data *data = i2c_get_clientdata(client);
@@ -519,7 +517,7 @@
 	via686a_write_value(client, VIA686A_REG_TEMP_OVER(nr), data->temp_over[nr]);
 	return count;
 }
-static ssize_t set_temp_min(struct device *dev, const char *buf, 
+static ssize_t set_temp_hyst(struct device *dev, const char *buf, 
 		size_t count, int nr) {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct via686a_data *data = i2c_get_clientdata(client);
@@ -534,30 +532,30 @@
 	return show_temp(dev, buf, 0x##offset - 1);			\
 }									\
 static ssize_t								\
-show_temp_##offset##_max (struct device *dev, char *buf)		\
+show_temp_##offset##_over (struct device *dev, char *buf)		\
 {									\
-	return show_temp_max(dev, buf, 0x##offset - 1);			\
+	return show_temp_over(dev, buf, 0x##offset - 1);			\
 }									\
 static ssize_t								\
-show_temp_##offset##_min (struct device *dev, char *buf)		\
+show_temp_##offset##_hyst (struct device *dev, char *buf)		\
 {									\
-	return show_temp_min(dev, buf, 0x##offset - 1);			\
+	return show_temp_hyst(dev, buf, 0x##offset - 1);			\
 }									\
-static ssize_t set_temp_##offset##_max (struct device *dev, 		\
+static ssize_t set_temp_##offset##_over (struct device *dev, 		\
 		const char *buf, size_t count) 				\
 {									\
-	return set_temp_max(dev, buf, count, 0x##offset - 1);		\
+	return set_temp_over(dev, buf, count, 0x##offset - 1);		\
 }									\
-static ssize_t set_temp_##offset##_min (struct device *dev, 		\
+static ssize_t set_temp_##offset##_hyst (struct device *dev, 		\
 		const char *buf, size_t count) 				\
 {									\
-	return set_temp_min(dev, buf, count, 0x##offset - 1);		\
+	return set_temp_hyst(dev, buf, count, 0x##offset - 1);		\
 }									\
 static DEVICE_ATTR(temp_input##offset, S_IRUGO, show_temp_##offset, NULL) \
 static DEVICE_ATTR(temp_max##offset, S_IRUGO | S_IWUSR, 		\
-		show_temp_##offset##_max, set_temp_##offset##_max) 	\
-static DEVICE_ATTR(temp_min##offset, S_IRUGO | S_IWUSR, 		\
-		show_temp_##offset##_min, set_temp_##offset##_min)	
+		show_temp_##offset##_over, set_temp_##offset##_over) 	\
+static DEVICE_ATTR(temp_hyst##offset, S_IRUGO | S_IWUSR, 		\
+		show_temp_##offset##_hyst, set_temp_##offset##_hyst)	
 
 show_temp_offset(1);
 show_temp_offset(2);
@@ -760,9 +758,9 @@
 	device_create_file(&new_client->dev, &dev_attr_temp_max1);
 	device_create_file(&new_client->dev, &dev_attr_temp_max2);
 	device_create_file(&new_client->dev, &dev_attr_temp_max3);
-	device_create_file(&new_client->dev, &dev_attr_temp_min1);
-	device_create_file(&new_client->dev, &dev_attr_temp_min2);
-	device_create_file(&new_client->dev, &dev_attr_temp_min3);
+	device_create_file(&new_client->dev, &dev_attr_temp_hyst1);
+	device_create_file(&new_client->dev, &dev_attr_temp_hyst2);
+	device_create_file(&new_client->dev, &dev_attr_temp_hyst3);
 	device_create_file(&new_client->dev, &dev_attr_fan_input1);
 	device_create_file(&new_client->dev, &dev_attr_fan_input2);
 	device_create_file(&new_client->dev, &dev_attr_fan_min1);
diff -Nru a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c
--- a/drivers/i2c/chips/w83781d.c	Tue Dec 30 12:32:05 2003
+++ b/drivers/i2c/chips/w83781d.c	Tue Dec 30 12:32:05 2003
@@ -309,11 +309,11 @@
 	u8 fan[3];		/* Register value */
 	u8 fan_min[3];		/* Register value */
 	u8 temp;
-	u8 temp_min;		/* Register value */
 	u8 temp_max;		/* Register value */
+	u8 temp_hyst;		/* Register value */
 	u16 temp_add[2];	/* Register value */
 	u16 temp_max_add[2];	/* Register value */
-	u16 temp_min_add[2];	/* Register value */
+	u16 temp_hyst_add[2];	/* Register value */
 	u8 fan_div[3];		/* Register encoding, shifted right */
 	u8 vid;			/* Register encoding, combined */
 	u32 alarms;		/* Register encoding, combined */
@@ -510,8 +510,8 @@
 	} \
 }
 show_temp_reg(temp);
-show_temp_reg(temp_min);
 show_temp_reg(temp_max);
+show_temp_reg(temp_hyst);
 
 #define store_temp_reg(REG, reg) \
 static ssize_t store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \
@@ -538,8 +538,8 @@
 	 \
 	return count; \
 }
-store_temp_reg(OVER, min);
-store_temp_reg(HYST, max);
+store_temp_reg(OVER, max);
+store_temp_reg(HYST, hyst);
 
 #define sysfs_temp_offset(offset) \
 static ssize_t \
@@ -562,8 +562,8 @@
 
 #define sysfs_temp_offsets(offset) \
 sysfs_temp_offset(offset); \
-sysfs_temp_reg_offset(min, offset); \
-sysfs_temp_reg_offset(max, offset);
+sysfs_temp_reg_offset(max, offset); \
+sysfs_temp_reg_offset(hyst, offset);
 
 sysfs_temp_offsets(1);
 sysfs_temp_offsets(2);
@@ -573,7 +573,7 @@
 do { \
 device_create_file(&client->dev, &dev_attr_temp_input##offset); \
 device_create_file(&client->dev, &dev_attr_temp_max##offset); \
-device_create_file(&client->dev, &dev_attr_temp_min##offset); \
+device_create_file(&client->dev, &dev_attr_temp_hyst##offset); \
 } while (0)
 
 static ssize_t
@@ -1865,15 +1865,15 @@
 		}
 
 		data->temp = w83781d_read_value(client, W83781D_REG_TEMP(1));
-		data->temp_min =
-		    w83781d_read_value(client, W83781D_REG_TEMP_OVER(1));
 		data->temp_max =
+		    w83781d_read_value(client, W83781D_REG_TEMP_OVER(1));
+		data->temp_hyst =
 		    w83781d_read_value(client, W83781D_REG_TEMP_HYST(1));
 		data->temp_add[0] =
 		    w83781d_read_value(client, W83781D_REG_TEMP(2));
 		data->temp_max_add[0] =
 		    w83781d_read_value(client, W83781D_REG_TEMP_OVER(2));
-		data->temp_min_add[0] =
+		data->temp_hyst_add[0] =
 		    w83781d_read_value(client, W83781D_REG_TEMP_HYST(2));
 		if (data->type != w83783s && data->type != w83697hf) {
 			data->temp_add[1] =
@@ -1881,7 +1881,7 @@
 			data->temp_max_add[1] =
 			    w83781d_read_value(client,
 					       W83781D_REG_TEMP_OVER(3));
-			data->temp_min_add[1] =
+			data->temp_hyst_add[1] =
 			    w83781d_read_value(client,
 					       W83781D_REG_TEMP_HYST(3));
 		}


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                                         ` Greg KH
@ 2003-12-30 22:06                                           ` Greg KH
  2003-12-30 22:06                                             ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.9.7, 2003/12/04 13:53:58-08:00, khali@linux-fr.org

[PATCH] I2C: add KT600 support to i2c-viapro driver

This patch adds support for the KT600 to the i2c-viapro driver. It was
confirmed to work by Lou, lm-sensors at fixit dot nospammail dot net in
this post:
http://archives.andrew.net.au/lm-sensors/msg05299.html


 drivers/i2c/busses/Kconfig      |    1 +
 drivers/i2c/busses/i2c-viapro.c |    8 ++++++++
 2 files changed, 9 insertions(+)


diff -Nru a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
--- a/drivers/i2c/busses/Kconfig	Tue Dec 30 12:31:28 2003
+++ b/drivers/i2c/busses/Kconfig	Tue Dec 30 12:31:28 2003
@@ -310,6 +310,7 @@
 	  8233
 	  8233A
 	  8235
+	  8237
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-viapro.
diff -Nru a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
--- a/drivers/i2c/busses/i2c-viapro.c	Tue Dec 30 12:31:28 2003
+++ b/drivers/i2c/busses/i2c-viapro.c	Tue Dec 30 12:31:28 2003
@@ -29,6 +29,7 @@
 	8233
 	8233A (0x3147 and 0x3177)
 	8235
+	8237
    Note: we assume there can only be one device, with one SMBus interface.
 */
 
@@ -430,6 +431,13 @@
 	{
 		.vendor		= PCI_VENDOR_ID_VIA,
 		.device 	= PCI_DEVICE_ID_VIA_8235,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= SMBBA3
+	},
+	{
+		.vendor		= PCI_VENDOR_ID_VIA,
+		.device 	= PCI_DEVICE_ID_VIA_8237,
 		.subvendor	= PCI_ANY_ID,
 		.subdevice	= PCI_ANY_ID,
 		.driver_data	= SMBBA3


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                                       ` Greg KH
@ 2003-12-30 22:06                                         ` Greg KH
  2003-12-30 22:06                                           ` Greg KH
  0 siblings, 1 reply; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.9.6, 2003/12/04 13:53:39-08:00, khali@linux-fr.org

[PATCH] I2C: add Serverworks CSB6 support to i2c-piix4

This patch adds support for the Serverworks CSB6 to i2c-piix4 driver. It
was confirmed to work by lasirona at yahoo dot com in support ticket
#1424:
http://secure.netroedge.com/~lm78/readticket.cgi?ticket=1424


 drivers/i2c/busses/Kconfig     |    3 ++-
 drivers/i2c/busses/i2c-piix4.c |    9 ++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)


diff -Nru a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
--- a/drivers/i2c/busses/Kconfig	Tue Dec 30 12:31:40 2003
+++ b/drivers/i2c/busses/Kconfig	Tue Dec 30 12:31:40 2003
@@ -161,11 +161,12 @@
 	help
 	  If you say yes to this option, support will be included for the Intel
 	  PIIX4 family of mainboard I2C interfaces.  Specifically, the following
-	  versions of the chipset is supported:
+	  versions of the chipset are supported:
 	    Intel PIIX4
 	    Intel 440MX
 	    Serverworks OSB4
 	    Serverworks CSB5
+	    Serverworks CSB6
 	    SMSC Victory66
 
 	  This driver can also be built as a module.  If so, the module
diff -Nru a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
--- a/drivers/i2c/busses/i2c-piix4.c	Tue Dec 30 12:31:40 2003
+++ b/drivers/i2c/busses/i2c-piix4.c	Tue Dec 30 12:31:40 2003
@@ -22,7 +22,7 @@
 /*
    Supports:
 	Intel PIIX4, 440MX
-	Serverworks OSB4, CSB5
+	Serverworks OSB4, CSB5, CSB6
 	SMSC Victory66
 
    Note: we assume there can only be one device, with one SMBus interface.
@@ -418,6 +418,13 @@
 	{
 		.vendor =	PCI_VENDOR_ID_SERVERWORKS,
 		.device =	PCI_DEVICE_ID_SERVERWORKS_CSB5,
+		.subvendor =	PCI_ANY_ID,
+		.subdevice =	PCI_ANY_ID,
+		.driver_data =	0,
+	},
+	{
+		.vendor =	PCI_VENDOR_ID_SERVERWORKS,
+		.device =	PCI_DEVICE_ID_SERVERWORKS_CSB6,
 		.subvendor =	PCI_ANY_ID,
 		.subdevice =	PCI_ANY_ID,
 		.driver_data =	0,


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] i2c driver fixes for 2.6.0
  2003-12-30 22:06                                           ` Greg KH
@ 2003-12-30 22:06                                             ` Greg KH
  0 siblings, 0 replies; 24+ messages in thread
From: Greg KH @ 2003-12-30 22:06 UTC (permalink / raw)
  To: linux-kernel, sensors

ChangeSet 1.1496.9.8, 2003/12/04 14:26:44-08:00, khali@linux-fr.org

[PATCH] I2C: it87 and via686a alarms

> it87 and via686a violate the sysfs standard by having "alarm" instead
> of "alarms", would you please fix in your next patch?

I'm not the only one allowed to send patches to Greg, you know ;)
Anyway, here we go. Greg, here is a patch that corrects the standard
violation reported by Mark. Tested to compile.

(It also removes a useless comment in it87.c.)


 drivers/i2c/chips/it87.c    |    9 ++++-----
 drivers/i2c/chips/via686a.c |    8 ++++----
 2 files changed, 8 insertions(+), 9 deletions(-)


diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
--- a/drivers/i2c/chips/it87.c	Tue Dec 30 12:31:15 2003
+++ b/drivers/i2c/chips/it87.c	Tue Dec 30 12:31:15 2003
@@ -412,7 +412,6 @@
 show_temp_offset(2);
 show_temp_offset(3);
 
-/* more like overshoot temperature */
 static ssize_t show_sensor(struct device *dev, char *buf, int nr)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -561,15 +560,15 @@
 show_fan_offset(2);
 show_fan_offset(3);
 
-/* Alarm */
-static ssize_t show_alarm(struct device *dev, char *buf)
+/* Alarms */
+static ssize_t show_alarms(struct device *dev, char *buf)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct it87_data *data = i2c_get_clientdata(client);
 	it87_update_client(client);
 	return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms));
 }
-static DEVICE_ATTR(alarm, S_IRUGO | S_IWUSR, show_alarm, NULL);
+static DEVICE_ATTR(alarms, S_IRUGO | S_IWUSR, show_alarms, NULL);
 
 /* This function is called when:
      * it87_driver is inserted (when this module is loaded), for each
@@ -749,7 +748,7 @@
 	device_create_file(&new_client->dev, &dev_attr_fan_div1);
 	device_create_file(&new_client->dev, &dev_attr_fan_div2);
 	device_create_file(&new_client->dev, &dev_attr_fan_div3);
-	device_create_file(&new_client->dev, &dev_attr_alarm);
+	device_create_file(&new_client->dev, &dev_attr_alarms);
 
 	return 0;
 
diff -Nru a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c
--- a/drivers/i2c/chips/via686a.c	Tue Dec 30 12:31:15 2003
+++ b/drivers/i2c/chips/via686a.c	Tue Dec 30 12:31:15 2003
@@ -635,14 +635,14 @@
 show_fan_offset(1);
 show_fan_offset(2);
 
-/* Alarm */
-static ssize_t show_alarm(struct device *dev, char *buf) {
+/* Alarms */
+static ssize_t show_alarms(struct device *dev, char *buf) {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct via686a_data *data = i2c_get_clientdata(client);
 	via686a_update_client(client);
 	return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms));
 }
-static DEVICE_ATTR(alarm, S_IRUGO | S_IWUSR, show_alarm, NULL);
+static DEVICE_ATTR(alarms, S_IRUGO | S_IWUSR, show_alarms, NULL);
 
 /* The driver. I choose to use type i2c_driver, as at is identical to both
    smbus_driver and isa_driver, and clients could be of either kind */
@@ -767,7 +767,7 @@
 	device_create_file(&new_client->dev, &dev_attr_fan_min2);
 	device_create_file(&new_client->dev, &dev_attr_fan_div1);
 	device_create_file(&new_client->dev, &dev_attr_fan_div2);
-	device_create_file(&new_client->dev, &dev_attr_alarm);
+	device_create_file(&new_client->dev, &dev_attr_alarms);
 
 	return 0;
 


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2003-12-30 23:01 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-30 22:02 [BK PATCH] i2c driver fixes for 2.6.0 Greg KH
2003-12-30 22:06 ` [PATCH] " Greg KH
2003-12-30 22:06   ` Greg KH
2003-12-30 22:06     ` Greg KH
2003-12-30 22:06       ` Greg KH
2003-12-30 22:06         ` Greg KH
2003-12-30 22:06           ` Greg KH
2003-12-30 22:06             ` Greg KH
2003-12-30 22:06               ` Greg KH
2003-12-30 22:06                 ` Greg KH
2003-12-30 22:06                   ` Greg KH
2003-12-30 22:06                     ` Greg KH
2003-12-30 22:06                       ` Greg KH
2003-12-30 22:06                         ` Greg KH
2003-12-30 22:06                           ` Greg KH
2003-12-30 22:06                             ` Greg KH
2003-12-30 22:06                               ` Greg KH
2003-12-30 22:06                                 ` Greg KH
2003-12-30 22:06                                   ` Greg KH
2003-12-30 22:06                                     ` Greg KH
2003-12-30 22:06                                       ` Greg KH
2003-12-30 22:06                                         ` Greg KH
2003-12-30 22:06                                           ` Greg KH
2003-12-30 22:06                                             ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).