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

[PATCH] w83627ehf: Add alarms support

Add alarms support for the W83627EHF/EHG hardware monitoring chip.

This is based on an earlier patch from Rudolf Marek.

Signed-off-by: Rudolf Marek <r.marek@sh.cvut.cz>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Jean Delvare and committed by
Greg Kroah-Hartman
a4589dbb cf0676fe

+46
+46
drivers/hwmon/w83627ehf.c
··· 141 141 #define W83627EHF_REG_DIODE 0x59 142 142 #define W83627EHF_REG_SMI_OVT 0x4C 143 143 144 + #define W83627EHF_REG_ALARM1 0x459 145 + #define W83627EHF_REG_ALARM2 0x45A 146 + #define W83627EHF_REG_ALARM3 0x45B 147 + 144 148 /* 145 149 * Conversions 146 150 */ ··· 222 218 s16 temp[2]; 223 219 s16 temp_max[2]; 224 220 s16 temp_max_hyst[2]; 221 + u32 alarms; 225 222 }; 226 223 227 224 static inline int is_word_sized(u16 reg) ··· 432 427 W83627EHF_REG_TEMP_HYST[i]); 433 428 } 434 429 430 + data->alarms = w83627ehf_read_value(client, 431 + W83627EHF_REG_ALARM1) | 432 + (w83627ehf_read_value(client, 433 + W83627EHF_REG_ALARM2) << 8) | 434 + (w83627ehf_read_value(client, 435 + W83627EHF_REG_ALARM3) << 16); 436 + 435 437 data->last_updated = jiffies; 436 438 data->valid = 1; 437 439 } ··· 486 474 store_in_reg(MIN, min) 487 475 store_in_reg(MAX, max) 488 476 477 + static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, char *buf) 478 + { 479 + struct w83627ehf_data *data = w83627ehf_update_device(dev); 480 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 481 + int nr = sensor_attr->index; 482 + return sprintf(buf, "%u\n", (data->alarms >> nr) & 0x01); 483 + } 484 + 489 485 static struct sensor_device_attribute sda_in_input[] = { 490 486 SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0), 491 487 SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), ··· 505 485 SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), 506 486 SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), 507 487 SENSOR_ATTR(in9_input, S_IRUGO, show_in, NULL, 9), 488 + }; 489 + 490 + static struct sensor_device_attribute sda_in_alarm[] = { 491 + SENSOR_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0), 492 + SENSOR_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1), 493 + SENSOR_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2), 494 + SENSOR_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3), 495 + SENSOR_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8), 496 + SENSOR_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 21), 497 + SENSOR_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 20), 498 + SENSOR_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 16), 499 + SENSOR_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 17), 500 + SENSOR_ATTR(in9_alarm, S_IRUGO, show_alarm, NULL, 19), 508 501 }; 509 502 510 503 static struct sensor_device_attribute sda_in_min[] = { ··· 549 516 static void device_create_file_in(struct device *dev, int i) 550 517 { 551 518 device_create_file(dev, &sda_in_input[i].dev_attr); 519 + device_create_file(dev, &sda_in_alarm[i].dev_attr); 552 520 device_create_file(dev, &sda_in_min[i].dev_attr); 553 521 device_create_file(dev, &sda_in_max[i].dev_attr); 554 522 } ··· 652 618 SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4), 653 619 }; 654 620 621 + static struct sensor_device_attribute sda_fan_alarm[] = { 622 + SENSOR_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6), 623 + SENSOR_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7), 624 + SENSOR_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 11), 625 + SENSOR_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 10), 626 + SENSOR_ATTR(fan5_alarm, S_IRUGO, show_alarm, NULL, 23), 627 + }; 628 + 655 629 static struct sensor_device_attribute sda_fan_min[] = { 656 630 SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, 657 631 store_fan_min, 0), ··· 684 642 static void device_create_file_fan(struct device *dev, int i) 685 643 { 686 644 device_create_file(dev, &sda_fan_input[i].dev_attr); 645 + device_create_file(dev, &sda_fan_alarm[i].dev_attr); 687 646 device_create_file(dev, &sda_fan_div[i].dev_attr); 688 647 device_create_file(dev, &sda_fan_min[i].dev_attr); 689 648 } ··· 772 729 store_temp_max_hyst, 0), 773 730 SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, 774 731 store_temp_max_hyst, 1), 732 + SENSOR_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4), 733 + SENSOR_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5), 734 + SENSOR_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13), 775 735 }; 776 736 777 737 /*