MIPS: Sibyte: Use hweight8 instead of counting bits
[linux-2.6-block.git] / arch / mips / mm / cerr-sb1.c
index 11a916629d3b57859796766d589ac5a1837b2c84..3571090ba17816e332a2843d6aee478131154932 100644 (file)
@@ -154,7 +154,7 @@ static void check_bus_watcher(void)
        if (status & ~(1UL << 31)) {
                l2_err = csr_in32(IOADDR(A_BUS_L2_ERRORS));
 #ifdef DUMP_L2_ECC_TAG_ON_ERROR
-               l2_tag = in64(IO_SPACE_BASE | A_L2_ECC_TAG);
+               l2_tag = in64(IOADDR(A_L2_ECC_TAG));
 #endif
                memio_err = csr_in32(IOADDR(A_BUS_MEM_IO_ERRORS));
                printk("Bus watcher error counters: %08x %08x\n", l2_err, memio_err);
@@ -177,15 +177,15 @@ extern void check_bus_watcher(void);
 
 asmlinkage void sb1_cache_error(void)
 {
-       uint64_t cerr_dpa;
        uint32_t errctl, cerr_i, cerr_d, dpalo, dpahi, eepc, res;
+       unsigned long long cerr_dpa;
 
 #ifdef CONFIG_SIBYTE_BW_TRACE
        /* Freeze the trace buffer now */
 #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
-       csr_out32(M_BCM1480_SCD_TRACE_CFG_FREEZE, IO_SPACE_BASE | A_SCD_TRACE_CFG);
+       csr_out32(M_BCM1480_SCD_TRACE_CFG_FREEZE, IOADDR(A_SCD_TRACE_CFG));
 #else
-       csr_out32(M_SCD_TRACE_CFG_FREEZE, IO_SPACE_BASE | A_SCD_TRACE_CFG);
+       csr_out32(M_SCD_TRACE_CFG_FREEZE, IOADDR(A_SCD_TRACE_CFG));
 #endif
        printk("Trace buffer frozen\n");
 #endif
@@ -271,14 +271,22 @@ asmlinkage void sb1_cache_error(void)
 
 /* Parity lookup table. */
 static const uint8_t parity[256] = {
-       0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
-       1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,
-       1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,
-       0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
-       1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,
-       0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
-       0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
-       1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0
+       0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
+       1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
+       1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
+       0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
+       1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
+       0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
+       0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
+       1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
+       1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
+       0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
+       0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
+       1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
+       0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
+       1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
+       1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
+       0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0
 };
 
 /* Masks to select bits for Hamming parity, mask_72_64[i] for bit[i] */
@@ -329,8 +337,9 @@ static uint32_t extract_ic(unsigned short addr, int data)
 {
        unsigned short way;
        int valid;
-       uint64_t taglo, va, tlo_tmp;
        uint32_t taghi, taglolo, taglohi;
+       unsigned long long taglo, va;
+       uint64_t tlo_tmp;
        uint8_t lru;
        int res = 0;
 
@@ -484,8 +493,8 @@ static uint32_t extract_dc(unsigned short addr, int data)
 {
        int valid, way;
        unsigned char state;
-       uint64_t taglo, pa;
        uint32_t taghi, taglolo, taglohi;
+       unsigned long long taglo, pa;
        uint8_t ecc, lru;
        int res = 0;
 
@@ -535,8 +544,8 @@ static uint32_t extract_dc(unsigned short addr, int data)
                }
 
                if (data) {
-                       uint64_t datalo;
                        uint32_t datalohi, datalolo, datahi;
+                       unsigned long long datalo;
                        int offset;
                        char bad_ecc = 0;
 
@@ -558,13 +567,10 @@ static uint32_t extract_dc(unsigned short addr, int data)
                                datalo = ((unsigned long long)datalohi << 32) | datalolo;
                                ecc = dc_ecc(datalo);
                                if (ecc != datahi) {
-                                       int bits = 0;
+                                       int bits;
                                        bad_ecc |= 1 << (3-offset);
                                        ecc ^= datahi;
-                                       while (ecc) {
-                                               if (ecc & 1) bits++;
-                                               ecc >>= 1;
-                                       }
+                                       bits = hweight8(ecc);
                                        res |= (bits == 1) ? CP0_CERRD_DATA_SBE : CP0_CERRD_DATA_DBE;
                                }
                                printk("  %02X-%016llX", datahi, datalo);