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: (emc1403) Fix I2C address range
hwmon: (lm63) Consider LM64 temperature offset

+48 -13
+1 -1
drivers/hwmon/emc1403.c
··· 344 344 } 345 345 346 346 static const unsigned short emc1403_address_list[] = { 347 - 0x18, 0x2a, 0x4c, 0x4d, I2C_CLIENT_END 347 + 0x18, 0x29, 0x4c, 0x4d, I2C_CLIENT_END 348 348 }; 349 349 350 350 static const struct i2c_device_id emc1403_idtable[] = {
+47 -12
drivers/hwmon/lm63.c
··· 98 98 * value, it uses signed 8-bit values with LSB = 1 degree Celsius. 99 99 * For remote temperature, low and high limits, it uses signed 11-bit values 100 100 * with LSB = 0.125 degree Celsius, left-justified in 16-bit registers. 101 + * For LM64 the actual remote diode temperature is 16 degree Celsius higher 102 + * than the register reading. Remote temperature setpoints have to be 103 + * adapted accordingly. 101 104 */ 102 105 103 106 #define FAN_FROM_REG(reg) ((reg) == 0xFFFC || (reg) == 0 ? 0 : \ ··· 168 165 struct mutex update_lock; 169 166 char valid; /* zero until following fields are valid */ 170 167 unsigned long last_updated; /* in jiffies */ 168 + int kind; 169 + int temp2_offset; 171 170 172 171 /* registers values */ 173 172 u8 config, config_fan; ··· 252 247 return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2); 253 248 } 254 249 255 - static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, 256 - char *buf) 250 + /* 251 + * There are 8bit registers for both local(temp1) and remote(temp2) sensor. 252 + * For remote sensor registers temp2_offset has to be considered, 253 + * for local sensor it must not. 254 + * So we need separate 8bit accessors for local and remote sensor. 255 + */ 256 + static ssize_t show_local_temp8(struct device *dev, 257 + struct device_attribute *devattr, 258 + char *buf) 257 259 { 258 260 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 259 261 struct lm63_data *data = lm63_update_device(dev); 260 262 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[attr->index])); 261 263 } 262 264 263 - static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy, 264 - const char *buf, size_t count) 265 + static ssize_t show_remote_temp8(struct device *dev, 266 + struct device_attribute *devattr, 267 + char *buf) 268 + { 269 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 270 + struct lm63_data *data = lm63_update_device(dev); 271 + return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[attr->index]) 272 + + data->temp2_offset); 273 + } 274 + 275 + static ssize_t set_local_temp8(struct device *dev, 276 + struct device_attribute *dummy, 277 + const char *buf, size_t count) 265 278 { 266 279 struct i2c_client *client = to_i2c_client(dev); 267 280 struct lm63_data *data = i2c_get_clientdata(client); ··· 297 274 { 298 275 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 299 276 struct lm63_data *data = lm63_update_device(dev); 300 - return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->temp11[attr->index])); 277 + return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->temp11[attr->index]) 278 + + data->temp2_offset); 301 279 } 302 280 303 281 static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, ··· 318 294 int nr = attr->index; 319 295 320 296 mutex_lock(&data->update_lock); 321 - data->temp11[nr] = TEMP11_TO_REG(val); 297 + data->temp11[nr] = TEMP11_TO_REG(val - data->temp2_offset); 322 298 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], 323 299 data->temp11[nr] >> 8); 324 300 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], ··· 334 310 { 335 311 struct lm63_data *data = lm63_update_device(dev); 336 312 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[2]) 313 + + data->temp2_offset 337 314 - TEMP8_FROM_REG(data->temp2_crit_hyst)); 338 315 } 339 316 ··· 349 324 long hyst; 350 325 351 326 mutex_lock(&data->update_lock); 352 - hyst = TEMP8_FROM_REG(data->temp8[2]) - val; 327 + hyst = TEMP8_FROM_REG(data->temp8[2]) + data->temp2_offset - val; 353 328 i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, 354 329 HYST_TO_REG(hyst)); 355 330 mutex_unlock(&data->update_lock); ··· 380 355 static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1); 381 356 static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL); 382 357 383 - static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0); 384 - static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8, 385 - set_temp8, 1); 358 + static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_local_temp8, NULL, 0); 359 + static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_local_temp8, 360 + set_local_temp8, 1); 386 361 387 362 static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0); 388 363 static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11, 389 364 set_temp11, 1); 390 365 static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11, 391 366 set_temp11, 2); 392 - static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp8, NULL, 2); 367 + /* 368 + * On LM63, temp2_crit can be set only once, which should be job 369 + * of the bootloader. 370 + */ 371 + static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_remote_temp8, 372 + NULL, 2); 393 373 static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, 394 374 set_temp2_crit_hyst); 395 375 ··· 509 479 data->valid = 0; 510 480 mutex_init(&data->update_lock); 511 481 512 - /* Initialize the LM63 chip */ 482 + /* Set the device type */ 483 + data->kind = id->driver_data; 484 + if (data->kind == lm64) 485 + data->temp2_offset = 16000; 486 + 487 + /* Initialize chip */ 513 488 lm63_init_client(new_client); 514 489 515 490 /* Register sysfs hooks */