[PATCH v1 2/4] x86/fpu/xstate: Simplify xstate_calculate_size()

Chang S. Bae posted 4 patches 2 years, 7 months ago
[PATCH v1 2/4] x86/fpu/xstate: Simplify xstate_calculate_size()
Posted by Chang S. Bae 2 years, 7 months ago
This size calculation code uses xfeatures_get_offset() only for the
compacted format. But, it is capable of handling both formats. Use it
for simpler and more concise code.

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/x86/kernel/fpu/xstate.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 2f03acc47f62..d488621b280e 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -563,14 +563,11 @@ static bool __init check_xstate_against_struct(int nr)
 static unsigned int xstate_calculate_size(u64 xfeatures, bool compacted)
 {
 	unsigned int topmost = fls64(xfeatures) -  1;
-	unsigned int offset = xstate_offsets[topmost];
 
 	if (topmost <= XFEATURE_SSE)
 		return sizeof(struct xregs_state);
 
-	if (compacted)
-		offset = xfeature_get_offset(xfeatures, topmost);
-	return offset + xstate_sizes[topmost];
+	return xfeature_get_offset(xfeatures, topmost) + xstate_sizes[topmost];
 }
 
 /*
-- 
2.34.1