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