Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/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

+21 -12
+15 -7
drivers/hwmon/lm95241.c
··· 98 98 }; 99 99 100 100 /* Conversions */ 101 - static int TempFromReg(u8 val_h, u8 val_l) 101 + static int temp_from_reg_signed(u8 val_h, u8 val_l) 102 102 { 103 - if (val_h & 0x80) 104 - return val_h - 0x100; 105 - return val_h * 1000 + val_l * 1000 / 256; 103 + s16 val_hl = (val_h << 8) | val_l; 104 + return val_hl * 1000 / 256; 105 + } 106 + 107 + static int temp_from_reg_unsigned(u8 val_h, u8 val_l) 108 + { 109 + u16 val_hl = (val_h << 8) | val_l; 110 + return val_hl * 1000 / 256; 106 111 } 107 112 108 113 static struct lm95241_data *lm95241_update_device(struct device *dev) ··· 140 135 char *buf) 141 136 { 142 137 struct lm95241_data *data = lm95241_update_device(dev); 138 + int index = to_sensor_dev_attr(attr)->index; 143 139 144 140 return snprintf(buf, PAGE_SIZE - 1, "%d\n", 145 - TempFromReg(data->temp[to_sensor_dev_attr(attr)->index], 146 - data->temp[to_sensor_dev_attr(attr)->index + 1])); 141 + index == 0 || (data->config & (1 << (index / 2))) ? 142 + temp_from_reg_signed(data->temp[index], data->temp[index + 1]) : 143 + temp_from_reg_unsigned(data->temp[index], 144 + data->temp[index + 1])); 147 145 } 148 146 149 147 static ssize_t show_type(struct device *dev, struct device_attribute *attr, ··· 347 339 if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID) 348 340 == MANUFACTURER_ID) 349 341 && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) 350 - >= DEFAULT_REVISION)) { 342 + == DEFAULT_REVISION)) { 351 343 name = DEVNAME; 352 344 } else { 353 345 dev_dbg(&adapter->dev, "LM95241 detection failed at 0x%02x\n",
+6 -5
drivers/hwmon/pmbus.c
··· 59 59 if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34)) 60 60 info->func[0] |= PMBUS_HAVE_STATUS_FAN34; 61 61 } 62 - if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_1)) { 62 + if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_1)) 63 63 info->func[0] |= PMBUS_HAVE_TEMP; 64 - if (pmbus_check_byte_register(client, 0, 65 - PMBUS_STATUS_TEMPERATURE)) 66 - info->func[0] |= PMBUS_HAVE_STATUS_TEMP; 67 - } 68 64 if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_2)) 69 65 info->func[0] |= PMBUS_HAVE_TEMP2; 70 66 if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_3)) 71 67 info->func[0] |= PMBUS_HAVE_TEMP3; 68 + if (info->func[0] & (PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 69 + | PMBUS_HAVE_TEMP3) 70 + && pmbus_check_byte_register(client, 0, 71 + PMBUS_STATUS_TEMPERATURE)) 72 + info->func[0] |= PMBUS_HAVE_STATUS_TEMP; 72 73 73 74 /* Sensors detected on all pages */ 74 75 for (page = 0; page < info->pages; page++) {