Commit 0d73adc1 authored by Jean Delvare's avatar Jean Delvare Committed by Linus Torvalds

[PATCH] I2C: 24RF08 corruption prevention (again)

The 24RF08 corruption prevention in the eeprom and max6875 drivers wasn't
complete. For one thing, the additional quick write should happen as soon
as possible and unconditionally, while both drivers had error paths before.
For another, when a given chip is forced, the core does not emit a quick
write, so a second quick write would cause the corruption rather than
prevent it.

I plan to move the corruption prevention in the core in the long run, so
that individual drivers don't have to care anymore. But I need to merge
i2c_probe and i2c_detect before I do (work in progress).
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 86749e85
...@@ -163,6 +163,11 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -163,6 +163,11 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
struct eeprom_data *data; struct eeprom_data *data;
int err = 0; int err = 0;
/* prevent 24RF08 corruption */
if (kind < 0)
i2c_smbus_xfer(adapter, address, 0, 0, 0,
I2C_SMBUS_QUICK, NULL);
/* There are three ways we can read the EEPROM data: /* There are three ways we can read the EEPROM data:
(1) I2C block reads (faster, but unsupported by most adapters) (1) I2C block reads (faster, but unsupported by most adapters)
(2) Consecutive byte reads (100% overhead) (2) Consecutive byte reads (100% overhead)
...@@ -187,9 +192,6 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -187,9 +192,6 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
new_client->driver = &eeprom_driver; new_client->driver = &eeprom_driver;
new_client->flags = 0; new_client->flags = 0;
/* prevent 24RF08 corruption */
i2c_smbus_write_quick(new_client, 0);
/* Fill in the remaining client fields */ /* Fill in the remaining client fields */
strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE);
data->valid = 0; data->valid = 0;
......
...@@ -343,6 +343,11 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -343,6 +343,11 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
struct max6875_data *data; struct max6875_data *data;
int err = 0; int err = 0;
/* Prevent 24RF08 corruption (in case of user error) */
if (kind < 0)
i2c_smbus_xfer(adapter, address, 0, 0, 0,
I2C_SMBUS_QUICK, NULL);
/* There are three ways we can read the EEPROM data: /* There are three ways we can read the EEPROM data:
(1) I2C block reads (faster, but unsupported by most adapters) (1) I2C block reads (faster, but unsupported by most adapters)
(2) Consecutive byte reads (100% overhead) (2) Consecutive byte reads (100% overhead)
...@@ -370,9 +375,6 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -370,9 +375,6 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
new_client->driver = &max6875_driver; new_client->driver = &max6875_driver;
new_client->flags = 0; new_client->flags = 0;
/* Prevent 24RF08 corruption */
i2c_smbus_write_quick(new_client, 0);
/* Setup the user section */ /* Setup the user section */
data->blocks[max6875_eeprom_user].type = max6875_eeprom_user; data->blocks[max6875_eeprom_user].type = max6875_eeprom_user;
data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES; data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment