xref: /linux/include/linux/hwmon.h (revision 8184f107c1fe860a93ece55d6d5f7cc25af276b9)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3     hwmon.h - part of lm_sensors, Linux kernel modules for hardware monitoring
4 
5     This file declares helper functions for the sysfs class "hwmon",
6     for use by sensors drivers.
7 
8     Copyright (C) 2005 Mark M. Hoffman <mhoffman@lightlink.com>
9 
10 */
11 
12 #ifndef _HWMON_H_
13 #define _HWMON_H_
14 
15 #include <linux/bitops.h>
16 #include <linux/cleanup.h>
17 
18 struct device;
19 struct attribute_group;
20 
21 enum hwmon_sensor_types {
22 	hwmon_chip,
23 	hwmon_temp,
24 	hwmon_in,
25 	hwmon_curr,
26 	hwmon_power,
27 	hwmon_energy,
28 	hwmon_energy64,
29 	hwmon_humidity,
30 	hwmon_fan,
31 	hwmon_pwm,
32 	hwmon_intrusion,
33 	hwmon_max,
34 };
35 
36 enum hwmon_chip_attributes {
37 	hwmon_chip_temp_reset_history,
38 	hwmon_chip_in_reset_history,
39 	hwmon_chip_curr_reset_history,
40 	hwmon_chip_power_reset_history,
41 	hwmon_chip_register_tz,
42 	hwmon_chip_update_interval,
43 	hwmon_chip_update_interval_us,
44 	hwmon_chip_alarms,
45 	hwmon_chip_samples,
46 	hwmon_chip_curr_samples,
47 	hwmon_chip_in_samples,
48 	hwmon_chip_power_samples,
49 	hwmon_chip_temp_samples,
50 	hwmon_chip_beep_enable,
51 	hwmon_chip_pec,
52 };
53 
54 #define HWMON_C_TEMP_RESET_HISTORY	BIT(hwmon_chip_temp_reset_history)
55 #define HWMON_C_IN_RESET_HISTORY	BIT(hwmon_chip_in_reset_history)
56 #define HWMON_C_CURR_RESET_HISTORY	BIT(hwmon_chip_curr_reset_history)
57 #define HWMON_C_POWER_RESET_HISTORY	BIT(hwmon_chip_power_reset_history)
58 #define HWMON_C_REGISTER_TZ		BIT(hwmon_chip_register_tz)
59 #define HWMON_C_UPDATE_INTERVAL		BIT(hwmon_chip_update_interval)
60 #define HWMON_C_UPDATE_INTERVAL_US	BIT(hwmon_chip_update_interval_us)
61 #define HWMON_C_ALARMS			BIT(hwmon_chip_alarms)
62 #define HWMON_C_SAMPLES			BIT(hwmon_chip_samples)
63 #define HWMON_C_CURR_SAMPLES		BIT(hwmon_chip_curr_samples)
64 #define HWMON_C_IN_SAMPLES		BIT(hwmon_chip_in_samples)
65 #define HWMON_C_POWER_SAMPLES		BIT(hwmon_chip_power_samples)
66 #define HWMON_C_TEMP_SAMPLES		BIT(hwmon_chip_temp_samples)
67 #define HWMON_C_BEEP_ENABLE		BIT(hwmon_chip_beep_enable)
68 #define HWMON_C_PEC			BIT(hwmon_chip_pec)
69 
70 enum hwmon_temp_attributes {
71 	hwmon_temp_enable,
72 	hwmon_temp_input,
73 	hwmon_temp_type,
74 	hwmon_temp_lcrit,
75 	hwmon_temp_lcrit_hyst,
76 	hwmon_temp_min,
77 	hwmon_temp_min_hyst,
78 	hwmon_temp_max,
79 	hwmon_temp_max_hyst,
80 	hwmon_temp_crit,
81 	hwmon_temp_crit_hyst,
82 	hwmon_temp_emergency,
83 	hwmon_temp_emergency_hyst,
84 	hwmon_temp_alarm,
85 	hwmon_temp_lcrit_alarm,
86 	hwmon_temp_min_alarm,
87 	hwmon_temp_max_alarm,
88 	hwmon_temp_crit_alarm,
89 	hwmon_temp_emergency_alarm,
90 	hwmon_temp_fault,
91 	hwmon_temp_offset,
92 	hwmon_temp_label,
93 	hwmon_temp_lowest,
94 	hwmon_temp_highest,
95 	hwmon_temp_reset_history,
96 	hwmon_temp_rated_min,
97 	hwmon_temp_rated_max,
98 	hwmon_temp_beep,
99 };
100 
101 #define HWMON_T_ENABLE		BIT(hwmon_temp_enable)
102 #define HWMON_T_INPUT		BIT(hwmon_temp_input)
103 #define HWMON_T_TYPE		BIT(hwmon_temp_type)
104 #define HWMON_T_LCRIT		BIT(hwmon_temp_lcrit)
105 #define HWMON_T_LCRIT_HYST	BIT(hwmon_temp_lcrit_hyst)
106 #define HWMON_T_MIN		BIT(hwmon_temp_min)
107 #define HWMON_T_MIN_HYST	BIT(hwmon_temp_min_hyst)
108 #define HWMON_T_MAX		BIT(hwmon_temp_max)
109 #define HWMON_T_MAX_HYST	BIT(hwmon_temp_max_hyst)
110 #define HWMON_T_CRIT		BIT(hwmon_temp_crit)
111 #define HWMON_T_CRIT_HYST	BIT(hwmon_temp_crit_hyst)
112 #define HWMON_T_EMERGENCY	BIT(hwmon_temp_emergency)
113 #define HWMON_T_EMERGENCY_HYST	BIT(hwmon_temp_emergency_hyst)
114 #define HWMON_T_ALARM		BIT(hwmon_temp_alarm)
115 #define HWMON_T_MIN_ALARM	BIT(hwmon_temp_min_alarm)
116 #define HWMON_T_MAX_ALARM	BIT(hwmon_temp_max_alarm)
117 #define HWMON_T_CRIT_ALARM	BIT(hwmon_temp_crit_alarm)
118 #define HWMON_T_LCRIT_ALARM	BIT(hwmon_temp_lcrit_alarm)
119 #define HWMON_T_EMERGENCY_ALARM	BIT(hwmon_temp_emergency_alarm)
120 #define HWMON_T_FAULT		BIT(hwmon_temp_fault)
121 #define HWMON_T_OFFSET		BIT(hwmon_temp_offset)
122 #define HWMON_T_LABEL		BIT(hwmon_temp_label)
123 #define HWMON_T_LOWEST		BIT(hwmon_temp_lowest)
124 #define HWMON_T_HIGHEST		BIT(hwmon_temp_highest)
125 #define HWMON_T_RESET_HISTORY	BIT(hwmon_temp_reset_history)
126 #define HWMON_T_RATED_MIN	BIT(hwmon_temp_rated_min)
127 #define HWMON_T_RATED_MAX	BIT(hwmon_temp_rated_max)
128 #define HWMON_T_BEEP		BIT(hwmon_temp_beep)
129 
130 enum hwmon_in_attributes {
131 	hwmon_in_enable,
132 	hwmon_in_input,
133 	hwmon_in_min,
134 	hwmon_in_max,
135 	hwmon_in_lcrit,
136 	hwmon_in_crit,
137 	hwmon_in_lemergency,
138 	hwmon_in_emergency,
139 	hwmon_in_average,
140 	hwmon_in_lowest,
141 	hwmon_in_highest,
142 	hwmon_in_reset_history,
143 	hwmon_in_label,
144 	hwmon_in_alarm,
145 	hwmon_in_min_alarm,
146 	hwmon_in_max_alarm,
147 	hwmon_in_lcrit_alarm,
148 	hwmon_in_crit_alarm,
149 	hwmon_in_lemergency_alarm,
150 	hwmon_in_emergency_alarm,
151 	hwmon_in_rated_min,
152 	hwmon_in_rated_max,
153 	hwmon_in_beep,
154 	hwmon_in_fault,
155 };
156 
157 #define HWMON_I_ENABLE		BIT(hwmon_in_enable)
158 #define HWMON_I_INPUT		BIT(hwmon_in_input)
159 #define HWMON_I_MIN		BIT(hwmon_in_min)
160 #define HWMON_I_MAX		BIT(hwmon_in_max)
161 #define HWMON_I_LCRIT		BIT(hwmon_in_lcrit)
162 #define HWMON_I_CRIT		BIT(hwmon_in_crit)
163 #define HWMON_I_LEMERGENCY	BIT(hwmon_in_lemergency)
164 #define HWMON_I_EMERGENCY	BIT(hwmon_in_emergency)
165 #define HWMON_I_AVERAGE		BIT(hwmon_in_average)
166 #define HWMON_I_LOWEST		BIT(hwmon_in_lowest)
167 #define HWMON_I_HIGHEST		BIT(hwmon_in_highest)
168 #define HWMON_I_RESET_HISTORY	BIT(hwmon_in_reset_history)
169 #define HWMON_I_LABEL		BIT(hwmon_in_label)
170 #define HWMON_I_ALARM		BIT(hwmon_in_alarm)
171 #define HWMON_I_MIN_ALARM	BIT(hwmon_in_min_alarm)
172 #define HWMON_I_MAX_ALARM	BIT(hwmon_in_max_alarm)
173 #define HWMON_I_LCRIT_ALARM	BIT(hwmon_in_lcrit_alarm)
174 #define HWMON_I_CRIT_ALARM	BIT(hwmon_in_crit_alarm)
175 #define HWMON_I_LEMERGENCY_ALARM BIT(hwmon_in_lemergency_alarm)
176 #define HWMON_I_EMERGENCY_ALARM	BIT(hwmon_in_emergency_alarm)
177 #define HWMON_I_RATED_MIN	BIT(hwmon_in_rated_min)
178 #define HWMON_I_RATED_MAX	BIT(hwmon_in_rated_max)
179 #define HWMON_I_BEEP		BIT(hwmon_in_beep)
180 #define HWMON_I_FAULT		BIT(hwmon_in_fault)
181 
182 enum hwmon_curr_attributes {
183 	hwmon_curr_enable,
184 	hwmon_curr_input,
185 	hwmon_curr_min,
186 	hwmon_curr_max,
187 	hwmon_curr_lcrit,
188 	hwmon_curr_crit,
189 	hwmon_curr_emergency,
190 	hwmon_curr_average,
191 	hwmon_curr_lowest,
192 	hwmon_curr_highest,
193 	hwmon_curr_reset_history,
194 	hwmon_curr_label,
195 	hwmon_curr_alarm,
196 	hwmon_curr_min_alarm,
197 	hwmon_curr_max_alarm,
198 	hwmon_curr_lcrit_alarm,
199 	hwmon_curr_crit_alarm,
200 	hwmon_curr_emergency_alarm,
201 	hwmon_curr_rated_min,
202 	hwmon_curr_rated_max,
203 	hwmon_curr_beep,
204 };
205 
206 #define HWMON_C_ENABLE		BIT(hwmon_curr_enable)
207 #define HWMON_C_INPUT		BIT(hwmon_curr_input)
208 #define HWMON_C_MIN		BIT(hwmon_curr_min)
209 #define HWMON_C_MAX		BIT(hwmon_curr_max)
210 #define HWMON_C_LCRIT		BIT(hwmon_curr_lcrit)
211 #define HWMON_C_CRIT		BIT(hwmon_curr_crit)
212 #define HWMON_C_EMERGENCY	BIT(hwmon_curr_emergency)
213 #define HWMON_C_AVERAGE		BIT(hwmon_curr_average)
214 #define HWMON_C_LOWEST		BIT(hwmon_curr_lowest)
215 #define HWMON_C_HIGHEST		BIT(hwmon_curr_highest)
216 #define HWMON_C_RESET_HISTORY	BIT(hwmon_curr_reset_history)
217 #define HWMON_C_LABEL		BIT(hwmon_curr_label)
218 #define HWMON_C_ALARM		BIT(hwmon_curr_alarm)
219 #define HWMON_C_MIN_ALARM	BIT(hwmon_curr_min_alarm)
220 #define HWMON_C_MAX_ALARM	BIT(hwmon_curr_max_alarm)
221 #define HWMON_C_LCRIT_ALARM	BIT(hwmon_curr_lcrit_alarm)
222 #define HWMON_C_CRIT_ALARM	BIT(hwmon_curr_crit_alarm)
223 #define HWMON_C_EMERGENCY_ALARM	BIT(hwmon_curr_emergency_alarm)
224 #define HWMON_C_RATED_MIN	BIT(hwmon_curr_rated_min)
225 #define HWMON_C_RATED_MAX	BIT(hwmon_curr_rated_max)
226 #define HWMON_C_BEEP		BIT(hwmon_curr_beep)
227 
228 enum hwmon_power_attributes {
229 	hwmon_power_enable,
230 	hwmon_power_average,
231 	hwmon_power_average_interval,
232 	hwmon_power_average_interval_max,
233 	hwmon_power_average_interval_min,
234 	hwmon_power_average_highest,
235 	hwmon_power_average_lowest,
236 	hwmon_power_average_max,
237 	hwmon_power_average_min,
238 	hwmon_power_input,
239 	hwmon_power_input_highest,
240 	hwmon_power_input_lowest,
241 	hwmon_power_reset_history,
242 	hwmon_power_accuracy,
243 	hwmon_power_cap,
244 	hwmon_power_cap_hyst,
245 	hwmon_power_cap_max,
246 	hwmon_power_cap_min,
247 	hwmon_power_min,
248 	hwmon_power_max,
249 	hwmon_power_crit,
250 	hwmon_power_lcrit,
251 	hwmon_power_label,
252 	hwmon_power_alarm,
253 	hwmon_power_cap_alarm,
254 	hwmon_power_min_alarm,
255 	hwmon_power_max_alarm,
256 	hwmon_power_lcrit_alarm,
257 	hwmon_power_crit_alarm,
258 	hwmon_power_rated_min,
259 	hwmon_power_rated_max,
260 };
261 
262 #define HWMON_P_ENABLE			BIT(hwmon_power_enable)
263 #define HWMON_P_AVERAGE			BIT(hwmon_power_average)
264 #define HWMON_P_AVERAGE_INTERVAL	BIT(hwmon_power_average_interval)
265 #define HWMON_P_AVERAGE_INTERVAL_MAX	BIT(hwmon_power_average_interval_max)
266 #define HWMON_P_AVERAGE_INTERVAL_MIN	BIT(hwmon_power_average_interval_min)
267 #define HWMON_P_AVERAGE_HIGHEST		BIT(hwmon_power_average_highest)
268 #define HWMON_P_AVERAGE_LOWEST		BIT(hwmon_power_average_lowest)
269 #define HWMON_P_AVERAGE_MAX		BIT(hwmon_power_average_max)
270 #define HWMON_P_AVERAGE_MIN		BIT(hwmon_power_average_min)
271 #define HWMON_P_INPUT			BIT(hwmon_power_input)
272 #define HWMON_P_INPUT_HIGHEST		BIT(hwmon_power_input_highest)
273 #define HWMON_P_INPUT_LOWEST		BIT(hwmon_power_input_lowest)
274 #define HWMON_P_RESET_HISTORY		BIT(hwmon_power_reset_history)
275 #define HWMON_P_ACCURACY		BIT(hwmon_power_accuracy)
276 #define HWMON_P_CAP			BIT(hwmon_power_cap)
277 #define HWMON_P_CAP_HYST		BIT(hwmon_power_cap_hyst)
278 #define HWMON_P_CAP_MAX			BIT(hwmon_power_cap_max)
279 #define HWMON_P_CAP_MIN			BIT(hwmon_power_cap_min)
280 #define HWMON_P_MIN			BIT(hwmon_power_min)
281 #define HWMON_P_MAX			BIT(hwmon_power_max)
282 #define HWMON_P_LCRIT			BIT(hwmon_power_lcrit)
283 #define HWMON_P_CRIT			BIT(hwmon_power_crit)
284 #define HWMON_P_LABEL			BIT(hwmon_power_label)
285 #define HWMON_P_ALARM			BIT(hwmon_power_alarm)
286 #define HWMON_P_CAP_ALARM		BIT(hwmon_power_cap_alarm)
287 #define HWMON_P_MIN_ALARM		BIT(hwmon_power_min_alarm)
288 #define HWMON_P_MAX_ALARM		BIT(hwmon_power_max_alarm)
289 #define HWMON_P_LCRIT_ALARM		BIT(hwmon_power_lcrit_alarm)
290 #define HWMON_P_CRIT_ALARM		BIT(hwmon_power_crit_alarm)
291 #define HWMON_P_RATED_MIN		BIT(hwmon_power_rated_min)
292 #define HWMON_P_RATED_MAX		BIT(hwmon_power_rated_max)
293 
294 enum hwmon_energy_attributes {
295 	hwmon_energy_enable,
296 	hwmon_energy_input,
297 	hwmon_energy_label,
298 };
299 
300 #define HWMON_E_ENABLE			BIT(hwmon_energy_enable)
301 #define HWMON_E_INPUT			BIT(hwmon_energy_input)
302 #define HWMON_E_LABEL			BIT(hwmon_energy_label)
303 
304 enum hwmon_humidity_attributes {
305 	hwmon_humidity_enable,
306 	hwmon_humidity_input,
307 	hwmon_humidity_label,
308 	hwmon_humidity_min,
309 	hwmon_humidity_min_hyst,
310 	hwmon_humidity_max,
311 	hwmon_humidity_max_hyst,
312 	hwmon_humidity_alarm,
313 	hwmon_humidity_fault,
314 	hwmon_humidity_rated_min,
315 	hwmon_humidity_rated_max,
316 	hwmon_humidity_min_alarm,
317 	hwmon_humidity_max_alarm,
318 };
319 
320 #define HWMON_H_ENABLE			BIT(hwmon_humidity_enable)
321 #define HWMON_H_INPUT			BIT(hwmon_humidity_input)
322 #define HWMON_H_LABEL			BIT(hwmon_humidity_label)
323 #define HWMON_H_MIN			BIT(hwmon_humidity_min)
324 #define HWMON_H_MIN_HYST		BIT(hwmon_humidity_min_hyst)
325 #define HWMON_H_MAX			BIT(hwmon_humidity_max)
326 #define HWMON_H_MAX_HYST		BIT(hwmon_humidity_max_hyst)
327 #define HWMON_H_ALARM			BIT(hwmon_humidity_alarm)
328 #define HWMON_H_FAULT			BIT(hwmon_humidity_fault)
329 #define HWMON_H_RATED_MIN		BIT(hwmon_humidity_rated_min)
330 #define HWMON_H_RATED_MAX		BIT(hwmon_humidity_rated_max)
331 #define HWMON_H_MIN_ALARM		BIT(hwmon_humidity_min_alarm)
332 #define HWMON_H_MAX_ALARM		BIT(hwmon_humidity_max_alarm)
333 
334 enum hwmon_fan_attributes {
335 	hwmon_fan_enable,
336 	hwmon_fan_input,
337 	hwmon_fan_label,
338 	hwmon_fan_min,
339 	hwmon_fan_max,
340 	hwmon_fan_div,
341 	hwmon_fan_pulses,
342 	hwmon_fan_target,
343 	hwmon_fan_alarm,
344 	hwmon_fan_min_alarm,
345 	hwmon_fan_max_alarm,
346 	hwmon_fan_fault,
347 	hwmon_fan_beep,
348 };
349 
350 #define HWMON_F_ENABLE			BIT(hwmon_fan_enable)
351 #define HWMON_F_INPUT			BIT(hwmon_fan_input)
352 #define HWMON_F_LABEL			BIT(hwmon_fan_label)
353 #define HWMON_F_MIN			BIT(hwmon_fan_min)
354 #define HWMON_F_MAX			BIT(hwmon_fan_max)
355 #define HWMON_F_DIV			BIT(hwmon_fan_div)
356 #define HWMON_F_PULSES			BIT(hwmon_fan_pulses)
357 #define HWMON_F_TARGET			BIT(hwmon_fan_target)
358 #define HWMON_F_ALARM			BIT(hwmon_fan_alarm)
359 #define HWMON_F_MIN_ALARM		BIT(hwmon_fan_min_alarm)
360 #define HWMON_F_MAX_ALARM		BIT(hwmon_fan_max_alarm)
361 #define HWMON_F_FAULT			BIT(hwmon_fan_fault)
362 #define HWMON_F_BEEP			BIT(hwmon_fan_beep)
363 
364 enum hwmon_pwm_attributes {
365 	hwmon_pwm_input,
366 	hwmon_pwm_enable,
367 	hwmon_pwm_mode,
368 	hwmon_pwm_freq,
369 	hwmon_pwm_auto_channels_temp,
370 };
371 
372 #define HWMON_PWM_INPUT			BIT(hwmon_pwm_input)
373 #define HWMON_PWM_ENABLE		BIT(hwmon_pwm_enable)
374 #define HWMON_PWM_MODE			BIT(hwmon_pwm_mode)
375 #define HWMON_PWM_FREQ			BIT(hwmon_pwm_freq)
376 #define HWMON_PWM_AUTO_CHANNELS_TEMP	BIT(hwmon_pwm_auto_channels_temp)
377 
378 enum hwmon_intrusion_attributes {
379 	hwmon_intrusion_alarm,
380 	hwmon_intrusion_beep,
381 };
382 #define HWMON_INTRUSION_ALARM		BIT(hwmon_intrusion_alarm)
383 #define HWMON_INTRUSION_BEEP		BIT(hwmon_intrusion_beep)
384 
385 /**
386  * struct hwmon_ops - hwmon device operations
387  * @visible:	Static visibility. If non-zero, 'is_visible' is ignored.
388  * @is_visible: Callback to return attribute visibility. Mandatory unless
389  *		'visible' is non-zero.
390  *		Parameters are:
391  *		@const void *drvdata:
392  *			Pointer to driver-private data structure passed
393  *			as argument to hwmon_device_register_with_info().
394  *		@type:	Sensor type
395  *		@attr:	Sensor attribute
396  *		@channel:
397  *			Channel number
398  *		The function returns the file permissions.
399  *		If the return value is 0, no attribute will be created.
400  * @read:	Read callback for data attributes. Mandatory if readable
401  *		data attributes are present.
402  *		Parameters are:
403  *		@dev:	Pointer to hardware monitoring device
404  *		@type:	Sensor type
405  *		@attr:	Sensor attribute
406  *		@channel:
407  *			Channel number
408  *		@val:	Pointer to returned value
409  *		The function returns 0 on success or a negative error number.
410  * @read_string:
411  *		Read callback for string attributes. Mandatory if string
412  *		attributes are present.
413  *		Parameters are:
414  *		@dev:	Pointer to hardware monitoring device
415  *		@type:	Sensor type
416  *		@attr:	Sensor attribute
417  *		@channel:
418  *			Channel number
419  *		@str:	Pointer to returned string
420  *		The function returns 0 on success or a negative error number.
421  * @write:	Write callback for data attributes. Mandatory if writeable
422  *		data attributes are present.
423  *		Parameters are:
424  *		@dev:	Pointer to hardware monitoring device
425  *		@type:	Sensor type
426  *		@attr:	Sensor attribute
427  *		@channel:
428  *			Channel number
429  *		@val:	Value to write
430  *		The function returns 0 on success or a negative error number.
431  */
432 struct hwmon_ops {
433 	umode_t visible;
434 	umode_t (*is_visible)(const void *drvdata, enum hwmon_sensor_types type,
435 			      u32 attr, int channel);
436 	int (*read)(struct device *dev, enum hwmon_sensor_types type,
437 		    u32 attr, int channel, long *val);
438 	int (*read_string)(struct device *dev, enum hwmon_sensor_types type,
439 		    u32 attr, int channel, const char **str);
440 	int (*write)(struct device *dev, enum hwmon_sensor_types type,
441 		     u32 attr, int channel, long val);
442 };
443 
444 /**
445  * struct hwmon_channel_info - Channel information
446  * @type:	Channel type.
447  * @config:	Pointer to NULL-terminated list of channel parameters.
448  *		Use for per-channel attributes.
449  */
450 struct hwmon_channel_info {
451 	enum hwmon_sensor_types type;
452 	const u32 *config;
453 };
454 
455 #define HWMON_CHANNEL_INFO(stype, ...)		\
456 	(&(const struct hwmon_channel_info) {	\
457 		.type = hwmon_##stype,		\
458 		.config = (const u32 []) {	\
459 			__VA_ARGS__, 0		\
460 		}				\
461 	})
462 
463 /**
464  * struct hwmon_chip_info - Chip configuration
465  * @ops:	Pointer to hwmon operations.
466  * @info:	Null-terminated list of channel information.
467  */
468 struct hwmon_chip_info {
469 	const struct hwmon_ops *ops;
470 	const struct hwmon_channel_info * const *info;
471 };
472 
473 /* hwmon_device_register() is deprecated */
474 struct device *hwmon_device_register(struct device *dev);
475 
476 /*
477  * hwmon_device_register_with_groups() and
478  * devm_hwmon_device_register_with_groups() are deprecated.
479  */
480 struct device *
481 hwmon_device_register_with_groups(struct device *dev, const char *name,
482 				  void *drvdata,
483 				  const struct attribute_group **groups);
484 struct device *
485 devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
486 				       void *drvdata,
487 				       const struct attribute_group **groups);
488 struct device *
489 hwmon_device_register_with_info(struct device *dev,
490 				const char *name, void *drvdata,
491 				const struct hwmon_chip_info *info,
492 				const struct attribute_group **extra_groups);
493 struct device *
494 hwmon_device_register_for_thermal(struct device *dev, const char *name,
495 				  void *drvdata);
496 struct device *
497 devm_hwmon_device_register_with_info(struct device *dev,
498 				const char *name, void *drvdata,
499 				const struct hwmon_chip_info *info,
500 				const struct attribute_group **extra_groups);
501 
502 void hwmon_device_unregister(struct device *dev);
503 
504 int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type,
505 		       u32 attr, int channel);
506 
507 char *hwmon_sanitize_name(const char *name);
508 char *devm_hwmon_sanitize_name(struct device *dev, const char *name);
509 
510 void hwmon_lock(struct device *dev);
511 void hwmon_unlock(struct device *dev);
512 
513 DEFINE_GUARD(hwmon_lock, struct device *, hwmon_lock(_T), hwmon_unlock(_T))
514 
515 /**
516  * hwmon_is_bad_char - Is the char invalid in a hwmon name
517  * @ch: the char to be considered
518  *
519  * hwmon_is_bad_char() can be used to determine if the given character
520  * may not be used in a hwmon name.
521  *
522  * Returns true if the char is invalid, false otherwise.
523  */
524 static inline bool hwmon_is_bad_char(const char ch)
525 {
526 	switch (ch) {
527 	case '-':
528 	case '*':
529 	case ' ':
530 	case '\t':
531 	case '\n':
532 		return true;
533 	default:
534 		return false;
535 	}
536 }
537 
538 #endif
539