Blob Blame History Raw
From: Harald Freudenberger <freude@linux.ibm.com>
Subject: s390/zcrypt: Rework struct ap_qact_ap_info.
Patch-mainline: v4.15-rc1
Git-commit: 56c5c6834e330caca7584445f4dc103515eb7175
References: FATE#325689, LTC#167899, bsc#1113520

Summary:     zcrypt: AP bus support for alternate driver(s)
Description: AP bus support for alternate driver(s) and deterministic
             driver binding. For details please read the patch header
             for commit 7e0bdbe5c21cb8316a694e46ad5aad339f6894a6

Upstream-Description:

             s390/zcrypt: Rework struct ap_qact_ap_info.

             The ap_qact_ap_info struct can get more easy handled when the fields
             in there can be accessed by their names but also the struct as a whole
             with just an unsigned long value. This patch reworks this struct to be
             a union and adapt the using code accordingly.

             Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
             Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Acked-by: Petr Tesarik <ptesarik@suse.com>
---
 drivers/s390/crypto/ap_asm.h |   40 ++++++++++++++++++++--------------------
 drivers/s390/crypto/ap_bus.c |    2 +-
 2 files changed, 21 insertions(+), 21 deletions(-)

--- a/drivers/s390/crypto/ap_asm.h
+++ b/drivers/s390/crypto/ap_asm.h
@@ -117,45 +117,45 @@ static inline int ap_qci(void *config)
 }
 
 /*
- * struct ap_qact_ap_info - used together with the
+ * union ap_qact_ap_info - used together with the
  * ap_aqic() function to provide a convenient way
  * to handle the ap info needed by the qact function.
  */
-struct ap_qact_ap_info {
-	unsigned int _res1   : 3;
-	unsigned int mode    : 3;
-	unsigned int _res2   : 26;
-	unsigned int cat     : 8;
-	unsigned int _res3   : 8;
-	unsigned char ver[2];
+union ap_qact_ap_info {
+	unsigned long val;
+	struct {
+		unsigned int	  : 3;
+		unsigned int mode : 3;
+		unsigned int	  : 26;
+		unsigned int cat  : 8;
+		unsigned int	  : 8;
+		unsigned char ver[2];
+	};
 };
 
 /**
  * ap_qact(): Query AP combatibility type.
  * @qid: The AP queue number
- * @apinfo: On input the info about the AP queue (content of GR1
- *	    according to the AR). On output the alternate AP queue
- *	    info provided by the qact function in GR2 is stored in.
+ * @apinfo: On input the info about the AP queue. On output the
+ *	    alternate AP queue info provided by the qact function
+ *	    in GR2 is stored in.
  *
  * Returns AP queue status. Check response_code field for failures.
  */
 static inline struct ap_queue_status ap_qact(ap_qid_t qid, int ifbit,
-					     struct ap_qact_ap_info *apinfo)
+					     union ap_qact_ap_info *apinfo)
 {
 	register unsigned long reg0 asm ("0") = qid | (5UL << 24)
 		| ((ifbit & 0x01) << 22);
-	register struct ap_qact_ap_info reg1_in asm ("1") = *apinfo;
+	register unsigned long reg1_in asm ("1") = apinfo->val;
 	register struct ap_queue_status reg1_out asm ("1");
-	register unsigned long reg2_in asm ("2") = 0;
-	register struct ap_qact_ap_info reg2_out asm ("2");
+	register unsigned long reg2 asm ("2") = 0;
 
 	asm volatile(
 		".long 0xb2af0000"		/* PQAP(QACT) */
-		: "+d" (reg0), "+d" (reg1_in), "=d" (reg1_out),
-		  "+d" (reg2_in), "=d" (reg2_out)
-		:
-		: "cc");
-	*apinfo = reg2_out;
+		: "+d" (reg0), "+d" (reg1_in), "=d" (reg1_out), "+d" (reg2)
+		: : "cc");
+	apinfo->val = reg2;
 	return reg1_out;
 }
 
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -1021,7 +1021,7 @@ static int ap_get_compatible_type(ap_qid
 	 */
 	if (ap_qact_available()) {
 		struct ap_queue_status status;
-		struct ap_qact_ap_info apinfo = {0};
+		union ap_qact_ap_info apinfo = {0};
 
 		apinfo.mode = (func >> 26) & 0x07;
 		apinfo.cat = AP_DEVICE_TYPE_CEX6;