Skip to contentSkip to conversation

i2c driver fixes for 2.6.0-test7

PATCH New Greg KH 1 participant 5 messages Oct 10, 2003

Subsystems (3)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 i2c driver fixes for 2.6.0-test7

Hi,

Here are some i2c driver fixes for 2.6.0-test7. They fix a bug in the i2c-dev class code, fix oopses in the i2c-sis630 driver, and fix a potential use-before-initialized error in the i2c chip drivers.

Please pull from: bk://kernel.bkbits.net/gregkh/linux/i2c-2.6

thanks,

greg k-h

 drivers/i2c/busses/Kconfig      |    4 +-
 drivers/i2c/busses/i2c-sis630.c |   67 ++++++++++++++++++++++++++++------------
 drivers/i2c/chips/Kconfig       |   16 ++++-----
 drivers/i2c/chips/adm1021.c     |    6 ++-
 drivers/i2c/chips/it87.c        |    7 ++--
 drivers/i2c/chips/lm75.c        |    5 ++
 drivers/i2c/chips/lm78.c        |    7 ++--
 drivers/i2c/chips/lm85.c        |    6 ++-
 drivers/i2c/chips/via686a.c     |    7 ++--
 drivers/i2c/chips/w83781d.c     |    6 ++-
 drivers/i2c/i2c-dev.c           |   17 ++++++++--
 11 files changed, 99 insertions(+), 49 deletions(-)

-----

<amalysh:web.de>:
o I2C: i2c-sis630 driver fixes

Greg Kroah-Hartman:
o I2C: fix i2c-dev class release function bug

Jean Delvare:
o I2C: correct some errors in i2c/chips/Kconfig
o I2C: Chip driver initialization fixes

author
#1 lore raw

PATCH 1/1 i2c driver fixes for 2.6.0-test7

ChangeSet 1.1337.1.1, 2003/10/09 13:33:03-07:00, [email protected]

[PATCH] I2C: Chip driver initialization fixes

fixes all chip drivers by moving the initialization before any sysfs entry is created.

 drivers/i2c/chips/adm1021.c |    6 ++++--
 drivers/i2c/chips/it87.c    |    7 ++++---
 drivers/i2c/chips/lm75.c    |    5 ++++-
 drivers/i2c/chips/lm78.c    |    7 ++++---
 drivers/i2c/chips/lm85.c    |    6 ++++--
 drivers/i2c/chips/via686a.c |    7 ++++---
 drivers/i2c/chips/w83781d.c |    6 ++++--
 7 files changed, 28 insertions(+), 16 deletions(-)
drivers/i2c/chips/adm1021.c +4 -2
diff -Nru a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c
@@ -322,6 +322,10 @@
 	if ((err = i2c_attach_client(new_client)))
 		goto error3;
 
+	/* Initialize the ADM1021 chip */
+	adm1021_init_client(new_client);
+
+	/* Register sysfs hooks */
 	device_create_file(&new_client->dev, &dev_attr_temp_max1);
 	device_create_file(&new_client->dev, &dev_attr_temp_min1);
 	device_create_file(&new_client->dev, &dev_attr_temp_input1);
@@ -332,8 +336,6 @@
 	if (data->type == adm1021)
 		device_create_file(&new_client->dev, &dev_attr_die_code);
 
-	/* Initialize the ADM1021 chip */
-	adm1021_init_client(new_client);
 	return 0;
 
 error3:
drivers/i2c/chips/it87.c +4 -3
diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
@@ -701,7 +701,10 @@
 	if ((err = i2c_attach_client(new_client)))
 		goto ERROR1;
 
-	/* register sysfs hooks */
+	/* Initialize the IT87 chip */
+	it87_init_client(new_client, data);
+
+	/* Register sysfs hooks */
 	device_create_file(&new_client->dev, &dev_attr_in_input0);
 	device_create_file(&new_client->dev, &dev_attr_in_input1);
 	device_create_file(&new_client->dev, &dev_attr_in_input2);
@@ -750,8 +753,6 @@
 	device_create_file(&new_client->dev, &dev_attr_fan_div3);
 	device_create_file(&new_client->dev, &dev_attr_alarm);
 
-	/* Initialize the IT87 chip */
-	it87_init_client(new_client, data);
 	return 0;
 
 ERROR1:
drivers/i2c/chips/lm75.c +4 -1
diff -Nru a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c
@@ -204,11 +204,14 @@
 	if ((err = i2c_attach_client(new_client)))
 		goto exit_free;
 
