x86/sgx: Add encls_faulted() helper
[linux-2.6-microblaze.git] / arch / x86 / kernel / cpu / sgx / encls.h
index be5c496..9b20484 100644 (file)
        } while (0);                                                      \
 }
 
+/*
+ * encls_faulted() - Check if an ENCLS leaf faulted given an error code
+ * @ret:       the return value of an ENCLS leaf function call
+ *
+ * Return:
+ * - true:     ENCLS leaf faulted.
+ * - false:    Otherwise.
+ */
+static inline bool encls_faulted(int ret)
+{
+       return ret & ENCLS_FAULT_FLAG;
+}
+
 /**
  * encls_failed() - Check if an ENCLS function failed
  * @ret:       the return value of an ENCLS function call
@@ -50,7 +63,7 @@
  */
 static inline bool encls_failed(int ret)
 {
-       if (ret & ENCLS_FAULT_FLAG)
+       if (encls_faulted(ret))
                return ENCLS_TRAPNR(ret) != X86_TRAP_PF;
 
        return !!ret;