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

hwmon: Add intrusion templates

Add templates for intrusion%d_alarm and intrusion%d_beep.
Note, these start at 0.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Link: https://lore.kernel.org/r/20191124202030.45360-2-linux@treblig.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Dr. David Alan Gilbert and committed by
Guenter Roeck
4413405f 4703d911

+16 -1
+8 -1
drivers/hwmon/hwmon.c
··· 188 188 189 189 static int hwmon_attr_base(enum hwmon_sensor_types type) 190 190 { 191 - if (type == hwmon_in) 191 + if (type == hwmon_in || type == hwmon_intrusion) 192 192 return 0; 193 193 return 1; 194 194 } ··· 474 474 [hwmon_pwm_freq] = "pwm%d_freq", 475 475 }; 476 476 477 + static const char * const hwmon_intrusion_attr_templates[] = { 478 + [hwmon_intrusion_alarm] = "intrusion%d_alarm", 479 + [hwmon_intrusion_beep] = "intrusion%d_beep", 480 + }; 481 + 477 482 static const char * const *__templates[] = { 478 483 [hwmon_chip] = hwmon_chip_attrs, 479 484 [hwmon_temp] = hwmon_temp_attr_templates, ··· 489 484 [hwmon_humidity] = hwmon_humidity_attr_templates, 490 485 [hwmon_fan] = hwmon_fan_attr_templates, 491 486 [hwmon_pwm] = hwmon_pwm_attr_templates, 487 + [hwmon_intrusion] = hwmon_intrusion_attr_templates, 492 488 }; 493 489 494 490 static const int __templates_size[] = { ··· 502 496 [hwmon_humidity] = ARRAY_SIZE(hwmon_humidity_attr_templates), 503 497 [hwmon_fan] = ARRAY_SIZE(hwmon_fan_attr_templates), 504 498 [hwmon_pwm] = ARRAY_SIZE(hwmon_pwm_attr_templates), 499 + [hwmon_intrusion] = ARRAY_SIZE(hwmon_intrusion_attr_templates), 505 500 }; 506 501 507 502 static int hwmon_num_channel_attrs(const struct hwmon_channel_info *info)
+8
include/linux/hwmon.h
··· 27 27 hwmon_humidity, 28 28 hwmon_fan, 29 29 hwmon_pwm, 30 + hwmon_intrusion, 30 31 hwmon_max, 31 32 }; 32 33 ··· 306 305 #define HWMON_PWM_ENABLE BIT(hwmon_pwm_enable) 307 306 #define HWMON_PWM_MODE BIT(hwmon_pwm_mode) 308 307 #define HWMON_PWM_FREQ BIT(hwmon_pwm_freq) 308 + 309 + enum hwmon_intrusion_attributes { 310 + hwmon_intrusion_alarm, 311 + hwmon_intrusion_beep, 312 + }; 313 + #define HWMON_INTRUSION_ALARM BIT(hwmon_intrusion_alarm) 314 + #define HWMON_INTRUSION_BEEP BIT(hwmon_intrusion_beep) 309 315 310 316 /** 311 317 * struct hwmon_ops - hwmon device operations