I2C fixes for 2.6.10-rc2
Subsystems (4)
PATCH 1/1 I2C fixes for 2.6.10-rc2
Hi,
Here are some i2c driver fixes for 2.6.10-rc2.
Please pull from: bk://kernel.bkbits.net/gregkh/linux/i2c-2.6
Individual patches will follow, sent to the sensors and linux-kernel lists.
thanks,
greg k-h
Documentation/i2c/writing-clients | 20 ++++++++++++++++---- drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-amd756-s4882.c | 7 +++++-- drivers/i2c/busses/i2c-nforce2.c | 9 ++++----- drivers/i2c/chips/smsc47m1.c | 29 +++++++++++++++++++++-------- drivers/i2c/i2c-core.c | 20 -------------------- include/linux/pci_ids.h | 2 ++ 7 files changed, 49 insertions(+), 39 deletions(-)
-----
<thomas:plx.com>:
o I2C: i2c-nforce2.c add support for nForce3 Pro 150 MCP
Gabriel Paubert:
o I2C: minor comment fix
Jean Delvare:
o I2C: Cleanups to the recent smbus functions removal
o I2C: Fixes to the i2c-amd756-s4882 driver
o I2C: Do not register useless smsc47m1
PATCH 1/1 I2C fixes for 2.6.10-rc2
ChangeSet 1.2164, 2004/11/19 09:12:35-08:00, [email protected]
[PATCH] I2C: Do not register useless smsc47m1
While verifying my stack of patches against what you sent to Linus last week, I noticed this one. Looks like I simply forgot to send it to you, as I cannot find any trace of it in the lm_sensors mailing-list archives.
The patch prevents an smsc47m1 device from being registered when no monitoring function is actually active within the chip. See this ticket for background:
http://secure.netroedge.com/~lm78/readticket.cgi?ticket=1801
This is certainly better to explicitely fail in this case than leave the user with an empty sysfs directory (except for alarms), which tends to make him/her think of a driver bug, which it isn't (what it really is is a BIOS brokenness).
drivers/i2c/chips/smsc47m1.c | 29 +++++++++++++++++++++-------- 1 files changed, 21 insertions(+), 8 deletions(-)
drivers/i2c/chips/smsc47m1.c +21 -8
@@ -394,6 +394,7 @@struct i2c_client *new_client;struct smsc47m1_data *data;int err =0 ; +int fan1, fan2, pwm1, pwm2;if (!i2c_is_isa_adapter (adapter)) {return 0 ;
@@ -423,6 +424,22 @@ new_client->id = smsc47m1_id++;init_MUTEX (&data->update_lock); +/* If no function is properly configured, there's no point in +actually registering the chip. */ + fan1 = (smsc47m1_read_value (new_client,SMSC47M1_REG_TPIN (0 )) &0x05 ) + ==0x05 ; + fan2 = (smsc47m1_read_value (new_client,SMSC47M1_REG_TPIN (1 )) &0x05 ) + ==0x05 ; + pwm1 = (smsc47m1_read_value (new_client,SMSC47M1_REG_PPIN (0 )) &0x05 ) + ==0x04 ; + pwm2 = (smsc47m1_read_value (new_client,SMSC47M1_REG_PPIN (1 )) &0x05 ) + ==0x04 ; +if (!(fan1 || fan2 || pwm1 || pwm2)) { +dev_warn (&new_client->dev,"Device is not configured, will not use\n" ); + err = -ENODEV ; + goto error_free; + } +if ((err =i2c_attach_client (new_client))) goto error_free;
@@ -434,8 +451,7 @@function. */ smsc47m1_update_device (&new_client->dev,1 ); -if ((smsc47m1_read_value (new_client,SMSC47M1_REG_TPIN (0 )) &0x05 ) - ==0x05 ) { +if (fan1) {device_create_file (&new_client->dev, &dev_attr_fan1_input);device_create_file (&new_client->dev, &dev_attr_fan1_min);device_create_file (&new_client->dev, &dev_attr_fan1_div);
@@ -443,8 +459,7 @@dev_dbg (&new_client->dev,"Fan 1 not enabled by hardware, " "skipping\n" ); -if ((smsc47m1_read_value (new_client,SMSC47M1_REG_TPIN (1 )) &0x05 ) - ==0x05 ) { +if (fan2) {device_create_file (&new_client->dev, &dev_attr_fan2_input);device_create_file (&new_client->dev, &dev_attr_fan2_min);device_create_file (&new_client->dev, &dev_attr_fan2_div);
@@ -452,15 +467,13 @@dev_dbg (&new_client->dev,"Fan 2 not enabled by hardware, " "skipping\n" ); -if ((smsc47m1_read_value (new_client,SMSC47M1_REG_PPIN (0 )) &0x05 ) - ==0x04 ) { +if (pwm1) {device_create_file (&new_client->dev, &dev_attr_pwm1);device_create_file (&new_client->dev, &dev_attr_pwm1_enable); }else dev_dbg (&new_client->dev,"PWM 1 not enabled by hardware, " "skipping\n" ); -if ((smsc47m1_read_value (new_client,SMSC47M1_REG_PPIN (1 )) &0x05 ) - ==0x04 ) { +if (pwm2) {device_create_file (&new_client->dev, &dev_attr_pwm2);device_create_file (&new_client->dev, &dev_attr_pwm2_enable); }else
ChangeSet 1.2165, 2004/11/19 09:13:08-08:00, [email protected]
[PATCH] I2C: Fixes to the i2c-amd756-s4882 driver
While working on the 2.4 version of the i2c-amd756-s4882 driver, I noticed a few quirks on the 2.6 version I sent to you. The following patch attempts to fix them.
drivers/i2c/busses/i2c-amd756-s4882.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-amd756-s4882.c +5 -2
@@ -35,6 +35,7 @@#include <linux/module.h> #include <linux/kernel.h> +#include <linux/slab.h> #include <linux/init.h> #include <linux/i2c.h>
@@ -156,7 +157,9 @@/* Unregister physical bus */ error =i2c_del_adapter (&amd756_smbus);if (error) { -if (error != -EINVAL ) +if (error == -EINVAL ) + error = -ENODEV ; +else dev_err (&amd756_smbus.dev,"Physical bus removal " "failed\n" ); goto ERROR0;
@@ -200,7 +203,7 @@I2C_SMBUS_WRITE ,0x03 , I2C_SMBUS_BYTE_DATA, &ioconfig);if (error) { -dev_dbg (&amd756_smbus.dev,"PCA9556 configuration failed\n" ); +dev_err (&amd756_smbus.dev,"PCA9556 configuration failed\n" ); error = -EIO ; goto ERROR3; }
ChangeSet 1.2166, 2004/11/19 09:13:45-08:00, [email protected]
[PATCH] I2C: Cleanups to the recent smbus functions removal
This patch cleans up the recent removal of smbus functions proposed by Arjan and then fixed by Gabriel. Changes are as follow:
1* Discard i2c_smbus_block_process_call, as it isn't used anywhere
either. I guess that Arjan missed it because it wasn't exported.
2* Document the functions removal, so that people have at least an idea
that the functions can be restored later if needed.
Documentation/i2c/writing-clients | 20 ++++++++++++++++---- drivers/i2c/i2c-core.c | 19 ------------------- 2 files changed, 16 insertions(+), 23 deletions(-)
Documentation/i2c/writing-clients +16 -4
@@ -676,13 +676,25 @@ extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command); extern s32 i2c_smbus_write_word_data(struct i2c_client * client, u8 command, u16 value); - extern s32 i2c_smbus_process_call(struct i2c_client * client, - u8 command, u16 value); - extern s32 i2c_smbus_read_block_data(struct i2c_client * client, - u8 command, u8 *values); extern s32 i2c_smbus_write_block_data(struct i2c_client * client, u8 command, u8 length, u8 *values); + +These ones were removed in Linux 2.6.10 because they had no users, but could +be added back later if needed: + + extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, + u8 command, u8 *values); + extern s32 i2c_smbus_read_block_data(struct i2c_client * client, + u8 command, u8 *values); + extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, + u8 command, u8 length, + u8 *values); + extern s32 i2c_smbus_process_call(struct i2c_client * client, + u8 command, u16 value); + extern s32 i2c_smbus_block_process_call(struct i2c_client *client, + u8 command, u8 length, + u8 *values) All these transactions return -1 on failure. The 'write' transactions return 0 on success; the 'read' transactions return the read value, except
drivers/i2c/i2c-core.c +0 -19
@@ -1038,25 +1038,6 @@ }/* Returns the number of read bytes */ -s32 i2c_smbus_block_process_call (struct i2c_client *client,u8 command,u8 length,u8 *values) -{ -union i2c_smbus_data data; -int i; -if (length >I2C_SMBUS_BLOCK_MAX -1 ) -return -1 ; - data.block[0 ] = length; -for (i =1 ; i <= length; i++) - data.block[i] = values[i-1 ]; -if (i2c_smbus_xfer (client->adapter,client->addr,client->flags, -I2C_SMBUS_WRITE , command, -I2C_SMBUS_BLOCK_PROC_CALL , &data)) -return -1 ; -for (i =1 ; i <= data.block[0 ]; i++) - values[i-1 ] = data.block[i]; -return data.block[0 ]; -} - -/* Returns the number of read bytes */ s32 i2c_smbus_read_i2c_block_data (struct i2c_client *client,u8 command,u8 *values) {union i2c_smbus_data data;
ChangeSet 1.2167, 2004/11/19 09:14:15-08:00, [email protected]
[PATCH] I2C: minor comment fix
It seems so. BTW I hate wrong comments and happened to add one in my patch. To fix my blunder, can you apply the appended one line removal on top of Jean's patch.
drivers/i2c/i2c-core.c | 1 - 1 files changed, 1 deletion(-)
drivers/i2c/i2c-core.c +0 -1
@@ -1021,7 +1021,6 @@ I2C_SMBUS_WORD_DATA,&data); } -/* Returns the number of bytes transferred */ s32 i2c_smbus_write_block_data (struct i2c_client *client,u8 command,u8 length,u8 *values) {
ChangeSet 1.2168, 2004/11/19 09:14:38-08:00, [email protected]
[PATCH] I2C: i2c-nforce2.c add support for nForce3 Pro 150 MCP
This is the all new and improved version of the patch:
- following the advise from Jean Delvare I removed the redundant definition of the PCI IDs from the driver and just add them to the pci_ids.h file.
- the patch is now created against linux 2.6.10-RC2.
drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-nforce2.c | 9 ++++----- include/linux/pci_ids.h | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/i2c/busses/Kconfig +1 -0
@@ -218,6 +218,7 @@ help If you say yes to this option, support will be included for the Nvidia Nforce2 family of mainboard I2C interfaces. + This driver also supports the nForce3 Pro 150 MCP. This driver can also be built as a module. If so, the module will be called i2c-nforce2.
drivers/i2c/busses/i2c-nforce2.c +4 -5
@@ -1,6 +1,7 @@/* SMBus driver for nVidia nForce2 MCP +Added nForce3 Pro 150 Thomas Leibold <[email protected]>, Ported to 2.5 Patrick Dreker <[email protected]>, Copyright (c) 2003 Hans-Frieder Vogt <[email protected]>, Based on
@@ -25,6 +26,7 @@/* SUPPORTED DEVICES PCI ID nForce2 MCP 0064 +nForce3 Pro150 MCP 00D4 This driver supports the 2 SMBuses that are included in the MCP2 of the nForce2 chipset.
@@ -49,11 +51,6 @@MODULE_DESCRIPTION ("nForce2 SMBus driver" ); -#ifndef PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS -#define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS 0x0064 -#endif - -struct nforce2_smbus {struct pci_dev *dev;struct i2c_adapter adapter;
@@ -293,6 +290,8 @@static struct pci_device_id nforce2_ids[] = { {PCI_VENDOR_ID_NVIDIA ,PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS , +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {PCI_VENDOR_ID_NVIDIA ,PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, {0 } };
include/linux/pci_ids.h +2 -0
@@ -1082,6 +1082,7 @@#define PCI_DEVICE_ID_NVIDIA_NVENET_8 0x0056#define PCI_DEVICE_ID_NVIDIA_NVENET_9 0x0057#define PCI_DEVICE_ID_NVIDIA_CK804_AUDIO 0x0059 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS 0x0064#define PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE 0x0065#define PCI_DEVICE_ID_NVIDIA_NVENET_2 0x0066#define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a
@@ -1093,6 +1094,7 @@#define PCI_DEVICE_ID_NVIDIA_NFORCE3 0x00d1#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da#define PCI_DEVICE_ID_NVIDIA_NFORCE3S 0x00e1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS 0x00d4#define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5#define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d6#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da