aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/amd76x_edac.c
diff options
context:
space:
mode:
authorDoug Thompson <norsk5@xmission.com>2006-06-30 04:56:08 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-30 14:25:39 -0400
commit1318952514d5651c453d89989595a9df3b37267b (patch)
treedf793132fa7e24e53c68897d4302d964eb07b526 /drivers/edac/amd76x_edac.c
parent2d7bbb91c8df26c60d223205a087507430024177 (diff)
[PATCH] EDAC: probe1 cleanup 1-of-2
- Add lower-level functions that handle various parts of the initialization done by the xxx_probe1() functions. Some of the xxx_probe1() functions are much too long and complicated (see "Chapter 5: Functions" in Documentation/CodingStyle). - Cleanup of probe1() functions in EDAC Signed-off-by: Doug Thompson <norsk5@xmission.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/edac/amd76x_edac.c')
-rw-r--r--drivers/edac/amd76x_edac.c74
1 files changed, 38 insertions, 36 deletions
diff --git a/drivers/edac/amd76x_edac.c b/drivers/edac/amd76x_edac.c
index 303cb500b37..702141c5501 100644
--- a/drivers/edac/amd76x_edac.c
+++ b/drivers/edac/amd76x_edac.c
@@ -182,6 +182,38 @@ static void amd76x_check(struct mem_ctl_info *mci)
182 amd76x_process_error_info(mci, &info, 1); 182 amd76x_process_error_info(mci, &info, 1);
183} 183}
184 184
185static void amd76x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
186 enum edac_type edac_mode)
187{
188 struct csrow_info *csrow;
189 u32 mba, mba_base, mba_mask, dms;
190 int index;
191
192 for (index = 0; index < mci->nr_csrows; index++) {
193 csrow = &mci->csrows[index];
194
195 /* find the DRAM Chip Select Base address and mask */
196 pci_read_config_dword(pdev,
197 AMD76X_MEM_BASE_ADDR + (index * 4),
198 &mba);
199
200 if (!(mba & BIT(0)))
201 continue;
202
203 mba_base = mba & 0xff800000UL;
204 mba_mask = ((mba & 0xff80) << 16) | 0x7fffffUL;
205 pci_read_config_dword(pdev, AMD76X_DRAM_MODE_STATUS, &dms);
206 csrow->first_page = mba_base >> PAGE_SHIFT;
207 csrow->nr_pages = (mba_mask + 1) >> PAGE_SHIFT;
208 csrow->last_page = csrow->first_page + csrow->nr_pages - 1;
209 csrow->page_mask = mba_mask >> PAGE_SHIFT;
210 csrow->grain = csrow->nr_pages << PAGE_SHIFT;
211 csrow->mtype = MEM_RDDR;
212 csrow->dtype = ((dms >> index) & 0x1) ? DEV_X4 : DEV_UNKNOWN;
213 csrow->edac_mode = edac_mode;
214 }
215}
216
185/** 217/**
186 * amd76x_probe1 - Perform set up for detected device 218 * amd76x_probe1 - Perform set up for detected device
187 * @pdev; PCI device detected 219 * @pdev; PCI device detected
@@ -193,15 +225,13 @@ static void amd76x_check(struct mem_ctl_info *mci)
193 */ 225 */
194static int amd76x_probe1(struct pci_dev *pdev, int dev_idx) 226static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
195{ 227{
196 int rc = -ENODEV; 228 static const enum edac_type ems_modes[] = {
197 int index;
198 struct mem_ctl_info *mci = NULL;
199 enum edac_type ems_modes[] = {
200 EDAC_NONE, 229 EDAC_NONE,
201 EDAC_EC, 230 EDAC_EC,
202 EDAC_SECDED, 231 EDAC_SECDED,
203 EDAC_SECDED 232 EDAC_SECDED
204 }; 233 };
234 struct mem_ctl_info *mci = NULL;
205 u32 ems; 235 u32 ems;
206 u32 ems_mode; 236 u32 ems_mode;
207 struct amd76x_error_info discard; 237 struct amd76x_error_info discard;
@@ -212,8 +242,7 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
212 mci = edac_mc_alloc(0, AMD76X_NR_CSROWS, AMD76X_NR_CHANS); 242 mci = edac_mc_alloc(0, AMD76X_NR_CSROWS, AMD76X_NR_CHANS);
213 243
214 if (mci == NULL) { 244 if (mci == NULL) {
215 rc = -ENOMEM; 245 return -ENOMEM;
216 goto fail;
217 } 246 }
218 247
219 debugf0("%s(): mci = %p\n", __func__, mci); 248 debugf0("%s(): mci = %p\n", __func__, mci);
@@ -228,33 +257,7 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
228 mci->edac_check = amd76x_check; 257 mci->edac_check = amd76x_check;
229 mci->ctl_page_to_phys = NULL; 258 mci->ctl_page_to_phys = NULL;
230 259
231 for (index = 0; index < mci->nr_csrows; index++) { 260 amd76x_init_csrows(mci, pdev, ems_modes[ems_mode]);
232 struct csrow_info *csrow = &mci->csrows[index];
233 u32 mba;
234 u32 mba_base;
235 u32 mba_mask;
236 u32 dms;
237
238 /* find the DRAM Chip Select Base address and mask */
239 pci_read_config_dword(pdev,
240 AMD76X_MEM_BASE_ADDR + (index * 4), &mba);
241
242 if (!(mba & BIT(0)))
243 continue;
244
245 mba_base = mba & 0xff800000UL;
246 mba_mask = ((mba & 0xff80) << 16) | 0x7fffffUL;
247 pci_read_config_dword(pdev, AMD76X_DRAM_MODE_STATUS, &dms);
248 csrow->first_page = mba_base >> PAGE_SHIFT;
249 csrow->nr_pages = (mba_mask + 1) >> PAGE_SHIFT;
250 csrow->last_page = csrow->first_page + csrow->nr_pages - 1;
251 csrow->page_mask = mba_mask >> PAGE_SHIFT;
252 csrow->grain = csrow->nr_pages << PAGE_SHIFT;
253 csrow->mtype = MEM_RDDR;
254 csrow->dtype = ((dms >> index) & 0x1) ? DEV_X4 : DEV_UNKNOWN;
255 csrow->edac_mode = ems_modes[ems_mode];
256 }
257
258 amd76x_get_error_info(mci, &discard); /* clear counters */ 261 amd76x_get_error_info(mci, &discard); /* clear counters */
259 262
260 /* Here we assume that we will never see multiple instances of this 263 /* Here we assume that we will never see multiple instances of this
@@ -270,9 +273,8 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
270 return 0; 273 return 0;
271 274
272fail: 275fail:
273 if (mci != NULL) 276 edac_mc_free(mci);
274 edac_mc_free(mci); 277 return -ENODEV;
275 return rc;
276} 278}
277 279
278/* returns count (>= 0), or negative on error */ 280/* returns count (>= 0), or negative on error */