From: Mauro Carvalho Chehab Date: Tue, 26 Feb 2013 13:18:35 +0000 (-0300) Subject: edac: replace mc_event_error_type() by a define X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fghes_v5;p=users%2Fmchehab%2Fedac.git edac: replace mc_event_error_type() by a define While this works properly inside the Kernel, when a perf userspace tries to parse the ras:mc_event, it will fail with: function mc_event_error_type not defined That happens because this inline function doesn't exist in userspace. Replace it by a define, to avoid the userspace error as a workaround. This is the second trial of this workaround. On the first trial attempt, a logic similar to this was used: +#define mc_event_error_type(err_type) \ +({ \ + char *__mc_event_err_type; \ + switch (err_type) { \ + case HW_EVENT_ERR_CORRECTED: \ + __mc_event_err_type = "Corrected"; \ + break; \ ... + __mc_event_err_type; \ +}) The above failed, as the trace-cmd parsing library complained with regards to the {} block there. Signed-off-by: Mauro Carvalho Chehab --- diff --git a/include/linux/edac.h b/include/linux/edac.h index 4fd4999ccb5b..f9c148423980 100644 --- a/include/linux/edac.h +++ b/include/linux/edac.h @@ -112,20 +112,25 @@ enum hw_event_mc_err_type { HW_EVENT_ERR_INFO, }; -static inline char *mc_event_error_type(const unsigned int err_type) -{ - switch (err_type) { - case HW_EVENT_ERR_CORRECTED: - return "Corrected"; - case HW_EVENT_ERR_UNCORRECTED: - return "Uncorrected"; - case HW_EVENT_ERR_FATAL: - return "Fatal"; - default: - case HW_EVENT_ERR_INFO: - return "Info"; - } -} +/* + * Convert from hw_event_mc_err_type into an string. + * + * As this macro is used on trace, and userspace uses the format + * definition at [DEBUGFS]/tracing/events/ras/mc_event/format, + * the syntax used here should be very pedantic, otherwise userspace + * won't be able to parse it. Based on previous tests, no inline + * functions nor {} blocks are allowed here. Thankfully, there's + * now only 4 types of errors, so, still not so big to make impossible + * to use this kind of conditional logic. + */ +#define mc_event_error_type(err_type) \ +( (err_type) == HW_EVENT_ERR_CORRECTED ? "Corrected" : \ + ( (err_type) == HW_EVENT_ERR_UNCORRECTED ? "Uncorrected" : \ + ( (err_type) == HW_EVENT_ERR_FATAL ? "Fatal" : \ + "Info" \ + ) \ + ) \ +) /** * enum mem_type - memory types. For a more detailed reference, please see