Skip to content

Commit

Permalink
hwmon: Add support for enable attributes to hwmon core
Browse files Browse the repository at this point in the history
The hwmon ABI supports enable attributes since commit fb41a71
("hwmon: Document the sensor enable attribute"), but did not
add support for those attributes to the hwmon core. Do that now.

Since the enable attributes are logically the most important attributes,
they are added as first attribute to the attribute list. Move
hwmon_in_enable from last to first place for consistency.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Guenter Roeck committed Jan 23, 2020
1 parent 266cd58 commit 002c6b5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 7 additions & 1 deletion drivers/hwmon/hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ static const char * const hwmon_chip_attrs[] = {
};

static const char * const hwmon_temp_attr_templates[] = {
[hwmon_temp_enable] = "temp%d_enable",
[hwmon_temp_input] = "temp%d_input",
[hwmon_temp_type] = "temp%d_type",
[hwmon_temp_lcrit] = "temp%d_lcrit",
Expand Down Expand Up @@ -370,6 +371,7 @@ static const char * const hwmon_temp_attr_templates[] = {
};

static const char * const hwmon_in_attr_templates[] = {
[hwmon_in_enable] = "in%d_enable",
[hwmon_in_input] = "in%d_input",
[hwmon_in_min] = "in%d_min",
[hwmon_in_max] = "in%d_max",
Expand All @@ -385,10 +387,10 @@ static const char * const hwmon_in_attr_templates[] = {
[hwmon_in_max_alarm] = "in%d_max_alarm",
[hwmon_in_lcrit_alarm] = "in%d_lcrit_alarm",
[hwmon_in_crit_alarm] = "in%d_crit_alarm",
[hwmon_in_enable] = "in%d_enable",
};

static const char * const hwmon_curr_attr_templates[] = {
[hwmon_curr_enable] = "curr%d_enable",
[hwmon_curr_input] = "curr%d_input",
[hwmon_curr_min] = "curr%d_min",
[hwmon_curr_max] = "curr%d_max",
Expand All @@ -407,6 +409,7 @@ static const char * const hwmon_curr_attr_templates[] = {
};

static const char * const hwmon_power_attr_templates[] = {
[hwmon_power_enable] = "power%d_enable",
[hwmon_power_average] = "power%d_average",
[hwmon_power_average_interval] = "power%d_average_interval",
[hwmon_power_average_interval_max] = "power%d_interval_max",
Expand Down Expand Up @@ -438,11 +441,13 @@ static const char * const hwmon_power_attr_templates[] = {
};

static const char * const hwmon_energy_attr_templates[] = {
[hwmon_energy_enable] = "energy%d_enable",
[hwmon_energy_input] = "energy%d_input",
[hwmon_energy_label] = "energy%d_label",
};

static const char * const hwmon_humidity_attr_templates[] = {
[hwmon_humidity_enable] = "humidity%d_enable",
[hwmon_humidity_input] = "humidity%d_input",
[hwmon_humidity_label] = "humidity%d_label",
[hwmon_humidity_min] = "humidity%d_min",
Expand All @@ -454,6 +459,7 @@ static const char * const hwmon_humidity_attr_templates[] = {
};

static const char * const hwmon_fan_attr_templates[] = {
[hwmon_fan_enable] = "fan%d_enable",
[hwmon_fan_input] = "fan%d_input",
[hwmon_fan_label] = "fan%d_label",
[hwmon_fan_min] = "fan%d_min",
Expand Down
18 changes: 15 additions & 3 deletions include/linux/hwmon.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ enum hwmon_chip_attributes {
#define HWMON_C_TEMP_SAMPLES BIT(hwmon_chip_temp_samples)

enum hwmon_temp_attributes {
hwmon_temp_input = 0,
hwmon_temp_enable,
hwmon_temp_input,
hwmon_temp_type,
hwmon_temp_lcrit,
hwmon_temp_lcrit_hyst,
Expand All @@ -86,6 +87,7 @@ enum hwmon_temp_attributes {
hwmon_temp_reset_history,
};

#define HWMON_T_ENABLE BIT(hwmon_temp_enable)
#define HWMON_T_INPUT BIT(hwmon_temp_input)
#define HWMON_T_TYPE BIT(hwmon_temp_type)
#define HWMON_T_LCRIT BIT(hwmon_temp_lcrit)
Expand All @@ -112,6 +114,7 @@ enum hwmon_temp_attributes {
#define HWMON_T_RESET_HISTORY BIT(hwmon_temp_reset_history)

enum hwmon_in_attributes {
hwmon_in_enable,
hwmon_in_input,
hwmon_in_min,
hwmon_in_max,
Expand All @@ -127,9 +130,9 @@ enum hwmon_in_attributes {
hwmon_in_max_alarm,
hwmon_in_lcrit_alarm,
hwmon_in_crit_alarm,
hwmon_in_enable,
};

#define HWMON_I_ENABLE BIT(hwmon_in_enable)
#define HWMON_I_INPUT BIT(hwmon_in_input)
#define HWMON_I_MIN BIT(hwmon_in_min)
#define HWMON_I_MAX BIT(hwmon_in_max)
Expand All @@ -145,9 +148,9 @@ enum hwmon_in_attributes {
#define HWMON_I_MAX_ALARM BIT(hwmon_in_max_alarm)
#define HWMON_I_LCRIT_ALARM BIT(hwmon_in_lcrit_alarm)
#define HWMON_I_CRIT_ALARM BIT(hwmon_in_crit_alarm)
#define HWMON_I_ENABLE BIT(hwmon_in_enable)

enum hwmon_curr_attributes {
hwmon_curr_enable,
hwmon_curr_input,
hwmon_curr_min,
hwmon_curr_max,
Expand All @@ -165,6 +168,7 @@ enum hwmon_curr_attributes {
hwmon_curr_crit_alarm,
};

#define HWMON_C_ENABLE BIT(hwmon_curr_enable)
#define HWMON_C_INPUT BIT(hwmon_curr_input)
#define HWMON_C_MIN BIT(hwmon_curr_min)
#define HWMON_C_MAX BIT(hwmon_curr_max)
Expand All @@ -182,6 +186,7 @@ enum hwmon_curr_attributes {
#define HWMON_C_CRIT_ALARM BIT(hwmon_curr_crit_alarm)

enum hwmon_power_attributes {
hwmon_power_enable,
hwmon_power_average,
hwmon_power_average_interval,
hwmon_power_average_interval_max,
Expand Down Expand Up @@ -212,6 +217,7 @@ enum hwmon_power_attributes {
hwmon_power_crit_alarm,
};

#define HWMON_P_ENABLE BIT(hwmon_power_enable)
#define HWMON_P_AVERAGE BIT(hwmon_power_average)
#define HWMON_P_AVERAGE_INTERVAL BIT(hwmon_power_average_interval)
#define HWMON_P_AVERAGE_INTERVAL_MAX BIT(hwmon_power_average_interval_max)
Expand Down Expand Up @@ -242,14 +248,17 @@ enum hwmon_power_attributes {
#define HWMON_P_CRIT_ALARM BIT(hwmon_power_crit_alarm)

enum hwmon_energy_attributes {
hwmon_energy_enable,
hwmon_energy_input,
hwmon_energy_label,
};

#define HWMON_E_ENABLE BIT(hwmon_energy_enable)
#define HWMON_E_INPUT BIT(hwmon_energy_input)
#define HWMON_E_LABEL BIT(hwmon_energy_label)

enum hwmon_humidity_attributes {
hwmon_humidity_enable,
hwmon_humidity_input,
hwmon_humidity_label,
hwmon_humidity_min,
Expand All @@ -260,6 +269,7 @@ enum hwmon_humidity_attributes {
hwmon_humidity_fault,
};

#define HWMON_H_ENABLE BIT(hwmon_humidity_enable)
#define HWMON_H_INPUT BIT(hwmon_humidity_input)
#define HWMON_H_LABEL BIT(hwmon_humidity_label)
#define HWMON_H_MIN BIT(hwmon_humidity_min)
Expand All @@ -270,6 +280,7 @@ enum hwmon_humidity_attributes {
#define HWMON_H_FAULT BIT(hwmon_humidity_fault)

enum hwmon_fan_attributes {
hwmon_fan_enable,
hwmon_fan_input,
hwmon_fan_label,
hwmon_fan_min,
Expand All @@ -283,6 +294,7 @@ enum hwmon_fan_attributes {
hwmon_fan_fault,
};

#define HWMON_F_ENABLE BIT(hwmon_fan_enable)
#define HWMON_F_INPUT BIT(hwmon_fan_input)
#define HWMON_F_LABEL BIT(hwmon_fan_label)
#define HWMON_F_MIN BIT(hwmon_fan_min)
Expand Down

0 comments on commit 002c6b5

Please sign in to comment.