Don't return bad values if reads fail

git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1684 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Mark D. Studebaker committed 2003-01-04 20:21:22 +00:00
1 parent 40afee2752
commit b316273d00
2 files changed
+41 -26

No files matched your search

+2
View File
@@ -22,11 +22,13 @@ ask CVS about it:
File sensors.conf.eg: Fix vt1211/vt8231 thermistor calculations
Library: Add support for exponents and logarithms for vt1211/vt8235 temps
Makefile: Generate warnings if new library won't be found by ld.so
Module adm1021: Ignore failed reads and report old value
Module i2c-i810.c: Fix for some chips
Modules mtp008, smsc47m1, vt1211, vt8231, w83781d: Standardize and improve
pwm and pwm enable support; update docs
Module w83627hf: New
Program mkpatch: Fix vt8231 compile; keep tsunami from menu on non-alpha
Program pwmtest: New
Program sensors-detect: Add super i/o detection (smsc47m1, vt1211,
w83627hf, w83697hf)
+39 -26
View File
@@ -142,6 +142,7 @@ static int adm1021_command(struct i2c_client *client, unsigned int cmd,
static void adm1021_inc_use(struct i2c_client *client);
static void adm1021_dec_use(struct i2c_client *client);
static int adm1021_read_value(struct i2c_client *client, u8 reg);
static int adm1021_rd_good(u8 *val, struct i2c_client *client, u8 reg);
static int adm1021_write_value(struct i2c_client *client, u8 reg,
u16 value);
static void adm1021_temp(struct i2c_client *client, int operation,
@@ -426,6 +427,19 @@ int adm1021_read_value(struct i2c_client *client, u8 reg)
return i2c_smbus_read_byte_data(client, reg);
}
/* only update value if read succeeded */
int adm1021_rd_good(u8 *val, struct i2c_client *client, u8 reg)
{
int i;
i = i2c_smbus_read_byte_data(client, reg);
if(i < 0)
return i;
else {
*val = i;
return 0;
}
}
int adm1021_write_value(struct i2c_client *client, u8 reg, u16 value)
{
if (read_only > 0)
@@ -447,34 +461,33 @@ void adm1021_update_client(struct i2c_client *client)
printk("Starting adm1021 update\n");
#endif
data->temp = adm1021_read_value(client, ADM1021_REG_TEMP);
data->temp_os =
adm1021_read_value(client, ADM1021_REG_TOS_R);
data->temp_hyst =
adm1021_read_value(client, ADM1021_REG_THYST_R);
data->remote_temp =
adm1021_read_value(client, ADM1021_REG_REMOTE_TEMP);
data->remote_temp_os =
adm1021_read_value(client, ADM1021_REG_REMOTE_TOS_R);
data->remote_temp_hyst =
adm1021_read_value(client, ADM1021_REG_REMOTE_THYST_R);
data->alarms =
adm1021_read_value(client, ADM1021_REG_STATUS) & 0xec;
adm1021_rd_good(&(data->temp), client, ADM1021_REG_TEMP);
adm1021_rd_good(&(data->temp_os), client, ADM1021_REG_TOS_R);
adm1021_rd_good(&(data->temp_hyst), client,
ADM1021_REG_THYST_R);
adm1021_rd_good(&(data->remote_temp), client,
ADM1021_REG_REMOTE_TEMP);
adm1021_rd_good(&(data->remote_temp_os), client,
ADM1021_REG_REMOTE_TOS_R);
adm1021_rd_good(&(data->remote_temp_hyst), client,
ADM1021_REG_REMOTE_THYST_R);
if(!adm1021_rd_good(&(data->alarms), client,
ADM1021_REG_STATUS))
data->alarms &= 0xec;
if (data->type == adm1021)
data->die_code =
adm1021_read_value(client,
ADM1021_REG_DIE_CODE);
adm1021_rd_good(&(data->die_code), client,
ADM1021_REG_DIE_CODE);
if (data->type == adm1023) {
data->remote_temp_prec =
adm1021_read_value(client, ADM1021_REG_REM_TEMP_PREC);
data->remote_temp_os_prec =
adm1021_read_value(client, ADM1021_REG_REM_TOS_PREC);
data->remote_temp_hyst_prec =
adm1021_read_value(client, ADM1021_REG_REM_THYST_PREC);
data->remote_temp_offset =
adm1021_read_value(client, ADM1021_REG_REM_OFFSET);
data->remote_temp_offset_prec =
adm1021_read_value(client, ADM1021_REG_REM_OFFSET_PREC);
adm1021_rd_good(&(data->remote_temp_prec), client,
ADM1021_REG_REM_TEMP_PREC);
adm1021_rd_good(&(data->remote_temp_os_prec), client,
ADM1021_REG_REM_TOS_PREC);
adm1021_rd_good(&(data->remote_temp_hyst_prec), client,
ADM1021_REG_REM_THYST_PREC);
adm1021_rd_good(&(data->remote_temp_offset), client,
ADM1021_REG_REM_OFFSET);
adm1021_rd_good(&(data->remote_temp_offset_prec),
client, ADM1021_REG_REM_OFFSET_PREC);
}
data->last_updated = jiffies;
data->valid = 1;