+	/* Initialize the LM75 chip */
+	lm75_init_client(new_client);
+	
+	/* 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_input);
 
-	lm75_init_client(new_client);
 	return 0;
 
 exit_free:
drivers/i2c/chips/lm78.c +4 -3
diff -Nru a/drivers/i2c/chips/lm78.c b/drivers/i2c/chips/lm78.c
@@ -648,7 +648,10 @@
 	if ((err = i2c_attach_client(new_client)))
 		goto ERROR2;
 
-	/* register sysfs hooks */
+	/* Initialize the LM78 chip */
+	lm78_init_client(new_client);
+
+	/* Register sysfs hooks */
 	device_create_file(&new_client->dev, &dev_attr_in_input0);
 	device_create_file(&new_client->dev, &dev_attr_in_min0);
 	device_create_file(&new_client->dev, &dev_attr_in_max0);
@@ -685,8 +688,6 @@
 	device_create_file(&new_client->dev, &dev_attr_alarms);
 	device_create_file(&new_client->dev, &dev_attr_vid);
 
-	/* Initialize the LM78 chip */
-	lm78_init_client(new_client);
 	return 0;
 
 ERROR2:
drivers/i2c/chips/lm85.c +4 -2
diff -Nru a/drivers/i2c/chips/lm85.c b/drivers/i2c/chips/lm85.c
@@ -888,6 +888,10 @@
 	/* Set the VRM version */
 	data->vrm = LM85_INIT_VRM ;
 
+	/* Initialize the LM85 chip */
+	lm85_init_client(new_client);
+
+	/* Register sysfs hooks */
 	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_input3);
@@ -930,8 +934,6 @@
 	device_create_file(&new_client->dev, &dev_attr_vid);
 	device_create_file(&new_client->dev, &dev_attr_alarms);
 
-	/* Initialize the LM85 chip */
-	lm85_init_client(new_client);
 	return 0;
 
 	/* Error out and cleanup code */
drivers/i2c/chips/via686a.c +4 -3
diff -Nru a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c
@@ -735,7 +735,10 @@
 	if ((err = i2c_attach_client(new_client)))
 		goto ERROR3;
 	
-	/* register sysfs hooks */
+	/* Initialize the VIA686A chip */
+	via686a_init_client(new_client);
+
+	/* Register sysfs hooks */
 	device_create_file(&new_client->dev, &dev_attr_in_input0);
 	device_create_file(&new_client->dev, &dev_attr_in_input1);
 	device_create_file(&new_client->dev, &dev_attr_in_input2);
@@ -768,8 +771,6 @@
 	device_create_file(&new_client->dev, &dev_attr_fan_div2);
 	device_create_file(&new_client->dev, &dev_attr_alarm);
 
-	/* Initialize the VIA686A chip */
-	via686a_init_client(new_client);
 	return 0;
 
       ERROR3:
drivers/i2c/chips/w83781d.c +4 -2
diff -Nru a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c
@@ -1346,6 +1346,10 @@
 		data->lm75[1] = NULL;
 	}
 
+	/* Initialize the chip */
+	w83781d_init_client(new_client);
+
+	/* Register sysfs hooks */
 	device_create_file_in(new_client, 0);
 	if (kind != w83783s && kind != w83697hf)
 		device_create_file_in(new_client, 1);
@@ -1408,8 +1412,6 @@
 	}
 #endif
 
-	/* Initialize the chip */
-	w83781d_init_client(new_client);
 	return 0;
 
 ERROR3:
author
#2 lore raw

ChangeSet 1.1337.1.2, 2003/10/09 13:35:09-07:00, [email protected]

[PATCH] I2C: correct some errors in i2c/chips/Kconfig

 drivers/i2c/chips/Kconfig |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
drivers/i2c/chips/Kconfig +8 -8
diff -Nru a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
@@ -15,7 +15,7 @@
 	help
 	  If you say yes here you get support for Analog Devices ADM1021 
 	  and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
-	  Genesys Logic GL523SM, National Semi LM84, TI THMC10,
+	  Genesys Logic GL523SM, National Semiconductor LM84, TI THMC10,
 	  and the XEON processor built-in sensor.
 
 	  This driver can also be built as a module.  If so, the module
@@ -34,30 +34,30 @@
 	  will be called eeprom.
 
 config SENSORS_IT87
-	tristate "National Semiconductors IT87 and compatibles"
+	tristate "ITE IT87xx and compatibles"
 	depends on I2C && EXPERIMENTAL
 	select I2C_SENSOR
 	help
-	  If you say yes here you get support for National Semiconductor IT87
-	  sensor chips and clones: IT8705F, IT8712F and SiS960.
+	  If you say yes here you get support for ITE IT87xx sensor chips
+	  and clones: SiS960.
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called it87.
 
 config SENSORS_LM75
