diff options
author | Doug Thompson <norsk5@xmission.com> | 2006-06-30 04:56:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-30 14:25:39 -0400 |
commit | 1318952514d5651c453d89989595a9df3b37267b (patch) | |
tree | df793132fa7e24e53c68897d4302d964eb07b526 /drivers/edac/r82600_edac.c | |
parent | 2d7bbb91c8df26c60d223205a087507430024177 (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/r82600_edac.c')
-rw-r--r-- | drivers/edac/r82600_edac.c | 118 |
1 files changed, 61 insertions, 57 deletions
diff --git a/drivers/edac/r82600_edac.c b/drivers/edac/r82600_edac.c index eb3aa615dc57..fecdb2c9ee28 100644 --- a/drivers/edac/r82600_edac.c +++ b/drivers/edac/r82600_edac.c | |||
@@ -205,25 +205,72 @@ static void r82600_check(struct mem_ctl_info *mci) | |||
205 | r82600_process_error_info(mci, &info, 1); | 205 | r82600_process_error_info(mci, &info, 1); |
206 | } | 206 | } |
207 | 207 | ||
208 | static int r82600_probe1(struct pci_dev *pdev, int dev_idx) | 208 | static inline int ecc_enabled(u8 dramcr) |
209 | { | 209 | { |
210 | int rc = -ENODEV; | 210 | return dramcr & BIT(5); |
211 | } | ||
212 | |||
213 | static void r82600_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev, | ||
214 | u8 dramcr) | ||
215 | { | ||
216 | struct csrow_info *csrow; | ||
211 | int index; | 217 | int index; |
212 | struct mem_ctl_info *mci = NULL; | 218 | u8 drbar; /* SDRAM Row Boundry Address Register */ |
219 | u32 row_high_limit, row_high_limit_last; | ||
220 | u32 reg_sdram, ecc_on, row_base; | ||
221 | |||
222 | ecc_on = ecc_enabled(dramcr); | ||
223 | reg_sdram = dramcr & BIT(4); | ||
224 | row_high_limit_last = 0; | ||
225 | |||
226 | for (index = 0; index < mci->nr_csrows; index++) { | ||
227 | csrow = &mci->csrows[index]; | ||
228 | |||
229 | /* find the DRAM Chip Select Base address and mask */ | ||
230 | pci_read_config_byte(pdev, R82600_DRBA + index, &drbar); | ||
231 | |||
232 | debugf1("%s() Row=%d DRBA = %#0x\n", __func__, index, drbar); | ||
233 | |||
234 | row_high_limit = ((u32) drbar << 24); | ||
235 | /* row_high_limit = ((u32)drbar << 24) | 0xffffffUL; */ | ||
236 | |||
237 | debugf1("%s() Row=%d, Boundry Address=%#0x, Last = %#0x\n", | ||
238 | __func__, index, row_high_limit, row_high_limit_last); | ||
239 | |||
240 | /* Empty row [p.57] */ | ||
241 | if (row_high_limit == row_high_limit_last) | ||
242 | continue; | ||
243 | |||
244 | row_base = row_high_limit_last; | ||
245 | |||
246 | csrow->first_page = row_base >> PAGE_SHIFT; | ||
247 | csrow->last_page = (row_high_limit >> PAGE_SHIFT) - 1; | ||
248 | csrow->nr_pages = csrow->last_page - csrow->first_page + 1; | ||
249 | /* Error address is top 19 bits - so granularity is * | ||
250 | * 14 bits */ | ||
251 | csrow->grain = 1 << 14; | ||
252 | csrow->mtype = reg_sdram ? MEM_RDDR : MEM_DDR; | ||
253 | /* FIXME - check that this is unknowable with this chipset */ | ||
254 | csrow->dtype = DEV_UNKNOWN; | ||
255 | |||
256 | /* Mode is global on 82600 */ | ||
257 | csrow->edac_mode = ecc_on ? EDAC_SECDED : EDAC_NONE; | ||
258 | row_high_limit_last = row_high_limit; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | static int r82600_probe1(struct pci_dev *pdev, int dev_idx) | ||
263 | { | ||
264 | struct mem_ctl_info *mci; | ||
213 | u8 dramcr; | 265 | u8 dramcr; |
214 | u32 ecc_on; | ||
215 | u32 reg_sdram; | ||
216 | u32 eapr; | 266 | u32 eapr; |
217 | u32 scrub_disabled; | 267 | u32 scrub_disabled; |
218 | u32 sdram_refresh_rate; | 268 | u32 sdram_refresh_rate; |
219 | u32 row_high_limit_last = 0; | ||
220 | struct r82600_error_info discard; | 269 | struct r82600_error_info discard; |
221 | 270 | ||
222 | debugf0("%s()\n", __func__); | 271 | debugf0("%s()\n", __func__); |
223 | pci_read_config_byte(pdev, R82600_DRAMC, &dramcr); | 272 | pci_read_config_byte(pdev, R82600_DRAMC, &dramcr); |
224 | pci_read_config_dword(pdev, R82600_EAP, &eapr); | 273 | pci_read_config_dword(pdev, R82600_EAP, &eapr); |
225 | ecc_on = dramcr & BIT(5); | ||
226 | reg_sdram = dramcr & BIT(4); | ||
227 | scrub_disabled = eapr & BIT(31); | 274 | scrub_disabled = eapr & BIT(31); |
228 | sdram_refresh_rate = dramcr & (BIT(0) | BIT(1)); | 275 | sdram_refresh_rate = dramcr & (BIT(0) | BIT(1)); |
229 | debugf2("%s(): sdram refresh rate = %#0x\n", __func__, | 276 | debugf2("%s(): sdram refresh rate = %#0x\n", __func__, |
@@ -231,10 +278,8 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx) | |||
231 | debugf2("%s(): DRAMC register = %#0x\n", __func__, dramcr); | 278 | debugf2("%s(): DRAMC register = %#0x\n", __func__, dramcr); |
232 | mci = edac_mc_alloc(0, R82600_NR_CSROWS, R82600_NR_CHANS); | 279 | mci = edac_mc_alloc(0, R82600_NR_CSROWS, R82600_NR_CHANS); |
233 | 280 | ||
234 | if (mci == NULL) { | 281 | if (mci == NULL) |
235 | rc = -ENOMEM; | 282 | return -ENOMEM; |
236 | goto fail; | ||
237 | } | ||
238 | 283 | ||
239 | debugf0("%s(): mci = %p\n", __func__, mci); | 284 | debugf0("%s(): mci = %p\n", __func__, mci); |
240 | mci->dev = &pdev->dev; | 285 | mci->dev = &pdev->dev; |
@@ -250,7 +295,7 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx) | |||
250 | * is possible. */ | 295 | * is possible. */ |
251 | mci->edac_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; | 296 | mci->edac_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; |
252 | 297 | ||
253 | if (ecc_on) { | 298 | if (ecc_enabled(dramcr)) { |
254 | if (scrub_disabled) | 299 | if (scrub_disabled) |
255 | debugf3("%s(): mci = %p - Scrubbing disabled! EAP: " | 300 | debugf3("%s(): mci = %p - Scrubbing disabled! EAP: " |
256 | "%#0x\n", __func__, mci, eapr); | 301 | "%#0x\n", __func__, mci, eapr); |
@@ -262,46 +307,7 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx) | |||
262 | mci->ctl_name = "R82600"; | 307 | mci->ctl_name = "R82600"; |
263 | mci->edac_check = r82600_check; | 308 | mci->edac_check = r82600_check; |
264 | mci->ctl_page_to_phys = NULL; | 309 | mci->ctl_page_to_phys = NULL; |
265 | 310 | r82600_init_csrows(mci, pdev, dramcr); | |
266 | for (index = 0; index < mci->nr_csrows; index++) { | ||
267 | struct csrow_info *csrow = &mci->csrows[index]; | ||
268 | u8 drbar; /* sDram Row Boundry Address Register */ | ||
269 | u32 row_high_limit; | ||
270 | u32 row_base; | ||
271 | |||
272 | /* find the DRAM Chip Select Base address and mask */ | ||
273 | pci_read_config_byte(pdev, R82600_DRBA + index, &drbar); | ||
274 | |||
275 | debugf1("MC%d: %s() Row=%d DRBA = %#0x\n", mci->mc_idx, | ||
276 | __func__, index, drbar); | ||
277 | |||
278 | row_high_limit = ((u32) drbar << 24); | ||
279 | /* row_high_limit = ((u32)drbar << 24) | 0xffffffUL; */ | ||
280 | |||
281 | debugf1("MC%d: %s() Row=%d, Boundry Address=%#0x, Last = " | ||
282 | "%#0x \n", mci->mc_idx, __func__, index, | ||
283 | row_high_limit, row_high_limit_last); | ||
284 | |||
285 | /* Empty row [p.57] */ | ||
286 | if (row_high_limit == row_high_limit_last) | ||
287 | continue; | ||
288 | |||
289 | row_base = row_high_limit_last; | ||
290 | csrow->first_page = row_base >> PAGE_SHIFT; | ||
291 | csrow->last_page = (row_high_limit >> PAGE_SHIFT) - 1; | ||
292 | csrow->nr_pages = csrow->last_page - csrow->first_page + 1; | ||
293 | /* Error address is top 19 bits - so granularity is * | ||
294 | * 14 bits */ | ||
295 | csrow->grain = 1 << 14; | ||
296 | csrow->mtype = reg_sdram ? MEM_RDDR : MEM_DDR; | ||
297 | /* FIXME - check that this is unknowable with this chipset */ | ||
298 | csrow->dtype = DEV_UNKNOWN; | ||
299 | |||
300 | /* Mode is global on 82600 */ | ||
301 | csrow->edac_mode = ecc_on ? EDAC_SECDED : EDAC_NONE; | ||
302 | row_high_limit_last = row_high_limit; | ||
303 | } | ||
304 | |||
305 | r82600_get_error_info(mci, &discard); /* clear counters */ | 311 | r82600_get_error_info(mci, &discard); /* clear counters */ |
306 | 312 | ||
307 | /* Here we assume that we will never see multiple instances of this | 313 | /* Here we assume that we will never see multiple instances of this |
@@ -324,10 +330,8 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx) | |||
324 | return 0; | 330 | return 0; |
325 | 331 | ||
326 | fail: | 332 | fail: |
327 | if (mci) | 333 | edac_mc_free(mci); |
328 | edac_mc_free(mci); | 334 | return -ENODEV; |
329 | |||
330 | return rc; | ||
331 | } | 335 | } |
332 | 336 | ||
333 | /* returns count (>= 0), or negative on error */ | 337 | /* returns count (>= 0), or negative on error */ |