Merge tag 'v6.4-p1' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[linux-2.6-microblaze.git] / drivers / crypto / ccp / sev-dev.c
index e346c00..b1f3327 100644 (file)
@@ -7,6 +7,7 @@
  * Author: Brijesh Singh <brijesh.singh@amd.com>
  */
 
+#include <linux/bitfield.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/kthread.h>
@@ -24,6 +25,7 @@
 #include <linux/cpufeature.h>
 #include <linux/fs.h>
 #include <linux/fs_struct.h>
+#include <linux/psp.h>
 
 #include <asm/smp.h>
 #include <asm/cacheflush.h>
@@ -102,7 +104,7 @@ static void sev_irq_handler(int irq, void *data, unsigned int status)
 
        /* Check if it is SEV command completion: */
        reg = ioread32(sev->io_regs + sev->vdata->cmdresp_reg);
-       if (reg & PSP_CMDRESP_RESP) {
+       if (FIELD_GET(PSP_CMDRESP_RESP, reg)) {
                sev->int_rcvd = 1;
                wake_up(&sev->int_queue);
        }
@@ -346,9 +348,7 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
 
        sev->int_rcvd = 0;
 
-       reg = cmd;
-       reg <<= SEV_CMDRESP_CMD_SHIFT;
-       reg |= SEV_CMDRESP_IOC;
+       reg = FIELD_PREP(SEV_CMDRESP_CMD, cmd) | SEV_CMDRESP_IOC;
        iowrite32(reg, sev->io_regs + sev->vdata->cmdresp_reg);
 
        /* wait for command completion */
@@ -366,11 +366,11 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
        psp_timeout = psp_cmd_timeout;
 
        if (psp_ret)
-               *psp_ret = reg & PSP_CMDRESP_ERR_MASK;
+               *psp_ret = FIELD_GET(PSP_CMDRESP_STS, reg);
 
-       if (reg & PSP_CMDRESP_ERR_MASK) {
-               dev_dbg(sev->dev, "sev command %#x failed (%#010x)\n",
-                       cmd, reg & PSP_CMDRESP_ERR_MASK);
+       if (FIELD_GET(PSP_CMDRESP_STS, reg)) {
+               dev_dbg(sev->dev, "sev command %#x failed (%#010lx)\n",
+                       cmd, FIELD_GET(PSP_CMDRESP_STS, reg));
                ret = -EIO;
        } else {
                ret = sev_write_init_ex_file_if_required(cmd);