aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Jones <ajones@riverbed.com>2008-07-25 04:49:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:48 -0400
commitb238e57723a6fb2c365fc35de5d7c48ccf9300cd (patch)
tree5dd7fc42abedd6c5168b3f375b5a67de69305e9d
parent178d5a742291976d13bff55fa2b130879d4510de (diff)
edac: i5100: cleanup
Some code cleanliness issues found by Andrew Morton (thanks!) which should not affect functionality, but which should help make the code more maintainable. In particular, we now: * convert all #define's w/ a parameter to static inlines * use 1UL rather than 1ULL when calculating an unsigned long * use pci_disable_device The resulting code is tested and seems to work fine... Signed-off-by: Arthur Jones <ajones@riverbed.com> Cc: Doug Thompson <dougthompson@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/edac/i5100_edac.c396
1 files changed, 261 insertions, 135 deletions
diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
index d85e7992eb6a..22db05a67bfb 100644
--- a/drivers/edac/i5100_edac.c
+++ b/drivers/edac/i5100_edac.c
@@ -21,36 +21,19 @@
21 21
22#include "edac_core.h" 22#include "edac_core.h"
23 23
24/* register addresses and bit field accessors... */ 24/* register addresses */
25 25
26/* device 16, func 1 */ 26/* device 16, func 1 */
27#define I5100_MC 0x40 /* Memory Control Register */ 27#define I5100_MC 0x40 /* Memory Control Register */
28#define I5100_MC_ERRDETEN(a) ((a) >> 5 & 1)
29#define I5100_MS 0x44 /* Memory Status Register */ 28#define I5100_MS 0x44 /* Memory Status Register */
30#define I5100_SPDDATA 0x48 /* Serial Presence Detect Status Reg */ 29#define I5100_SPDDATA 0x48 /* Serial Presence Detect Status Reg */
31#define I5100_SPDDATA_RDO(a) ((a) >> 15 & 1)
32#define I5100_SPDDATA_SBE(a) ((a) >> 13 & 1)
33#define I5100_SPDDATA_BUSY(a) ((a) >> 12 & 1)
34#define I5100_SPDDATA_DATA(a) ((a) & ((1 << 8) - 1))
35#define I5100_SPDCMD 0x4c /* Serial Presence Detect Command Reg */ 30#define I5100_SPDCMD 0x4c /* Serial Presence Detect Command Reg */
36#define I5100_SPDCMD_DTI(a) (((a) & ((1 << 4) - 1)) << 28)
37#define I5100_SPDCMD_CKOVRD(a) (((a) & 1) << 27)
38#define I5100_SPDCMD_SA(a) (((a) & ((1 << 3) - 1)) << 24)
39#define I5100_SPDCMD_BA(a) (((a) & ((1 << 8) - 1)) << 16)
40#define I5100_SPDCMD_DATA(a) (((a) & ((1 << 8) - 1)) << 8)
41#define I5100_SPDCMD_CMD(a) ((a) & 1)
42#define I5100_TOLM 0x6c /* Top of Low Memory */ 31#define I5100_TOLM 0x6c /* Top of Low Memory */
43#define I5100_TOLM_TOLM(a) ((a) >> 12 & ((1 << 4) - 1))
44#define I5100_MIR0 0x80 /* Memory Interleave Range 0 */ 32#define I5100_MIR0 0x80 /* Memory Interleave Range 0 */
45#define I5100_MIR1 0x84 /* Memory Interleave Range 1 */ 33#define I5100_MIR1 0x84 /* Memory Interleave Range 1 */
46#define I5100_AMIR_0 0x8c /* Adjusted Memory Interleave Range 0 */ 34#define I5100_AMIR_0 0x8c /* Adjusted Memory Interleave Range 0 */
47#define I5100_AMIR_1 0x90 /* Adjusted Memory Interleave Range 1 */ 35#define I5100_AMIR_1 0x90 /* Adjusted Memory Interleave Range 1 */
48#define I5100_MIR_LIMIT(a) ((a) >> 4 & ((1 << 12) - 1))
49#define I5100_MIR_WAY1(a) ((a) >> 1 & 1)
50#define I5100_MIR_WAY0(a) ((a) & 1)
51#define I5100_FERR_NF_MEM 0xa0 /* MC First Non Fatal Errors */ 36#define I5100_FERR_NF_MEM 0xa0 /* MC First Non Fatal Errors */
52#define I5100_FERR_NF_MEM_CHAN_INDX(a) ((a) >> 28 & 1)
53#define I5100_FERR_NF_MEM_SPD_MASK (1 << 18)
54#define I5100_FERR_NF_MEM_M16ERR_MASK (1 << 16) 37#define I5100_FERR_NF_MEM_M16ERR_MASK (1 << 16)
55#define I5100_FERR_NF_MEM_M15ERR_MASK (1 << 15) 38#define I5100_FERR_NF_MEM_M15ERR_MASK (1 << 15)
56#define I5100_FERR_NF_MEM_M14ERR_MASK (1 << 14) 39#define I5100_FERR_NF_MEM_M14ERR_MASK (1 << 14)
@@ -72,47 +55,214 @@
72 I5100_FERR_NF_MEM_M5ERR_MASK | \ 55 I5100_FERR_NF_MEM_M5ERR_MASK | \
73 I5100_FERR_NF_MEM_M4ERR_MASK | \ 56 I5100_FERR_NF_MEM_M4ERR_MASK | \
74 I5100_FERR_NF_MEM_M1ERR_MASK) 57 I5100_FERR_NF_MEM_M1ERR_MASK)
75#define I5100_FERR_NF_MEM_ANY(a) ((a) & I5100_FERR_NF_MEM_ANY_MASK)
76#define I5100_NERR_NF_MEM 0xa4 /* MC Next Non-Fatal Errors */ 58#define I5100_NERR_NF_MEM 0xa4 /* MC Next Non-Fatal Errors */
77#define I5100_NERR_NF_MEM_ANY(a) I5100_FERR_NF_MEM_ANY(a)
78#define I5100_EMASK_MEM 0xa8 /* MC Error Mask Register */ 59#define I5100_EMASK_MEM 0xa8 /* MC Error Mask Register */
79 60
80/* device 21 and 22, func 0 */ 61/* device 21 and 22, func 0 */
81#define I5100_MTR_0 0x154 /* Memory Technology Registers 0-3 */ 62#define I5100_MTR_0 0x154 /* Memory Technology Registers 0-3 */
82#define I5100_DMIR 0x15c /* DIMM Interleave Range */ 63#define I5100_DMIR 0x15c /* DIMM Interleave Range */
83#define I5100_DMIR_LIMIT(a) ((a) >> 16 & ((1 << 11) - 1))
84#define I5100_DMIR_RANK(a, i) ((a) >> (4 * i) & ((1 << 2) - 1))
85#define I5100_MTR_4 0x1b0 /* Memory Technology Registers 4,5 */
86#define I5100_MTR_PRESENT(a) ((a) >> 10 & 1)
87#define I5100_MTR_ETHROTTLE(a) ((a) >> 9 & 1)
88#define I5100_MTR_WIDTH(a) ((a) >> 8 & 1)
89#define I5100_MTR_NUMBANK(a) ((a) >> 6 & 1)
90#define I5100_MTR_NUMROW(a) ((a) >> 2 & ((1 << 2) - 1))
91#define I5100_MTR_NUMCOL(a) ((a) & ((1 << 2) - 1))
92#define I5100_VALIDLOG 0x18c /* Valid Log Markers */ 64#define I5100_VALIDLOG 0x18c /* Valid Log Markers */
93#define I5100_VALIDLOG_REDMEMVALID(a) ((a) >> 2 & 1)
94#define I5100_VALIDLOG_RECMEMVALID(a) ((a) >> 1 & 1)
95#define I5100_VALIDLOG_NRECMEMVALID(a) ((a) & 1)
96#define I5100_NRECMEMA 0x190 /* Non-Recoverable Memory Error Log Reg A */ 65#define I5100_NRECMEMA 0x190 /* Non-Recoverable Memory Error Log Reg A */
97#define I5100_NRECMEMA_MERR(a) ((a) >> 15 & ((1 << 5) - 1))
98#define I5100_NRECMEMA_BANK(a) ((a) >> 12 & ((1 << 3) - 1))
99#define I5100_NRECMEMA_RANK(a) ((a) >> 8 & ((1 << 3) - 1))
100#define I5100_NRECMEMA_DM_BUF_ID(a) ((a) & ((1 << 8) - 1))
101#define I5100_NRECMEMB 0x194 /* Non-Recoverable Memory Error Log Reg B */ 66#define I5100_NRECMEMB 0x194 /* Non-Recoverable Memory Error Log Reg B */
102#define I5100_NRECMEMB_CAS(a) ((a) >> 16 & ((1 << 13) - 1))
103#define I5100_NRECMEMB_RAS(a) ((a) & ((1 << 16) - 1))
104#define I5100_REDMEMA 0x198 /* Recoverable Memory Data Error Log Reg A */ 67#define I5100_REDMEMA 0x198 /* Recoverable Memory Data Error Log Reg A */
105#define I5100_REDMEMA_SYNDROME(a) (a)
106#define I5100_REDMEMB 0x19c /* Recoverable Memory Data Error Log Reg B */ 68#define I5100_REDMEMB 0x19c /* Recoverable Memory Data Error Log Reg B */
107#define I5100_REDMEMB_ECC_LOCATOR(a) ((a) & ((1 << 18) - 1))
108#define I5100_RECMEMA 0x1a0 /* Recoverable Memory Error Log Reg A */ 69#define I5100_RECMEMA 0x1a0 /* Recoverable Memory Error Log Reg A */
109#define I5100_RECMEMA_MERR(a) I5100_NRECMEMA_MERR(a)
110#define I5100_RECMEMA_BANK(a) I5100_NRECMEMA_BANK(a)
111#define I5100_RECMEMA_RANK(a) I5100_NRECMEMA_RANK(a)
112#define I5100_RECMEMA_DM_BUF_ID(a) I5100_NRECMEMA_DM_BUF_ID(a)
113#define I5100_RECMEMB 0x1a4 /* Recoverable Memory Error Log Reg B */ 70#define I5100_RECMEMB 0x1a4 /* Recoverable Memory Error Log Reg B */
114#define I5100_RECMEMB_CAS(a) I5100_NRECMEMB_CAS(a) 71#define I5100_MTR_4 0x1b0 /* Memory Technology Registers 4,5 */
115#define I5100_RECMEMB_RAS(a) I5100_NRECMEMB_RAS(a) 72
73/* bit field accessors */
74
75static inline u32 i5100_mc_errdeten(u32 mc)
76{
77 return mc >> 5 & 1;
78}
79
80static inline u16 i5100_spddata_rdo(u16 a)
81{
82 return a >> 15 & 1;
83}
84
85static inline u16 i5100_spddata_sbe(u16 a)
86{
87 return a >> 13 & 1;
88}
89
90static inline u16 i5100_spddata_busy(u16 a)
91{
92 return a >> 12 & 1;
93}
94
95static inline u16 i5100_spddata_data(u16 a)
96{
97 return a & ((1 << 8) - 1);
98}
99
100static inline u32 i5100_spdcmd_create(u32 dti, u32 ckovrd, u32 sa, u32 ba,
101 u32 data, u32 cmd)
102{
103 return ((dti & ((1 << 4) - 1)) << 28) |
104 ((ckovrd & 1) << 27) |
105 ((sa & ((1 << 3) - 1)) << 24) |
106 ((ba & ((1 << 8) - 1)) << 16) |
107 ((data & ((1 << 8) - 1)) << 8) |
108 (cmd & 1);
109}
110
111static inline u16 i5100_tolm_tolm(u16 a)
112{
113 return a >> 12 & ((1 << 4) - 1);
114}
115
116static inline u16 i5100_mir_limit(u16 a)
117{
118 return a >> 4 & ((1 << 12) - 1);
119}
120
121static inline u16 i5100_mir_way1(u16 a)
122{
123 return a >> 1 & 1;
124}
125
126static inline u16 i5100_mir_way0(u16 a)
127{
128 return a & 1;
129}
130
131static inline u32 i5100_ferr_nf_mem_chan_indx(u32 a)
132{
133 return a >> 28 & 1;
134}
135
136static inline u32 i5100_ferr_nf_mem_any(u32 a)
137{
138 return a & I5100_FERR_NF_MEM_ANY_MASK;
139}
140
141static inline u32 i5100_nerr_nf_mem_any(u32 a)
142{
143 return i5100_ferr_nf_mem_any(a);
144}
145
146static inline u32 i5100_dmir_limit(u32 a)
147{
148 return a >> 16 & ((1 << 11) - 1);
149}
150
151static inline u32 i5100_dmir_rank(u32 a, u32 i)
152{
153 return a >> (4 * i) & ((1 << 2) - 1);
154}
155
156<