mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-06 15:51:34 +00:00
better handling of read errors
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1689 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
3978a26e03
commit
8ddee6dd5c
2 files changed
+24
-12
No files matched your search
+12
-6
@@ -180,6 +180,7 @@ int ddcmon_detect(struct i2c_adapter *adapter, int address,
|
||||
}
|
||||
|
||||
data = (struct ddcmon_data *) (new_client + 1);
|
||||
memset(data, 0xff, DDCMON_SIZE);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
@@ -273,7 +274,7 @@ void ddcmon_dec_use(struct i2c_client *client)
|
||||
void ddcmon_update_client(struct i2c_client *client)
|
||||
{
|
||||
struct ddcmon_data *data = client->data;
|
||||
int i;
|
||||
int i, j;
|
||||
|
||||
down(&data->update_lock);
|
||||
|
||||
@@ -283,23 +284,28 @@ void ddcmon_update_client(struct i2c_client *client)
|
||||
I2C_FUNC_SMBUS_READ_I2C_BLOCK))
|
||||
{
|
||||
for (i=0; i<DDCMON_SIZE; i+=I2C_SMBUS_I2C_BLOCK_MAX)
|
||||
if(i2c_smbus_read_i2c_block_data(client,
|
||||
if (i2c_smbus_read_i2c_block_data(client,
|
||||
i, data->data + i)
|
||||
!= I2C_SMBUS_I2C_BLOCK_MAX)
|
||||
break;
|
||||
goto DONE;
|
||||
} else {
|
||||
if (i2c_smbus_write_byte(client, 0)) {
|
||||
#ifdef DEBUG
|
||||
printk("ddcmon read start has failed!\n");
|
||||
#endif
|
||||
goto DONE;
|
||||
}
|
||||
for (i = 0; i < DDCMON_SIZE; i++) {
|
||||
j = i2c_smbus_read_byte(client);
|
||||
if (j < 0)
|
||||
goto DONE;
|
||||
data->data[i] = (u8) j;
|
||||
}
|
||||
for (i = 0; i < DDCMON_SIZE; i++)
|
||||
data->data[i] = (u8) i2c_smbus_read_byte(client);
|
||||
}
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
DONE:
|
||||
up(&data->update_lock);
|
||||
}
|
||||
|
||||
|
||||
+12
-6
@@ -215,6 +215,7 @@ int eeprom_detect(struct i2c_adapter *adapter, int address,
|
||||
}
|
||||
|
||||
data = (struct eeprom_data *) (new_client + 1);
|
||||
memset(data, 0xff, EEPROM_SIZE);
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
@@ -334,7 +335,7 @@ int eeprom_write_value(struct i2c_client *client, u8 reg, u8 value)
|
||||
void eeprom_update_client(struct i2c_client *client)
|
||||
{
|
||||
struct eeprom_data *data = client->data;
|
||||
int i;
|
||||
int i, j;
|
||||
|
||||
down(&data->update_lock);
|
||||
|
||||
@@ -349,23 +350,28 @@ void eeprom_update_client(struct i2c_client *client)
|
||||
I2C_FUNC_SMBUS_READ_I2C_BLOCK))
|
||||
{
|
||||
for (i=0; i<EEPROM_SIZE; i+=I2C_SMBUS_I2C_BLOCK_MAX)
|
||||
if(i2c_smbus_read_i2c_block_data(client,
|
||||
if (i2c_smbus_read_i2c_block_data(client,
|
||||
i, data->data + i)
|
||||
!= I2C_SMBUS_I2C_BLOCK_MAX)
|
||||
break;
|
||||
goto DONE;
|
||||
} else {
|
||||
if (i2c_smbus_write_byte(client, 0)) {
|
||||
#ifdef DEBUG
|
||||
printk("eeprom read start has failed!\n");
|
||||
#endif
|
||||
goto DONE;
|
||||
}
|
||||
for (i = 0; i < EEPROM_SIZE; i++) {
|
||||
j = i2c_smbus_read_byte(client);
|
||||
if (j < 0)
|
||||
goto DONE;
|
||||
data->data[i] = (u8) j;
|
||||
}
|
||||
for (i = 0; i < EEPROM_SIZE; i++)
|
||||
data->data[i] = (u8) i2c_smbus_read_byte(client);
|
||||
}
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
DONE:
|
||||
up(&data->update_lock);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user