hw/pxa2xx.c: Fix handling of R/WC bits in PMCR
authorPeter Maydell <peter.maydell@linaro.org>
Wed, 9 Nov 2011 20:46:35 +0000 (20:46 +0000)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 11 Nov 2011 18:49:53 +0000 (12:49 -0600)
Fix a bug in handling the write-one-to-clear bits in the PMCR
which meant that we would always clear the bit even if the
value written was a zero. Spotted by Coverity (see bug 887883).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/pxa2xx.c

index bfc28a9..d38b922 100644 (file)
@@ -114,7 +114,9 @@ static void pxa2xx_pm_write(void *opaque, target_phys_addr_t addr,
 
     switch (addr) {
     case PMCR:
-        s->pm_regs[addr >> 2] &= 0x15 & ~(value & 0x2a);
+        /* Clear the write-one-to-clear bits... */
+        s->pm_regs[addr >> 2] &= ~(value & 0x2a);
+        /* ...and set the plain r/w bits */
         s->pm_regs[addr >> 2] |= value & 0x15;
         break;