-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hwmon: (core) Add trace events to _attr_show/store functions
Trace events are useful for people who collect data from the Ftrace outputs. There're people who analyse the relationship of cpufreq, thermal and hwmon (power/voltage/current) using the convenient and timestamped Ftrace outputs, while unlike cpufreq and thermal subsystems the hwmon does not have trace events supported yet. So this patch adds initial trace events for the hwmon core. To call hwmon_attr_base() for aligned attr index numbers, it also moves the function upward. Ftrace outputs: ...: hwmon_attr_show_string: index=2, attr_name=in2_label, val=VDD_5V ...: hwmon_attr_show: index=2, attr_name=in2_input, val=5112 ...: hwmon_attr_show: index=2, attr_name=curr2_input, val=440 Note that the _attr_show and _attr_store functions are tied to the _with_info API. So a hwmon driver requiring the trace events feature should use _with_info API to register a hwmon device. Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
- Loading branch information
Nicolin Chen
authored and
Guenter Roeck
committed
Oct 12, 2018
1 parent
d4b0166
commit 61b8ab2
Showing
3 changed files
with
92 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#undef TRACE_SYSTEM | ||
#define TRACE_SYSTEM hwmon | ||
|
||
#if !defined(_TRACE_HWMON_H) || defined(TRACE_HEADER_MULTI_READ) | ||
#define _TRACE_HWMON_H | ||
|
||
#include <linux/tracepoint.h> | ||
|
||
DECLARE_EVENT_CLASS(hwmon_attr_class, | ||
|
||
TP_PROTO(int index, const char *attr_name, long val), | ||
|
||
TP_ARGS(index, attr_name, val), | ||
|
||
TP_STRUCT__entry( | ||
__field(int, index) | ||
__string(attr_name, attr_name) | ||
__field(long, val) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->index = index; | ||
__assign_str(attr_name, attr_name); | ||
__entry->val = val; | ||
), | ||
|
||
TP_printk("index=%d, attr_name=%s, val=%ld", | ||
__entry->index, __get_str(attr_name), __entry->val) | ||
); | ||
|
||
DEFINE_EVENT(hwmon_attr_class, hwmon_attr_show, | ||
|
||
TP_PROTO(int index, const char *attr_name, long val), | ||
|
||
TP_ARGS(index, attr_name, val) | ||
); | ||
|
||
DEFINE_EVENT(hwmon_attr_class, hwmon_attr_store, | ||
|
||
TP_PROTO(int index, const char *attr_name, long val), | ||
|
||
TP_ARGS(index, attr_name, val) | ||
); | ||
|
||
TRACE_EVENT(hwmon_attr_show_string, | ||
|
||
TP_PROTO(int index, const char *attr_name, const char *s), | ||
|
||
TP_ARGS(index, attr_name, s), | ||
|
||
TP_STRUCT__entry( | ||
__field(int, index) | ||
__string(attr_name, attr_name) | ||
__string(label, s) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->index = index; | ||
__assign_str(attr_name, attr_name); | ||
__assign_str(label, s); | ||
), | ||
|
||
TP_printk("index=%d, attr_name=%s, val=%s", | ||
__entry->index, __get_str(attr_name), __get_str(label)) | ||
); | ||
|
||
#endif /* _TRACE_HWMON_H */ | ||
|
||
/* This part must be outside protection */ | ||
#include <trace/define_trace.h> |