-	tristate "National Semiconductors LM75 and compatibles"
+	tristate "National Semiconductor LM75 and compatibles"
 	depends on I2C && EXPERIMENTAL
 	select I2C_SENSOR
 	help
 	  If you say yes here you get support for National Semiconductor LM75
 	  sensor chips and clones: Dallas Semi DS75 and DS1775, TelCon
-	  TCN75, and National Semi LM77.
+	  TCN75, and National Semiconductor LM77.
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called lm75.
 
 config SENSORS_LM78
-	tristate "National Semiconductors LM78 and compatibles"
+	tristate "National Semiconductor LM78 and compatibles"
 	depends on I2C && EXPERIMENTAL
 	select I2C_SENSOR
 	help
@@ -69,7 +69,7 @@
 	  will be called lm78.
 
 config SENSORS_LM85
-	tristate "National Semiconductors LM85 and compatibles"
+	tristate "National Semiconductor LM85 and compatibles"
 	depends on I2C && EXPERIMENTAL
 	select I2C_SENSOR
 	help
author
#3 lore raw

ChangeSet 1.1337.1.3, 2003/10/10 14:11:04-07:00, [email protected]

[PATCH] I2C: i2c-sis630 driver fixes

attached you can find a patch that should fix i2c-sis630 driver for 2.6.0-X kernel. With i2c-sis630 from stock 2.6.0-X we have oops and driver was not correct registered against i2c-core.

Changes:
1) fixed a oops while modprobing
2) added check for buffer overflow for i2c block data read transaction
3) added 'force' modprobe parameter. It's allow more easily testing for not yet supported SiS chips.

 drivers/i2c/busses/Kconfig      |    4 +-
 drivers/i2c/busses/i2c-sis630.c |   67 ++++++++++++++++++++++++++++------------
 2 files changed, 49 insertions(+), 22 deletions(-)
drivers/i2c/busses/Kconfig +2 -2
diff -Nru a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
@@ -248,11 +248,11 @@
 	  will be called i2c-sis5595.
 
 config I2C_SIS630
-	tristate "SiS 630"
+	tristate "SiS 630/730"
 	depends on I2C && PCI && EXPERIMENTAL
 	help
 	  If you say yes to this option, support will be included for the 
-	  SiS630 SMBus (a subset of I2C) interface.
+	  SiS630 and SiS730 SMBus (a subset of I2C) interface.
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-sis630.
drivers/i2c/busses/i2c-sis630.c +47 -20

150 lines not on this page · raw message

author
#4 lore raw

ChangeSet 1.1337.1.4, 2003/10/10 14:59:18-07:00, [email protected]

[PATCH] I2C: fix i2c-dev class release function bug.

There was no release function, that was the bug :)
It caused bad messages to show up in the syslog whenever a i2c driver was removed, and could easily oops.

 drivers/i2c/i2c-dev.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
drivers/i2c/i2c-dev.c +14 -3
diff -Nru a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
@@ -49,6 +49,7 @@
 	int minor;
 	struct i2c_adapter *adap;
 	struct class_device class_dev;
+	struct completion released;	/* FIXME, we need a class_device_unregister() */
 };
 #define to_i2c_dev(d) container_of(d, struct i2c_dev, class_dev)
 
@@ -112,7 +113,6 @@
 	spin_lock(&i2c_dev_array_lock);
 	i2c_dev_array[i2c_dev->minor] = NULL;
 	spin_unlock(&i2c_dev_array_lock);
-	kfree(i2c_dev);
 }
 
 static ssize_t show_dev(struct class_device *class_dev, char *buf)
@@ -421,8 +421,15 @@
 	.release	= i2cdev_release,
 };
 
+static void release_i2c_dev(struct class_device *dev)
+{
+	struct i2c_dev *i2c_dev = to_i2c_dev(dev);
+	complete(&i2c_dev->released);
+}
+
 static struct class i2c_dev_class = {
-	.name	= "i2c-dev",
+	.name		= "i2c-dev",
+	.release	= &release_i2c_dev,
 };
 
 static int i2cdev_attach_adapter(struct i2c_adapter *adap)
@@ -453,6 +460,7 @@
 	return 0;
 error:
 	return_i2c_dev(i2c_dev);
+	kfree(i2c_dev);
 	return retval;
 }
 
@@ -464,9 +472,12 @@
 	if (!i2c_dev)
 		return -ENODEV;
 
-	class_device_unregister(&i2c_dev->class_dev);
+	init_completion(&i2c_dev->released);
 	devfs_remove("i2c/%d", i2c_dev->minor);
 	return_i2c_dev(i2c_dev);
+	class_device_unregister(&i2c_dev->class_dev);
+	wait_for_completion(&i2c_dev->released);
+	kfree(i2c_dev);
 
 	dev_dbg(&adap->dev, "Adapter unregistered\n");
 	return 0;