CONFIG_SYS_[ID]CACHE_OFF: unify the 'any' case
authorTrevor Woerner <trevor@toganlabs.com>
Fri, 3 May 2019 13:40:56 +0000 (09:40 -0400)
committerTom Rini <trini@konsulko.com>
Sat, 18 May 2019 12:15:34 +0000 (08:15 -0400)
According to De Morgan's Law[1]:
!(A && B) = !A || !B
!(A || B) = !A && !B

There are 5 places in the code where we find:
#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
and 4 places in the code where we find:
#if (!defined(CONFIG_SYS_ICACHE_OFF) || !defined(CONFIG_SYS_DCACHE_OFF))

In words, the construct:
!defined(CONFIG_SYS_[DI]CACHE_OFF)
means:
"is the [DI]CACHE on?"
and the construct:
defined(CONFIG_SYS_[DI]CACHE_OFF)
means:
"is the [DI]CACHE off?"

Therefore
!(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
means:
"the opposite of 'are they both off?'"
in other words:
"are either or both on?"
and:
(!defined(CONFIG_SYS_ICACHE_OFF) || !defined(CONFIG_SYS_DCACHE_OFF)
means:
"are either or both on?"

As a result, I've converted the 4 instances of '(!A || !B)' to '!(A && B)' for
consistency.

[1] https://en.wikipedia.org/wiki/De_Morgan%27s_laws

Signed-off-by: Trevor Woerner <trevor@toganlabs.com>
arch/arm/cpu/arm11/cpu.c
arch/nds32/cpu/n1213/start.S
arch/nds32/lib/cache.c
arch/xtensa/cpu/start.S

index 41feeefec1606d0358856f84bc4c0edad10e9122..4aa704b9eeb8d1e01c4b83f95bcdf75d10589d74 100644 (file)
@@ -97,7 +97,7 @@ void flush_dcache_all(void)
 }
 #endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
 
-#if !defined(CONFIG_SYS_ICACHE_OFF) || !defined(CONFIG_SYS_DCACHE_OFF)
+#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
 void enable_caches(void)
 {
 #ifndef CONFIG_SYS_ICACHE_OFF
index cf966e2132e8e438a5c8cf55b00adddb017ca592..4e6a0e7a31e7b63c6a28e8e6c840d335b640e28c 100644 (file)
@@ -129,7 +129,7 @@ set_ivb:
        mfsr    $r1, $mr8
        and     $r1, $r1, $r0
        mtsr    $r1, $mr8
-#if (!defined(CONFIG_SYS_ICACHE_OFF) || !defined(CONFIG_SYS_DCACHE_OFF))
+#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
 /*
  * MMU_CTL NTC0 Cacheable/Write-Back
  */
index 9ab30d19653b6c8727e4f2c8bb69e3675b3194f7..3e5aa7cda8a78717d5a33818a2d2d76820e58973 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #include <common.h>
-#if (!defined(CONFIG_SYS_ICACHE_OFF) || !defined(CONFIG_SYS_DCACHE_OFF))
+#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
 static inline unsigned long CACHE_SET(unsigned char cache)
 {
        if (cache == ICACHE)
index 66acb4c61044c46e826bdaf6f63d44fa8c2ea478..0fafb1c4f8e6df9999274774452afbc3bc6ec2d5 100644 (file)
@@ -164,8 +164,7 @@ _start:
         * enable data/instruction cache for relocated image.
         */
 #if XCHAL_HAVE_SPANNING_WAY && \
-       (!defined(CONFIG_SYS_DCACHE_OFF) || \
-        !defined(CONFIG_SYS_ICACHE_OFF))
+       !(defined(CONFIG_SYS_DCACHE_OFF) && defined(CONFIG_SYS_ICACHE_OFF))
        srli    a7, a4, 29
        slli    a7, a7, 29
        addi    a7, a7, XCHAL_SPANNING_WAY