aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/edac_mc_sysfs.c
diff options
context:
space:
mode:
authorBorislav Petkov <borislav.petkov@amd.com>2010-11-24 13:52:09 -0500
committerBorislav Petkov <borislav.petkov@amd.com>2011-01-07 05:38:31 -0500
commit390944439f746824faec51b576f50cb5ef18745b (patch)
tree5fd15e75e8e5e5d3dc1e176c655829f9d0f83aa9 /drivers/edac/edac_mc_sysfs.c
parent360b7f3c602ed80ce8c6b2585dcb76883a440c17 (diff)
EDAC: Fixup scrubrate manipulation
Make the ->{get|set}_sdram_scrub_rate return the actual scrub rate bandwidth it succeeded setting and remove superfluous arg pointer used for that. A negative value returned still means that an error occurred while setting the scrubrate. Document this for future reference. Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'drivers/edac/edac_mc_sysfs.c')
-rw-r--r--drivers/edac/edac_mc_sysfs.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index dce61f7ba38b..39d97cfdf58c 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -436,56 +436,55 @@ static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
436 return count; 436 return count;
437} 437}
438 438
439/* memory scrubbing */ 439/* Memory scrubbing interface:
440 *
441 * A MC driver can limit the scrubbing bandwidth based on the CPU type.
442 * Therefore, ->set_sdram_scrub_rate should be made to return the actual
443 * bandwidth that is accepted or 0 when scrubbing is to be disabled.
444 *
445 * Negative value still means that an error has occurred while setting
446 * the scrub rate.
447 */
440static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci, 448static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci,
441 const char *data, size_t count) 449 const char *data, size_t count)
442{ 450{
443 unsigned long bandwidth = 0; 451 unsigned long bandwidth = 0;
444 int err; 452 int new_bw = 0;
445 453
446 if (!mci->set_sdram_scrub_rate) { 454 if (!mci->set_sdram_scrub_rate)
447 edac_printk(KERN_WARNING, EDAC_MC,
448 "Memory scrub rate setting not implemented!\n");
449 return -EINVAL; 455 return -EINVAL;
450 }
451 456
452 if (strict_strtoul(data, 10, &bandwidth) < 0) 457 if (strict_strtoul(data, 10, &bandwidth) < 0)
453 return -EINVAL; 458 return -EINVAL;
454 459
455 err = mci->set_sdram_scrub_rate(mci, (u32)bandwidth); 460 new_bw = mci->set_sdram_scrub_rate(mci, bandwidth);
456 if (err) { 461 if (new_bw >= 0) {
457 edac_printk(KERN_DEBUG, EDAC_MC, 462 edac_printk(KERN_DEBUG, EDAC_MC, "Scrub rate set to %d\n", new_bw);
458 "Failed setting scrub rate to %lu\n", bandwidth);
459 return -EINVAL;
460 }
461 else {
462 edac_printk(KERN_DEBUG, EDAC_MC,
463 "Scrub rate set to: %lu\n", bandwidth);
464 return count; 463 return count;
465 } 464 }
465
466 edac_printk(KERN_DEBUG, EDAC_MC, "Error setting scrub rate to: %lu\n", bandwidth);
467 return -EINVAL;
466} 468}
467 469
470/*
471 * ->get_sdram_scrub_rate() return value semantics same as above.
472 */
468static ssize_t mci_sdram_scrub_rate_show(struct mem_ctl_info *mci, char *data) 473static ssize_t mci_sdram_scrub_rate_show(struct mem_ctl_info *mci, char *data)
469{ 474{
470 u32 bandwidth = 0; 475 int bandwidth = 0;
471 int err;
472 476
473 if (!mci->get_sdram_scrub_rate) { 477 if (!mci->get_sdram_scrub_rate)
474 edac_printk(KERN_WARNING, EDAC_MC,
475 "Memory scrub rate reading not implemented\n");
476 return -EINVAL; 478 return -EINVAL;
477 }
478 479
479 err = mci->get_sdram_scrub_rate(mci, &bandwidth); 480 bandwidth = mci->get_sdram_scrub_rate(mci);
480 if (err) { 481 if (bandwidth < 0) {
481 edac_printk(KERN_DEBUG, EDAC_MC, "Error reading scrub rate\n"); 482 edac_printk(KERN_DEBUG, EDAC_MC, "Error reading scrub rate\n");
482 return err; 483 return bandwidth;
483 }
484 else {
485 edac_printk(KERN_DEBUG, EDAC_MC,
486 "Read scrub rate: %d\n", bandwidth);
487 return sprintf(data, "%d\n", bandwidth);
488 } 484 }
485
486 edac_printk(KERN_DEBUG, EDAC_MC, "Read scrub rate: %d\n", bandwidth);
487 return sprintf(data, "%d\n", bandwidth);
489} 488}
490 489
491/* default attribute files for the MCI object */ 490/* default attribute files for the MCI object */