Skip to content

Commit

Permalink
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/groeck/staging

* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging:
  hwmon: (pmbus) Improve auto-detection of temperature status register
  hwmon: (lm95241) Fix negative temperature results
  hwmon: (lm95241) Fix chip detection code
  • Loading branch information
torvalds committed Jul 10, 2011
2 parents aa4c495 + 22e6b23 commit e3bbfa7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
22 changes: 15 additions & 7 deletions drivers/hwmon/lm95241.c
Expand Up @@ -98,11 +98,16 @@ struct lm95241_data {
};

/* Conversions */
static int TempFromReg(u8 val_h, u8 val_l)
static int temp_from_reg_signed(u8 val_h, u8 val_l)
{
if (val_h & 0x80)
return val_h - 0x100;
return val_h * 1000 + val_l * 1000 / 256;
s16 val_hl = (val_h << 8) | val_l;
return val_hl * 1000 / 256;
}

static int temp_from_reg_unsigned(u8 val_h, u8 val_l)
{
u16 val_hl = (val_h << 8) | val_l;
return val_hl * 1000 / 256;
}

static struct lm95241_data *lm95241_update_device(struct device *dev)
Expand Down Expand Up @@ -135,10 +140,13 @@ static ssize_t show_input(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct lm95241_data *data = lm95241_update_device(dev);
int index = to_sensor_dev_attr(attr)->index;

return snprintf(buf, PAGE_SIZE - 1, "%d\n",
TempFromReg(data->temp[to_sensor_dev_attr(attr)->index],
data->temp[to_sensor_dev_attr(attr)->index + 1]));
index == 0 || (data->config & (1 << (index / 2))) ?
temp_from_reg_signed(data->temp[index], data->temp[index + 1]) :
temp_from_reg_unsigned(data->temp[index],
data->temp[index + 1]));
}

static ssize_t show_type(struct device *dev, struct device_attribute *attr,
Expand Down Expand Up @@ -339,7 +347,7 @@ static int lm95241_detect(struct i2c_client *new_client,
if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID)
== MANUFACTURER_ID)
&& (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID)
>= DEFAULT_REVISION)) {
== DEFAULT_REVISION)) {
name = DEVNAME;
} else {
dev_dbg(&adapter->dev, "LM95241 detection failed at 0x%02x\n",
Expand Down
11 changes: 6 additions & 5 deletions drivers/hwmon/pmbus.c
Expand Up @@ -59,16 +59,17 @@ static void pmbus_find_sensor_groups(struct i2c_client *client,
if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34))
info->func[0] |= PMBUS_HAVE_STATUS_FAN34;
}
if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_1)) {
if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_1))
info->func[0] |= PMBUS_HAVE_TEMP;
if (pmbus_check_byte_register(client, 0,
PMBUS_STATUS_TEMPERATURE))
info->func[0] |= PMBUS_HAVE_STATUS_TEMP;
}
if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_2))
info->func[0] |= PMBUS_HAVE_TEMP2;
if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_3))
info->func[0] |= PMBUS_HAVE_TEMP3;
if (info->func[0] & (PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2
| PMBUS_HAVE_TEMP3)
&& pmbus_check_byte_register(client, 0,
PMBUS_STATUS_TEMPERATURE))
info->func[0] |= PMBUS_HAVE_STATUS_TEMP;

/* Sensors detected on all pages */
for (page = 0; page < info->pages; page++) {
Expand Down

0 comments on commit e3bbfa7

Please sign in to comment.