[xen staging] microcode/intel: use union to get fields without shifting and masking

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen staging] microcode/intel: use union to get fields without shifting and masking

patchbot
commit af9a3de69f8b8e8398fbb8c726598c866ff25aca
Author:     Chao Gao <[hidden email]>
AuthorDate: Mon Mar 11 15:57:26 2019 +0800
Commit:     Wei Liu <[hidden email]>
CommitDate: Tue Mar 12 18:14:25 2019 +0000

    microcode/intel: use union to get fields without shifting and masking
   
    No functional change.
   
    Signed-off-by: Chao Gao <[hidden email]>
    Reviewed-by: Roger Pau Monné <[hidden email]>
    Acked-by: Jan Beulich <[hidden email]>
---
 xen/arch/x86/microcode_intel.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/microcode_intel.c b/xen/arch/x86/microcode_intel.c
index 9657575c29..22fdecae22 100644
--- a/xen/arch/x86/microcode_intel.c
+++ b/xen/arch/x86/microcode_intel.c
@@ -37,7 +37,14 @@
 struct microcode_header_intel {
     unsigned int hdrver;
     unsigned int rev;
-    unsigned int date;
+    union {
+        struct {
+            uint16_t year;
+            uint8_t day;
+            uint8_t month;
+        };
+        unsigned int date;
+    };
     unsigned int sig;
     unsigned int cksum;
     unsigned int ldrver;
@@ -316,9 +323,9 @@ static int apply_microcode(unsigned int cpu)
     printk(KERN_INFO "microcode: CPU%d updated from revision "
            "%#x to %#x, date = %04x-%02x-%02x \n",
            cpu_num, uci->cpu_sig.rev, val[1],
-           uci->mc.mc_intel->hdr.date & 0xffff,
-           uci->mc.mc_intel->hdr.date >> 24,
-           (uci->mc.mc_intel->hdr.date >> 16) & 0xff);
+           uci->mc.mc_intel->hdr.year,
+           uci->mc.mc_intel->hdr.month,
+           uci->mc.mc_intel->hdr.day);
     uci->cpu_sig.rev = val[1];
 
     return 0;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog