* [BK PATCH] i2c driver fixes for 2.6.0-test3 @ 2003-08-15 18:32 Greg KH 2003-08-15 18:33 ` [PATCH] i2c driver changes 2.6.0-test3 Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-08-15 18:32 UTC (permalink / raw) To: torvalds; +Cc: linux-kernel, sensors Hi, Here are some i2c driver fixes for 2.6.0-test3. They include a fix for the i2c-dev driver that has gone into 2.4 and a pii4x bugfix from Tom Rini. I've also added adapter and client "name" files in sysfs as the driver core no longer supplies them. Please pull from: bk://kernel.bkbits.net/gregkh/linux/i2c-2.5 thanks, greg k-h drivers/i2c/busses/i2c-nforce2.c | 29 ++++----------------------- drivers/i2c/busses/i2c-piix4.c | 13 ++++++++++-- drivers/i2c/chips/Makefile | 4 ++- drivers/i2c/chips/adm1021.c | 8 +++---- drivers/i2c/i2c-core.c | 28 ++++++++++++++++++++++++++ drivers/i2c/i2c-dev.c | 41 ++++++++++++++++++++++++--------------- 6 files changed, 77 insertions(+), 46 deletions(-) ----- <khali:linux-fr.org>: o i2c: user/kernel bug and memory leak in i2c-dev Greg Kroah-Hartman: o I2C: add adapter and client name files as the driver core no longer provides them o I2C: fix up the wording for the pii4x bugfix o i2c: move w83481d to top of link order due to chip address takeover ability o i2c: fix up "raw" printk() call Mark M. Hoffman: o I2C: i2c nforce2.c fixes Rusty Lynch: o I2C: bugfix for initialization bug in adm1021 driver Tom Rini: o I2C: Fix for i2c-piix4 with on some boards ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] i2c driver changes 2.6.0-test3 2003-08-15 18:32 [BK PATCH] i2c driver fixes for 2.6.0-test3 Greg KH @ 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-08-15 18:33 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1123.18.1, 2003/08/11 14:36:10-07:00, trini@kernel.crashing.org [PATCH] I2C: Fix for i2c-piix4 with on some boards Hello all. On some boards with an Intel PIIX4 the BIOS (such as the one found on a Force CPCI-735) will incorrectly configure the chipset, and leaves a register in an undefined state causing i2c to behave strangley. The following patches (first vs lm_sensors-2.8.0 and then vs 2.6.0-test3) fixes the issue. drivers/i2c/busses/i2c-piix4.c | 9 +++++++++ 1 files changed, 9 insertions(+) diff -Nru a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c --- a/drivers/i2c/busses/i2c-piix4.c Fri Aug 15 11:27:13 2003 +++ b/drivers/i2c/busses/i2c-piix4.c Fri Aug 15 11:27:13 2003 @@ -160,6 +160,15 @@ } pci_read_config_byte(PIIX4_dev, SMBHSTCFG, &temp); + + /* 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) { + printk("Fixed I2C problem on Force CPCI735\n"); + temp = temp & 0xfd; + pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp); + } + /* If force_addr is set, we program the new address here. Just to make sure, we disable the PIIX4 first. */ if (force_addr) { ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] i2c driver changes 2.6.0-test3 2003-08-15 18:33 ` [PATCH] i2c driver changes 2.6.0-test3 Greg KH @ 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-08-15 18:33 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1123.18.2, 2003/08/11 14:36:29-07:00, khali@linux-fr.org [PATCH] i2c: user/kernel bug and memory leak in i2c-dev drivers/i2c/i2c-dev.c | 41 ++++++++++++++++++++++++++--------------- 1 files changed, 26 insertions(+), 15 deletions(-) diff -Nru a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c --- a/drivers/i2c/i2c-dev.c Fri Aug 15 11:27:09 2003 +++ b/drivers/i2c/i2c-dev.c Fri Aug 15 11:27:09 2003 @@ -181,6 +181,7 @@ struct i2c_smbus_ioctl_data data_arg; union i2c_smbus_data temp; struct i2c_msg *rdwr_pa; + u8 **data_ptrs; int i,datasize,res; unsigned long funcs; @@ -214,7 +215,7 @@ return (copy_to_user((unsigned long __user *)arg, &funcs, sizeof(unsigned long)))?-EFAULT:0; - case I2C_RDWR: + case I2C_RDWR: if (copy_from_user(&rdwr_arg, (struct i2c_rdwr_ioctl_data __user *)arg, sizeof(rdwr_arg))) @@ -231,28 +232,37 @@ if (rdwr_pa == NULL) return -ENOMEM; + if (copy_from_user(rdwr_pa, rdwr_arg.msgs, + rdwr_arg.nmsgs * sizeof(struct i2c_msg))) { + kfree(rdwr_pa); + return -EFAULT; + } + + data_ptrs = (u8 **) kmalloc(rdwr_arg.nmsgs * sizeof(u8 *), + GFP_KERNEL); + if (data_ptrs == NULL) { + kfree(rdwr_pa); + return -ENOMEM; + } + res = 0; for( i=0; i<rdwr_arg.nmsgs; i++ ) { - if(copy_from_user(&(rdwr_pa[i]), - &(rdwr_arg.msgs[i]), - sizeof(rdwr_pa[i]))) { - res = -EFAULT; - break; - } /* Limit the size of the message to a sane amount */ if (rdwr_pa[i].len > 8192) { res = -EINVAL; break; } + data_ptrs[i] = rdwr_pa[i].buf; rdwr_pa[i].buf = kmalloc(rdwr_pa[i].len, GFP_KERNEL); if(rdwr_pa[i].buf == NULL) { res = -ENOMEM; break; } if(copy_from_user(rdwr_pa[i].buf, - rdwr_arg.msgs[i].buf, + data_ptrs[i], rdwr_pa[i].len)) { - res = -EFAULT; + ++i; /* Needs to be kfreed too */ + res = -EFAULT; break; } } @@ -260,18 +270,18 @@ int j; for (j = 0; j < i; ++j) kfree(rdwr_pa[j].buf); + kfree(data_ptrs); kfree(rdwr_pa); return res; } - if (!res) { - res = i2c_transfer(client->adapter, - rdwr_pa, - rdwr_arg.nmsgs); - } + + res = i2c_transfer(client->adapter, + rdwr_pa, + rdwr_arg.nmsgs); while(i-- > 0) { if( res>=0 && (rdwr_pa[i].flags & I2C_M_RD)) { if(copy_to_user( - rdwr_arg.msgs[i].buf, + data_ptrs[i], rdwr_pa[i].buf, rdwr_pa[i].len)) { res = -EFAULT; @@ -279,6 +289,7 @@ } kfree(rdwr_pa[i].buf); } + kfree(data_ptrs); kfree(rdwr_pa); return res; ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] i2c driver changes 2.6.0-test3 2003-08-15 18:33 ` Greg KH @ 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-08-15 18:33 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1123.18.3, 2003/08/11 14:36:57-07:00, greg@kroah.com [PATCH] i2c: fix up "raw" printk() call. drivers/i2c/busses/i2c-piix4.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) diff -Nru a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c --- a/drivers/i2c/busses/i2c-piix4.c Fri Aug 15 11:27:05 2003 +++ b/drivers/i2c/busses/i2c-piix4.c Fri Aug 15 11:27:05 2003 @@ -164,7 +164,7 @@ /* 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) { - printk("Fixed I2C problem on Force CPCI735\n"); + dev_info(&PIIX4_dev->dev, "Fixed I2C problem on Force CPCI735\n"); temp = temp & 0xfd; pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp); } ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] i2c driver changes 2.6.0-test3 2003-08-15 18:33 ` Greg KH @ 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-08-15 18:33 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1123.18.4, 2003/08/11 15:22:22-07:00, greg@kroah.com i2c: move w83481d to top of link order due to chip address takeover ability. Fixes http://bugme.osdl.org/show_bug.cgi?id=1066 drivers/i2c/chips/Makefile | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) diff -Nru a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile --- a/drivers/i2c/chips/Makefile Fri Aug 15 11:27:01 2003 +++ b/drivers/i2c/chips/Makefile Fri Aug 15 11:27:01 2003 @@ -2,10 +2,12 @@ # Makefile for the kernel hardware sensors chip drivers. # +# w83781d goes first, as it can override other driver's addresses. +obj-$(CONFIG_SENSORS_W83781D) += w83781d.o + obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o obj-$(CONFIG_SENSORS_IT87) += it87.o obj-$(CONFIG_SENSORS_LM75) += lm75.o obj-$(CONFIG_SENSORS_LM78) += lm78.o obj-$(CONFIG_SENSORS_LM85) += lm85.o obj-$(CONFIG_SENSORS_VIA686A) += via686a.o -obj-$(CONFIG_SENSORS_W83781D) += w83781d.o ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] i2c driver changes 2.6.0-test3 2003-08-15 18:33 ` Greg KH @ 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-08-15 18:33 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1123.18.5, 2003/08/14 14:13:01-07:00, mhoffman@lightlink.com [PATCH] I2C: i2c nforce2.c fixes This patch restores a line that was wrongly removed. There are also some trivial cleanups. It applies & compiles vs. 2.6.0-test3. It's untested (no hardware here). drivers/i2c/busses/i2c-nforce2.c | 29 +++++------------------------ 1 files changed, 5 insertions(+), 24 deletions(-) diff -Nru a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c --- a/drivers/i2c/busses/i2c-nforce2.c Fri Aug 15 11:26:57 2003 +++ b/drivers/i2c/busses/i2c-nforce2.c Fri Aug 15 11:26:57 2003 @@ -51,10 +51,6 @@ #ifndef PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS #define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS 0x0064 #endif -/* TODO: sync with lm-sensors */ -#ifndef I2C_HW_SMBUS_NFORCE2 -#define I2C_HW_SMBUS_NFORCE2 0x0c -#endif struct nforce2_smbus { @@ -128,20 +124,10 @@ .name = "unset", }; - -#if 0 -/* Internally used pause function */ -static void nforce2_do_pause(unsigned int amount) -{ - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(amount); -} -#endif - /* Return -1 on error. See smbus.h for more information */ -static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, - char read_write, u8 command, int size, - union i2c_smbus_data * data) +static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, + unsigned short flags, char read_write, + u8 command, int size, union i2c_smbus_data * data) { struct nforce2_smbus *smbus = adap->algo_data; unsigned char protocol, pec, temp; @@ -249,7 +235,7 @@ #if 0 do { - nforce2_do_pause(1); + i2c_do_pause(1); temp = inb_p(NVIDIA_SMB_STS); } while (((temp & NVIDIA_SMB_STS_DONE) == 0) && (timeout++ < MAX_TIMEOUT)); #endif @@ -332,13 +318,8 @@ smbus->base, smbus->base+smbus->size-1, name); return -1; } -/* - smbus->adapter.owner = THIS_MODULE; - smbus->adapter.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_NFORCE2; - smbus->adapter.algo = &smbus_algorithm; - smbus->adapter.algo_data = smbus; -*/ smbus->adapter = nforce2_adapter; + smbus->adapter.algo_data = smbus; smbus->adapter.dev.parent = &dev->dev; snprintf(smbus->adapter.name, DEVICE_NAME_SIZE, "SMBus nForce2 adapter at %04x", smbus->base); ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] i2c driver changes 2.6.0-test3 2003-08-15 18:33 ` Greg KH @ 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-08-15 18:33 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1123.18.6, 2003/08/14 14:31:21-07:00, rusty@linux.co.intel.com [PATCH] I2C: bugfix for initialization bug in adm1021 driver While initializing the adm1021 device, the driver is performing a conversion from fixed point to Celcius on values that were declaired as Celcius. On my Dell Precision 220 this results in a shutdown after a couple of minutes running. This is a very simple patch against the 2.6.0-test3 tree that just removes the conversion. drivers/i2c/chips/adm1021.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff -Nru a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c --- a/drivers/i2c/chips/adm1021.c Fri Aug 15 11:26:53 2003 +++ b/drivers/i2c/chips/adm1021.c Fri Aug 15 11:26:53 2003 @@ -356,13 +356,13 @@ { /* Initialize the adm1021 chip */ adm1021_write_value(client, ADM1021_REG_TOS_W, - TEMP_TO_REG(adm1021_INIT_TOS)); + adm1021_INIT_TOS); adm1021_write_value(client, ADM1021_REG_THYST_W, - TEMP_TO_REG(adm1021_INIT_THYST)); + adm1021_INIT_THYST); adm1021_write_value(client, ADM1021_REG_REMOTE_TOS_W, - TEMP_TO_REG(adm1021_INIT_REMOTE_TOS)); + adm1021_INIT_REMOTE_TOS); adm1021_write_value(client, ADM1021_REG_REMOTE_THYST_W, - TEMP_TO_REG(adm1021_INIT_REMOTE_THYST)); + adm1021_INIT_REMOTE_THYST); /* Enable ADC and disable suspend mode */ adm1021_write_value(client, ADM1021_REG_CONFIG_W, 0); /* Set Conversion rate to 1/sec (this can be tinkered with) */ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] i2c driver changes 2.6.0-test3 2003-08-15 18:33 ` Greg KH @ 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-08-15 18:33 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1123.18.7, 2003/08/14 14:46:08-07:00, greg@kroah.com [PATCH] I2C: fix up the wording for the pii4x bugfix. drivers/i2c/busses/i2c-piix4.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) diff -Nru a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c --- a/drivers/i2c/busses/i2c-piix4.c Fri Aug 15 11:26:49 2003 +++ b/drivers/i2c/busses/i2c-piix4.c Fri Aug 15 11:26:49 2003 @@ -164,7 +164,7 @@ /* 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, "Fixed I2C problem on Force CPCI735\n"); + dev_info(&PIIX4_dev->dev, "Worked around buggy BIOS (I2C)\n"); temp = temp & 0xfd; pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp); } ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] i2c driver changes 2.6.0-test3 2003-08-15 18:33 ` Greg KH @ 2003-08-15 18:33 ` Greg KH 0 siblings, 0 replies; 9+ messages in thread From: Greg KH @ 2003-08-15 18:33 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1123.18.8, 2003/08/15 11:06:52-07:00, greg@kroah.com I2C: add adapter and client name files as the driver core no longer provides them. drivers/i2c/i2c-core.c | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+) diff -Nru a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c --- a/drivers/i2c/i2c-core.c Fri Aug 15 11:26:44 2003 +++ b/drivers/i2c/i2c-core.c Fri Aug 15 11:26:44 2003 @@ -79,12 +79,36 @@ .release = &i2c_adapter_class_dev_release, }; +static ssize_t show_adapter_name(struct device *dev, char *buf) +{ + struct i2c_adapter *adap = dev_to_i2c_adapter(dev); + return sprintf(buf, "%s\n", adap->name); +} +static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); + + static void i2c_client_release(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); complete(&client->released); } +static ssize_t show_client_name(struct device *dev, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + return sprintf(buf, "%s\n", client->name); +} + +/* + * We can't use the DEVICE_ATTR() macro here as we want the same filename for a + * different type of a device. So beware if the DEVICE_ATTR() macro ever + * changes, this definition will also have to change. + */ +static struct device_attribute dev_attr_client_name = { + .attr = {.name = "name", .mode = S_IRUGO, .owner = THIS_MODULE }, + .show = &show_client_name, +}; + /* --------------------------------------------------- * registering functions @@ -120,6 +144,7 @@ adap->dev.driver = &i2c_adapter_driver; adap->dev.release = &i2c_adapter_dev_release; device_register(&adap->dev); + device_create_file(&adap->dev, &dev_attr_name); /* Add this adapter to the i2c_adapter class */ memset(&adap->class_dev, 0x00, sizeof(struct class_device)); @@ -184,6 +209,7 @@ init_completion(&adap->dev_released); init_completion(&adap->class_dev_released); class_device_unregister(&adap->class_dev); + device_remove_file(&adap->dev, &dev_attr_name); device_unregister(&adap->dev); list_del(&adap->list); @@ -361,6 +387,7 @@ "%d-%04x", i2c_adapter_id(adapter), client->addr); printk("registering %s\n", client->dev.bus_id); device_register(&client->dev); + device_create_file(&client->dev, &dev_attr_client_name); return 0; } @@ -387,6 +414,7 @@ down(&adapter->clist_lock); list_del(&client->list); init_completion(&client->released); + device_remove_file(&client->dev, &dev_attr_client_name); device_unregister(&client->dev); up(&adapter->clist_lock); wait_for_completion(&client->released); ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2003-08-15 18:46 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-08-15 18:32 [BK PATCH] i2c driver fixes for 2.6.0-test3 Greg KH 2003-08-15 18:33 ` [PATCH] i2c driver changes 2.6.0-test3 Greg KH 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` Greg KH 2003-08-15 18:33 ` 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).