Skip to content

Commit

Permalink
hwmon: Add intrusion templates
Browse files Browse the repository at this point in the history
Add templates for intrusion%d_alarm and intrusion%d_beep.
Note, these start at 0.

Signed-off-by: Dr. David Alan Gilbert <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Guenter Roeck <[email protected]>
  • Loading branch information
Dr. David Alan Gilbert authored and groeck committed Jan 23, 2020
1 parent 4703d91 commit 4413405
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/hwmon/hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static int hwmon_thermal_add_sensor(struct device *dev, int index)

static int hwmon_attr_base(enum hwmon_sensor_types type)
{
if (type == hwmon_in)
if (type == hwmon_in || type == hwmon_intrusion)
return 0;
return 1;
}
Expand Down Expand Up @@ -474,6 +474,11 @@ static const char * const hwmon_pwm_attr_templates[] = {
[hwmon_pwm_freq] = "pwm%d_freq",
};

static const char * const hwmon_intrusion_attr_templates[] = {
[hwmon_intrusion_alarm] = "intrusion%d_alarm",
[hwmon_intrusion_beep] = "intrusion%d_beep",
};

static const char * const *__templates[] = {
[hwmon_chip] = hwmon_chip_attrs,
[hwmon_temp] = hwmon_temp_attr_templates,
Expand All @@ -484,6 +489,7 @@ static const char * const *__templates[] = {
[hwmon_humidity] = hwmon_humidity_attr_templates,
[hwmon_fan] = hwmon_fan_attr_templates,
[hwmon_pwm] = hwmon_pwm_attr_templates,
[hwmon_intrusion] = hwmon_intrusion_attr_templates,
};

static const int __templates_size[] = {
Expand All @@ -496,6 +502,7 @@ static const int __templates_size[] = {
[hwmon_humidity] = ARRAY_SIZE(hwmon_humidity_attr_templates),
[hwmon_fan] = ARRAY_SIZE(hwmon_fan_attr_templates),
[hwmon_pwm] = ARRAY_SIZE(hwmon_pwm_attr_templates),
[hwmon_intrusion] = ARRAY_SIZE(hwmon_intrusion_attr_templates),
};

static int hwmon_num_channel_attrs(const struct hwmon_channel_info *info)
Expand Down
8 changes: 8 additions & 0 deletions include/linux/hwmon.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum hwmon_sensor_types {
hwmon_humidity,
hwmon_fan,
hwmon_pwm,
hwmon_intrusion,
hwmon_max,
};

Expand Down Expand Up @@ -306,6 +307,13 @@ enum hwmon_pwm_attributes {
#define HWMON_PWM_MODE BIT(hwmon_pwm_mode)
#define HWMON_PWM_FREQ BIT(hwmon_pwm_freq)

enum hwmon_intrusion_attributes {
hwmon_intrusion_alarm,
hwmon_intrusion_beep,
};
#define HWMON_INTRUSION_ALARM BIT(hwmon_intrusion_alarm)
#define HWMON_INTRUSION_BEEP BIT(hwmon_intrusion_beep)

/**
* struct hwmon_ops - hwmon device operations
* @is_visible: Callback to return attribute visibility. Mandatory.
Expand Down

0 comments on commit 4413405

Please sign in to comment.