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

hwmon: Add support for enable attributes to hwmon core

The hwmon ABI supports enable attributes since commit fb41a710f84e
("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>

+22 -4
+7 -1
drivers/hwmon/hwmon.c
··· 343 343 }; 344 344 345 345 static const char * const hwmon_temp_attr_templates[] = { 346 + [hwmon_temp_enable] = "temp%d_enable", 346 347 [hwmon_temp_input] = "temp%d_input", 347 348 [hwmon_temp_type] = "temp%d_type", 348 349 [hwmon_temp_lcrit] = "temp%d_lcrit", ··· 371 370 }; 372 371 373 372 static const char * const hwmon_in_attr_templates[] = { 373 + [hwmon_in_enable] = "in%d_enable", 374 374 [hwmon_in_input] = "in%d_input", 375 375 [hwmon_in_min] = "in%d_min", 376 376 [hwmon_in_max] = "in%d_max", ··· 387 385 [hwmon_in_max_alarm] = "in%d_max_alarm", 388 386 [hwmon_in_lcrit_alarm] = "in%d_lcrit_alarm", 389 387 [hwmon_in_crit_alarm] = "in%d_crit_alarm", 390 - [hwmon_in_enable] = "in%d_enable", 391 388 }; 392 389 393 390 static const char * const hwmon_curr_attr_templates[] = { 391 + [hwmon_curr_enable] = "curr%d_enable", 394 392 [hwmon_curr_input] = "curr%d_input", 395 393 [hwmon_curr_min] = "curr%d_min", 396 394 [hwmon_curr_max] = "curr%d_max", ··· 409 407 }; 410 408 411 409 static const char * const hwmon_power_attr_templates[] = { 410 + [hwmon_power_enable] = "power%d_enable", 412 411 [hwmon_power_average] = "power%d_average", 413 412 [hwmon_power_average_interval] = "power%d_average_interval", 414 413 [hwmon_power_average_interval_max] = "power%d_interval_max", ··· 441 438 }; 442 439 443 440 static const char * const hwmon_energy_attr_templates[] = { 441 + [hwmon_energy_enable] = "energy%d_enable", 444 442 [hwmon_energy_input] = "energy%d_input", 445 443 [hwmon_energy_label] = "energy%d_label", 446 444 }; 447 445 448 446 static const char * const hwmon_humidity_attr_templates[] = { 447 + [hwmon_humidity_enable] = "humidity%d_enable", 449 448 [hwmon_humidity_input] = "humidity%d_input", 450 449 [hwmon_humidity_label] = "humidity%d_label", 451 450 [hwmon_humidity_min] = "humidity%d_min", ··· 459 454 }; 460 455 461 456 static const char * const hwmon_fan_attr_templates[] = { 457 + [hwmon_fan_enable] = "fan%d_enable", 462 458 [hwmon_fan_input] = "fan%d_input", 463 459 [hwmon_fan_label] = "fan%d_label", 464 460 [hwmon_fan_min] = "fan%d_min",
+15 -3
include/linux/hwmon.h
··· 60 60 #define HWMON_C_TEMP_SAMPLES BIT(hwmon_chip_temp_samples) 61 61 62 62 enum hwmon_temp_attributes { 63 - hwmon_temp_input = 0, 63 + hwmon_temp_enable, 64 + hwmon_temp_input, 64 65 hwmon_temp_type, 65 66 hwmon_temp_lcrit, 66 67 hwmon_temp_lcrit_hyst, ··· 87 86 hwmon_temp_reset_history, 88 87 }; 89 88 89 + #define HWMON_T_ENABLE BIT(hwmon_temp_enable) 90 90 #define HWMON_T_INPUT BIT(hwmon_temp_input) 91 91 #define HWMON_T_TYPE BIT(hwmon_temp_type) 92 92 #define HWMON_T_LCRIT BIT(hwmon_temp_lcrit) ··· 114 112 #define HWMON_T_RESET_HISTORY BIT(hwmon_temp_reset_history) 115 113 116 114 enum hwmon_in_attributes { 115 + hwmon_in_enable, 117 116 hwmon_in_input, 118 117 hwmon_in_min, 119 118 hwmon_in_max, ··· 130 127 hwmon_in_max_alarm, 131 128 hwmon_in_lcrit_alarm, 132 129 hwmon_in_crit_alarm, 133 - hwmon_in_enable, 134 130 }; 135 131 132 + #define HWMON_I_ENABLE BIT(hwmon_in_enable) 136 133 #define HWMON_I_INPUT BIT(hwmon_in_input) 137 134 #define HWMON_I_MIN BIT(hwmon_in_min) 138 135 #define HWMON_I_MAX BIT(hwmon_in_max) ··· 148 145 #define HWMON_I_MAX_ALARM BIT(hwmon_in_max_alarm) 149 146 #define HWMON_I_LCRIT_ALARM BIT(hwmon_in_lcrit_alarm) 150 147 #define HWMON_I_CRIT_ALARM BIT(hwmon_in_crit_alarm) 151 - #define HWMON_I_ENABLE BIT(hwmon_in_enable) 152 148 153 149 enum hwmon_curr_attributes { 150 + hwmon_curr_enable, 154 151 hwmon_curr_input, 155 152 hwmon_curr_min, 156 153 hwmon_curr_max, ··· 168 165 hwmon_curr_crit_alarm, 169 166 }; 170 167 168 + #define HWMON_C_ENABLE BIT(hwmon_curr_enable) 171 169 #define HWMON_C_INPUT BIT(hwmon_curr_input) 172 170 #define HWMON_C_MIN BIT(hwmon_curr_min) 173 171 #define HWMON_C_MAX BIT(hwmon_curr_max) ··· 186 182 #define HWMON_C_CRIT_ALARM BIT(hwmon_curr_crit_alarm) 187 183 188 184 enum hwmon_power_attributes { 185 + hwmon_power_enable, 189 186 hwmon_power_average, 190 187 hwmon_power_average_interval, 191 188 hwmon_power_average_interval_max, ··· 217 212 hwmon_power_crit_alarm, 218 213 }; 219 214 215 + #define HWMON_P_ENABLE BIT(hwmon_power_enable) 220 216 #define HWMON_P_AVERAGE BIT(hwmon_power_average) 221 217 #define HWMON_P_AVERAGE_INTERVAL BIT(hwmon_power_average_interval) 222 218 #define HWMON_P_AVERAGE_INTERVAL_MAX BIT(hwmon_power_average_interval_max) ··· 248 242 #define HWMON_P_CRIT_ALARM BIT(hwmon_power_crit_alarm) 249 243 250 244 enum hwmon_energy_attributes { 245 + hwmon_energy_enable, 251 246 hwmon_energy_input, 252 247 hwmon_energy_label, 253 248 }; 254 249 250 + #define HWMON_E_ENABLE BIT(hwmon_energy_enable) 255 251 #define HWMON_E_INPUT BIT(hwmon_energy_input) 256 252 #define HWMON_E_LABEL BIT(hwmon_energy_label) 257 253 258 254 enum hwmon_humidity_attributes { 255 + hwmon_humidity_enable, 259 256 hwmon_humidity_input, 260 257 hwmon_humidity_label, 261 258 hwmon_humidity_min, ··· 269 260 hwmon_humidity_fault, 270 261 }; 271 262 263 + #define HWMON_H_ENABLE BIT(hwmon_humidity_enable) 272 264 #define HWMON_H_INPUT BIT(hwmon_humidity_input) 273 265 #define HWMON_H_LABEL BIT(hwmon_humidity_label) 274 266 #define HWMON_H_MIN BIT(hwmon_humidity_min) ··· 280 270 #define HWMON_H_FAULT BIT(hwmon_humidity_fault) 281 271 282 272 enum hwmon_fan_attributes { 273 + hwmon_fan_enable, 283 274 hwmon_fan_input, 284 275 hwmon_fan_label, 285 276 hwmon_fan_min, ··· 294 283 hwmon_fan_fault, 295 284 }; 296 285 286 + #define HWMON_F_ENABLE BIT(hwmon_fan_enable) 297 287 #define HWMON_F_INPUT BIT(hwmon_fan_input) 298 288 #define HWMON_F_LABEL BIT(hwmon_fan_label) 299 289 #define HWMON_F_MIN BIT(hwmon_fan_min)