]> git.baikalelectronics.ru Git - kernel.git/commitdiff
s390/cio: simplify the calculation of variables
authorHaowen Bai <baihaowen@meizu.com>
Thu, 7 Apr 2022 02:16:47 +0000 (10:16 +0800)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 25 Apr 2022 11:54:13 +0000 (13:54 +0200)
Fix the following coccicheck warnings:
./arch/s390/include/asm/scsw.h:695:47-49: WARNING
 !A || A && B is equivalent to !A || B

I apply a readable version just to get rid of a warning.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Link: https://lore.kernel.org/r/1649297808-5048-1-git-send-email-baihaowen@meizu.com
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/include/asm/scsw.h

index a7c3ccf681da074af56d68177719d1f84508da2e..7ce584aff5bb5def0ea00f323c37d1fcdb55b30a 100644 (file)
@@ -508,9 +508,21 @@ static inline int scsw_cmd_is_valid_zcc(union scsw *scsw)
  */
 static inline int scsw_cmd_is_valid_ectl(union scsw *scsw)
 {
-       return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
-              !(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS) &&
-              (scsw->cmd.stctl & SCSW_STCTL_ALERT_STATUS);
+       /* Must be status pending. */
+       if (!(scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND))
+               return 0;
+
+       /* Must have alert status. */
+       if (!(scsw->cmd.stctl & SCSW_STCTL_ALERT_STATUS))
+               return 0;
+
+       /* Must be alone or together with primary, secondary or both,
+        * => no intermediate status.
+        */
+       if (scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS)
+               return 0;
+
+       return 1;
 }
 
 /**
@@ -522,10 +534,25 @@ static inline int scsw_cmd_is_valid_ectl(union scsw *scsw)
  */
 static inline int scsw_cmd_is_valid_pno(union scsw *scsw)
 {
-       return (scsw->cmd.fctl != 0) &&
-              (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
-              (!(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS) ||
-                 (scsw->cmd.actl & SCSW_ACTL_SUSPENDED));
+       /* Must indicate at least one I/O function. */
+       if (!scsw->cmd.fctl)
+               return 0;
+
+       /* Must be status pending. */
+       if (!(scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND))
+               return 0;
+
+       /* Can be status pending alone, or with any combination of primary,
+        * secondary and alert => no intermediate status.
+        */
+       if (!(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS))
+               return 1;
+
+       /* If intermediate, must be suspended. */
+       if (scsw->cmd.actl & SCSW_ACTL_SUSPENDED)
+               return 1;
+
+       return 0;
 }
 
 /**
@@ -675,9 +702,21 @@ static inline int scsw_tm_is_valid_q(union scsw *scsw)
  */
 static inline int scsw_tm_is_valid_ectl(union scsw *scsw)
 {
-       return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
-              !(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) &&
-              (scsw->tm.stctl & SCSW_STCTL_ALERT_STATUS);
+       /* Must be status pending. */
+       if (!(scsw->tm.stctl & SCSW_STCTL_STATUS_PEND))
+               return 0;
+
+       /* Must have alert status. */
+       if (!(scsw->tm.stctl & SCSW_STCTL_ALERT_STATUS))
+               return 0;
+
+       /* Must be alone or together with primary, secondary or both,
+        * => no intermediate status.
+        */
+       if (scsw->tm.stctl & SCSW_STCTL_INTER_STATUS)
+               return 0;
+
+       return 1;
 }
 
 /**
@@ -689,11 +728,25 @@ static inline int scsw_tm_is_valid_ectl(union scsw *scsw)
  */
 static inline int scsw_tm_is_valid_pno(union scsw *scsw)
 {
-       return (scsw->tm.fctl != 0) &&
-              (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
-              (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) ||
-                ((scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) &&
-                 (scsw->tm.actl & SCSW_ACTL_SUSPENDED)));
+       /* Must indicate at least one I/O function. */
+       if (!scsw->tm.fctl)
+               return 0;
+
+       /* Must be status pending. */
+       if (!(scsw->tm.stctl & SCSW_STCTL_STATUS_PEND))
+               return 0;
+
+       /* Can be status pending alone, or with any combination of primary,
+        * secondary and alert => no intermediate status.
+        */
+       if (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS))
+               return 1;
+
+       /* If intermediate, must be suspended. */
+       if (scsw->tm.actl & SCSW_ACTL_SUSPENDED)
+               return 1;
+
+       return 0;
 }
 
 /**