* [BK PATCH] i2c driver fixes for 2.6.0-test7 @ 2003-10-10 23:10 Greg KH 2003-10-10 23:11 ` [PATCH] " Greg KH 0 siblings, 1 reply; 5+ messages in thread From: Greg KH @ 2003-10-10 23:10 UTC (permalink / raw) To: torvalds; +Cc: linux-kernel, sensors 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] i2c driver fixes for 2.6.0-test7 2003-10-10 23:10 [BK PATCH] i2c driver fixes for 2.6.0-test7 Greg KH @ 2003-10-10 23:11 ` Greg KH 2003-10-10 23:11 ` Greg KH 0 siblings, 1 reply; 5+ messages in thread From: Greg KH @ 2003-10-10 23:11 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1337.1.1, 2003/10/09 13:33:03-07:00, khali@linux-fr.org [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(-) diff -Nru a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c --- a/drivers/i2c/chips/adm1021.c Fri Oct 10 16:00:52 2003 +++ b/drivers/i2c/chips/adm1021.c Fri Oct 10 16:00:52 2003 @@ -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: diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c --- a/drivers/i2c/chips/it87.c Fri Oct 10 16:00:52 2003 +++ b/drivers/i2c/chips/it87.c Fri Oct 10 16:00:52 2003 @@ -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: diff -Nru a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c --- a/drivers/i2c/chips/lm75.c Fri Oct 10 16:00:52 2003 +++ b/drivers/i2c/chips/lm75.c Fri Oct 10 16:00:52 2003 @@ -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: diff -Nru a/drivers/i2c/chips/lm78.c b/drivers/i2c/chips/lm78.c --- a/drivers/i2c/chips/lm78.c Fri Oct 10 16:00:52 2003 +++ b/drivers/i2c/chips/lm78.c Fri Oct 10 16:00:52 2003 @@ -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: diff -Nru a/drivers/i2c/chips/lm85.c b/drivers/i2c/chips/lm85.c --- a/drivers/i2c/chips/lm85.c Fri Oct 10 16:00:52 2003 +++ b/drivers/i2c/chips/lm85.c Fri Oct 10 16:00:52 2003 @@ -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 */ diff -Nru a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c --- a/drivers/i2c/chips/via686a.c Fri Oct 10 16:00:52 2003 +++ b/drivers/i2c/chips/via686a.c Fri Oct 10 16:00:52 2003 @@ -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: diff -Nru a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c --- a/drivers/i2c/chips/w83781d.c Fri Oct 10 16:00:52 2003 +++ b/drivers/i2c/chips/w83781d.c Fri Oct 10 16:00:52 2003 @@ -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: ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c driver fixes for 2.6.0-test7 2003-10-10 23:11 ` [PATCH] " Greg KH @ 2003-10-10 23:11 ` Greg KH 2003-10-10 23:11 ` Greg KH 0 siblings, 1 reply; 5+ messages in thread From: Greg KH @ 2003-10-10 23:11 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1337.1.2, 2003/10/09 13:35:09-07:00, khali@linux-fr.org [PATCH] I2C: correct some errors in i2c/chips/Kconfig drivers/i2c/chips/Kconfig | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff -Nru a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig --- a/drivers/i2c/chips/Kconfig Fri Oct 10 16:00:47 2003 +++ b/drivers/i2c/chips/Kconfig Fri Oct 10 16:00:47 2003 @@ -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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c driver fixes for 2.6.0-test7 2003-10-10 23:11 ` Greg KH @ 2003-10-10 23:11 ` Greg KH 2003-10-10 23:11 ` Greg KH 0 siblings, 1 reply; 5+ messages in thread From: Greg KH @ 2003-10-10 23:11 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1337.1.3, 2003/10/10 14:11:04-07:00, amalysh@web.de [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(-) diff -Nru a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig --- a/drivers/i2c/busses/Kconfig Fri Oct 10 16:00:43 2003 +++ b/drivers/i2c/busses/Kconfig Fri Oct 10 16:00:43 2003 @@ -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. diff -Nru a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c --- a/drivers/i2c/busses/i2c-sis630.c Fri Oct 10 16:00:43 2003 +++ b/drivers/i2c/busses/i2c-sis630.c Fri Oct 10 16:00:43 2003 @@ -25,10 +25,10 @@ Fixed the typo in sis630_access (Thanks to Mark M. Hoffman) Changed sis630_transaction.(Thanks to Mark M. Hoffman) 18.09.2002 - Added SIS730 as supported + Added SIS730 as supported. 21.09.2002 Added high_clock module option.If this option is set - used Host Master Clock 56KHz (default 14KHz).For now we are save old Host + used Host Master Clock 56KHz (default 14KHz).For now we save old Host Master Clock and after transaction completed restore (otherwise it's confuse BIOS and hung Machine). 24.09.2002 @@ -95,12 +95,22 @@ /* insmod parameters */ static int high_clock = 0; +static int force = 0; MODULE_PARM(high_clock, "i"); MODULE_PARM_DESC(high_clock, "Set Host Master Clock to 56KHz (default 14KHz)."); +MODULE_PARM(force, "i"); +MODULE_PARM_DESC(force, "Forcibly enable the SIS630. DANGEROUS!"); - +/* acpi base address */ static unsigned short acpi_base = 0; +/* supported chips */ +static int supported[] = { + PCI_DEVICE_ID_SI_630, + PCI_DEVICE_ID_SI_730, + 0 /* terminates the list */ +}; + static inline u8 sis630_read(u8 reg) { return inb(acpi_base + reg); @@ -277,6 +287,10 @@ if (len == 0) data->block[0] = sis630_read(SMB_COUNT); + /* just to be sure */ + if (data->block[0] > 32) + data->block[0] = 32; + dev_dbg(&adap->dev, "block data read len=0x%x\n", data->block[0]); for (i=0; i < 8 && len < data->block[0]; i++,len++) { @@ -372,16 +386,26 @@ I2C_FUNC_SMBUS_BLOCK_DATA; } -static int sis630_setup(struct pci_dev *dummy) +static int sis630_setup(struct pci_dev *sis630_dev) { unsigned char b; - struct pci_dev *sis630_dev = NULL; - int retval = -ENODEV; + struct pci_dev *dummy = NULL; + int retval = -ENODEV, i; - /* We need ISA bridge and not pci device passed in. */ - sis630_dev = pci_get_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, sis630_dev); - if (!sis630_dev) { - dev_err(&dummy->dev, "Error: Can't detect 85C503/5513 ISA bridge!\n"); + /* check for supported SiS devices */ + for (i=0; supported[i] > 0 ; i++) { + if ((dummy = pci_get_device(PCI_VENDOR_ID_SI, supported[i], dummy))) + break; /* found */ + } + + if (dummy) { + pci_dev_put(dummy); + } + else if (force > 0) { + dev_err(&sis630_dev->dev, "WARNING: Can't detect SIS630 compatible device, but " + "loading because of force option enabled\n"); + } + else { return -ENODEV; } @@ -389,19 +413,19 @@ Enable ACPI first , so we can accsess reg 74-75 in acpi io space and read acpi base addr */ - if (!pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG,&b)) { + if (pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG,&b)) { dev_err(&sis630_dev->dev, "Error: Can't read bios ctl reg\n"); goto exit; } - /* if ACPI already enabled , do nothing */ if (!(b & 0x80) && - !pci_write_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, b | 0x80)) { + pci_write_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, b | 0x80)) { dev_err(&sis630_dev->dev, "Error: Can't enable ACPI\n"); goto exit; } + /* Determine the ACPI base address */ - if (!pci_read_config_word(sis630_dev,SIS630_ACPI_BASE_REG,&acpi_base)) { + if (pci_read_config_word(sis630_dev,SIS630_ACPI_BASE_REG,&acpi_base)) { dev_err(&sis630_dev->dev, "Error: Can't determine ACPI base address\n"); goto exit; } @@ -418,7 +442,8 @@ retval = 0; exit: - pci_dev_put(sis630_dev); + if (retval) + acpi_base = 0; return retval; } @@ -432,19 +457,18 @@ static struct i2c_adapter sis630_adapter = { .owner = THIS_MODULE, + .class = I2C_ADAP_CLASS_SMBUS, .name = "unset", .algo = &smbus_algorithm, }; static struct pci_device_id sis630_ids[] __devinitdata = { - { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630) }, - { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_730) }, + { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) }, { 0, } }; static int __devinit sis630_probe(struct pci_dev *dev, const struct pci_device_id *id) { - if (sis630_setup(dev)) { dev_err(&dev->dev, "SIS630 comp. bus not detected, module not inserted.\n"); return -ENODEV; @@ -461,7 +485,11 @@ static void __devexit sis630_remove(struct pci_dev *dev) { - i2c_del_adapter(&sis630_adapter); + if (acpi_base) { + i2c_del_adapter(&sis630_adapter); + release_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION); + acpi_base = 0; + } } @@ -481,7 +509,6 @@ static void __exit i2c_sis630_exit(void) { pci_unregister_driver(&sis630_driver); - release_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION); } ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c driver fixes for 2.6.0-test7 2003-10-10 23:11 ` Greg KH @ 2003-10-10 23:11 ` Greg KH 0 siblings, 0 replies; 5+ messages in thread From: Greg KH @ 2003-10-10 23:11 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1337.1.4, 2003/10/10 14:59:18-07:00, greg@kroah.com [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(-) diff -Nru a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c --- a/drivers/i2c/i2c-dev.c Fri Oct 10 16:00:34 2003 +++ b/drivers/i2c/i2c-dev.c Fri Oct 10 16:00:34 2003 @@ -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; ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-10-10 23:21 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2003-10-10 23:10 [BK PATCH] i2c driver fixes for 2.6.0-test7 Greg KH 2003-10-10 23:11 ` [PATCH] " Greg KH 2003-10-10 23:11 ` Greg KH 2003-10-10 23:11 ` Greg KH 2003-10-10 23:11 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox