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