aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/edac/edac_core.h173
-rw-r--r--drivers/edac/edac_device.c186
-rw-r--r--drivers/edac/edac_device_sysfs.c389
-rw-r--r--drivers/edac/edac_mc.c202
-rw-r--r--drivers/edac/edac_mc.h2
-rw-r--r--drivers/edac/edac_mc_sysfs.c336
-rw-r--r--drivers/edac/edac_module.c22
-rw-r--r--drivers/edac/edac_module.h16
-rw-r--r--drivers/edac/edac_pci.c75
-rw-r--r--drivers/edac/edac_pci_sysfs.c140
-rw-r--r--drivers/edac/edac_stub.c2
11 files changed, 722 insertions, 821 deletions
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h
index 5371e230a4ae..c511ad4de901 100644
--- a/drivers/edac/edac_core.h
+++ b/drivers/edac/edac_core.h
@@ -84,7 +84,7 @@ extern int edac_debug_level;
84#define debugf3( ... ) edac_debug_printk(3, __VA_ARGS__ ) 84#define debugf3( ... ) edac_debug_printk(3, __VA_ARGS__ )
85#define debugf4( ... ) edac_debug_printk(4, __VA_ARGS__ ) 85#define debugf4( ... ) edac_debug_printk(4, __VA_ARGS__ )
86 86
87#else /* !CONFIG_EDAC_DEBUG */ 87#else /* !CONFIG_EDAC_DEBUG */
88 88
89#define debugf0( ... ) 89#define debugf0( ... )
90#define debugf1( ... ) 90#define debugf1( ... )
@@ -92,7 +92,7 @@ extern int edac_debug_level;
92#define debugf3( ... ) 92#define debugf3( ... )
93#define debugf4( ... ) 93#define debugf4( ... )
94 94
95#endif /* !CONFIG_EDAC_DEBUG */ 95#endif /* !CONFIG_EDAC_DEBUG */
96 96
97#define BIT(x) (1 << (x)) 97#define BIT(x) (1 << (x))
98 98
@@ -135,9 +135,9 @@ enum mem_type {
135 MEM_DDR, /* Double data rate SDRAM */ 135 MEM_DDR, /* Double data rate SDRAM */
136 MEM_RDDR, /* Registered Double data rate SDRAM */ 136 MEM_RDDR, /* Registered Double data rate SDRAM */
137 MEM_RMBS, /* Rambus DRAM */ 137 MEM_RMBS, /* Rambus DRAM */
138 MEM_DDR2, /* DDR2 RAM */ 138 MEM_DDR2, /* DDR2 RAM */
139 MEM_FB_DDR2, /* fully buffered DDR2 */ 139 MEM_FB_DDR2, /* fully buffered DDR2 */
140 MEM_RDDR2, /* Registered DDR2 RAM */ 140 MEM_RDDR2, /* Registered DDR2 RAM */
141}; 141};
142 142
143#define MEM_FLAG_EMPTY BIT(MEM_EMPTY) 143#define MEM_FLAG_EMPTY BIT(MEM_EMPTY)
@@ -211,7 +211,7 @@ enum scrub_type {
211#define OP_RUNNING_POLL_INTR 0x203 211#define OP_RUNNING_POLL_INTR 0x203
212#define OP_OFFLINE 0x300 212#define OP_OFFLINE 0x300
213 213
214extern char * edac_align_ptr(void *ptr, unsigned size); 214extern char *edac_align_ptr(void *ptr, unsigned size);
215 215
216/* 216/*
217 * There are several things to be aware of that aren't at all obvious: 217 * There are several things to be aware of that aren't at all obvious:
@@ -298,7 +298,7 @@ extern char * edac_align_ptr(void *ptr, unsigned size);
298struct channel_info { 298struct channel_info {
299 int chan_idx; /* channel index */ 299 int chan_idx; /* channel index */
300 u32 ce_count; /* Correctable Errors for this CHANNEL */ 300 u32 ce_count; /* Correctable Errors for this CHANNEL */
301 char label[EDAC_MC_LABEL_LEN + 1]; /* DIMM label on motherboard */ 301 char label[EDAC_MC_LABEL_LEN + 1]; /* DIMM label on motherboard */
302 struct csrow_info *csrow; /* the parent */ 302 struct csrow_info *csrow; /* the parent */
303}; 303};
304 304
@@ -327,7 +327,7 @@ struct csrow_info {
327}; 327};
328 328
329struct mem_ctl_info { 329struct mem_ctl_info {
330 struct list_head link; /* for global list of mem_ctl_info structs */ 330 struct list_head link; /* for global list of mem_ctl_info structs */
331 unsigned long mtype_cap; /* memory types supported by mc */ 331 unsigned long mtype_cap; /* memory types supported by mc */
332 unsigned long edac_ctl_cap; /* Mem controller EDAC capabilities */ 332 unsigned long edac_ctl_cap; /* Mem controller EDAC capabilities */
333 unsigned long edac_cap; /* configuration capabilities - this is 333 unsigned long edac_cap; /* configuration capabilities - this is
@@ -344,14 +344,14 @@ struct mem_ctl_info {
344 /* Translates sdram memory scrub rate given in bytes/sec to the 344 /* Translates sdram memory scrub rate given in bytes/sec to the
345 internal representation and configures whatever else needs 345 internal representation and configures whatever else needs
346 to be configured. 346 to be configured.
347 */ 347 */
348 int (*set_sdram_scrub_rate) (struct mem_ctl_info *mci, u32 *bw); 348 int (*set_sdram_scrub_rate) (struct mem_ctl_info * mci, u32 * bw);
349 349
350 /* Get the current sdram memory scrub rate from the internal 350 /* Get the current sdram memory scrub rate from the internal
351 representation and converts it to the closest matching 351 representation and converts it to the closest matching
352 bandwith in bytes/sec. 352 bandwith in bytes/sec.
353 */ 353 */
354 int (*get_sdram_scrub_rate) (struct mem_ctl_info *mci, u32 *bw); 354 int (*get_sdram_scrub_rate) (struct mem_ctl_info * mci, u32 * bw);
355 355
356 /* pointer to edac checking routine */ 356 /* pointer to edac checking routine */
357 void (*edac_check) (struct mem_ctl_info * mci); 357 void (*edac_check) (struct mem_ctl_info * mci);
@@ -362,7 +362,7 @@ struct mem_ctl_info {
362 */ 362 */
363 /* FIXME - why not send the phys page to begin with? */ 363 /* FIXME - why not send the phys page to begin with? */
364 unsigned long (*ctl_page_to_phys) (struct mem_ctl_info * mci, 364 unsigned long (*ctl_page_to_phys) (struct mem_ctl_info * mci,
365 unsigned long page); 365 unsigned long page);
366 int mc_idx; 366 int mc_idx;
367 int nr_csrows; 367 int nr_csrows;
368 struct csrow_info *csrows; 368 struct csrow_info *csrows;
@@ -444,8 +444,8 @@ struct mem_ctl_info {
444 */ 444 */
445 445
446struct edac_device_counter { 446struct edac_device_counter {
447 u32 ue_count; 447 u32 ue_count;
448 u32 ce_count; 448 u32 ce_count;
449}; 449};
450 450
451#define INC_COUNTER(cnt) (cnt++) 451#define INC_COUNTER(cnt) (cnt++)
@@ -455,14 +455,13 @@ struct edac_device_counter {
455 * to specify attributes of the edac_block 455 * to specify attributes of the edac_block
456 */ 456 */
457struct edac_attrib_spec { 457struct edac_attrib_spec {
458 char name[EDAC_DEVICE_NAME_LEN + 1]; 458 char name[EDAC_DEVICE_NAME_LEN + 1];
459 459
460 int type; 460 int type;
461#define EDAC_ATTR_INT 0x01 461#define EDAC_ATTR_INT 0x01
462#define EDAC_ATTR_CHAR 0x02 462#define EDAC_ATTR_CHAR 0x02
463}; 463};
464 464
465
466/* Attribute control structure 465/* Attribute control structure
467 * In this structure is a pointer to the driver's edac_attrib_spec 466 * In this structure is a pointer to the driver's edac_attrib_spec
468 * The life of this pointer is inclusive in the life of the driver's 467 * The life of this pointer is inclusive in the life of the driver's
@@ -471,9 +470,9 @@ struct edac_attrib_spec {
471struct edac_attrib { 470struct edac_attrib {
472 struct edac_device_block *block; /* Up Pointer */ 471 struct edac_device_block *block; /* Up Pointer */
473 472
474 struct edac_attrib_spec *spec; /* ptr to module spec entry */ 473 struct edac_attrib_spec *spec; /* ptr to module spec entry */
475 474
476 union { /* actual value */ 475 union { /* actual value */
477 int edac_attrib_int_value; 476 int edac_attrib_int_value;
478 char edac_attrib_char_value[EDAC_ATTRIB_VALUE_LEN + 1]; 477 char edac_attrib_char_value[EDAC_ATTRIB_VALUE_LEN + 1];
479 } edac_attrib_value; 478 } edac_attrib_value;
@@ -482,12 +481,12 @@ struct edac_attrib {
482/* device block control structure */ 481/* device block control structure */
483struct edac_device_block { 482struct edac_device_block {
484 struct edac_device_instance *instance; /* Up Pointer */ 483 struct edac_device_instance *instance; /* Up Pointer */
485 char name[EDAC_DEVICE_NAME_LEN + 1]; 484 char name[EDAC_DEVICE_NAME_LEN + 1];
486 485
487 struct edac_device_counter counters; /* basic UE and CE counters */ 486 struct edac_device_counter counters; /* basic UE and CE counters */
488 487
489 int nr_attribs; /* how many attributes */ 488 int nr_attribs; /* how many attributes */
490 struct edac_attrib *attribs; /* this block's attributes */ 489 struct edac_attrib *attribs; /* this block's attributes */
491 490
492 /* edac sysfs device control */ 491 /* edac sysfs device control */
493 struct kobject kobj; 492 struct kobject kobj;
@@ -501,7 +500,7 @@ struct edac_device_instance {
501 500
502 struct edac_device_counter counters; /* instance counters */ 501 struct edac_device_counter counters; /* instance counters */
503 502
504 u32 nr_blocks; /* how many blocks */ 503 u32 nr_blocks; /* how many blocks */
505 struct edac_device_block *blocks; /* block array */ 504 struct edac_device_block *blocks; /* block array */
506 505
507 /* edac sysfs device control */ 506 /* edac sysfs device control */
@@ -509,7 +508,6 @@ struct edac_device_instance {
509 struct completion kobj_complete; 508 struct completion kobj_complete;
510}; 509};
511 510
512
513/* 511/*
514 * Abstract edac_device control info structure 512 * Abstract edac_device control info structure
515 * 513 *
@@ -539,9 +537,9 @@ struct edac_device_ctl_info {
539#endif 537#endif
540 538
541 /* pointer to edac polling checking routine: 539 /* pointer to edac polling checking routine:
542 * If NOT NULL: points to polling check routine 540 * If NOT NULL: points to polling check routine
543 * If NULL: Then assumes INTERRUPT operation, where 541 * If NULL: Then assumes INTERRUPT operation, where
544 * MC driver will receive events 542 * MC driver will receive events
545 */ 543 */
546 void (*edac_check) (struct edac_device_ctl_info * edac_dev); 544 void (*edac_check) (struct edac_device_ctl_info * edac_dev);
547 545
@@ -553,7 +551,7 @@ struct edac_device_ctl_info {
553 551
554 void *pvt_info; /* pointer to 'private driver' info */ 552 void *pvt_info; /* pointer to 'private driver' info */
555 553
556 unsigned long start_time;/* edac_device load start time (jiffies)*/ 554 unsigned long start_time; /* edac_device load start time (jiffies) */
557 555
558 /* these are for safe removal of mc devices from global list while 556 /* these are for safe removal of mc devices from global list while
559 * NMI handlers may be traversing list 557 * NMI handlers may be traversing list
@@ -563,10 +561,10 @@ struct edac_device_ctl_info {
563 561
564 /* sysfs top name under 'edac' directory 562 /* sysfs top name under 'edac' directory
565 * and instance name: 563 * and instance name:
566 * cpu/cpu0/... 564 * cpu/cpu0/...
567 * cpu/cpu1/... 565 * cpu/cpu1/...
568 * cpu/cpu2/... 566 * cpu/cpu2/...
569 * ... 567 * ...
570 */ 568 */
571 char name[EDAC_DEVICE_NAME_LEN + 1]; 569 char name[EDAC_DEVICE_NAME_LEN + 1];
572 570
@@ -594,8 +592,7 @@ struct edac_device_ctl_info {
594 container_of(w,struct edac_device_ctl_info,work) 592 container_of(w,struct edac_device_ctl_info,work)
595 593
596/* Function to calc the number of delay jiffies from poll_msec */ 594/* Function to calc the number of delay jiffies from poll_msec */
597static inline void edac_device_calc_delay( 595static inline void edac_device_calc_delay(struct edac_device_ctl_info *edac_dev)
598 struct edac_device_ctl_info *edac_dev)
599{ 596{
600 /* convert from msec to jiffies */ 597 /* convert from msec to jiffies */
601 edac_dev->delay = edac_dev->poll_msec * HZ / 1000; 598 edac_dev->delay = edac_dev->poll_msec * HZ / 1000;
@@ -609,15 +606,14 @@ static inline void edac_device_calc_delay(
609 * it is going to control/register with the EDAC CORE. 606 * it is going to control/register with the EDAC CORE.
610 */ 607 */
611extern struct edac_device_ctl_info *edac_device_alloc_ctl_info( 608extern struct edac_device_ctl_info *edac_device_alloc_ctl_info(
612 unsigned sizeof_private, 609 unsigned sizeof_private,
613 char *edac_device_name, 610 char *edac_device_name,
614 unsigned nr_instances, 611 unsigned nr_instances,
615 char *edac_block_name, 612 char *edac_block_name,
616 unsigned nr_blocks, 613 unsigned nr_blocks,
617 unsigned offset_value, 614 unsigned offset_value,
618 struct edac_attrib_spec *attrib_spec, 615 struct edac_attrib_spec *attrib_spec,
619 unsigned nr_attribs 616 unsigned nr_attribs);
620);
621 617
622/* The offset value can be: 618/* The offset value can be:
623 * -1 indicating no offset value 619 * -1 indicating no offset value
@@ -627,13 +623,13 @@ extern struct edac_device_ctl_info *edac_device_alloc_ctl_info(
627 */ 623 */
628#define BLOCK_OFFSET_VALUE_OFF ((unsigned) -1) 624#define BLOCK_OFFSET_VALUE_OFF ((unsigned) -1)
629 625
630extern void edac_device_free_ctl_info( struct edac_device_ctl_info *ctl_info); 626extern void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info);
631 627
632#ifdef CONFIG_PCI 628#ifdef CONFIG_PCI
633 629
634struct edac_pci_counter { 630struct edac_pci_counter {
635 atomic_t pe_count; 631 atomic_t pe_count;
636 atomic_t npe_count; 632 atomic_t npe_count;
637}; 633};
638 634
639/* 635/*
@@ -658,9 +654,9 @@ struct edac_pci_ctl_info {
658#endif 654#endif
659 655
660 /* pointer to edac polling checking routine: 656 /* pointer to edac polling checking routine:
661 * If NOT NULL: points to polling check routine 657 * If NOT NULL: points to polling check routine
662 * If NULL: Then assumes INTERRUPT operation, where 658 * If NULL: Then assumes INTERRUPT operation, where
663 * MC driver will receive events 659 * MC driver will receive events
664 */ 660 */
665 void (*edac_check) (struct edac_pci_ctl_info * edac_dev); 661 void (*edac_check) (struct edac_pci_ctl_info * edac_dev);
666 662
@@ -672,7 +668,7 @@ struct edac_pci_ctl_info {
672 668
673 void *pvt_info; /* pointer to 'private driver' info */ 669 void *pvt_info; /* pointer to 'private driver' info */
674 670
675 unsigned long start_time;/* edac_pci load start time (jiffies)*/ 671 unsigned long start_time; /* edac_pci load start time (jiffies) */
676 672
677 /* these are for safe removal of devices from global list while 673 /* these are for safe removal of devices from global list while
678 * NMI handlers may be traversing list 674 * NMI handlers may be traversing list
@@ -682,10 +678,10 @@ struct edac_pci_ctl_info {
682 678
683 /* sysfs top name under 'edac' directory 679 /* sysfs top name under 'edac' directory
684 * and instance name: 680 * and instance name:
685 * cpu/cpu0/... 681 * cpu/cpu0/...
686 * cpu/cpu1/... 682 * cpu/cpu1/...
687 * cpu/cpu2/... 683 * cpu/cpu2/...
688 * ... 684 * ...
689 */ 685 */
690 char name[EDAC_DEVICE_NAME_LEN + 1]; 686 char name[EDAC_DEVICE_NAME_LEN + 1];
691 687
@@ -704,7 +700,7 @@ struct edac_pci_ctl_info {
704 700
705/* write all or some bits in a byte-register*/ 701/* write all or some bits in a byte-register*/
706static inline void pci_write_bits8(struct pci_dev *pdev, int offset, u8 value, 702static inline void pci_write_bits8(struct pci_dev *pdev, int offset, u8 value,
707 u8 mask) 703 u8 mask)
708{ 704{
709 if (mask != 0xff) { 705 if (mask != 0xff) {
710 u8 buf; 706 u8 buf;
@@ -720,7 +716,7 @@ static inline void pci_write_bits8(struct pci_dev *pdev, int offset, u8 value,
720 716
721/* write all or some bits in a word-register*/ 717/* write all or some bits in a word-register*/
722static inline void pci_write_bits16(struct pci_dev *pdev, int offset, 718static inline void pci_write_bits16(struct pci_dev *pdev, int offset,
723 u16 value, u16 mask) 719 u16 value, u16 mask)
724{ 720{
725 if (mask != 0xffff) { 721 if (mask != 0xffff) {
726 u16 buf; 722 u16 buf;
@@ -736,7 +732,7 @@ static inline void pci_write_bits16(struct pci_dev *pdev, int offset,
736 732
737/* write all or some bits in a dword-register*/ 733/* write all or some bits in a dword-register*/
738static inline void pci_write_bits32(struct pci_dev *pdev, int offset, 734static inline void pci_write_bits32(struct pci_dev *pdev, int offset,
739 u32 value, u32 mask) 735 u32 value, u32 mask)
740{ 736{
741 if (mask != 0xffff) { 737 if (mask != 0xffff) {
742 u32 buf; 738 u32 buf;
@@ -750,13 +746,13 @@ static inline void pci_write_bits32(struct pci_dev *pdev, int offset,
750 pci_write_config_dword(pdev, offset, value); 746 pci_write_config_dword(pdev, offset, value);
751} 747}
752 748
753#endif /* CONFIG_PCI */ 749#endif /* CONFIG_PCI */
754 750
755extern struct mem_ctl_info * edac_mc_find(int idx); 751extern struct mem_ctl_info *edac_mc_find(int idx);
756extern int edac_mc_add_mc(struct mem_ctl_info *mci,int mc_idx); 752extern int edac_mc_add_mc(struct mem_ctl_info *mci, int mc_idx);
757extern struct mem_ctl_info * edac_mc_del_mc(struct device *dev); 753extern struct mem_ctl_info *edac_mc_del_mc(struct device *dev);
758extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci, 754extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
759 unsigned long page); 755 unsigned long page);
760 756
761/* 757/*
762 * The no info errors are used when error overflows are reported. 758 * The no info errors are used when error overflows are reported.
@@ -769,44 +765,43 @@ extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
769 * statement clutter and extra function arguments. 765 * statement clutter and extra function arguments.
770 */ 766 */
771extern void edac_mc_handle_ce(struct mem_ctl_info *mci, 767extern void edac_mc_handle_ce(struct mem_ctl_info *mci,
772 unsigned long page_frame_number, unsigned long offset_in_page, 768 unsigned long page_frame_number,
773 unsigned long syndrome, int row, int channel, 769 unsigned long offset_in_page,
774 const char *msg); 770 unsigned long syndrome, int row, int channel,
771 const char *msg);
775extern void edac_mc_handle_ce_no_info(struct mem_ctl_info *mci, 772extern void edac_mc_handle_ce_no_info(struct mem_ctl_info *mci,
776 const char *msg); 773 const char *msg);
777extern void edac_mc_handle_ue(struct mem_ctl_info *mci, 774extern void edac_mc_handle_ue(struct mem_ctl_info *mci,
778 unsigned long page_frame_number, unsigned long offset_in_page, 775 unsigned long page_frame_number,
779 int row, const char *msg); 776 unsigned long offset_in_page, int row,
777 const char *msg);
780extern void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci, 778extern void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci,
781 const char *msg); 779 const char *msg);
782extern void edac_mc_handle_fbd_ue(struct mem_ctl_info *mci, 780extern void edac_mc_handle_fbd_ue(struct mem_ctl_info *mci, unsigned int csrow,
783 unsigned int csrow, 781 unsigned int channel0, unsigned int channel1,
784 unsigned int channel0, 782 char *msg);
785 unsigned int channel1, 783extern void edac_mc_handle_fbd_ce(struct mem_ctl_info *mci, unsigned int csrow,
786 char *msg); 784 unsigned int channel, char *msg);
787extern void edac_mc_handle_fbd_ce(struct mem_ctl_info *mci,
788 unsigned int csrow,
789 unsigned int channel,
790 char *msg);
791 785
792/* 786/*
793 * edac_device APIs 787 * edac_device APIs
794 */ 788 */
795extern struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows, 789extern struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
796 unsigned nr_chans); 790 unsigned nr_chans);
797extern void edac_mc_free(struct mem_ctl_info *mci); 791extern void edac_mc_free(struct mem_ctl_info *mci);
798extern int edac_device_add_device(struct edac_device_ctl_info *edac_dev, int edac_idx); 792extern int edac_device_add_device(struct edac_device_ctl_info *edac_dev,
799extern struct edac_device_ctl_info * edac_device_del_device(struct device *dev); 793 int edac_idx);
794extern struct edac_device_ctl_info *edac_device_del_device(struct device *dev);
800extern void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev, 795extern void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev,
801 int inst_nr, int block_nr, const char *msg); 796 int inst_nr, int block_nr, const char *msg);
802extern void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev, 797extern void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev,
803 int inst_nr, int block_nr, const char *msg); 798 int inst_nr, int block_nr, const char *msg);
804 799
805/* 800/*
806 * edac_pci APIs 801 * edac_pci APIs
807 */ 802 */
808extern struct edac_pci_ctl_info * 803extern struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt, const char
809edac_pci_alloc_ctl_info(unsigned int sz_pvt, const char *edac_pci_name); 804 *edac_pci_name);
810 805
811extern void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci); 806extern void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci);
812 807
@@ -814,10 +809,10 @@ extern void
814edac_pci_reset_delay_period(struct edac_pci_ctl_info *pci, unsigned long value); 809edac_pci_reset_delay_period(struct edac_pci_ctl_info *pci, unsigned long value);
815 810
816extern int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx); 811extern int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx);
817extern struct edac_pci_ctl_info * edac_pci_del_device(struct device *dev); 812extern struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev);
818 813
819extern struct edac_pci_ctl_info * 814extern struct edac_pci_ctl_info *edac_pci_create_generic_ctl(struct device *dev, const char
820edac_pci_create_generic_ctl(struct device *dev, const char *mod_name); 815 *mod_name);
821 816
822extern void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci); 817extern void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci);
823extern int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci); 818extern int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci);
@@ -826,6 +821,6 @@ extern void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci);
826/* 821/*
827 * edac misc APIs 822 * edac misc APIs
828 */ 823 */
829extern char * edac_op_state_toString(int op_state); 824extern char *edac_op_state_toString(int op_state);
830 825
831#endif /* _EDAC_CORE_H_ */ 826#endif /* _EDAC_CORE_H_ */
diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
index 3db8effa1fd0..4ce978b72d34 100644
--- a/drivers/edac/edac_device.c
+++ b/drivers/edac/edac_device.c
@@ -35,7 +35,6 @@
35static DECLARE_MUTEX(device_ctls_mutex); 35static DECLARE_MUTEX(device_ctls_mutex);
36static struct list_head edac_device_list = LIST_HEAD_INIT(edac_device_list); 36static struct list_head edac_device_list = LIST_HEAD_INIT(edac_device_list);
37 37
38
39static inline void lock_device_list(void) 38static inline void lock_device_list(void)
40{ 39{
41 down(&device_ctls_mutex); 40 down(&device_ctls_mutex);
@@ -46,18 +45,17 @@ static inline void unlock_device_list(void)
46 up(&device_ctls_mutex); 45 up(&device_ctls_mutex);
47} 46}
48 47
49
50#ifdef CONFIG_EDAC_DEBUG 48#ifdef CONFIG_EDAC_DEBUG
51static void edac_device_dump_device(struct edac_device_ctl_info *edac_dev) 49static void edac_device_dump_device(struct edac_device_ctl_info *edac_dev)
52{ 50{
53 debugf3("\tedac_dev = %p dev_idx=%d \n", edac_dev,edac_dev->dev_idx); 51 debugf3("\tedac_dev = %p dev_idx=%d \n", edac_dev, edac_dev->dev_idx);
54 debugf4("\tedac_dev->edac_check = %p\n", edac_dev->edac_check); 52 debugf4("\tedac_dev->edac_check = %p\n", edac_dev->edac_check);
55 debugf3("\tdev = %p\n", edac_dev->dev); 53 debugf3("\tdev = %p\n", edac_dev->dev);
56 debugf3("\tmod_name:ctl_name = %s:%s\n", 54 debugf3("\tmod_name:ctl_name = %s:%s\n",
57 edac_dev->mod_name, edac_dev->ctl_name); 55 edac_dev->mod_name, edac_dev->ctl_name);
58 debugf3("\tpvt_info = %p\n\n", edac_dev->pvt_info); 56 debugf3("\tpvt_info = %p\n\n", edac_dev->pvt_info);
59} 57}
60#endif /* CONFIG_EDAC_DEBUG */ 58#endif /* CONFIG_EDAC_DEBUG */
61 59
62/* 60/*
63 * The alloc() and free() functions for the 'edac_device' control info 61 * The alloc() and free() functions for the 'edac_device' control info
@@ -71,7 +69,8 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
71 char *edac_block_name, 69 char *edac_block_name,
72 unsigned nr_blocks, 70 unsigned nr_blocks,
73 unsigned offset_value, 71 unsigned offset_value,
74 struct edac_attrib_spec *attrib_spec, 72 struct edac_attrib_spec
73 *attrib_spec,
75 unsigned nr_attribs) 74 unsigned nr_attribs)
76{ 75{
77 struct edac_device_ctl_info *dev_ctl; 76 struct edac_device_ctl_info *dev_ctl;
@@ -84,35 +83,35 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
84 void *pvt; 83 void *pvt;
85 84
86 debugf1("%s() instances=%d blocks=%d\n", 85 debugf1("%s() instances=%d blocks=%d\n",
87 __func__,nr_instances,nr_blocks); 86 __func__, nr_instances, nr_blocks);
88 87
89 /* Figure out the offsets of the various items from the start of an 88 /* Figure out the offsets of the various items from the start of an
90 * ctl_info structure. We want the alignment of each item 89 * ctl_info structure. We want the alignment of each item
91 * to be at least as stringent as what the compiler would 90 * to be at least as stringent as what the compiler would
92 * provide if we could simply hardcode everything into a single struct. 91 * provide if we could simply hardcode everything into a single struct.
93 */ 92 */
94 dev_ctl = (struct edac_device_ctl_info *) 0; 93 dev_ctl = (struct edac_device_ctl_info *)0;
95 94
96 /* Calc the 'end' offset past the ctl_info structure */ 95 /* Calc the 'end' offset past the ctl_info structure */
97 dev_inst = (struct edac_device_instance *) 96 dev_inst = (struct edac_device_instance *)
98 edac_align_ptr(&dev_ctl[1],sizeof(*dev_inst)); 97 edac_align_ptr(&dev_ctl[1], sizeof(*dev_inst));
99 98
100 /* Calc the 'end' offset past the instance array */ 99 /* Calc the 'end' offset past the instance array */
101 dev_blk = (struct edac_device_block *) 100 dev_blk = (struct edac_device_block *)
102 edac_align_ptr(&dev_inst[nr_instances],sizeof(*dev_blk)); 101 edac_align_ptr(&dev_inst[nr_instances], sizeof(*dev_blk));
103 102
104 /* Calc the 'end' offset past the dev_blk array */ 103 /* Calc the 'end' offset past the dev_blk array */
105 count = nr_instances * nr_blocks; 104 count = nr_instances * nr_blocks;
106 dev_attrib = (struct edac_attrib *) 105 dev_attrib = (struct edac_attrib *)
107 edac_align_ptr(&dev_blk[count],sizeof(*dev_attrib)); 106 edac_align_ptr(&dev_blk[count], sizeof(*dev_attrib));
108 107
109 /* Check for case of NO attributes specified */ 108 /* Check for case of NO attributes specified */
110 if (nr_attribs > 0) 109 if (nr_attribs > 0)
111 count *= nr_attribs; 110 count *= nr_attribs;
112 111
113 /* Calc the 'end' offset past the attributes array */ 112 /* Calc the 'end' offset past the attributes array */
114 pvt = edac_align_ptr(&dev_attrib[count],sz_private); 113 pvt = edac_align_ptr(&dev_attrib[count], sz_private);
115 total_size = ((unsigned long) pvt) + sz_private; 114 total_size = ((unsigned long)pvt) + sz_private;
116 115
117 /* Allocate the amount of memory for the set of control structures */ 116 /* Allocate the amount of memory for the set of control structures */
118 if ((dev_ctl = kmalloc(total_size, GFP_KERNEL)) == NULL) 117 if ((dev_ctl = kmalloc(total_size, GFP_KERNEL)) == NULL)
@@ -122,22 +121,21 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
122 * rather than an imaginary chunk of memory located at address 0. 121 * rather than an imaginary chunk of memory located at address 0.
123 */ 122 */
124 dev_inst = (struct edac_device_instance *) 123 dev_inst = (struct edac_device_instance *)
125 (((char *) dev_ctl) + ((unsigned long) dev_inst)); 124 (((char *)dev_ctl) + ((unsigned long)dev_inst));
126 dev_blk = (struct edac_device_block *) 125 dev_blk = (struct edac_device_block *)
127 (((char *) dev_ctl) + ((unsigned long) dev_blk)); 126 (((char *)dev_ctl) + ((unsigned long)dev_blk));
128 dev_attrib = (struct edac_attrib *) 127 dev_attrib = (struct edac_attrib *)
129 (((char *) dev_ctl) + ((unsigned long) dev_attrib)); 128 (((char *)dev_ctl) + ((unsigned long)dev_attrib));
130 pvt = sz_private ? 129 pvt = sz_private ? (((char *)dev_ctl) + ((unsigned long)pvt)) : NULL;
131 (((char *) dev_ctl) + ((unsigned long) pvt)) : NULL;
132 130
133 memset(dev_ctl, 0, total_size); /* clear all fields */ 131 memset(dev_ctl, 0, total_size); /* clear all fields */
134 dev_ctl->nr_instances = nr_instances; 132 dev_ctl->nr_instances = nr_instances;
135 dev_ctl->instances = dev_inst; 133 dev_ctl->instances = dev_inst;
136 dev_ctl->pvt_info = pvt; 134 dev_ctl->pvt_info = pvt;
137 135
138 /* Name of this edac device, ensure null terminated */ 136 /* Name of this edac device, ensure null terminated */
139 snprintf(dev_ctl->name,sizeof(dev_ctl->name),"%s", edac_device_name); 137 snprintf(dev_ctl->name, sizeof(dev_ctl->name), "%s", edac_device_name);
140 dev_ctl->name[sizeof(dev_ctl->name)-1] = '\0'; 138 dev_ctl->name[sizeof(dev_ctl->name) - 1] = '\0';
141 139
142 /* Initialize every Instance */ 140 /* Initialize every Instance */
143 for (instance = 0; instance < nr_instances; instance++) { 141 for (instance = 0; instance < nr_instances; instance++) {
@@ -149,24 +147,22 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
149 147
150 /* name of this instance */ 148 /* name of this instance */
151 snprintf(inst->name, sizeof(inst->name), 149 snprintf(inst->name, sizeof(inst->name),
152 "%s%u", edac_device_name, instance); 150 "%s%u", edac_device_name, instance);
153 inst->name[sizeof(inst->name)-1] = '\0'; 151 inst->name[sizeof(inst->name) - 1] = '\0';
154 152
155 /* Initialize every block in each instance */ 153 /* Initialize every block in each instance */
156 for ( block = 0; 154 for (block = 0; block < nr_blocks; block++) {
157 block < nr_blocks;
158 block++) {
159 blk = &blk_p[block]; 155 blk = &blk_p[block];
160 blk->instance = inst; 156 blk->instance = inst;
161 blk->nr_attribs = nr_attribs; 157 blk->nr_attribs = nr_attribs;
162 attrib_p = &dev_attrib[block * nr_attribs]; 158 attrib_p = &dev_attrib[block * nr_attribs];
163 blk->attribs = attrib_p; 159 blk->attribs = attrib_p;
164 snprintf(blk->name, sizeof(blk->name), 160 snprintf(blk->name, sizeof(blk->name),
165 "%s%d", edac_block_name,block+1); 161 "%s%d", edac_block_name, block + 1);
166 blk->name[sizeof(blk->name)-1] = '\0'; 162 blk->name[sizeof(blk->name) - 1] = '\0';
167 163
168 debugf1("%s() instance=%d block=%d name=%s\n", 164 debugf1("%s() instance=%d block=%d name=%s\n",
169 __func__, instance,block,blk->name); 165 __func__, instance, block, blk->name);
170 166
171 if (attrib_spec != NULL) { 167 if (attrib_spec != NULL) {
172 /* when there is an attrib_spec passed int then 168 /* when there is an attrib_spec passed int then
@@ -178,7 +174,7 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
178 174
179 /* Link each attribute to the caller's 175 /* Link each attribute to the caller's
180 * spec entry, for name and type 176 * spec entry, for name and type
181 */ 177 */
182 attrib->spec = &attrib_spec[attr]; 178 attrib->spec = &attrib_spec[attr];
183 } 179 }
184 } 180 }
@@ -190,6 +186,7 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
190 186
191 return dev_ctl; 187 return dev_ctl;
192} 188}
189
193EXPORT_SYMBOL_GPL(edac_device_alloc_ctl_info); 190EXPORT_SYMBOL_GPL(edac_device_alloc_ctl_info);
194 191
195/* 192/*
@@ -197,19 +194,18 @@ EXPORT_SYMBOL_GPL(edac_device_alloc_ctl_info);
197 * frees the memory allocated by the edac_device_alloc_ctl_info() 194 * frees the memory allocated by the edac_device_alloc_ctl_info()
198 * function 195 * function
199 */ 196 */
200void edac_device_free_ctl_info( struct edac_device_ctl_info *ctl_info) { 197void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info)
198{
201 kfree(ctl_info); 199 kfree(ctl_info);
202} 200}
203EXPORT_SYMBOL_GPL(edac_device_free_ctl_info);
204
205 201
202EXPORT_SYMBOL_GPL(edac_device_free_ctl_info);
206 203
207/* 204/*
208 * find_edac_device_by_dev 205 * find_edac_device_by_dev
209 * scans the edac_device list for a specific 'struct device *' 206 * scans the edac_device list for a specific 'struct device *'
210 */ 207 */
211static struct edac_device_ctl_info * 208static struct edac_device_ctl_info *find_edac_device_by_dev(struct device *dev)
212find_edac_device_by_dev(struct device *dev)
213{ 209{
214 struct edac_device_ctl_info *edac_dev; 210 struct edac_device_ctl_info *edac_dev;
215 struct list_head *item; 211 struct list_head *item;
@@ -234,7 +230,7 @@ find_edac_device_by_dev(struct device *dev)
234 * 0 on success 230 * 0 on success
235 * 1 on failure. 231 * 1 on failure.
236 */ 232 */
237static int add_edac_dev_to_global_list (struct edac_device_ctl_info *edac_dev) 233static int add_edac_dev_to_global_list(struct edac_device_ctl_info *edac_dev)
238{ 234{
239 struct list_head *item, *insert_before; 235 struct list_head *item, *insert_before;
240 struct edac_device_ctl_info *rover; 236 struct edac_device_ctl_info *rover;
@@ -261,17 +257,18 @@ static int add_edac_dev_to_global_list (struct edac_device_ctl_info *edac_dev)
261 list_add_tail_rcu(&edac_dev->link, insert_before); 257 list_add_tail_rcu(&edac_dev->link, insert_before);
262 return 0; 258 return 0;
263 259
264fail0: 260 fail0:
265 edac_printk(KERN_WARNING, EDAC_MC, 261 edac_printk(KERN_WARNING, EDAC_MC,
266 "%s (%s) %s %s already assigned %d\n", 262 "%s (%s) %s %s already assigned %d\n",
267 rover->dev->bus_id, dev_name(rover), 263 rover->dev->bus_id, dev_name(rover),
268 rover->mod_name, rover->ctl_name, rover->dev_idx); 264 rover->mod_name, rover->ctl_name, rover->dev_idx);
269 return 1; 265 return 1;
270 266
271fail1: 267 fail1:
272 edac_printk(KERN_WARNING, EDAC_MC, 268 edac_printk(KERN_WARNING, EDAC_MC,
273 "bug in low-level driver: attempt to assign\n" 269 "bug in low-level driver: attempt to assign\n"
274 " duplicate dev_idx %d in %s()\n", rover->dev_idx, __func__); 270 " duplicate dev_idx %d in %s()\n", rover->dev_idx,
271 __func__);
275 return 1; 272 return 1;
276} 273}
277 274
@@ -290,8 +287,8 @@ static void complete_edac_device_list_del(struct rcu_head *head)
290/* 287/*
291 * del_edac_device_from_global_list 288 * del_edac_device_from_global_list
292 */ 289 */
293static void del_edac_device_from_global_list( 290static void del_edac_device_from_global_list(struct edac_device_ctl_info
294 struct edac_device_ctl_info *edac_device) 291 *edac_device)
295{ 292{
296 list_del_rcu(&edac_device->link); 293 list_del_rcu(&edac_device->link);
297 init_completion(&edac_device->complete); 294 init_completion(&edac_device->complete);
@@ -308,7 +305,7 @@ static void del_edac_device_from_global_list(
308 * 305 *
309 * Caller must hold device_ctls_mutex. 306 * Caller must hold device_ctls_mutex.
310 */ 307 */
311struct edac_device_ctl_info * edac_device_find(int idx) 308struct edac_device_ctl_info *edac_device_find(int idx)
312{ 309{
313 struct list_head *item; 310 struct list_head *item;
314 struct edac_device_ctl_info *edac_dev; 311 struct edac_device_ctl_info *edac_dev;
@@ -328,8 +325,8 @@ struct edac_device_ctl_info * edac_device_find(int idx)
328 325
329 return NULL; 326 return NULL;
330} 327}
331EXPORT_SYMBOL(edac_device_find);
332 328
329EXPORT_SYMBOL(edac_device_find);
333 330
334/* 331/*
335 * edac_device_workq_function 332 * edac_device_workq_function
@@ -338,14 +335,13 @@ EXPORT_SYMBOL(edac_device_find);
338#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) 335#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
339static void edac_device_workq_function(struct work_struct *work_req) 336static void edac_device_workq_function(struct work_struct *work_req)
340{ 337{
341 struct delayed_work *d_work = (struct delayed_work*) work_req; 338 struct delayed_work *d_work = (struct delayed_work *)work_req;
342 struct edac_device_ctl_info *edac_dev = 339 struct edac_device_ctl_info *edac_dev = to_edac_device_ctl_work(d_work);
343 to_edac_device_ctl_work(d_work);
344#else 340#else
345static void edac_device_workq_function(void *ptr) 341static void edac_device_workq_function(void *ptr)
346{ 342{
347 struct edac_device_ctl_info *edac_dev = 343 struct edac_device_ctl_info *edac_dev =
348 (struct edac_device_ctl_info *) ptr; 344 (struct edac_device_ctl_info *)ptr;
349#endif 345#endif
350 346
351 //debugf0("%s() here and running\n", __func__); 347 //debugf0("%s() here and running\n", __func__);
@@ -353,14 +349,14 @@ static void edac_device_workq_function(void *ptr)
353 349
354 /* Only poll controllers that are running polled and have a check */ 350 /* Only poll controllers that are running polled and have a check */
355 if ((edac_dev->op_state == OP_RUNNING_POLL) && 351 if ((edac_dev->op_state == OP_RUNNING_POLL) &&
356 (edac_dev->edac_check != NULL)) { 352 (edac_dev->edac_check != NULL)) {
357 edac_dev->edac_check(edac_dev); 353 edac_dev->edac_check(edac_dev);
358 } 354 }
359 355
360 unlock_device_list(); 356 unlock_device_list();
361 357
362 /* Reschedule */ 358 /* Reschedule */
363 queue_delayed_work(edac_workqueue,&edac_dev->work, edac_dev->delay); 359 queue_delayed_work(edac_workqueue, &edac_dev->work, edac_dev->delay);
364} 360}
365 361
366/* 362/*
@@ -369,7 +365,7 @@ static void edac_device_workq_function(void *ptr)
369 * passing in the new delay period in msec 365 * passing in the new delay period in msec
370 */ 366 */
371void edac_device_workq_setup(struct edac_device_ctl_info *edac_dev, 367void edac_device_workq_setup(struct edac_device_ctl_info *edac_dev,
372 unsigned msec) 368 unsigned msec)
373{ 369{
374 debugf0("%s()\n", __func__); 370 debugf0("%s()\n", __func__);
375 371
@@ -403,9 +399,8 @@ void edac_device_workq_teardown(struct edac_device_ctl_info *edac_dev)
403 * edac_device_reset_delay_period 399 * edac_device_reset_delay_period
404 */ 400 */
405 401
406void edac_device_reset_delay_period( 402void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
407 struct edac_device_ctl_info *edac_dev, 403 unsigned long value)
408 unsigned long value)
409{ 404{
410 lock_device_list(); 405 lock_device_list();
411 406
@@ -450,7 +445,7 @@ int edac_device_add_device(struct edac_device_ctl_info *edac_dev, int edac_idx)
450 /* create this instance's sysfs entries */ 445 /* create this instance's sysfs entries */
451 if (edac_device_create_sysfs(edac_dev)) { 446 if (edac_device_create_sysfs(edac_dev)) {
452 edac_device_printk(edac_dev, KERN_WARNING, 447 edac_device_printk(edac_dev, KERN_WARNING,
453 "failed to create sysfs device\n"); 448 "failed to create sysfs device\n");
454 goto fail1; 449 goto fail1;
455 } 450 }
456 451
@@ -468,27 +463,27 @@ int edac_device_add_device(struct edac_device_ctl_info *edac_dev, int edac_idx)
468 edac_dev->op_state = OP_RUNNING_INTERRUPT; 463 edac_dev->op_state = OP_RUNNING_INTERRUPT;
469 } 464 }
470 465
471
472 /* Report action taken */ 466 /* Report action taken */
473 edac_device_printk(edac_dev, KERN_INFO, 467 edac_device_printk(edac_dev, KERN_INFO,
474 "Giving out device to module '%s' controller '%s': DEV '%s' (%s)\n", 468 "Giving out device to module '%s' controller '%s': DEV '%s' (%s)\n",
475 edac_dev->mod_name, 469 edac_dev->mod_name,
476 edac_dev->ctl_name, 470 edac_dev->ctl_name,
477 dev_name(edac_dev), 471 dev_name(edac_dev),
478 edac_op_state_toString(edac_dev->op_state) 472 edac_op_state_toString(edac_dev->op_state)
479 ); 473 );
480 474
481 unlock_device_list(); 475 unlock_device_list();
482 return 0; 476 return 0;
483 477
484fail1: 478 fail1:
485 /* Some error, so remove the entry from the lsit */ 479 /* Some error, so remove the entry from the lsit */
486 del_edac_device_from_global_list(edac_dev); 480 del_edac_device_from_global_list(edac_dev);
487 481
488fail0: 482 fail0:
489 unlock_device_list(); 483 unlock_device_list();
490 return 1; 484 return 1;
491} 485}
486
492EXPORT_SYMBOL_GPL(edac_device_add_device); 487EXPORT_SYMBOL_GPL(edac_device_add_device);
493 488
494/** 489/**
@@ -504,7 +499,7 @@ EXPORT_SYMBOL_GPL(edac_device_add_device);
504 * Pointer to removed edac_device structure, 499 * Pointer to removed edac_device structure,
505 * OR NULL if device not found. 500 * OR NULL if device not found.
506 */ 501 */
507struct edac_device_ctl_info * edac_device_del_device(struct device *dev) 502struct edac_device_ctl_info *edac_device_del_device(struct device *dev)
508{ 503{
509 struct edac_device_ctl_info *edac_dev; 504 struct edac_device_ctl_info *edac_dev;
510 505
@@ -532,16 +527,14 @@ struct edac_device_ctl_info * edac_device_del_device(struct device *dev)
532 unlock_device_list(); 527 unlock_device_list();
533 528
534 edac_printk(KERN_INFO, EDAC_MC, 529 edac_printk(KERN_INFO, EDAC_MC,
535 "Removed device %d for %s %s: DEV %s\n", 530 "Removed device %d for %s %s: DEV %s\n",
536 edac_dev->dev_idx, 531 edac_dev->dev_idx,
537 edac_dev->mod_name, 532 edac_dev->mod_name, edac_dev->ctl_name, dev_name(edac_dev));
538 edac_dev->ctl_name,
539 dev_name(edac_dev));
540 533
541 return edac_dev; 534 return edac_dev;
542} 535}
543EXPORT_SYMBOL_GPL(edac_device_del_device);
544 536
537EXPORT_SYMBOL_GPL(edac_device_del_device);
545 538
546static inline int edac_device_get_log_ce(struct edac_device_ctl_info *edac_dev) 539static inline int edac_device_get_log_ce(struct edac_device_ctl_info *edac_dev)
547{ 540{
@@ -553,8 +546,8 @@ static inline int edac_device_get_log_ue(struct edac_device_ctl_info *edac_dev)
553 return edac_dev->log_ue; 546 return edac_dev->log_ue;
554} 547}
555 548
556static inline int edac_device_get_panic_on_ue( 549static inline int edac_device_get_panic_on_ue(struct edac_device_ctl_info
557 struct edac_device_ctl_info *edac_dev) 550 *edac_dev)
558{ 551{
559 return edac_dev->panic_on_ue; 552 return edac_dev->panic_on_ue;
560} 553}
@@ -564,15 +557,16 @@ static inline int edac_device_get_panic_on_ue(
564 * perform a common output and handling of an 'edac_dev' CE event 557 * perform a common output and handling of an 'edac_dev' CE event
565 */ 558 */
566void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev, 559void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev,
567 int inst_nr, int block_nr, const char *msg) 560 int inst_nr, int block_nr, const char *msg)
568{ 561{
569 struct edac_device_instance *instance; 562 struct edac_device_instance *instance;
570 struct edac_device_block *block = NULL; 563 struct edac_device_block *block = NULL;
571 564
572 if ((inst_nr >= edac_dev->nr_instances) || (inst_nr < 0)) { 565 if ((inst_nr >= edac_dev->nr_instances) || (inst_nr < 0)) {
573 edac_device_printk(edac_dev, KERN_ERR, 566 edac_device_printk(edac_dev, KERN_ERR,
574 "INTERNAL ERROR: 'instance' out of range " 567 "INTERNAL ERROR: 'instance' out of range "
575 "(%d >= %d)\n", inst_nr, edac_dev->nr_instances); 568 "(%d >= %d)\n", inst_nr,
569 edac_dev->nr_instances);
576 return; 570 return;
577 } 571 }
578 572
@@ -580,8 +574,9 @@ void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev,
580 574
581 if ((block_nr >= instance->nr_blocks) || (block_nr < 0)) { 575 if ((block_nr >= instance->nr_blocks) || (block_nr < 0)) {
582 edac_device_printk(edac_dev, KERN_ERR, 576 edac_device_printk(edac_dev, KERN_ERR,
583 "INTERNAL ERROR: instance %d 'block' out of range " 577 "INTERNAL ERROR: instance %d 'block' out of range "
584 "(%d >= %d)\n", inst_nr, block_nr, instance->nr_blocks); 578 "(%d >= %d)\n", inst_nr, block_nr,
579 instance->nr_blocks);
585 return; 580 return;
586 } 581 }
587 582
@@ -596,10 +591,11 @@ void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev,
596 591
597 if (edac_device_get_log_ce(edac_dev)) 592 if (edac_device_get_log_ce(edac_dev))
598 edac_device_printk(edac_dev, KERN_WARNING, 593 edac_device_printk(edac_dev, KERN_WARNING,
599 "CE ctl: %s, instance: %s, block: %s: %s\n", 594 "CE ctl: %s, instance: %s, block: %s: %s\n",
600 edac_dev->ctl_name, instance->name, 595 edac_dev->ctl_name, instance->name,
601 block ? block->name : "N/A", msg); 596 block ? block->name : "N/A", msg);
602} 597}
598
603EXPORT_SYMBOL_GPL(edac_device_handle_ce); 599EXPORT_SYMBOL_GPL(edac_device_handle_ce);
604 600
605/* 601/*
@@ -607,15 +603,16 @@ EXPORT_SYMBOL_GPL(edac_device_handle_ce);
607 * perform a common output and handling of an 'edac_dev' UE event 603 * perform a common output and handling of an 'edac_dev' UE event
608 */ 604 */
609void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev, 605void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev,
610 int inst_nr, int block_nr, const char *msg) 606 int inst_nr, int block_nr, const char *msg)
611{ 607{
612 struct edac_device_instance *instance; 608 struct edac_device_instance *instance;
613 struct edac_device_block *block = NULL; 609 struct edac_device_block *block = NULL;
614 610
615 if ((inst_nr >= edac_dev->nr_instances) || (inst_nr < 0)) { 611 if ((inst_nr >= edac_dev->nr_instances) || (inst_nr < 0)) {
616 edac_device_printk(edac_dev, KERN_ERR, 612 edac_device_printk(edac_dev, KERN_ERR,
617 "INTERNAL ERROR: 'instance' out of range " 613 "INTERNAL ERROR: 'instance' out of range "
618 "(%d >= %d)\n", inst_nr, edac_dev->nr_instances); 614 "(%d >= %d)\n", inst_nr,
615 edac_dev->nr_instances);
619 return; 616 return;
620 } 617 }
621 618
@@ -623,8 +620,9 @@ void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev,
623 620
624 if ((block_nr >= instance->nr_blocks) || (block_nr < 0)) { 621 if ((block_nr >= instance->nr_blocks) || (block_nr < 0)) {
625 edac_device_printk(edac_dev, KERN_ERR, 622 edac_device_printk(edac_dev, KERN_ERR,
626 "INTERNAL ERROR: instance %d 'block' out of range " 623 "INTERNAL ERROR: instance %d 'block' out of range "
627 "(%d >= %d)\n", inst_nr, block_nr, instance->nr_blocks); 624 "(%d >= %d)\n", inst_nr, block_nr,
625 instance->nr_blocks);
628 return; 626 return;
629 } 627 }
630 628
@@ -639,14 +637,14 @@ void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev,
639 637
640 if (edac_device_get_log_ue(edac_dev)) 638 if (edac_device_get_log_ue(edac_dev))
641 edac_device_printk(edac_dev, KERN_EMERG, 639 edac_device_printk(edac_dev, KERN_EMERG,
642 "UE ctl: %s, instance: %s, block: %s: %s\n", 640 "UE ctl: %s, instance: %s, block: %s: %s\n",
643 edac_dev->ctl_name, instance->name, 641 edac_dev->ctl_name, instance->name,
644 block ? block->name : "N/A", msg); 642 block ? block->name : "N/A", msg);
645 643
646 if (edac_device_get_panic_on_ue(edac_dev)) 644 if (edac_device_get_panic_on_ue(edac_dev))
647 panic("EDAC %s: UE instance: %s, block %s: %s\n", 645 panic("EDAC %s: UE instance: %s, block %s: %s\n",
648 edac_dev->ctl_name, instance->name, 646 edac_dev->ctl_name, instance->name,
649 block ? block->name : "N/A", msg); 647 block ? block->name : "N/A", msg);
650} 648}
651EXPORT_SYMBOL_GPL(edac_device_handle_ue);
652 649
650EXPORT_SYMBOL_GPL(edac_device_handle_ue);
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index afb190502646..69305e637810 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -16,7 +16,6 @@
16#include "edac_core.h" 16#include "edac_core.h"
17#include "edac_module.h" 17#include "edac_module.h"
18 18
19
20#define EDAC_DEVICE_SYMLINK "device" 19#define EDAC_DEVICE_SYMLINK "device"
21 20
22#define to_edacdev(k) container_of(k, struct edac_device_ctl_info, kobj) 21#define to_edacdev(k) container_of(k, struct edac_device_ctl_info, kobj)
@@ -25,43 +24,41 @@
25#ifdef DKT 24#ifdef DKT
26 25
27static ssize_t edac_dev_ue_count_show(struct edac_device_ctl_info *edac_dev, 26static ssize_t edac_dev_ue_count_show(struct edac_device_ctl_info *edac_dev,
28 char *data) 27 char *data)
29{ 28{
30 return sprintf(data,"%d\n", edac_dev->ue_count); 29 return sprintf(data, "%d\n", edac_dev->ue_count);
31} 30}
32 31
33static ssize_t edac_dev_ce_count_show(struct edac_device_ctl_info *edac_dev, 32static ssize_t edac_dev_ce_count_show(struct edac_device_ctl_info *edac_dev,
34 char *data) 33 char *data)
35{ 34{
36 return sprintf(data,"%d\n", edac_dev->ce_count); 35 return sprintf(data, "%d\n", edac_dev->ce_count);
37} 36}
38 37
39static ssize_t edac_dev_seconds_show(struct edac_device_ctl_info *edac_dev, 38static ssize_t edac_dev_seconds_show(struct edac_device_ctl_info *edac_dev,
40 char *data) 39 char *data)
41{ 40{
42 return sprintf(data,"%ld\n", (jiffies - edac_dev->start_time) / HZ); 41 return sprintf(data, "%ld\n", (jiffies - edac_dev->start_time) / HZ);
43} 42}
44 43
45static ssize_t edac_dev_ctl_name_show(struct edac_device_ctl_info *edac_dev, 44static ssize_t edac_dev_ctl_name_show(struct edac_device_ctl_info *edac_dev,
46 char *data) 45 char *data)
47{ 46{
48 return sprintf(data,"%s\n", edac_dev->ctl_name); 47 return sprintf(data, "%s\n", edac_dev->ctl_name);
49} 48}
50 49
51
52struct edacdev_attribute { 50struct edacdev_attribute {
53 struct attribute attr; 51 struct attribute attr;
54 ssize_t (*show)(struct edac_device_ctl_info *,char *); 52 ssize_t(*show) (struct edac_device_ctl_info *, char *);
55 ssize_t (*store)(struct edac_device_ctl_info *, const char *,size_t); 53 ssize_t(*store) (struct edac_device_ctl_info *, const char *, size_t);
56}; 54};
57 55
58
59/* EDAC DEVICE show/store functions for top most object */ 56/* EDAC DEVICE show/store functions for top most object */
60static ssize_t edacdev_show(struct kobject *kobj, struct attribute *attr, 57static ssize_t edacdev_show(struct kobject *kobj, struct attribute *attr,
61 char *buffer) 58 char *buffer)
62{ 59{
63 struct edac_device_ctl_info *edac_dev = to_edacdev(kobj); 60 struct edac_device_ctl_info *edac_dev = to_edacdev(kobj);
64 struct edacdev_attribute * edacdev_attr = to_edacdev_attr(attr); 61 struct edacdev_attribute *edacdev_attr = to_edacdev_attr(attr);
65 62
66 if (edacdev_attr->show) 63 if (edacdev_attr->show)
67 return edacdev_attr->show(edac_dev, buffer); 64 return edacdev_attr->show(edac_dev, buffer);
@@ -70,10 +67,10 @@ static ssize_t edacdev_show(struct kobject *kobj, struct attribute *attr,
70} 67}
71 68
72static ssize_t edacdev_store(struct kobject *kobj, struct attribute *attr, 69static ssize_t edacdev_store(struct kobject *kobj, struct attribute *attr,
73 const char *buffer, size_t count) 70 const char *buffer, size_t count)
74{ 71{
75 struct edac_device_ctl_info *edac_dev = to_edacdev(kobj); 72 struct edac_device_ctl_info *edac_dev = to_edacdev(kobj);
76 struct edacdev_attribute * edacdev_attr = to_edacdev_attr(attr); 73 struct edacdev_attribute *edacdev_attr = to_edacdev_attr(attr);
77 74
78 if (edacdev_attr->store) 75 if (edacdev_attr->store)
79 return edacdev_attr->store(edac_dev, buffer, count); 76 return edacdev_attr->store(edac_dev, buffer, count);
@@ -94,14 +91,13 @@ static struct edacdev_attribute edac_dev_attr_##_name = { \
94}; 91};
95 92
96/* default Control file */ 93/* default Control file */
97EDACDEV_ATTR(reset_counters,S_IWUSR,NULL,edac_dev_reset_counters_store); 94EDACDEV_ATTR(reset_counters, S_IWUSR, NULL, edac_dev_reset_counters_store);
98 95
99/* default Attribute files */ 96/* default Attribute files */
100EDACDEV_ATTR(mc_name,S_IRUGO,edac_dev_ctl_name_show,NULL); 97EDACDEV_ATTR(mc_name, S_IRUGO, edac_dev_ctl_name_show, NULL);
101EDACDEV_ATTR(seconds_since_reset,S_IRUGO,edac_dev_seconds_show,NULL); 98EDACDEV_ATTR(seconds_since_reset, S_IRUGO, edac_dev_seconds_show, NULL);
102EDACDEV_ATTR(ue_count,S_IRUGO,edac_dev_ue_count_show,NULL); 99EDACDEV_ATTR(ue_count, S_IRUGO, edac_dev_ue_count_show, NULL);
103EDACDEV_ATTR(ce_count,S_IRUGO,edac_dev_ce_count_show,NULL); 100EDACDEV_ATTR(ce_count, S_IRUGO, edac_dev_ce_count_show, NULL);
104
105 101
106static struct edacdev_attribute *edacdev_attr[] = { 102static struct edacdev_attribute *edacdev_attr[] = {
107 &edacdev_attr_reset_counters, 103 &edacdev_attr_reset_counters,
@@ -127,7 +123,7 @@ static void edac_dev_instance_release(struct kobject *kobj)
127static struct kobj_type ktype_device = { 123static struct kobj_type ktype_device = {
128 .release = edac_dev_instance_release, 124 .release = edac_dev_instance_release,
129 .sysfs_ops = &edacdev_ops, 125 .sysfs_ops = &edacdev_ops,
130 .default_attrs = (struct attribute **) edacdev_attr, 126 .default_attrs = (struct attribute **)edacdev_attr,
131}; 127};
132 128
133#endif 129#endif
@@ -139,67 +135,66 @@ static struct kobj_type ktype_device = {
139 */ 135 */
140 136
141/* 'log_ue' */ 137/* 'log_ue' */
142static ssize_t edac_device_ctl_log_ue_show( 138static ssize_t edac_device_ctl_log_ue_show(struct edac_device_ctl_info
143 struct edac_device_ctl_info *ctl_info, char *data) 139 *ctl_info, char *data)
144{ 140{
145 return sprintf(data,"%u\n", ctl_info->log_ue); 141 return sprintf(data, "%u\n", ctl_info->log_ue);
146} 142}
147 143
148static ssize_t edac_device_ctl_log_ue_store( 144static ssize_t edac_device_ctl_log_ue_store(struct edac_device_ctl_info
149 struct edac_device_ctl_info *ctl_info, 145 *ctl_info, const char *data,
150 const char *data,size_t count) 146 size_t count)
151{ 147{
152 /* if parameter is zero, turn off flag, if non-zero turn on flag */ 148 /* if parameter is zero, turn off flag, if non-zero turn on flag */
153 ctl_info->log_ue = (simple_strtoul(data,NULL,0) != 0); 149 ctl_info->log_ue = (simple_strtoul(data, NULL, 0) != 0);
154 150
155 return count; 151 return count;
156} 152}
157 153
158/* 'log_ce' */ 154/* 'log_ce' */
159static ssize_t edac_device_ctl_log_ce_show( 155static ssize_t edac_device_ctl_log_ce_show(struct edac_device_ctl_info
160 struct edac_device_ctl_info *ctl_info,char *data) 156 *ctl_info, char *data)
161{ 157{
162 return sprintf(data,"%u\n", ctl_info->log_ce); 158 return sprintf(data, "%u\n", ctl_info->log_ce);
163} 159}
164 160
165static ssize_t edac_device_ctl_log_ce_store( 161static ssize_t edac_device_ctl_log_ce_store(struct edac_device_ctl_info
166 struct edac_device_ctl_info *ctl_info, 162 *ctl_info, const char *data,
167 const char *data,size_t count) 163 size_t count)
168{ 164{
169 /* if parameter is zero, turn off flag, if non-zero turn on flag */ 165 /* if parameter is zero, turn off flag, if non-zero turn on flag */
170 ctl_info->log_ce = (simple_strtoul(data,NULL,0) != 0); 166 ctl_info->log_ce = (simple_strtoul(data, NULL, 0) != 0);
171 167
172 return count; 168 return count;
173} 169}
174 170
175
176/* 'panic_on_ue' */ 171/* 'panic_on_ue' */
177static ssize_t edac_device_ctl_panic_on_ue_show( 172static ssize_t edac_device_ctl_panic_on_ue_show(struct edac_device_ctl_info
178 struct edac_device_ctl_info *ctl_info, char *data) 173 *ctl_info, char *data)
179{ 174{
180 return sprintf(data,"%u\n", ctl_info->panic_on_ue); 175 return sprintf(data, "%u\n", ctl_info->panic_on_ue);
181} 176}
182 177
183static ssize_t edac_device_ctl_panic_on_ue_store( 178static ssize_t edac_device_ctl_panic_on_ue_store(struct edac_device_ctl_info
184 struct edac_device_ctl_info *ctl_info, 179 *ctl_info, const char *data,
185 const char *data,size_t count) 180 size_t count)
186{ 181{
187 /* if parameter is zero, turn off flag, if non-zero turn on flag */ 182 /* if parameter is zero, turn off flag, if non-zero turn on flag */
188 ctl_info->panic_on_ue = (simple_strtoul(data,NULL,0) != 0); 183 ctl_info->panic_on_ue = (simple_strtoul(data, NULL, 0) != 0);
189 184
190 return count; 185 return count;
191} 186}
192 187
193/* 'poll_msec' show and store functions*/ 188/* 'poll_msec' show and store functions*/
194static ssize_t edac_device_ctl_poll_msec_show( 189static ssize_t edac_device_ctl_poll_msec_show(struct edac_device_ctl_info
195 struct edac_device_ctl_info *ctl_info, char *data) 190 *ctl_info, char *data)
196{ 191{
197 return sprintf(data,"%u\n", ctl_info->poll_msec); 192 return sprintf(data, "%u\n", ctl_info->poll_msec);
198} 193}
199 194
200static ssize_t edac_device_ctl_poll_msec_store( 195static ssize_t edac_device_ctl_poll_msec_store(struct edac_device_ctl_info
201 struct edac_device_ctl_info *ctl_info, 196 *ctl_info, const char *data,
202 const char *data,size_t count) 197 size_t count)
203{ 198{
204 unsigned long value; 199 unsigned long value;
205 200
@@ -208,18 +203,17 @@ static ssize_t edac_device_ctl_poll_msec_store(
208 * Then cancel last outstanding delay for the work request 203 * Then cancel last outstanding delay for the work request
209 * and set a new one. 204 * and set a new one.
210 */ 205 */
211 value = simple_strtoul(data,NULL,0); 206 value = simple_strtoul(data, NULL, 0);
212 edac_device_reset_delay_period(ctl_info,value); 207 edac_device_reset_delay_period(ctl_info, value);
213 208
214 return count; 209 return count;
215} 210}
216 211
217
218/* edac_device_ctl_info specific attribute structure */ 212/* edac_device_ctl_info specific attribute structure */
219struct ctl_info_attribute { 213struct ctl_info_attribute {
220 struct attribute attr; 214 struct attribute attr;
221 ssize_t (*show)(struct edac_device_ctl_info *,char *); 215 ssize_t(*show) (struct edac_device_ctl_info *, char *);
222 ssize_t (*store)(struct edac_device_ctl_info *,const char *,size_t); 216 ssize_t(*store) (struct edac_device_ctl_info *, const char *, size_t);
223}; 217};
224 218
225#define to_ctl_info(k) container_of(k, struct edac_device_ctl_info, kobj) 219#define to_ctl_info(k) container_of(k, struct edac_device_ctl_info, kobj)
@@ -227,34 +221,33 @@ struct ctl_info_attribute {
227 221
228/* Function to 'show' fields from the edac_dev 'ctl_info' structure */ 222/* Function to 'show' fields from the edac_dev 'ctl_info' structure */
229static ssize_t edac_dev_ctl_info_show(struct kobject *kobj, 223static ssize_t edac_dev_ctl_info_show(struct kobject *kobj,
230 struct attribute *attr, 224 struct attribute *attr, char *buffer)
231 char *buffer)
232{ 225{
233 struct edac_device_ctl_info *edac_dev = to_ctl_info(kobj); 226 struct edac_device_ctl_info *edac_dev = to_ctl_info(kobj);
234 struct ctl_info_attribute *ctl_info_attr = to_ctl_info_attr(attr); 227 struct ctl_info_attribute *ctl_info_attr = to_ctl_info_attr(attr);
235 228
236 if (ctl_info_attr->show) 229 if (ctl_info_attr->show)
237 return ctl_info_attr->show(edac_dev,buffer); 230 return ctl_info_attr->show(edac_dev, buffer);
238 return -EIO; 231 return -EIO;
239} 232}
240 233
241/* Function to 'store' fields into the edac_dev 'ctl_info' structure */ 234/* Function to 'store' fields into the edac_dev 'ctl_info' structure */
242static ssize_t edac_dev_ctl_info_store(struct kobject *kobj, 235static ssize_t edac_dev_ctl_info_store(struct kobject *kobj,
243 struct attribute *attr, 236 struct attribute *attr,
244 const char *buffer, size_t count) 237 const char *buffer, size_t count)
245{ 238{
246 struct edac_device_ctl_info *edac_dev = to_ctl_info(kobj); 239 struct edac_device_ctl_info *edac_dev = to_ctl_info(kobj);
247 struct ctl_info_attribute *ctl_info_attr = to_ctl_info_attr(attr); 240 struct ctl_info_attribute *ctl_info_attr = to_ctl_info_attr(attr);
248 241
249 if (ctl_info_attr->store) 242 if (ctl_info_attr->store)
250 return ctl_info_attr->store(edac_dev, buffer, count); 243 return ctl_info_attr->store(edac_dev, buffer, count);
251 return -EIO; 244 return -EIO;
252} 245}
253 246
254/* edac_dev file operations for an 'ctl_info' */ 247/* edac_dev file operations for an 'ctl_info' */
255static struct sysfs_ops device_ctl_info_ops = { 248static struct sysfs_ops device_ctl_info_ops = {
256 .show = edac_dev_ctl_info_show, 249 .show = edac_dev_ctl_info_show,
257 .store = edac_dev_ctl_info_store 250 .store = edac_dev_ctl_info_store
258}; 251};
259 252
260#define CTL_INFO_ATTR(_name,_mode,_show,_store) \ 253#define CTL_INFO_ATTR(_name,_mode,_show,_store) \
@@ -264,21 +257,16 @@ static struct ctl_info_attribute attr_ctl_info_##_name = { \
264 .store = _store, \ 257 .store = _store, \
265}; 258};
266 259
267
268/* Declare the various ctl_info attributes here and their respective ops */ 260/* Declare the various ctl_info attributes here and their respective ops */
269CTL_INFO_ATTR(log_ue,S_IRUGO|S_IWUSR, 261CTL_INFO_ATTR(log_ue, S_IRUGO | S_IWUSR,
270 edac_device_ctl_log_ue_show, 262 edac_device_ctl_log_ue_show, edac_device_ctl_log_ue_store);
271 edac_device_ctl_log_ue_store); 263CTL_INFO_ATTR(log_ce, S_IRUGO | S_IWUSR,
272CTL_INFO_ATTR(log_ce,S_IRUGO|S_IWUSR, 264 edac_device_ctl_log_ce_show, edac_device_ctl_log_ce_store);
273 edac_device_ctl_log_ce_show, 265CTL_INFO_ATTR(panic_on_ue, S_IRUGO | S_IWUSR,
274 edac_device_ctl_log_ce_store); 266 edac_device_ctl_panic_on_ue_show,
275CTL_INFO_ATTR(panic_on_ue,S_IRUGO|S_IWUSR, 267 edac_device_ctl_panic_on_ue_store);
276 edac_device_ctl_panic_on_ue_show, 268CTL_INFO_ATTR(poll_msec, S_IRUGO | S_IWUSR,
277 edac_device_ctl_panic_on_ue_store); 269 edac_device_ctl_poll_msec_show, edac_device_ctl_poll_msec_store);
278CTL_INFO_ATTR(poll_msec,S_IRUGO|S_IWUSR,
279 edac_device_ctl_poll_msec_show,
280 edac_device_ctl_poll_msec_store);
281
282 270
283/* Base Attributes of the EDAC_DEVICE ECC object */ 271/* Base Attributes of the EDAC_DEVICE ECC object */
284static struct ctl_info_attribute *device_ctrl_attr[] = { 272static struct ctl_info_attribute *device_ctrl_attr[] = {
@@ -303,10 +291,9 @@ static void edac_device_ctrl_master_release(struct kobject *kobj)
303static struct kobj_type ktype_device_ctrl = { 291static struct kobj_type ktype_device_ctrl = {
304 .release = edac_device_ctrl_master_release, 292 .release = edac_device_ctrl_master_release,
305 .sysfs_ops = &device_ctl_info_ops, 293 .sysfs_ops = &device_ctl_info_ops,
306 .default_attrs = (struct attribute **) device_ctrl_attr, 294 .default_attrs = (struct attribute **)device_ctrl_attr,
307}; 295};
308 296
309
310/**************** edac_device main kobj ctor/dtor code *********************/ 297/**************** edac_device main kobj ctor/dtor code *********************/
311 298
312/* 299/*
@@ -317,41 +304,39 @@ static struct kobj_type ktype_device_ctrl = {
317 * Return: 0 SUCCESS 304 * Return: 0 SUCCESS
318 * !0 FAILURE 305 * !0 FAILURE
319 */ 306 */
320static int edac_device_register_main_kobj( 307static int edac_device_register_main_kobj(struct edac_device_ctl_info *edac_dev)
321 struct edac_device_ctl_info *edac_dev)
322{ 308{
323 int err = 0; 309 int err = 0;
324 struct sysdev_class *edac_class; 310 struct sysdev_class *edac_class;
325 311
326 debugf1("%s()\n", __func__); 312 debugf1("%s()\n", __func__);
327 313
328 /* get the /sys/devices/system/edac reference */ 314 /* get the /sys/devices/system/edac reference */
329 edac_class = edac_get_edac_class(); 315 edac_class = edac_get_edac_class();
330 if (edac_class == NULL) { 316 if (edac_class == NULL) {
331 debugf1("%s() no edac_class error=%d\n", __func__, err); 317 debugf1("%s() no edac_class error=%d\n", __func__, err);
332 return err; 318 return err;
333 } 319 }
334 320
335 /* Point to the 'edac_class' this instance 'reports' to */ 321 /* Point to the 'edac_class' this instance 'reports' to */
336 edac_dev->edac_class = edac_class; 322 edac_dev->edac_class = edac_class;
337 323
338 /* Init the devices's kobject */ 324 /* Init the devices's kobject */
339 memset(&edac_dev->kobj, 0, sizeof (struct kobject)); 325 memset(&edac_dev->kobj, 0, sizeof(struct kobject));
340 edac_dev->kobj.ktype = &ktype_device_ctrl; 326 edac_dev->kobj.ktype = &ktype_device_ctrl;
341 327
342 /* set this new device under the edac_class kobject */ 328 /* set this new device under the edac_class kobject */
343 edac_dev->kobj.parent = &edac_class->kset.kobj; 329 edac_dev->kobj.parent = &edac_class->kset.kobj;
344 330
345 /* generate sysfs "..../edac/<name>" */ 331 /* generate sysfs "..../edac/<name>" */
346 debugf1("%s() set name of kobject to: %s\n", 332 debugf1("%s() set name of kobject to: %s\n", __func__, edac_dev->name);
347 __func__, edac_dev->name); 333 err = kobject_set_name(&edac_dev->kobj, "%s", edac_dev->name);
348 err = kobject_set_name(&edac_dev->kobj,"%s",edac_dev->name);
349 if (err) 334 if (err)
350 return err; 335 return err;
351 err = kobject_register(&edac_dev->kobj); 336 err = kobject_register(&edac_dev->kobj);
352 if (err) { 337 if (err) {
353 debugf1("%s()Failed to register '.../edac/%s'\n", 338 debugf1("%s()Failed to register '.../edac/%s'\n",
354 __func__,edac_dev->name); 339 __func__, edac_dev->name);
355 return err; 340 return err;
356 } 341 }
357 342
@@ -365,8 +350,8 @@ static int edac_device_register_main_kobj(
365 * edac_device_unregister_main_kobj: 350 * edac_device_unregister_main_kobj:
366 * the '..../edac/<name>' kobject 351 * the '..../edac/<name>' kobject
367 */ 352 */
368static void edac_device_unregister_main_kobj( 353static void edac_device_unregister_main_kobj(struct edac_device_ctl_info
369 struct edac_device_ctl_info *edac_dev) 354 *edac_dev)
370{ 355{
371 debugf0("%s()\n", __func__); 356 debugf0("%s()\n", __func__);
372 debugf1("%s() name of kobject is: %s\n", 357 debugf1("%s() name of kobject is: %s\n",
@@ -382,26 +367,23 @@ static void edac_device_unregister_main_kobj(
382 wait_for_completion(&edac_dev->kobj_complete); 367 wait_for_completion(&edac_dev->kobj_complete);
383} 368}
384 369
385
386/*************** edac_dev -> instance information ***********/ 370/*************** edac_dev -> instance information ***********/
387 371
388/* 372/*
389 * Set of low-level instance attribute show functions 373 * Set of low-level instance attribute show functions
390 */ 374 */
391static ssize_t instance_ue_count_show( 375static ssize_t instance_ue_count_show(struct edac_device_instance *instance,
392 struct edac_device_instance *instance, char *data) 376 char *data)
393{ 377{
394 return sprintf(data,"%u\n", instance->counters.ue_count); 378 return sprintf(data, "%u\n", instance->counters.ue_count);
395} 379}
396 380
397static ssize_t instance_ce_count_show( 381static ssize_t instance_ce_count_show(struct edac_device_instance *instance,
398 struct edac_device_instance *instance, char *data) 382 char *data)
399{ 383{
400 return sprintf(data,"%u\n", instance->counters.ce_count); 384 return sprintf(data, "%u\n", instance->counters.ce_count);
401} 385}
402 386
403
404
405#define to_instance(k) container_of(k, struct edac_device_instance, kobj) 387#define to_instance(k) container_of(k, struct edac_device_instance, kobj)
406#define to_instance_attr(a) container_of(a,struct instance_attribute,attr) 388#define to_instance_attr(a) container_of(a,struct instance_attribute,attr)
407 389
@@ -416,48 +398,42 @@ static void edac_device_ctrl_instance_release(struct kobject *kobj)
416 complete(&instance->kobj_complete); 398 complete(&instance->kobj_complete);
417} 399}
418 400
419
420/* instance specific attribute structure */ 401/* instance specific attribute structure */
421struct instance_attribute { 402struct instance_attribute {
422 struct attribute attr; 403 struct attribute attr;
423 ssize_t (*show)(struct edac_device_instance *,char *); 404 ssize_t(*show) (struct edac_device_instance *, char *);
424 ssize_t (*store)(struct edac_device_instance *,const char *,size_t); 405 ssize_t(*store) (struct edac_device_instance *, const char *, size_t);
425}; 406};
426 407
427
428/* Function to 'show' fields from the edac_dev 'instance' structure */ 408/* Function to 'show' fields from the edac_dev 'instance' structure */
429static ssize_t edac_dev_instance_show(struct kobject *kobj, 409static ssize_t edac_dev_instance_show(struct kobject *kobj,
430 struct attribute *attr, 410 struct attribute *attr, char *buffer)
431 char *buffer)
432{ 411{
433 struct edac_device_instance *instance = to_instance(kobj); 412 struct edac_device_instance *instance = to_instance(kobj);
434 struct instance_attribute *instance_attr = to_instance_attr(attr); 413 struct instance_attribute *instance_attr = to_instance_attr(attr);
435 414
436 if (instance_attr->show) 415 if (instance_attr->show)
437 return instance_attr->show(instance,buffer); 416 return instance_attr->show(instance, buffer);
438 return -EIO; 417 return -EIO;
439} 418}
440 419
441
442/* Function to 'store' fields into the edac_dev 'instance' structure */ 420/* Function to 'store' fields into the edac_dev 'instance' structure */
443static ssize_t edac_dev_instance_store(struct kobject *kobj, 421static ssize_t edac_dev_instance_store(struct kobject *kobj,
444 struct attribute *attr, 422 struct attribute *attr,
445 const char *buffer, size_t count) 423 const char *buffer, size_t count)
446{ 424{
447 struct edac_device_instance *instance = to_instance(kobj); 425 struct edac_device_instance *instance = to_instance(kobj);
448 struct instance_attribute *instance_attr = to_instance_attr(attr); 426 struct instance_attribute *instance_attr = to_instance_attr(attr);
449 427
450 if (instance_attr->store) 428 if (instance_attr->store)
451 return instance_attr->store(instance, buffer, count); 429 return instance_attr->store(instance, buffer, count);
452 return -EIO; 430 return -EIO;
453} 431}
454 432
455
456
457/* edac_dev file operations for an 'instance' */ 433/* edac_dev file operations for an 'instance' */
458static struct sysfs_ops device_instance_ops = { 434static struct sysfs_ops device_instance_ops = {
459 .show = edac_dev_instance_show, 435 .show = edac_dev_instance_show,
460 .store = edac_dev_instance_store 436 .store = edac_dev_instance_store
461}; 437};
462 438
463#define INSTANCE_ATTR(_name,_mode,_show,_store) \ 439#define INSTANCE_ATTR(_name,_mode,_show,_store) \
@@ -472,8 +448,8 @@ static struct instance_attribute attr_instance_##_name = { \
472 * Each contains a pointer to a show and an optional set 448 * Each contains a pointer to a show and an optional set
473 * function pointer that does the low level output/input 449 * function pointer that does the low level output/input
474 */ 450 */
475INSTANCE_ATTR(ce_count,S_IRUGO,instance_ce_count_show,NULL); 451INSTANCE_ATTR(ce_count, S_IRUGO, instance_ce_count_show, NULL);
476INSTANCE_ATTR(ue_count,S_IRUGO,instance_ue_count_show,NULL); 452INSTANCE_ATTR(ue_count, S_IRUGO, instance_ue_count_show, NULL);
477 453
478/* list of edac_dev 'instance' attributes */ 454/* list of edac_dev 'instance' attributes */
479static struct instance_attribute *device_instance_attr[] = { 455static struct instance_attribute *device_instance_attr[] = {
@@ -486,29 +462,24 @@ static struct instance_attribute *device_instance_attr[] = {
486static struct kobj_type ktype_instance_ctrl = { 462static struct kobj_type ktype_instance_ctrl = {
487 .release = edac_device_ctrl_instance_release, 463 .release = edac_device_ctrl_instance_release,
488 .sysfs_ops = &device_instance_ops, 464 .sysfs_ops = &device_instance_ops,
489 .default_attrs = (struct attribute **) device_instance_attr, 465 .default_attrs = (struct attribute **)device_instance_attr,
490}; 466};
491 467
492
493/*************** edac_dev -> instance -> block information *********/ 468/*************** edac_dev -> instance -> block information *********/
494 469
495/* 470/*
496 * Set of low-level block attribute show functions 471 * Set of low-level block attribute show functions
497 */ 472 */
498static ssize_t block_ue_count_show( 473static ssize_t block_ue_count_show(struct edac_device_block *block, char *data)
499 struct edac_device_block *block, char *data)
500{ 474{
501 return sprintf(data,"%u\n", block->counters.ue_count); 475 return sprintf(data, "%u\n", block->counters.ue_count);
502} 476}
503 477
504static ssize_t block_ce_count_show( 478static ssize_t block_ce_count_show(struct edac_device_block *block, char *data)
505 struct edac_device_block *block, char *data)
506{ 479{
507 return sprintf(data,"%u\n", block->counters.ce_count); 480 return sprintf(data, "%u\n", block->counters.ce_count);
508} 481}
509 482
510
511
512#define to_block(k) container_of(k, struct edac_device_block, kobj) 483#define to_block(k) container_of(k, struct edac_device_block, kobj)
513#define to_block_attr(a) container_of(a,struct block_attribute,attr) 484#define to_block_attr(a) container_of(a,struct block_attribute,attr)
514 485
@@ -525,46 +496,42 @@ static void edac_device_ctrl_block_release(struct kobject *kobj)
525 496
526/* block specific attribute structure */ 497/* block specific attribute structure */
527struct block_attribute { 498struct block_attribute {
528 struct attribute attr; 499 struct attribute attr;
529 ssize_t (*show)(struct edac_device_block *,char *); 500 ssize_t(*show) (struct edac_device_block *, char *);
530 ssize_t (*store)(struct edac_device_block *,const char *,size_t); 501 ssize_t(*store) (struct edac_device_block *, const char *, size_t);
531}; 502};
532 503
533/* Function to 'show' fields from the edac_dev 'block' structure */ 504/* Function to 'show' fields from the edac_dev 'block' structure */
534static ssize_t edac_dev_block_show(struct kobject *kobj, 505static ssize_t edac_dev_block_show(struct kobject *kobj,
535 struct attribute *attr, 506 struct attribute *attr, char *buffer)
536 char *buffer)
537{ 507{
538 struct edac_device_block *block = to_block(kobj); 508 struct edac_device_block *block = to_block(kobj);
539 struct block_attribute *block_attr = to_block_attr(attr); 509 struct block_attribute *block_attr = to_block_attr(attr);
540 510
541 if (block_attr->show) 511 if (block_attr->show)
542 return block_attr->show(block,buffer); 512 return block_attr->show(block, buffer);
543 return -EIO; 513 return -EIO;
544} 514}
545 515
546
547/* Function to 'store' fields into the edac_dev 'block' structure */ 516/* Function to 'store' fields into the edac_dev 'block' structure */
548static ssize_t edac_dev_block_store(struct kobject *kobj, 517static ssize_t edac_dev_block_store(struct kobject *kobj,
549 struct attribute *attr, 518 struct attribute *attr,
550 const char *buffer, size_t count) 519 const char *buffer, size_t count)
551{ 520{
552 struct edac_device_block *block = to_block(kobj); 521 struct edac_device_block *block = to_block(kobj);
553 struct block_attribute *block_attr = to_block_attr(attr); 522 struct block_attribute *block_attr = to_block_attr(attr);
554 523
555 if (block_attr->store) 524 if (block_attr->store)
556 return block_attr->store(block, buffer, count); 525 return block_attr->store(block, buffer, count);
557 return -EIO; 526 return -EIO;
558} 527}
559 528
560
561/* edac_dev file operations for a 'block' */ 529/* edac_dev file operations for a 'block' */
562static struct sysfs_ops device_block_ops = { 530static struct sysfs_ops device_block_ops = {
563 .show = edac_dev_block_show, 531 .show = edac_dev_block_show,
564 .store = edac_dev_block_store 532 .store = edac_dev_block_store
565}; 533};
566 534
567
568#define BLOCK_ATTR(_name,_mode,_show,_store) \ 535#define BLOCK_ATTR(_name,_mode,_show,_store) \
569static struct block_attribute attr_block_##_name = { \ 536static struct block_attribute attr_block_##_name = { \
570 .attr = {.name = __stringify(_name), .mode = _mode }, \ 537 .attr = {.name = __stringify(_name), .mode = _mode }, \
@@ -572,9 +539,8 @@ static struct block_attribute attr_block_##_name = { \
572 .store = _store, \ 539 .store = _store, \
573}; 540};
574 541
575BLOCK_ATTR(ce_count,S_IRUGO,block_ce_count_show,NULL); 542BLOCK_ATTR(ce_count, S_IRUGO, block_ce_count_show, NULL);
576BLOCK_ATTR(ue_count,S_IRUGO,block_ue_count_show,NULL); 543BLOCK_ATTR(ue_count, S_IRUGO, block_ue_count_show, NULL);
577
578 544
579/* list of edac_dev 'block' attributes */ 545/* list of edac_dev 'block' attributes */
580static struct block_attribute *device_block_attr[] = { 546static struct block_attribute *device_block_attr[] = {
@@ -587,19 +553,17 @@ static struct block_attribute *device_block_attr[] = {
587static struct kobj_type ktype_block_ctrl = { 553static struct kobj_type ktype_block_ctrl = {
588 .release = edac_device_ctrl_block_release, 554 .release = edac_device_ctrl_block_release,
589 .sysfs_ops = &device_block_ops, 555 .sysfs_ops = &device_block_ops,
590 .default_attrs = (struct attribute **) device_block_attr, 556 .default_attrs = (struct attribute **)device_block_attr,
591}; 557};
592 558
593
594/************** block ctor/dtor code ************/ 559/************** block ctor/dtor code ************/
595 560
596/* 561/*
597 * edac_device_create_block 562 * edac_device_create_block
598 */ 563 */
599static int edac_device_create_block( 564static int edac_device_create_block(struct edac_device_ctl_info *edac_dev,
600 struct edac_device_ctl_info *edac_dev, 565 struct edac_device_instance *instance,
601 struct edac_device_instance *instance, 566 int idx)
602 int idx)
603{ 567{
604 int err; 568 int err;
605 struct edac_device_block *block; 569 struct edac_device_block *block;
@@ -607,21 +571,21 @@ static int edac_device_create_block(
607 block = &instance->blocks[idx]; 571 block = &instance->blocks[idx];
608 572
609 debugf1("%s() Instance '%s' block[%d] '%s'\n", 573 debugf1("%s() Instance '%s' block[%d] '%s'\n",
610 __func__,instance->name, idx, block->name); 574 __func__, instance->name, idx, block->name);
611 575
612 /* init this block's kobject */ 576 /* init this block's kobject */
613 memset(&block->kobj, 0, sizeof (struct kobject)); 577 memset(&block->kobj, 0, sizeof(struct kobject));
614 block->kobj.parent = &instance->kobj; 578 block->kobj.parent = &instance->kobj;
615 block->kobj.ktype = &ktype_block_ctrl; 579 block->kobj.ktype = &ktype_block_ctrl;
616 580
617 err = kobject_set_name(&block->kobj,"%s",block->name); 581 err = kobject_set_name(&block->kobj, "%s", block->name);
618 if (err) 582 if (err)
619 return err; 583 return err;
620 584
621 err = kobject_register(&block->kobj); 585 err = kobject_register(&block->kobj);
622 if (err) { 586 if (err) {
623 debugf1("%s()Failed to register instance '%s'\n", 587 debugf1("%s()Failed to register instance '%s'\n",
624 __func__,block->name); 588 __func__, block->name);
625 return err; 589 return err;
626 } 590 }
627 591
@@ -631,10 +595,9 @@ static int edac_device_create_block(
631/* 595/*
632 * edac_device_delete_block(edac_dev,j); 596 * edac_device_delete_block(edac_dev,j);
633 */ 597 */
634static void edac_device_delete_block( 598static void edac_device_delete_block(struct edac_device_ctl_info *edac_dev,
635 struct edac_device_ctl_info *edac_dev, 599 struct edac_device_instance *instance,
636 struct edac_device_instance *instance, 600 int idx)
637 int idx)
638{ 601{
639 struct edac_device_block *block; 602 struct edac_device_block *block;
640 603
@@ -652,8 +615,8 @@ static void edac_device_delete_block(
652 * edac_device_create_instance 615 * edac_device_create_instance
653 * create just one instance of an edac_device 'instance' 616 * create just one instance of an edac_device 'instance'
654 */ 617 */
655static int edac_device_create_instance( 618static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev,
656 struct edac_device_ctl_info *edac_dev, int idx) 619 int idx)
657{ 620{
658 int i, j; 621 int i, j;
659 int err; 622 int err;
@@ -662,32 +625,32 @@ static int edac_device_create_instance(
662 instance = &edac_dev->instances[idx]; 625 instance = &edac_dev->instances[idx];
663 626
664 /* Init the instance's kobject */ 627 /* Init the instance's kobject */
665 memset(&instance->kobj, 0, sizeof (struct kobject)); 628 memset(&instance->kobj, 0, sizeof(struct kobject));
666 629
667 /* set this new device under the edac_device main kobject */ 630 /* set this new device under the edac_device main kobject */
668 instance->kobj.parent = &edac_dev->kobj; 631 instance->kobj.parent = &edac_dev->kobj;
669 instance->kobj.ktype = &ktype_instance_ctrl; 632 instance->kobj.ktype = &ktype_instance_ctrl;
670 633
671 err = kobject_set_name(&instance->kobj,"%s",instance->name); 634 err = kobject_set_name(&instance->kobj, "%s", instance->name);
672 if (err) 635 if (err)
673 return err; 636 return err;
674 637
675 err = kobject_register(&instance->kobj); 638 err = kobject_register(&instance->kobj);
676 if (err != 0) { 639 if (err != 0) {
677 debugf2("%s() Failed to register instance '%s'\n", 640 debugf2("%s() Failed to register instance '%s'\n",
678 __func__,instance->name); 641 __func__, instance->name);
679 return err; 642 return err;
680 } 643 }
681 644
682 debugf1("%s() now register '%d' blocks for instance %d\n", 645 debugf1("%s() now register '%d' blocks for instance %d\n",
683 __func__,instance->nr_blocks,idx); 646 __func__, instance->nr_blocks, idx);
684 647
685 /* register all blocks of this instance */ 648 /* register all blocks of this instance */
686 for (i = 0; i < instance->nr_blocks; i++ ) { 649 for (i = 0; i < instance->nr_blocks; i++) {
687 err = edac_device_create_block(edac_dev,instance,i); 650 err = edac_device_create_block(edac_dev, instance, i);
688 if (err) { 651 if (err) {
689 for (j = 0; j < i; j++) { 652 for (j = 0; j < i; j++) {
690 edac_device_delete_block(edac_dev,instance,j); 653 edac_device_delete_block(edac_dev, instance, j);
691 } 654 }
692 return err; 655 return err;
693 } 656 }
@@ -703,8 +666,8 @@ static int edac_device_create_instance(
703 * edac_device_remove_instance 666 * edac_device_remove_instance
704 * remove an edac_device instance 667 * remove an edac_device instance
705 */ 668 */
706static void edac_device_delete_instance( 669static void edac_device_delete_instance(struct edac_device_ctl_info *edac_dev,
707 struct edac_device_ctl_info *edac_dev, int idx) 670 int idx)
708{ 671{
709 int i; 672 int i;
710 struct edac_device_instance *instance; 673 struct edac_device_instance *instance;
@@ -713,7 +676,7 @@ static void edac_device_delete_instance(
713 676
714 /* unregister all blocks in this instance */ 677 /* unregister all blocks in this instance */
715 for (i = 0; i < instance->nr_blocks; i++) { 678 for (i = 0; i < instance->nr_blocks; i++) {
716 edac_device_delete_block(edac_dev,instance,i); 679 edac_device_delete_block(edac_dev, instance, i);
717 } 680 }
718 681
719 /* unregister this instance's kobject */ 682 /* unregister this instance's kobject */
@@ -735,12 +698,12 @@ static int edac_device_create_instances(struct edac_device_ctl_info *edac_dev)
735 debugf0("%s()\n", __func__); 698 debugf0("%s()\n", __func__);
736 699
737 /* iterate over creation of the instances */ 700 /* iterate over creation of the instances */
738 for (i = 0; i < edac_dev->nr_instances; i++ ) { 701 for (i = 0; i < edac_dev->nr_instances; i++) {
739 err = edac_device_create_instance(edac_dev,i); 702 err = edac_device_create_instance(edac_dev, i);
740 if (err) { 703 if (err) {
741 /* unwind previous instances on error */ 704 /* unwind previous instances on error */
742 for (j = 0; j < i; j++) { 705 for (j = 0; j < i; j++) {
743 edac_device_delete_instance(edac_dev,j); 706 edac_device_delete_instance(edac_dev, j);
744 } 707 }
745 return err; 708 return err;
746 } 709 }
@@ -758,8 +721,8 @@ static void edac_device_delete_instances(struct edac_device_ctl_info *edac_dev)
758 int i; 721 int i;
759 722
760 /* iterate over creation of the instances */ 723 /* iterate over creation of the instances */
761 for (i = 0; i < edac_dev->nr_instances; i++ ) { 724 for (i = 0; i < edac_dev->nr_instances; i++) {
762 edac_device_delete_instance(edac_dev,i); 725 edac_device_delete_instance(edac_dev, i);
763 } 726 }
764} 727}
765 728
@@ -777,7 +740,7 @@ static void edac_device_delete_instances(struct edac_device_ctl_info *edac_dev)
777int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev) 740int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev)
778{ 741{
779 int err; 742 int err;
780 struct kobject *edac_kobj=&edac_dev->kobj; 743 struct kobject *edac_kobj = &edac_dev->kobj;
781 744
782 /* register this instance's main kobj with the edac class kobj */ 745 /* register this instance's main kobj with the edac class kobj */
783 err = edac_device_register_main_kobj(edac_dev); 746 err = edac_device_register_main_kobj(edac_dev);
@@ -790,8 +753,7 @@ int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev)
790 * to the platform 'device' being used for this 753 * to the platform 'device' being used for this
791 */ 754 */
792 err = sysfs_create_link(edac_kobj, 755 err = sysfs_create_link(edac_kobj,
793 &edac_dev->dev->kobj, 756 &edac_dev->dev->kobj, EDAC_DEVICE_SYMLINK);
794 EDAC_DEVICE_SYMLINK);
795 if (err) { 757 if (err) {
796 debugf0("%s() sysfs_create_link() returned err= %d\n", 758 debugf0("%s() sysfs_create_link() returned err= %d\n",
797 __func__, err); 759 __func__, err);
@@ -811,7 +773,7 @@ int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev)
811 773
812 /* Error unwind stack */ 774 /* Error unwind stack */
813 775
814error0: 776 error0:
815 edac_device_unregister_main_kobj(edac_dev); 777 edac_device_unregister_main_kobj(edac_dev);
816 778
817 return err; 779 return err;
@@ -834,4 +796,3 @@ void edac_device_remove_sysfs(struct edac_device_ctl_info *edac_dev)
834 /* unregister the instance's main kobj */ 796 /* unregister the instance's main kobj */
835 edac_device_unregister_main_kobj(edac_dev); 797 edac_device_unregister_main_kobj(edac_dev);
836} 798}
837
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 2e8c198749a1..835319126bb6 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -34,7 +34,6 @@
34#include "edac_core.h" 34#include "edac_core.h"
35#include "edac_module.h" 35#include "edac_module.h"
36 36
37
38/* lock to memory controller's control array */ 37/* lock to memory controller's control array */
39static DEFINE_MUTEX(mem_ctls_mutex); 38static DEFINE_MUTEX(mem_ctls_mutex);
40static struct list_head mc_devices = LIST_HEAD_INIT(mc_devices); 39static struct list_head mc_devices = LIST_HEAD_INIT(mc_devices);
@@ -54,13 +53,11 @@ static void edac_mc_dump_csrow(struct csrow_info *csrow)
54{ 53{
55 debugf4("\tcsrow = %p\n", csrow); 54 debugf4("\tcsrow = %p\n", csrow);
56 debugf4("\tcsrow->csrow_idx = %d\n", csrow->csrow_idx); 55 debugf4("\tcsrow->csrow_idx = %d\n", csrow->csrow_idx);
57 debugf4("\tcsrow->first_page = 0x%lx\n", 56 debugf4("\tcsrow->first_page = 0x%lx\n", csrow->first_page);
58 csrow->first_page);
59 debugf4("\tcsrow->last_page = 0x%lx\n", csrow->last_page); 57 debugf4("\tcsrow->last_page = 0x%lx\n", csrow->last_page);
60 debugf4("\tcsrow->page_mask = 0x%lx\n", csrow->page_mask); 58 debugf4("\tcsrow->page_mask = 0x%lx\n", csrow->page_mask);
61 debugf4("\tcsrow->nr_pages = 0x%x\n", csrow->nr_pages); 59 debugf4("\tcsrow->nr_pages = 0x%x\n", csrow->nr_pages);
62 debugf4("\tcsrow->nr_channels = %d\n", 60 debugf4("\tcsrow->nr_channels = %d\n", csrow->nr_channels);
63 csrow->nr_channels);
64 debugf4("\tcsrow->channels = %p\n", csrow->channels); 61 debugf4("\tcsrow->channels = %p\n", csrow->channels);
65 debugf4("\tcsrow->mci = %p\n\n", csrow->mci); 62 debugf4("\tcsrow->mci = %p\n\n", csrow->mci);
66} 63}
@@ -75,12 +72,11 @@ static void edac_mc_dump_mci(struct mem_ctl_info *mci)
75 debugf3("\tmci->nr_csrows = %d, csrows = %p\n", 72 debugf3("\tmci->nr_csrows = %d, csrows = %p\n",
76 mci->nr_csrows, mci->csrows); 73 mci->nr_csrows, mci->csrows);
77 debugf3("\tdev = %p\n", mci->dev); 74 debugf3("\tdev = %p\n", mci->dev);
78 debugf3("\tmod_name:ctl_name = %s:%s\n", 75 debugf3("\tmod_name:ctl_name = %s:%s\n", mci->mod_name, mci->ctl_name);
79 mci->mod_name, mci->ctl_name);
80 debugf3("\tpvt_info = %p\n\n", mci->pvt_info); 76 debugf3("\tpvt_info = %p\n\n", mci->pvt_info);
81} 77}
82 78
83#endif /* CONFIG_EDAC_DEBUG */ 79#endif /* CONFIG_EDAC_DEBUG */
84 80
85/* 'ptr' points to a possibly unaligned item X such that sizeof(X) is 'size'. 81/* 'ptr' points to a possibly unaligned item X such that sizeof(X) is 'size'.
86 * Adjust 'ptr' so that its alignment is at least as stringent as what the 82 * Adjust 'ptr' so that its alignment is at least as stringent as what the
@@ -89,7 +85,7 @@ static void edac_mc_dump_mci(struct mem_ctl_info *mci)
89 * If 'size' is a constant, the compiler will optimize this whole function 85 * If 'size' is a constant, the compiler will optimize this whole function
90 * down to either a no-op or the addition of a constant to the value of 'ptr'. 86 * down to either a no-op or the addition of a constant to the value of 'ptr'.
91 */ 87 */
92char * edac_align_ptr(void *ptr, unsigned size) 88char *edac_align_ptr(void *ptr, unsigned size)
93{ 89{
94 unsigned align, r; 90 unsigned align, r;
95 91
@@ -106,14 +102,14 @@ char * edac_align_ptr(void *ptr, unsigned size)
106 else if (size > sizeof(char)) 102 else if (size > sizeof(char))
107 align = sizeof(short); 103 align = sizeof(short);
108 else 104 else
109 return (char *) ptr; 105 return (char *)ptr;
110 106
111 r = size % align; 107 r = size % align;
112 108
113 if (r == 0) 109 if (r == 0)
114 return (char *) ptr; 110 return (char *)ptr;
115 111
116 return (char *) (((unsigned long) ptr) + align - r); 112 return (char *)(((unsigned long)ptr) + align - r);
117} 113}
118 114
119/** 115/**
@@ -133,7 +129,7 @@ char * edac_align_ptr(void *ptr, unsigned size)
133 * struct mem_ctl_info pointer 129 * struct mem_ctl_info pointer
134 */ 130 */
135struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows, 131struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
136 unsigned nr_chans) 132 unsigned nr_chans)
137{ 133{
138 struct mem_ctl_info *mci; 134 struct mem_ctl_info *mci;
139 struct csrow_info *csi, *csrow; 135 struct csrow_info *csi, *csrow;
@@ -147,12 +143,12 @@ struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
147 * stringent as what the compiler would provide if we could simply 143 * stringent as what the compiler would provide if we could simply
148 * hardcode everything into a single struct. 144 * hardcode everything into a single struct.
149 */ 145 */
150 mci = (struct mem_ctl_info *) 0; 146 mci = (struct mem_ctl_info *)0;
151 csi = (struct csrow_info *)edac_align_ptr(&mci[1], sizeof(*csi)); 147 csi = (struct csrow_info *)edac_align_ptr(&mci[1], sizeof(*csi));
152 chi = (struct channel_info *) 148 chi = (struct channel_info *)
153 edac_align_ptr(&csi[nr_csrows], sizeof(*chi)); 149 edac_align_ptr(&csi[nr_csrows], sizeof(*chi));
154 pvt = edac_align_ptr(&chi[nr_chans * nr_csrows], sz_pvt); 150 pvt = edac_align_ptr(&chi[nr_chans * nr_csrows], sz_pvt);
155 size = ((unsigned long) pvt) + sz_pvt; 151 size = ((unsigned long)pvt) + sz_pvt;
156 152
157 if ((mci = kmalloc(size, GFP_KERNEL)) == NULL) 153 if ((mci = kmalloc(size, GFP_KERNEL)) == NULL)
158 return NULL; 154 return NULL;
@@ -160,11 +156,11 @@ struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
160 /* Adjust pointers so they point within the memory we just allocated 156 /* Adjust pointers so they point within the memory we just allocated
161 * rather than an imaginary chunk of memory located at address 0. 157 * rather than an imaginary chunk of memory located at address 0.
162 */ 158 */
163 csi = (struct csrow_info *) (((char *) mci) + ((unsigned long) csi)); 159 csi = (struct csrow_info *)(((char *)mci) + ((unsigned long)csi));
164 chi = (struct channel_info *) (((char *) mci) + ((unsigned long) chi)); 160 chi = (struct channel_info *)(((char *)mci) + ((unsigned long)chi));
165 pvt = sz_pvt ? (((char *) mci) + ((unsigned long) pvt)) : NULL; 161 pvt = sz_pvt ? (((char *)mci) + ((unsigned long)pvt)) : NULL;
166 162
167 memset(mci, 0, size); /* clear all fields */ 163 memset(mci, 0, size); /* clear all fields */
168 mci->csrows = csi; 164 mci->csrows = csi;
169 mci->pvt_info = pvt; 165 mci->pvt_info = pvt;
170 mci->nr_csrows = nr_csrows; 166 mci->nr_csrows = nr_csrows;
@@ -188,6 +184,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
188 184
189 return mci; 185 return mci;
190} 186}
187
191EXPORT_SYMBOL_GPL(edac_mc_alloc); 188EXPORT_SYMBOL_GPL(edac_mc_alloc);
192 189
193/** 190/**
@@ -198,6 +195,7 @@ void edac_mc_free(struct mem_ctl_info *mci)
198{ 195{
199 kfree(mci); 196 kfree(mci);
200} 197}
198
201EXPORT_SYMBOL_GPL(edac_mc_free); 199EXPORT_SYMBOL_GPL(edac_mc_free);
202 200
203static struct mem_ctl_info *find_mci_by_dev(struct device *dev) 201static struct mem_ctl_info *find_mci_by_dev(struct device *dev)
@@ -224,7 +222,7 @@ static int edac_mc_assert_error_check_and_clear(void)
224{ 222{
225 int old_state; 223 int old_state;
226 224
227 if(edac_op_state == EDAC_OPSTATE_POLL) 225 if (edac_op_state == EDAC_OPSTATE_POLL)
228 return 1; 226 return 1;
229 227
230 old_state = edac_err_assert; 228 old_state = edac_err_assert;
@@ -240,12 +238,12 @@ static int edac_mc_assert_error_check_and_clear(void)
240#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) 238#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
241static void edac_mc_workq_function(struct work_struct *work_req) 239static void edac_mc_workq_function(struct work_struct *work_req)
242{ 240{
243 struct delayed_work *d_work = (struct delayed_work*) work_req; 241 struct delayed_work *d_work = (struct delayed_work *)work_req;
244 struct mem_ctl_info *mci = to_edac_mem_ctl_work(d_work); 242 struct mem_ctl_info *mci = to_edac_mem_ctl_work(d_work);
245#else 243#else
246static void edac_mc_workq_function(void *ptr) 244static void edac_mc_workq_function(void *ptr)
247{ 245{
248 struct mem_ctl_info *mci = (struct mem_ctl_info *) ptr; 246 struct mem_ctl_info *mci = (struct mem_ctl_info *)ptr;
249#endif 247#endif
250 248
251 mutex_lock(&mem_ctls_mutex); 249 mutex_lock(&mem_ctls_mutex);
@@ -264,7 +262,7 @@ static void edac_mc_workq_function(void *ptr)
264 262
265 /* Reschedule */ 263 /* Reschedule */
266 queue_delayed_work(edac_workqueue, &mci->work, 264 queue_delayed_work(edac_workqueue, &mci->work,
267 msecs_to_jiffies(edac_mc_get_poll_msec())); 265 msecs_to_jiffies(edac_mc_get_poll_msec()));
268} 266}
269 267
270/* 268/*
@@ -320,7 +318,7 @@ void edac_reset_delay_period(struct mem_ctl_info *mci, unsigned long value)
320 * Before calling this function, caller must 318 * Before calling this function, caller must
321 * assign a unique value to mci->mc_idx. 319 * assign a unique value to mci->mc_idx.
322 */ 320 */
323static int add_mc_to_global_list (struct mem_ctl_info *mci) 321static int add_mc_to_global_list(struct mem_ctl_info *mci)
324{ 322{
325 struct list_head *item, *insert_before; 323 struct list_head *item, *insert_before;
326 struct mem_ctl_info *p; 324 struct mem_ctl_info *p;
@@ -346,13 +344,13 @@ static int add_mc_to_global_list (struct mem_ctl_info *mci)
346 atomic_inc(&edac_handlers); 344 atomic_inc(&edac_handlers);
347 return 0; 345 return 0;
348 346
349fail0: 347 fail0:
350 edac_printk(KERN_WARNING, EDAC_MC, 348 edac_printk(KERN_WARNING, EDAC_MC,
351 "%s (%s) %s %s already assigned %d\n", p->dev->bus_id, 349 "%s (%s) %s %s already assigned %d\n", p->dev->bus_id,
352 dev_name(mci), p->mod_name, p->ctl_name, p->mc_idx); 350 dev_name(mci), p->mod_name, p->ctl_name, p->mc_idx);
353 return 1; 351 return 1;
354 352
355fail1: 353 fail1:
356 edac_printk(KERN_WARNING, EDAC_MC, 354 edac_printk(KERN_WARNING, EDAC_MC,
357 "bug in low-level driver: attempt to assign\n" 355 "bug in low-level driver: attempt to assign\n"
358 " duplicate mc_idx %d in %s()\n", p->mc_idx, __func__); 356 " duplicate mc_idx %d in %s()\n", p->mc_idx, __func__);
@@ -385,7 +383,7 @@ static void del_mc_from_global_list(struct mem_ctl_info *mci)
385 * 383 *
386 * Caller must hold mem_ctls_mutex. 384 * Caller must hold mem_ctls_mutex.
387 */ 385 */
388struct mem_ctl_info * edac_mc_find(int idx) 386struct mem_ctl_info *edac_mc_find(int idx)
389{ 387{
390 struct list_head *item; 388 struct list_head *item;
391 struct mem_ctl_info *mci; 389 struct mem_ctl_info *mci;
@@ -403,6 +401,7 @@ struct mem_ctl_info * edac_mc_find(int idx)
403 401
404 return NULL; 402 return NULL;
405} 403}
404
406EXPORT_SYMBOL(edac_mc_find); 405EXPORT_SYMBOL(edac_mc_find);
407 406
408/** 407/**
@@ -433,8 +432,8 @@ int edac_mc_add_mc(struct mem_ctl_info *mci, int mc_idx)
433 432
434 edac_mc_dump_csrow(&mci->csrows[i]); 433 edac_mc_dump_csrow(&mci->csrows[i]);
435 for (j = 0; j < mci->csrows[i].nr_channels; j++) 434 for (j = 0; j < mci->csrows[i].nr_channels; j++)
436 edac_mc_dump_channel( 435 edac_mc_dump_channel(&mci->csrows[i].
437 &mci->csrows[i].channels[j]); 436 channels[j]);
438 } 437 }
439 } 438 }
440#endif 439#endif
@@ -448,7 +447,7 @@ int edac_mc_add_mc(struct mem_ctl_info *mci, int mc_idx)
448 447
449 if (edac_create_sysfs_mci_device(mci)) { 448 if (edac_create_sysfs_mci_device(mci)) {
450 edac_mc_printk(mci, KERN_WARNING, 449 edac_mc_printk(mci, KERN_WARNING,
451 "failed to create sysfs device\n"); 450 "failed to create sysfs device\n");
452 goto fail1; 451 goto fail1;
453 } 452 }
454 453
@@ -464,18 +463,19 @@ int edac_mc_add_mc(struct mem_ctl_info *mci, int mc_idx)
464 463
465 /* Report action taken */ 464 /* Report action taken */
466 edac_mc_printk(mci, KERN_INFO, "Giving out device to %s %s: DEV %s\n", 465 edac_mc_printk(mci, KERN_INFO, "Giving out device to %s %s: DEV %s\n",
467 mci->mod_name, mci->ctl_name, dev_name(mci)); 466 mci->mod_name, mci->ctl_name, dev_name(mci));
468 467
469 mutex_unlock(&mem_ctls_mutex); 468 mutex_unlock(&mem_ctls_mutex);
470 return 0; 469 return 0;
471 470
472fail1: 471 fail1:
473 del_mc_from_global_list(mci); 472 del_mc_from_global_list(mci);
474 473
475fail0: 474 fail0:
476 mutex_unlock(&mem_ctls_mutex); 475 mutex_unlock(&mem_ctls_mutex);
477 return 1; 476 return 1;
478} 477}
478
479EXPORT_SYMBOL_GPL(edac_mc_add_mc); 479EXPORT_SYMBOL_GPL(edac_mc_add_mc);
480 480
481/** 481/**
@@ -485,7 +485,7 @@ EXPORT_SYMBOL_GPL(edac_mc_add_mc);
485 * 485 *
486 * Return pointer to removed mci structure, or NULL if device not found. 486 * Return pointer to removed mci structure, or NULL if device not found.
487 */ 487 */
488struct mem_ctl_info * edac_mc_del_mc(struct device *dev) 488struct mem_ctl_info *edac_mc_del_mc(struct device *dev)
489{ 489{
490 struct mem_ctl_info *mci; 490 struct mem_ctl_info *mci;
491 491
@@ -507,10 +507,11 @@ struct mem_ctl_info * edac_mc_del_mc(struct device *dev)
507 del_mc_from_global_list(mci); 507 del_mc_from_global_list(mci);
508 mutex_unlock(&mem_ctls_mutex); 508 mutex_unlock(&mem_ctls_mutex);
509 edac_printk(KERN_INFO, EDAC_MC, 509 edac_printk(KERN_INFO, EDAC_MC,
510 "Removed device %d for %s %s: DEV %s\n", mci->mc_idx, 510 "Removed device %d for %s %s: DEV %s\n", mci->mc_idx,
511 mci->mod_name, mci->ctl_name, dev_name(mci)); 511 mci->mod_name, mci->ctl_name, dev_name(mci));
512 return mci; 512 return mci;
513} 513}
514
514EXPORT_SYMBOL_GPL(edac_mc_del_mc); 515EXPORT_SYMBOL_GPL(edac_mc_del_mc);
515 516
516static void edac_mc_scrub_block(unsigned long page, unsigned long offset, 517static void edac_mc_scrub_block(unsigned long page, unsigned long offset,
@@ -523,7 +524,7 @@ static void edac_mc_scrub_block(unsigned long page, unsigned long offset,
523 debugf3("%s()\n", __func__); 524 debugf3("%s()\n", __func__);
524 525
525 /* ECC error page was not in our memory. Ignore it. */ 526 /* ECC error page was not in our memory. Ignore it. */
526 if(!pfn_valid(page)) 527 if (!pfn_valid(page))
527 return; 528 return;
528 529
529 /* Find the actual page structure then map it and fix */ 530 /* Find the actual page structure then map it and fix */
@@ -575,18 +576,20 @@ int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci, unsigned long page)
575 576
576 if (row == -1) 577 if (row == -1)
577 edac_mc_printk(mci, KERN_ERR, 578 edac_mc_printk(mci, KERN_ERR,
578 "could not look up page error address %lx\n", 579 "could not look up page error address %lx\n",
579 (unsigned long) page); 580 (unsigned long)page);
580 581
581 return row; 582 return row;
582} 583}
584
583EXPORT_SYMBOL_GPL(edac_mc_find_csrow_by_page); 585EXPORT_SYMBOL_GPL(edac_mc_find_csrow_by_page);
584 586
585/* FIXME - setable log (warning/emerg) levels */ 587/* FIXME - setable log (warning/emerg) levels */
586/* FIXME - integrate with evlog: http://evlog.sourceforge.net/ */ 588/* FIXME - integrate with evlog: http://evlog.sourceforge.net/ */
587void edac_mc_handle_ce(struct mem_ctl_info *mci, 589void edac_mc_handle_ce(struct mem_ctl_info *mci,
588 unsigned long page_frame_number, unsigned long offset_in_page, 590 unsigned long page_frame_number,
589 unsigned long syndrome, int row, int channel, const char *msg) 591 unsigned long offset_in_page, unsigned long syndrome,
592 int row, int channel, const char *msg)
590{ 593{
591 unsigned long remapped_page; 594 unsigned long remapped_page;
592 595
@@ -596,8 +599,8 @@ void edac_mc_handle_ce(struct mem_ctl_info *mci,
596 if (row >= mci->nr_csrows || row < 0) { 599 if (row >= mci->nr_csrows || row < 0) {
597 /* something is wrong */ 600 /* something is wrong */
598 edac_mc_printk(mci, KERN_ERR, 601 edac_mc_printk(mci, KERN_ERR,
599 "INTERNAL ERROR: row out of range " 602 "INTERNAL ERROR: row out of range "
600 "(%d >= %d)\n", row, mci->nr_csrows); 603 "(%d >= %d)\n", row, mci->nr_csrows);
601 edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR"); 604 edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR");
602 return; 605 return;
603 } 606 }
@@ -605,9 +608,9 @@ void edac_mc_handle_ce(struct mem_ctl_info *mci,
605 if (channel >= mci->csrows[row].nr_channels || channel < 0) { 608 if (channel >= mci->csrows[row].nr_channels || channel < 0) {
606 /* something is wrong */ 609 /* something is wrong */
607 edac_mc_printk(mci, KERN_ERR, 610 edac_mc_printk(mci, KERN_ERR,
608 "INTERNAL ERROR: channel out of range " 611 "INTERNAL ERROR: channel out of range "
609 "(%d >= %d)\n", channel, 612 "(%d >= %d)\n", channel,
610 mci->csrows[row].nr_channels); 613 mci->csrows[row].nr_channels);
611 edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR"); 614 edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR");
612 return; 615 return;
613 } 616 }
@@ -615,11 +618,11 @@ void edac_mc_handle_ce(struct mem_ctl_info *mci,
615 if (edac_mc_get_log_ce()) 618 if (edac_mc_get_log_ce())
616 /* FIXME - put in DIMM location */ 619 /* FIXME - put in DIMM location */
617 edac_mc_printk(mci, KERN_WARNING, 620 edac_mc_printk(mci, KERN_WARNING,
618 "CE page 0x%lx, offset 0x%lx, grain %d, syndrome " 621 "CE page 0x%lx, offset 0x%lx, grain %d, syndrome "
619 "0x%lx, row %d, channel %d, label \"%s\": %s\n", 622 "0x%lx, row %d, channel %d, label \"%s\": %s\n",
620 page_frame_number, offset_in_page, 623 page_frame_number, offset_in_page,
621 mci->csrows[row].grain, syndrome, row, channel, 624 mci->csrows[row].grain, syndrome, row, channel,
622 mci->csrows[row].channels[channel].label, msg); 625 mci->csrows[row].channels[channel].label, msg);
623 626
624 mci->ce_count++; 627 mci->ce_count++;
625 mci->csrows[row].ce_count++; 628 mci->csrows[row].ce_count++;
@@ -640,25 +643,27 @@ void edac_mc_handle_ce(struct mem_ctl_info *mci,
640 page_frame_number; 643 page_frame_number;
641 644
642 edac_mc_scrub_block(remapped_page, offset_in_page, 645 edac_mc_scrub_block(remapped_page, offset_in_page,
643 mci->csrows[row].grain); 646 mci->csrows[row].grain);
644 } 647 }
645} 648}
649
646EXPORT_SYMBOL_GPL(edac_mc_handle_ce); 650EXPORT_SYMBOL_GPL(edac_mc_handle_ce);
647 651
648void edac_mc_handle_ce_no_info(struct mem_ctl_info *mci, const char *msg) 652void edac_mc_handle_ce_no_info(struct mem_ctl_info *mci, const char *msg)
649{ 653{
650 if (edac_mc_get_log_ce()) 654 if (edac_mc_get_log_ce())
651 edac_mc_printk(mci, KERN_WARNING, 655 edac_mc_printk(mci, KERN_WARNING,
652 "CE - no information available: %s\n", msg); 656 "CE - no information available: %s\n", msg);
653 657
654 mci->ce_noinfo_count++; 658 mci->ce_noinfo_count++;
655 mci->ce_count++; 659 mci->ce_count++;
656} 660}
661
657EXPORT_SYMBOL_GPL(edac_mc_handle_ce_no_info); 662EXPORT_SYMBOL_GPL(edac_mc_handle_ce_no_info);
658 663
659void edac_mc_handle_ue(struct mem_ctl_info *mci, 664void edac_mc_handle_ue(struct mem_ctl_info *mci,
660 unsigned long page_frame_number, unsigned long offset_in_page, 665 unsigned long page_frame_number,
661 int row, const char *msg) 666 unsigned long offset_in_page, int row, const char *msg)
662{ 667{
663 int len = EDAC_MC_LABEL_LEN * 4; 668 int len = EDAC_MC_LABEL_LEN * 4;
664 char labels[len + 1]; 669 char labels[len + 1];
@@ -672,41 +677,42 @@ void edac_mc_handle_ue(struct mem_ctl_info *mci,
672 if (row >= mci->nr_csrows || row < 0) { 677 if (row >= mci->nr_csrows || row < 0) {
673 /* something is wrong */ 678 /* something is wrong */
674 edac_mc_printk(mci, KERN_ERR, 679 edac_mc_printk(mci, KERN_ERR,
675 "INTERNAL ERROR: row out of range " 680 "INTERNAL ERROR: row out of range "
676 "(%d >= %d)\n", row, mci->nr_csrows); 681 "(%d >= %d)\n", row, mci->nr_csrows);
677 edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR"); 682 edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR");
678 return; 683 return;
679 } 684 }
680 685
681 chars = snprintf(pos, len + 1, "%s", 686 chars = snprintf(pos, len + 1, "%s",
682 mci->csrows[row].channels[0].label); 687 mci->csrows[row].channels[0].label);
683 len -= chars; 688 len -= chars;
684 pos += chars; 689 pos += chars;
685 690
686 for (chan = 1; (chan < mci->csrows[row].nr_channels) && (len > 0); 691 for (chan = 1; (chan < mci->csrows[row].nr_channels) && (len > 0);
687 chan++) { 692 chan++) {
688 chars = snprintf(pos, len + 1, ":%s", 693 chars = snprintf(pos, len + 1, ":%s",
689 mci->csrows[row].channels[chan].label); 694 mci->csrows[row].channels[chan].label);
690 len -= chars; 695 len -= chars;
691 pos += chars; 696 pos += chars;
692 } 697 }
693 698
694 if (edac_mc_get_log_ue()) 699 if (edac_mc_get_log_ue())
695 edac_mc_printk(mci, KERN_EMERG, 700 edac_mc_printk(mci, KERN_EMERG,
696 "UE page 0x%lx, offset 0x%lx, grain %d, row %d, " 701 "UE page 0x%lx, offset 0x%lx, grain %d, row %d, "
697 "labels \"%s\": %s\n", page_frame_number, 702 "labels \"%s\": %s\n", page_frame_number,
698 offset_in_page, mci->csrows[row].grain, row, labels, 703 offset_in_page, mci->csrows[row].grain, row,
699 msg); 704 labels, msg);
700 705
701 if (edac_mc_get_panic_on_ue()) 706 if (edac_mc_get_panic_on_ue())
702 panic("EDAC MC%d: UE page 0x%lx, offset 0x%lx, grain %d, " 707 panic("EDAC MC%d: UE page 0x%lx, offset 0x%lx, grain %d, "
703 "row %d, labels \"%s\": %s\n", mci->mc_idx, 708 "row %d, labels \"%s\": %s\n", mci->mc_idx,
704 page_frame_number, offset_in_page, 709 page_frame_number, offset_in_page,
705 mci->csrows[row].grain, row, labels, msg); 710 mci->csrows[row].grain, row, labels, msg);
706 711
707 mci->ue_count++; 712 mci->ue_count++;
708 mci->csrows[row].ue_count++; 713 mci->csrows[row].ue_count++;
709} 714}
715
710EXPORT_SYMBOL_GPL(edac_mc_handle_ue); 716EXPORT_SYMBOL_GPL(edac_mc_handle_ue);
711 717
712void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci, const char *msg) 718void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci, const char *msg)
@@ -716,22 +722,21 @@ void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci, const char *msg)
716 722
717 if (edac_mc_get_log_ue()) 723 if (edac_mc_get_log_ue())
718 edac_mc_printk(mci, KERN_WARNING, 724 edac_mc_printk(mci, KERN_WARNING,
719 "UE - no information available: %s\n", msg); 725 "UE - no information available: %s\n", msg);
720 mci->ue_noinfo_count++; 726 mci->ue_noinfo_count++;
721 mci->ue_count++; 727 mci->ue_count++;
722} 728}
723EXPORT_SYMBOL_GPL(edac_mc_handle_ue_no_info);
724 729
730EXPORT_SYMBOL_GPL(edac_mc_handle_ue_no_info);
725 731
726/************************************************************* 732/*************************************************************
727 * On Fully Buffered DIMM modules, this help function is 733 * On Fully Buffered DIMM modules, this help function is
728 * called to process UE events 734 * called to process UE events
729 */ 735 */
730void edac_mc_handle_fbd_ue(struct mem_ctl_info *mci, 736void edac_mc_handle_fbd_ue(struct mem_ctl_info *mci,
731 unsigned int csrow, 737 unsigned int csrow,
732 unsigned int channela, 738 unsigned int channela,
733 unsigned int channelb, 739 unsigned int channelb, char *msg)
734 char *msg)
735{ 740{
736 int len = EDAC_MC_LABEL_LEN * 4; 741 int len = EDAC_MC_LABEL_LEN * 4;
737 char labels[len + 1]; 742 char labels[len + 1];
@@ -741,8 +746,8 @@ void edac_mc_handle_fbd_ue(struct mem_ctl_info *mci,
741 if (csrow >= mci->nr_csrows) { 746 if (csrow >= mci->nr_csrows) {
742 /* something is wrong */ 747 /* something is wrong */
743 edac_mc_printk(mci, KERN_ERR, 748 edac_mc_printk(mci, KERN_ERR,
744 "INTERNAL ERROR: row out of range (%d >= %d)\n", 749 "INTERNAL ERROR: row out of range (%d >= %d)\n",
745 csrow, mci->nr_csrows); 750 csrow, mci->nr_csrows);
746 edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR"); 751 edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR");
747 return; 752 return;
748 } 753 }
@@ -750,9 +755,9 @@ void edac_mc_handle_fbd_ue(struct mem_ctl_info *mci,
750 if (channela >= mci->csrows[csrow].nr_channels) { 755 if (channela >= mci->csrows[csrow].nr_channels) {
751 /* something is wrong */ 756 /* something is wrong */
752 edac_mc_printk(mci, KERN_ERR, 757 edac_mc_printk(mci, KERN_ERR,
753 "INTERNAL ERROR: channel-a out of range " 758 "INTERNAL ERROR: channel-a out of range "
754 "(%d >= %d)\n", 759 "(%d >= %d)\n",
755 channela, mci->csrows[csrow].nr_channels); 760 channela, mci->csrows[csrow].nr_channels);
756 edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR"); 761 edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR");
757 return; 762 return;
758 } 763 }
@@ -760,9 +765,9 @@ void edac_mc_handle_fbd_ue(struct mem_ctl_info *mci,
760 if (channelb >= mci->csrows[csrow].nr_channels) { 765 if (channelb >= mci->csrows[csrow].nr_channels) {
761 /* something is wrong */ 766 /* something is wrong */
762 edac_mc_printk(mci, KERN_ERR, 767 edac_mc_printk(mci, KERN_ERR,
763 "INTERNAL ERROR: channel-b out of range " 768 "INTERNAL ERROR: channel-b out of range "
764 "(%d >= %d)\n", 769 "(%d >= %d)\n",
765 channelb, mci->csrows[csrow].nr_channels); 770 channelb, mci->csrows[csrow].nr_channels);
766 edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR"); 771 edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR");
767 return; 772 return;
768 } 773 }
@@ -773,21 +778,23 @@ void edac_mc_handle_fbd_ue(struct mem_ctl_info *mci,
773 /* Generate the DIMM labels from the specified channels */ 778 /* Generate the DIMM labels from the specified channels */
774 chars = snprintf(pos, len + 1, "%s", 779 chars = snprintf(pos, len + 1, "%s",
775 mci->csrows[csrow].channels[channela].label); 780 mci->csrows[csrow].channels[channela].label);
776 len -= chars; pos += chars; 781 len -= chars;
782 pos += chars;
777 chars = snprintf(pos, len + 1, "-%s", 783 chars = snprintf(pos, len + 1, "-%s",
778 mci->csrows[csrow].channels[channelb].label); 784 mci->csrows[csrow].channels[channelb].label);
779 785
780 if (edac_mc_get_log_ue()) 786 if (edac_mc_get_log_ue())
781 edac_mc_printk(mci, KERN_EMERG, 787 edac_mc_printk(mci, KERN_EMERG,
782 "UE row %d, channel-a= %d channel-b= %d " 788 "UE row %d, channel-a= %d channel-b= %d "
783 "labels \"%s\": %s\n", csrow, channela, channelb, 789 "labels \"%s\": %s\n", csrow, channela, channelb,
784 labels, msg); 790 labels, msg);
785 791
786 if (edac_mc_get_panic_on_ue()) 792 if (edac_mc_get_panic_on_ue())
787 panic("UE row %d, channel-a= %d channel-b= %d " 793 panic("UE row %d, channel-a= %d channel-b= %d "
788 "labels \"%s\": %s\n", csrow, channela, 794 "labels \"%s\": %s\n", csrow, channela,
789 channelb, labels, msg); 795 channelb, labels, msg);
790} 796}
797
791EXPORT_SYMBOL(edac_mc_handle_fbd_ue); 798EXPORT_SYMBOL(edac_mc_handle_fbd_ue);
792 799
793/************************************************************* 800/*************************************************************
@@ -795,25 +802,23 @@ EXPORT_SYMBOL(edac_mc_handle_fbd_ue);
795 * called to process CE events 802 * called to process CE events
796 */ 803 */
797void edac_mc_handle_fbd_ce(struct mem_ctl_info *mci, 804void edac_mc_handle_fbd_ce(struct mem_ctl_info *mci,
798 unsigned int csrow, 805 unsigned int csrow, unsigned int channel, char *msg)
799 unsigned int channel,
800 char *msg)
801{ 806{
802 807
803 /* Ensure boundary values */ 808 /* Ensure boundary values */
804 if (csrow >= mci->nr_csrows) { 809 if (csrow >= mci->nr_csrows) {
805 /* something is wrong */ 810 /* something is wrong */
806 edac_mc_printk(mci, KERN_ERR, 811 edac_mc_printk(mci, KERN_ERR,
807 "INTERNAL ERROR: row out of range (%d >= %d)\n", 812 "INTERNAL ERROR: row out of range (%d >= %d)\n",
808 csrow, mci->nr_csrows); 813 csrow, mci->nr_csrows);
809 edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR"); 814 edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR");
810 return; 815 return;
811 } 816 }
812 if (channel >= mci->csrows[csrow].nr_channels) { 817 if (channel >= mci->csrows[csrow].nr_channels) {
813 /* something is wrong */ 818 /* something is wrong */
814 edac_mc_printk(mci, KERN_ERR, 819 edac_mc_printk(mci, KERN_ERR,
815 "INTERNAL ERROR: channel out of range (%d >= %d)\n", 820 "INTERNAL ERROR: channel out of range (%d >= %d)\n",
816 channel, mci->csrows[csrow].nr_channels); 821 channel, mci->csrows[csrow].nr_channels);
817 edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR"); 822 edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR");
818 return; 823 return;
819 } 824 }
@@ -821,17 +826,16 @@ void edac_mc_handle_fbd_ce(struct mem_ctl_info *mci,
821 if (edac_mc_get_log_ce()) 826 if (edac_mc_get_log_ce())
822 /* FIXME - put in DIMM location */ 827 /* FIXME - put in DIMM location */
823 edac_mc_printk(mci, KERN_WARNING, 828 edac_mc_printk(mci, KERN_WARNING,
824 "CE row %d, channel %d, label \"%s\": %s\n", 829 "CE row %d, channel %d, label \"%s\": %s\n",
825 csrow, channel, 830 csrow, channel,
826 mci->csrows[csrow].channels[channel].label, 831 mci->csrows[csrow].channels[channel].label, msg);
827 msg);
828 832
829 mci->ce_count++; 833 mci->ce_count++;
830 mci->csrows[csrow].ce_count++; 834 mci->csrows[csrow].ce_count++;
831 mci->csrows[csrow].channels[channel].ce_count++; 835 mci->csrows[csrow].channels[channel].ce_count++;
832} 836}
833EXPORT_SYMBOL(edac_mc_handle_fbd_ce);
834 837
838EXPORT_SYMBOL(edac_mc_handle_fbd_ce);
835 839
836/* 840/*
837 * Iterate over all MC instances and check for ECC, et al, errors 841 * Iterate over all MC instances and check for ECC, et al, errors
diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h
index b92d2720a4de..12740f97483f 100644
--- a/drivers/edac/edac_mc.h
+++ b/drivers/edac/edac_mc.h
@@ -1,9 +1,7 @@
1 1
2
3/* 2/*
4 * Older .h file for edac, until all drivers are modified 3 * Older .h file for edac, until all drivers are modified
5 * 4 *
6 */ 5 */
7 6
8#include "edac_core.h" 7#include "edac_core.h"
9
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 7f8240f40db0..8eaa1d6a8a9f 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -48,14 +48,13 @@ module_param(edac_mc_panic_on_ue, int, 0644);
48MODULE_PARM_DESC(edac_mc_panic_on_ue, "Panic on uncorrected error: 0=off 1=on"); 48MODULE_PARM_DESC(edac_mc_panic_on_ue, "Panic on uncorrected error: 0=off 1=on");
49module_param(edac_mc_log_ue, int, 0644); 49module_param(edac_mc_log_ue, int, 0644);
50MODULE_PARM_DESC(edac_mc_log_ue, 50MODULE_PARM_DESC(edac_mc_log_ue,
51 "Log uncorrectable error to console: 0=off 1=on"); 51 "Log uncorrectable error to console: 0=off 1=on");
52module_param(edac_mc_log_ce, int, 0644); 52module_param(edac_mc_log_ce, int, 0644);
53MODULE_PARM_DESC(edac_mc_log_ce, 53MODULE_PARM_DESC(edac_mc_log_ce,
54 "Log correctable error to console: 0=off 1=on"); 54 "Log correctable error to console: 0=off 1=on");
55module_param(edac_mc_poll_msec, int, 0644); 55module_param(edac_mc_poll_msec, int, 0644);
56MODULE_PARM_DESC(edac_mc_poll_msec, "Polling period in milliseconds"); 56MODULE_PARM_DESC(edac_mc_poll_msec, "Polling period in milliseconds");
57 57
58
59/* 58/*
60 * various constants for Memory Controllers 59 * various constants for Memory Controllers
61 */ 60 */
@@ -116,13 +115,13 @@ static struct completion edac_memctrl_kobj_complete;
116 */ 115 */
117static ssize_t memctrl_int_show(void *ptr, char *buffer) 116static ssize_t memctrl_int_show(void *ptr, char *buffer)
118{ 117{
119 int *value = (int*) ptr; 118 int *value = (int *)ptr;
120 return sprintf(buffer, "%u\n", *value); 119 return sprintf(buffer, "%u\n", *value);
121} 120}
122 121
123static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count) 122static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count)
124{ 123{
125 int *value = (int*) ptr; 124 int *value = (int *)ptr;
126 125
127 if (isdigit(*buffer)) 126 if (isdigit(*buffer))
128 *value = simple_strtoul(buffer, NULL, 0); 127 *value = simple_strtoul(buffer, NULL, 0);
@@ -133,16 +132,16 @@ static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count)
133struct memctrl_dev_attribute { 132struct memctrl_dev_attribute {
134 struct attribute attr; 133 struct attribute attr;
135 void *value; 134 void *value;
136 ssize_t (*show)(void *,char *); 135 ssize_t(*show) (void *, char *);
137 ssize_t (*store)(void *, const char *, size_t); 136 ssize_t(*store) (void *, const char *, size_t);
138}; 137};
139 138
140/* Set of show/store abstract level functions for memory control object */ 139/* Set of show/store abstract level functions for memory control object */
141static ssize_t memctrl_dev_show(struct kobject *kobj, 140static ssize_t memctrl_dev_show(struct kobject *kobj,
142 struct attribute *attr, char *buffer) 141 struct attribute *attr, char *buffer)
143{ 142{
144 struct memctrl_dev_attribute *memctrl_dev; 143 struct memctrl_dev_attribute *memctrl_dev;
145 memctrl_dev = (struct memctrl_dev_attribute*)attr; 144 memctrl_dev = (struct memctrl_dev_attribute *)attr;
146 145
147 if (memctrl_dev->show) 146 if (memctrl_dev->show)
148 return memctrl_dev->show(memctrl_dev->value, buffer); 147 return memctrl_dev->show(memctrl_dev->value, buffer);
@@ -151,10 +150,10 @@ static ssize_t memctrl_dev_show(struct kobject *kobj,
151} 150}
152 151
153static ssize_t memctrl_dev_store(struct kobject *kobj, struct attribute *attr, 152static ssize_t memctrl_dev_store(struct kobject *kobj, struct attribute *attr,
154 const char *buffer, size_t count) 153 const char *buffer, size_t count)
155{ 154{
156 struct memctrl_dev_attribute *memctrl_dev; 155 struct memctrl_dev_attribute *memctrl_dev;
157 memctrl_dev = (struct memctrl_dev_attribute*)attr; 156 memctrl_dev = (struct memctrl_dev_attribute *)attr;
158 157
159 if (memctrl_dev->store) 158 if (memctrl_dev->store)
160 return memctrl_dev->store(memctrl_dev->value, buffer, count); 159 return memctrl_dev->store(memctrl_dev->value, buffer, count);
@@ -163,8 +162,8 @@ static ssize_t memctrl_dev_store(struct kobject *kobj, struct attribute *attr,
163} 162}
164 163
165static struct sysfs_ops memctrlfs_ops = { 164static struct sysfs_ops memctrlfs_ops = {
166 .show = memctrl_dev_show, 165 .show = memctrl_dev_show,
167 .store = memctrl_dev_store 166 .store = memctrl_dev_store
168}; 167};
169 168
170#define MEMCTRL_ATTR(_name,_mode,_show,_store) \ 169#define MEMCTRL_ATTR(_name,_mode,_show,_store) \
@@ -185,24 +184,16 @@ static struct memctrl_dev_attribute attr_##_name = { \
185 184
186/* csrow<id> control files */ 185/* csrow<id> control files */
187MEMCTRL_ATTR(edac_mc_panic_on_ue, 186MEMCTRL_ATTR(edac_mc_panic_on_ue,
188 S_IRUGO | S_IWUSR, 187 S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store);
189 memctrl_int_show,
190 memctrl_int_store);
191 188
192MEMCTRL_ATTR(edac_mc_log_ue, 189MEMCTRL_ATTR(edac_mc_log_ue,
193 S_IRUGO|S_IWUSR, 190 S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store);
194 memctrl_int_show,
195 memctrl_int_store);
196 191
197MEMCTRL_ATTR(edac_mc_log_ce, 192MEMCTRL_ATTR(edac_mc_log_ce,
198 S_IRUGO|S_IWUSR, 193 S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store);
199 memctrl_int_show,
200 memctrl_int_store);
201 194
202MEMCTRL_ATTR(edac_mc_poll_msec, 195MEMCTRL_ATTR(edac_mc_poll_msec,
203 S_IRUGO|S_IWUSR, 196 S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store);
204 memctrl_int_show,
205 memctrl_int_store);
206 197
207/* Base Attributes of the memory ECC object */ 198/* Base Attributes of the memory ECC object */
208static struct memctrl_dev_attribute *memctrl_attr[] = { 199static struct memctrl_dev_attribute *memctrl_attr[] = {
@@ -223,7 +214,7 @@ static void edac_memctrl_master_release(struct kobject *kobj)
223static struct kobj_type ktype_memctrl = { 214static struct kobj_type ktype_memctrl = {
224 .release = edac_memctrl_master_release, 215 .release = edac_memctrl_master_release,
225 .sysfs_ops = &memctrlfs_ops, 216 .sysfs_ops = &memctrlfs_ops,
226 .default_attrs = (struct attribute **) memctrl_attr, 217 .default_attrs = (struct attribute **)memctrl_attr,
227}; 218};
228 219
229/* Initialize the main sysfs entries for edac: 220/* Initialize the main sysfs entries for edac:
@@ -249,25 +240,25 @@ int edac_sysfs_memctrl_setup(void)
249 } 240 }
250 241
251 /* Init the MC's kobject */ 242 /* Init the MC's kobject */
252 memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj)); 243 memset(&edac_memctrl_kobj, 0, sizeof(edac_memctrl_kobj));
253 edac_memctrl_kobj.parent = &edac_class->kset.kobj; 244 edac_memctrl_kobj.parent = &edac_class->kset.kobj;
254 edac_memctrl_kobj.ktype = &ktype_memctrl; 245 edac_memctrl_kobj.ktype = &ktype_memctrl;
255 246
256 /* generate sysfs "..../edac/mc" */ 247 /* generate sysfs "..../edac/mc" */
257 err = kobject_set_name(&edac_memctrl_kobj,"mc"); 248 err = kobject_set_name(&edac_memctrl_kobj, "mc");
258 if (err) { 249 if (err) {
259 debugf1("%s() Failed to set name '.../edac/mc'\n", __func__ ); 250 debugf1("%s() Failed to set name '.../edac/mc'\n", __func__);
260 return err; 251 return err;
261 } 252 }
262 253
263 /* FIXME: maybe new sysdev_create_subdir() */ 254 /* FIXME: maybe new sysdev_create_subdir() */
264 err = kobject_register(&edac_memctrl_kobj); 255 err = kobject_register(&edac_memctrl_kobj);
265 if (err) { 256 if (err) {
266 debugf1("%s() Failed to register '.../edac/mc'\n", __func__ ); 257 debugf1("%s() Failed to register '.../edac/mc'\n", __func__);
267 return err; 258 return err;
268 } 259 }
269 260
270 debugf1("%s() Registered '.../edac/mc' kobject\n",__func__); 261 debugf1("%s() Registered '.../edac/mc' kobject\n", __func__);
271 return 0; 262 return 0;
272} 263}
273 264
@@ -286,63 +277,61 @@ void edac_sysfs_memctrl_teardown(void)
286 wait_for_completion(&edac_memctrl_kobj_complete); 277 wait_for_completion(&edac_memctrl_kobj_complete);
287} 278}
288 279
289
290/* EDAC sysfs CSROW data structures and methods 280/* EDAC sysfs CSROW data structures and methods
291 */ 281 */
292 282
293/* Set of more default csrow<id> attribute show/store functions */ 283/* Set of more default csrow<id> attribute show/store functions */
294static ssize_t csrow_ue_count_show(struct csrow_info *csrow, char *data, 284static ssize_t csrow_ue_count_show(struct csrow_info *csrow, char *data,
295 int private) 285 int private)
296{ 286{
297 return sprintf(data,"%u\n", csrow->ue_count); 287 return sprintf(data, "%u\n", csrow->ue_count);
298} 288}
299 289
300static ssize_t csrow_ce_count_show(struct csrow_info *csrow, char *data, 290static ssize_t csrow_ce_count_show(struct csrow_info *csrow, char *data,
301 int private) 291 int private)
302{ 292{
303 return sprintf(data,"%u\n", csrow->ce_count); 293 return sprintf(data, "%u\n", csrow->ce_count);
304} 294}
305 295
306static ssize_t csrow_size_show(struct csrow_info *csrow, char *data, 296static ssize_t csrow_size_show(struct csrow_info *csrow, char *data,
307 int private) 297 int private)
308{ 298{
309 return sprintf(data,"%u\n", PAGES_TO_MiB(csrow->nr_pages)); 299 return sprintf(data, "%u\n", PAGES_TO_MiB(csrow->nr_pages));
310} 300}
311 301
312static ssize_t csrow_mem_type_show(struct csrow_info *csrow, char *data, 302static ssize_t csrow_mem_type_show(struct csrow_info *csrow, char *data,
313 int private) 303 int private)
314{ 304{
315 return sprintf(data,"%s\n", mem_types[csrow->mtype]); 305 return sprintf(data, "%s\n", mem_types[csrow->mtype]);
316} 306}
317 307
318static ssize_t csrow_dev_type_show(struct csrow_info *csrow, char *data, 308static ssize_t csrow_dev_type_show(struct csrow_info *csrow, char *data,
319 int private) 309 int private)
320{ 310{
321 return sprintf(data,"%s\n", dev_types[csrow->dtype]); 311 return sprintf(data, "%s\n", dev_types[csrow->dtype]);
322} 312}
323 313
324static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data, 314static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data,
325 int private) 315 int private)
326{ 316{
327 return sprintf(data,"%s\n", edac_caps[csrow->edac_mode]); 317 return sprintf(data, "%s\n", edac_caps[csrow->edac_mode]);
328} 318}
329 319
330/* show/store functions for DIMM Label attributes */ 320/* show/store functions for DIMM Label attributes */
331static ssize_t channel_dimm_label_show(struct csrow_info *csrow, 321static ssize_t channel_dimm_label_show(struct csrow_info *csrow,
332 char *data, int channel) 322 char *data, int channel)
333{ 323{
334 return snprintf(data, EDAC_MC_LABEL_LEN,"%s", 324 return snprintf(data, EDAC_MC_LABEL_LEN, "%s",
335 csrow->channels[channel].label); 325 csrow->channels[channel].label);
336} 326}
337 327
338static ssize_t channel_dimm_label_store(struct csrow_info *csrow, 328static ssize_t channel_dimm_label_store(struct csrow_info *csrow,
339 const char *data, 329 const char *data,
340 size_t count, 330 size_t count, int channel)
341 int channel)
342{ 331{
343 ssize_t max_size = 0; 332 ssize_t max_size = 0;
344 333
345 max_size = min((ssize_t)count,(ssize_t)EDAC_MC_LABEL_LEN-1); 334 max_size = min((ssize_t) count, (ssize_t) EDAC_MC_LABEL_LEN - 1);
346 strncpy(csrow->channels[channel].label, data, max_size); 335 strncpy(csrow->channels[channel].label, data, max_size);
347 csrow->channels[channel].label[max_size] = '\0'; 336 csrow->channels[channel].label[max_size] = '\0';
348 337
@@ -351,8 +340,7 @@ static ssize_t channel_dimm_label_store(struct csrow_info *csrow,
351 340
352/* show function for dynamic chX_ce_count attribute */ 341/* show function for dynamic chX_ce_count attribute */
353static ssize_t channel_ce_count_show(struct csrow_info *csrow, 342static ssize_t channel_ce_count_show(struct csrow_info *csrow,
354 char *data, 343 char *data, int channel)
355 int channel)
356{ 344{
357 return sprintf(data, "%u\n", csrow->channels[channel].ce_count); 345 return sprintf(data, "%u\n", csrow->channels[channel].ce_count);
358} 346}
@@ -360,9 +348,9 @@ static ssize_t channel_ce_count_show(struct csrow_info *csrow,
360/* csrow specific attribute structure */ 348/* csrow specific attribute structure */
361struct csrowdev_attribute { 349struct csrowdev_attribute {
362 struct attribute attr; 350 struct attribute attr;
363 ssize_t (*show)(struct csrow_info *,char *,int); 351 ssize_t(*show) (struct csrow_info *, char *, int);
364 ssize_t (*store)(struct csrow_info *, const char *,size_t,int); 352 ssize_t(*store) (struct csrow_info *, const char *, size_t, int);
365 int private; 353 int private;
366}; 354};
367 355
368#define to_csrow(k) container_of(k, struct csrow_info, kobj) 356#define to_csrow(k) container_of(k, struct csrow_info, kobj)
@@ -370,36 +358,33 @@ struct csrowdev_attribute {
370 358
371/* Set of show/store higher level functions for default csrow attributes */ 359/* Set of show/store higher level functions for default csrow attributes */
372static ssize_t csrowdev_show(struct kobject *kobj, 360static ssize_t csrowdev_show(struct kobject *kobj,
373 struct attribute *attr, 361 struct attribute *attr, char *buffer)
374 char *buffer)
375{ 362{
376 struct csrow_info *csrow = to_csrow(kobj); 363 struct csrow_info *csrow = to_csrow(kobj);
377 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr); 364 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr);
378 365
379 if (csrowdev_attr->show) 366 if (csrowdev_attr->show)
380 return csrowdev_attr->show(csrow, 367 return csrowdev_attr->show(csrow,
381 buffer, 368 buffer, csrowdev_attr->private);
382 csrowdev_attr->private);
383 return -EIO; 369 return -EIO;
384} 370}
385 371
386static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr, 372static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr,
387 const char *buffer, size_t count) 373 const char *buffer, size_t count)
388{ 374{
389 struct csrow_info *csrow = to_csrow(kobj); 375 struct csrow_info *csrow = to_csrow(kobj);
390 struct csrowdev_attribute * csrowdev_attr = to_csrowdev_attr(attr); 376 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr);
391 377
392 if (csrowdev_attr->store) 378 if (csrowdev_attr->store)
393 return csrowdev_attr->store(csrow, 379 return csrowdev_attr->store(csrow,
394 buffer, 380 buffer,
395 count, 381 count, csrowdev_attr->private);
396 csrowdev_attr->private);
397 return -EIO; 382 return -EIO;
398} 383}
399 384
400static struct sysfs_ops csrowfs_ops = { 385static struct sysfs_ops csrowfs_ops = {
401 .show = csrowdev_show, 386 .show = csrowdev_show,
402 .store = csrowdev_store 387 .store = csrowdev_store
403}; 388};
404 389
405#define CSROWDEV_ATTR(_name,_mode,_show,_store,_private) \ 390#define CSROWDEV_ATTR(_name,_mode,_show,_store,_private) \
@@ -411,12 +396,12 @@ static struct csrowdev_attribute attr_##_name = { \
411}; 396};
412 397
413/* default cwrow<id>/attribute files */ 398/* default cwrow<id>/attribute files */
414CSROWDEV_ATTR(size_mb,S_IRUGO,csrow_size_show,NULL,0); 399CSROWDEV_ATTR(size_mb, S_IRUGO, csrow_size_show, NULL, 0);
415CSROWDEV_ATTR(dev_type,S_IRUGO,csrow_dev_type_show,NULL,0); 400CSROWDEV_ATTR(dev_type, S_IRUGO, csrow_dev_type_show, NULL, 0);
416CSROWDEV_ATTR(mem_type,S_IRUGO,csrow_mem_type_show,NULL,0); 401CSROWDEV_ATTR(mem_type, S_IRUGO, csrow_mem_type_show, NULL, 0);
417CSROWDEV_ATTR(edac_mode,S_IRUGO,csrow_edac_mode_show,NULL,0); 402CSROWDEV_ATTR(edac_mode, S_IRUGO, csrow_edac_mode_show, NULL, 0);
418CSROWDEV_ATTR(ue_count,S_IRUGO,csrow_ue_count_show,NULL,0); 403CSROWDEV_ATTR(ue_count, S_IRUGO, csrow_ue_count_show, NULL, 0);
419CSROWDEV_ATTR(ce_count,S_IRUGO,csrow_ce_count_show,NULL,0); 404CSROWDEV_ATTR(ce_count, S_IRUGO, csrow_ce_count_show, NULL, 0);
420 405
421/* default attributes of the CSROW<id> object */ 406/* default attributes of the CSROW<id> object */
422static struct csrowdev_attribute *default_csrow_attr[] = { 407static struct csrowdev_attribute *default_csrow_attr[] = {
@@ -429,98 +414,68 @@ static struct csrowdev_attribute *default_csrow_attr[] = {
429 NULL, 414 NULL,
430}; 415};
431 416
432
433/* possible dynamic channel DIMM Label attribute files */ 417/* possible dynamic channel DIMM Label attribute files */
434CSROWDEV_ATTR(ch0_dimm_label,S_IRUGO|S_IWUSR, 418CSROWDEV_ATTR(ch0_dimm_label, S_IRUGO | S_IWUSR,
435 channel_dimm_label_show, 419 channel_dimm_label_show, channel_dimm_label_store, 0);
436 channel_dimm_label_store, 420CSROWDEV_ATTR(ch1_dimm_label, S_IRUGO | S_IWUSR,
437 0 ); 421 channel_dimm_label_show, channel_dimm_label_store, 1);
438CSROWDEV_ATTR(ch1_dimm_label,S_IRUGO|S_IWUSR, 422CSROWDEV_ATTR(ch2_dimm_label, S_IRUGO | S_IWUSR,
439 channel_dimm_label_show, 423 channel_dimm_label_show, channel_dimm_label_store, 2);
440 channel_dimm_label_store, 424CSROWDEV_ATTR(ch3_dimm_label, S_IRUGO | S_IWUSR,
441 1 ); 425 channel_dimm_label_show, channel_dimm_label_store, 3);
442CSROWDEV_ATTR(ch2_dimm_label,S_IRUGO|S_IWUSR, 426CSROWDEV_ATTR(ch4_dimm_label, S_IRUGO | S_IWUSR,
443 channel_dimm_label_show, 427 channel_dimm_label_show, channel_dimm_label_store, 4);
444 channel_dimm_label_store, 428CSROWDEV_ATTR(ch5_dimm_label, S_IRUGO | S_IWUSR,
445 2 ); 429 channel_dimm_label_show, channel_dimm_label_store, 5);
446CSROWDEV_ATTR(ch3_dimm_label,S_IRUGO|S_IWUSR,
447 channel_dimm_label_show,
448 channel_dimm_label_store,
449 3 );
450CSROWDEV_ATTR(ch4_dimm_label,S_IRUGO|S_IWUSR,
451 channel_dimm_label_show,
452 channel_dimm_label_store,
453 4 );
454CSROWDEV_ATTR(ch5_dimm_label,S_IRUGO|S_IWUSR,
455 channel_dimm_label_show,
456 channel_dimm_label_store,
457 5 );
458 430
459/* Total possible dynamic DIMM Label attribute file table */ 431/* Total possible dynamic DIMM Label attribute file table */
460static struct csrowdev_attribute *dynamic_csrow_dimm_attr[] = { 432static struct csrowdev_attribute *dynamic_csrow_dimm_attr[] = {
461 &attr_ch0_dimm_label, 433 &attr_ch0_dimm_label,
462 &attr_ch1_dimm_label, 434 &attr_ch1_dimm_label,
463 &attr_ch2_dimm_label, 435 &attr_ch2_dimm_label,
464 &attr_ch3_dimm_label, 436 &attr_ch3_dimm_label,
465 &attr_ch4_dimm_label, 437 &attr_ch4_dimm_label,
466 &attr_ch5_dimm_label 438 &attr_ch5_dimm_label
467}; 439};
468 440
469/* possible dynamic channel ce_count attribute files */ 441/* possible dynamic channel ce_count attribute files */
470CSROWDEV_ATTR(ch0_ce_count,S_IRUGO|S_IWUSR, 442CSROWDEV_ATTR(ch0_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 0);
471 channel_ce_count_show, 443CSROWDEV_ATTR(ch1_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 1);
472 NULL, 444CSROWDEV_ATTR(ch2_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 2);
473 0 ); 445CSROWDEV_ATTR(ch3_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 3);
474CSROWDEV_ATTR(ch1_ce_count,S_IRUGO|S_IWUSR, 446CSROWDEV_ATTR(ch4_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 4);
475 channel_ce_count_show, 447CSROWDEV_ATTR(ch5_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 5);
476 NULL,
477 1 );
478CSROWDEV_ATTR(ch2_ce_count,S_IRUGO|S_IWUSR,
479 channel_ce_count_show,
480 NULL,
481 2 );
482CSROWDEV_ATTR(ch3_ce_count,S_IRUGO|S_IWUSR,
483 channel_ce_count_show,
484 NULL,
485 3 );
486CSROWDEV_ATTR(ch4_ce_count,S_IRUGO|S_IWUSR,
487 channel_ce_count_show,
488 NULL,
489 4 );
490CSROWDEV_ATTR(ch5_ce_count,S_IRUGO|S_IWUSR,
491 channel_ce_count_show,
492 NULL,
493 5 );
494 448
495/* Total possible dynamic ce_count attribute file table */ 449/* Total possible dynamic ce_count attribute file table */
496static struct csrowdev_attribute *dynamic_csrow_ce_count_attr[] = { 450static struct csrowdev_attribute *dynamic_csrow_ce_count_attr[] = {
497 &attr_ch0_ce_count, 451 &attr_ch0_ce_count,
498 &attr_ch1_ce_count, 452 &attr_ch1_ce_count,
499 &attr_ch2_ce_count, 453 &attr_ch2_ce_count,
500 &attr_ch3_ce_count, 454 &attr_ch3_ce_count,
501 &attr_ch4_ce_count, 455 &attr_ch4_ce_count,
502 &attr_ch5_ce_count 456 &attr_ch5_ce_count
503}; 457};
504 458
505
506#define EDAC_NR_CHANNELS 6 459#define EDAC_NR_CHANNELS 6
507 460
508/* Create dynamic CHANNEL files, indexed by 'chan', under specifed CSROW */ 461/* Create dynamic CHANNEL files, indexed by 'chan', under specifed CSROW */
509static int edac_create_channel_files(struct kobject *kobj, int chan) 462static int edac_create_channel_files(struct kobject *kobj, int chan)
510{ 463{
511 int err=-ENODEV; 464 int err = -ENODEV;
512 465
513 if (chan >= EDAC_NR_CHANNELS) 466 if (chan >= EDAC_NR_CHANNELS)
514 return err; 467 return err;
515 468
516 /* create the DIMM label attribute file */ 469 /* create the DIMM label attribute file */
517 err = sysfs_create_file(kobj, 470 err = sysfs_create_file(kobj,
518 (struct attribute *) dynamic_csrow_dimm_attr[chan]); 471 (struct attribute *)
472 dynamic_csrow_dimm_attr[chan]);
519 473
520 if (!err) { 474 if (!err) {
521 /* create the CE Count attribute file */ 475 /* create the CE Count attribute file */
522 err = sysfs_create_file(kobj, 476 err = sysfs_create_file(kobj,
523 (struct attribute *)dynamic_csrow_ce_count_attr[chan]); 477 (struct attribute *)
478 dynamic_csrow_ce_count_attr[chan]);
524 } else { 479 } else {
525 debugf1("%s() dimm labels and ce_count files created", 480 debugf1("%s() dimm labels and ce_count files created",
526 __func__); 481 __func__);
@@ -542,14 +497,12 @@ static void edac_csrow_instance_release(struct kobject *kobj)
542static struct kobj_type ktype_csrow = { 497static struct kobj_type ktype_csrow = {
543 .release = edac_csrow_instance_release, 498 .release = edac_csrow_instance_release,
544 .sysfs_ops = &csrowfs_ops, 499 .sysfs_ops = &csrowfs_ops,
545 .default_attrs = (struct attribute **) default_csrow_attr, 500 .default_attrs = (struct attribute **)default_csrow_attr,
546}; 501};
547 502
548/* Create a CSROW object under specifed edac_mc_device */ 503/* Create a CSROW object under specifed edac_mc_device */
549static int edac_create_csrow_object( 504static int edac_create_csrow_object(struct kobject *edac_mci_kobj,
550 struct kobject *edac_mci_kobj, 505 struct csrow_info *csrow, int index)
551 struct csrow_info *csrow,
552 int index)
553{ 506{
554 int err = 0; 507 int err = 0;
555 int chan; 508 int chan;
@@ -562,7 +515,7 @@ static int edac_create_csrow_object(
562 csrow->kobj.ktype = &ktype_csrow; 515 csrow->kobj.ktype = &ktype_csrow;
563 516
564 /* name this instance of csrow<id> */ 517 /* name this instance of csrow<id> */
565 err = kobject_set_name(&csrow->kobj,"csrow%d",index); 518 err = kobject_set_name(&csrow->kobj, "csrow%d", index);
566 if (err) 519 if (err)
567 goto error_exit; 520 goto error_exit;
568 521
@@ -573,20 +526,20 @@ static int edac_create_csrow_object(
573 * namely, the DIMM labels and the channel ce_count 526 * namely, the DIMM labels and the channel ce_count
574 */ 527 */
575 for (chan = 0; chan < csrow->nr_channels; chan++) { 528 for (chan = 0; chan < csrow->nr_channels; chan++) {
576 err = edac_create_channel_files(&csrow->kobj,chan); 529 err = edac_create_channel_files(&csrow->kobj, chan);
577 if (err) 530 if (err)
578 break; 531 break;
579 } 532 }
580 } 533 }
581 534
582error_exit: 535 error_exit:
583 return err; 536 return err;
584} 537}
585 538
586/* default sysfs methods and data structures for the main MCI kobject */ 539/* default sysfs methods and data structures for the main MCI kobject */
587 540
588static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci, 541static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
589 const char *data, size_t count) 542 const char *data, size_t count)
590{ 543{
591 int row, chan; 544 int row, chan;
592 545
@@ -611,7 +564,7 @@ static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
611 564
612/* memory scrubbing */ 565/* memory scrubbing */
613static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci, 566static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci,
614 const char *data, size_t count) 567 const char *data, size_t count)
615{ 568{
616 u32 bandwidth = -1; 569 u32 bandwidth = -1;
617 570
@@ -619,20 +572,20 @@ static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci,
619 572
620 memctrl_int_store(&bandwidth, data, count); 573 memctrl_int_store(&bandwidth, data, count);
621 574
622 if (!(*mci->set_sdram_scrub_rate)(mci, &bandwidth)) { 575 if (!(*mci->set_sdram_scrub_rate) (mci, &bandwidth)) {
623 edac_printk(KERN_DEBUG, EDAC_MC, 576 edac_printk(KERN_DEBUG, EDAC_MC,
624 "Scrub rate set successfully, applied: %d\n", 577 "Scrub rate set successfully, applied: %d\n",
625 bandwidth); 578 bandwidth);
626 } else { 579 } else {
627 /* FIXME: error codes maybe? */ 580 /* FIXME: error codes maybe? */
628 edac_printk(KERN_DEBUG, EDAC_MC, 581 edac_printk(KERN_DEBUG, EDAC_MC,
629 "Scrub rate set FAILED, could not apply: %d\n", 582 "Scrub rate set FAILED, could not apply: %d\n",
630 bandwidth); 583 bandwidth);
631 } 584 }
632 } else { 585 } else {
633 /* FIXME: produce "not implemented" ERROR for user-side. */ 586 /* FIXME: produce "not implemented" ERROR for user-side. */
634 edac_printk(KERN_WARNING, EDAC_MC, 587 edac_printk(KERN_WARNING, EDAC_MC,
635 "Memory scrubbing 'set'control is not implemented!\n"); 588 "Memory scrubbing 'set'control is not implemented!\n");
636 } 589 }
637 return count; 590 return count;
638} 591}
@@ -642,20 +595,20 @@ static ssize_t mci_sdram_scrub_rate_show(struct mem_ctl_info *mci, char *data)
642 u32 bandwidth = -1; 595 u32 bandwidth = -1;
643 596
644 if (mci->get_sdram_scrub_rate) { 597 if (mci->get_sdram_scrub_rate) {
645 if (!(*mci->get_sdram_scrub_rate)(mci, &bandwidth)) { 598 if (!(*mci->get_sdram_scrub_rate) (mci, &bandwidth)) {
646 edac_printk(KERN_DEBUG, EDAC_MC, 599 edac_printk(KERN_DEBUG, EDAC_MC,
647 "Scrub rate successfully, fetched: %d\n", 600 "Scrub rate successfully, fetched: %d\n",
648 bandwidth); 601 bandwidth);
649 } else { 602 } else {
650 /* FIXME: error codes maybe? */ 603 /* FIXME: error codes maybe? */
651 edac_printk(KERN_DEBUG, EDAC_MC, 604 edac_printk(KERN_DEBUG, EDAC_MC,
652 "Scrub rate fetch FAILED, got: %d\n", 605 "Scrub rate fetch FAILED, got: %d\n",
653 bandwidth); 606 bandwidth);
654 } 607 }
655 } else { 608 } else {
656 /* FIXME: produce "not implemented" ERROR for user-side. */ 609 /* FIXME: produce "not implemented" ERROR for user-side. */
657 edac_printk(KERN_WARNING, EDAC_MC, 610 edac_printk(KERN_WARNING, EDAC_MC,
658 "Memory scrubbing 'get' control is not implemented\n"); 611 "Memory scrubbing 'get' control is not implemented\n");
659 } 612 }
660 return sprintf(data, "%d\n", bandwidth); 613 return sprintf(data, "%d\n", bandwidth);
661} 614}
@@ -663,32 +616,32 @@ static ssize_t mci_sdram_scrub_rate_show(struct mem_ctl_info *mci, char *data)
663/* default attribute files for the MCI object */ 616/* default attribute files for the MCI object */
664static ssize_t mci_ue_count_show(struct mem_ctl_info *mci, char *data) 617static ssize_t mci_ue_count_show(struct mem_ctl_info *mci, char *data)
665{ 618{
666 return sprintf(data,"%d\n", mci->ue_count); 619 return sprintf(data, "%d\n", mci->ue_count);
667} 620}
668 621
669static ssize_t mci_ce_count_show(struct mem_ctl_info *mci, char *data) 622static ssize_t mci_ce_count_show(struct mem_ctl_info *mci, char *data)
670{ 623{
671 return sprintf(data,"%d\n", mci->ce_count); 624 return sprintf(data, "%d\n", mci->ce_count);
672} 625}
673 626
674static ssize_t mci_ce_noinfo_show(struct mem_ctl_info *mci, char *data) 627static ssize_t mci_ce_noinfo_show(struct mem_ctl_info *mci, char *data)
675{ 628{
676 return sprintf(data,"%d\n", mci->ce_noinfo_count); 629 return sprintf(data, "%d\n", mci->ce_noinfo_count);
677} 630}
678 631
679static ssize_t mci_ue_noinfo_show(struct mem_ctl_info *mci, char *data) 632static ssize_t mci_ue_noinfo_show(struct mem_ctl_info *mci, char *data)
680{ 633{
681 return sprintf(data,"%d\n", mci->ue_noinfo_count); 634 return sprintf(data, "%d\n", mci->ue_noinfo_count);
682} 635}
683 636
684static ssize_t mci_seconds_show(struct mem_ctl_info *mci, char *data) 637static ssize_t mci_seconds_show(struct mem_ctl_info *mci, char *data)
685{ 638{
686 return sprintf(data,"%ld\n", (jiffies - mci->start_time) / HZ); 639 return sprintf(data, "%ld\n", (jiffies - mci->start_time) / HZ);
687} 640}
688 641
689static ssize_t mci_ctl_name_show(struct mem_ctl_info *mci, char *data) 642static ssize_t mci_ctl_name_show(struct mem_ctl_info *mci, char *data)
690{ 643{
691 return sprintf(data,"%s\n", mci->ctl_name); 644 return sprintf(data, "%s\n", mci->ctl_name);
692} 645}
693 646
694static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data) 647static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data)
@@ -696,7 +649,7 @@ static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data)
696 int total_pages, csrow_idx; 649 int total_pages, csrow_idx;
697 650
698 for (total_pages = csrow_idx = 0; csrow_idx < mci->nr_csrows; 651 for (total_pages = csrow_idx = 0; csrow_idx < mci->nr_csrows;
699 csrow_idx++) { 652 csrow_idx++) {
700 struct csrow_info *csrow = &mci->csrows[csrow_idx]; 653 struct csrow_info *csrow = &mci->csrows[csrow_idx];
701 654
702 if (!csrow->nr_pages) 655 if (!csrow->nr_pages)
@@ -705,13 +658,13 @@ static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data)
705 total_pages += csrow->nr_pages; 658 total_pages += csrow->nr_pages;
706 } 659 }
707 660
708 return sprintf(data,"%u\n", PAGES_TO_MiB(total_pages)); 661 return sprintf(data, "%u\n", PAGES_TO_MiB(total_pages));
709} 662}
710 663
711struct mcidev_attribute { 664struct mcidev_attribute {
712 struct attribute attr; 665 struct attribute attr;
713 ssize_t (*show)(struct mem_ctl_info *,char *); 666 ssize_t(*show) (struct mem_ctl_info *, char *);
714 ssize_t (*store)(struct mem_ctl_info *, const char *,size_t); 667 ssize_t(*store) (struct mem_ctl_info *, const char *, size_t);
715}; 668};
716 669
717#define to_mci(k) container_of(k, struct mem_ctl_info, edac_mci_kobj) 670#define to_mci(k) container_of(k, struct mem_ctl_info, edac_mci_kobj)
@@ -719,10 +672,10 @@ struct mcidev_attribute {
719 672
720/* MCI show/store functions for top most object */ 673/* MCI show/store functions for top most object */
721static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr, 674static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr,
722 char *buffer) 675 char *buffer)
723{ 676{
724 struct mem_ctl_info *mem_ctl_info = to_mci(kobj); 677 struct mem_ctl_info *mem_ctl_info = to_mci(kobj);
725 struct mcidev_attribute * mcidev_attr = to_mcidev_attr(attr); 678 struct mcidev_attribute *mcidev_attr = to_mcidev_attr(attr);
726 679
727 if (mcidev_attr->show) 680 if (mcidev_attr->show)
728 return mcidev_attr->show(mem_ctl_info, buffer); 681 return mcidev_attr->show(mem_ctl_info, buffer);
@@ -731,10 +684,10 @@ static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr,
731} 684}
732 685
733static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr, 686static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr,
734 const char *buffer, size_t count) 687 const char *buffer, size_t count)
735{ 688{
736 struct mem_ctl_info *mem_ctl_info = to_mci(kobj); 689 struct mem_ctl_info *mem_ctl_info = to_mci(kobj);
737 struct mcidev_attribute * mcidev_attr = to_mcidev_attr(attr); 690 struct mcidev_attribute *mcidev_attr = to_mcidev_attr(attr);
738 691
739 if (mcidev_attr->store) 692 if (mcidev_attr->store)
740 return mcidev_attr->store(mem_ctl_info, buffer, count); 693 return mcidev_attr->store(mem_ctl_info, buffer, count);
@@ -755,20 +708,20 @@ static struct mcidev_attribute mci_attr_##_name = { \
755}; 708};
756 709
757/* default Control file */ 710/* default Control file */
758MCIDEV_ATTR(reset_counters,S_IWUSR,NULL,mci_reset_counters_store); 711MCIDEV_ATTR(reset_counters, S_IWUSR, NULL, mci_reset_counters_store);
759 712
760/* default Attribute files */ 713/* default Attribute files */
761MCIDEV_ATTR(mc_name,S_IRUGO,mci_ctl_name_show,NULL); 714MCIDEV_ATTR(mc_name, S_IRUGO, mci_ctl_name_show, NULL);
762MCIDEV_ATTR(size_mb,S_IRUGO,mci_size_mb_show,NULL); 715MCIDEV_ATTR(size_mb, S_IRUGO, mci_size_mb_show, NULL);
763MCIDEV_ATTR(seconds_since_reset,S_IRUGO,mci_seconds_show,NULL); 716MCIDEV_ATTR(seconds_since_reset, S_IRUGO, mci_seconds_show, NULL);
764MCIDEV_ATTR(ue_noinfo_count,S_IRUGO,mci_ue_noinfo_show,NULL); 717MCIDEV_ATTR(ue_noinfo_count, S_IRUGO, mci_ue_noinfo_show, NULL);
765MCIDEV_ATTR(ce_noinfo_count,S_IRUGO,mci_ce_noinfo_show,NULL); 718MCIDEV_ATTR(ce_noinfo_count, S_IRUGO, mci_ce_noinfo_show, NULL);
766MCIDEV_ATTR(ue_count,S_IRUGO,mci_ue_count_show,NULL); 719MCIDEV_ATTR(ue_count, S_IRUGO, mci_ue_count_show, NULL);
767MCIDEV_ATTR(ce_count,S_IRUGO,mci_ce_count_show,NULL); 720MCIDEV_ATTR(ce_count, S_IRUGO, mci_ce_count_show, NULL);
768 721
769/* memory scrubber attribute file */ 722/* memory scrubber attribute file */
770MCIDEV_ATTR(sdram_scrub_rate,S_IRUGO|S_IWUSR,mci_sdram_scrub_rate_show,\ 723MCIDEV_ATTR(sdram_scrub_rate, S_IRUGO | S_IWUSR, mci_sdram_scrub_rate_show,
771 mci_sdram_scrub_rate_store); 724 mci_sdram_scrub_rate_store);
772 725
773static struct mcidev_attribute *mci_attr[] = { 726static struct mcidev_attribute *mci_attr[] = {
774 &mci_attr_reset_counters, 727 &mci_attr_reset_counters,
@@ -798,10 +751,9 @@ static void edac_mci_instance_release(struct kobject *kobj)
798static struct kobj_type ktype_mci = { 751static struct kobj_type ktype_mci = {
799 .release = edac_mci_instance_release, 752 .release = edac_mci_instance_release,
800 .sysfs_ops = &mci_ops, 753 .sysfs_ops = &mci_ops,
801 .default_attrs = (struct attribute **) mci_attr, 754 .default_attrs = (struct attribute **)mci_attr,
802}; 755};
803 756
804
805#define EDAC_DEVICE_SYMLINK "device" 757#define EDAC_DEVICE_SYMLINK "device"
806 758
807/* 759/*
@@ -817,13 +769,13 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
817 int i; 769 int i;
818 int err; 770 int err;
819 struct csrow_info *csrow; 771 struct csrow_info *csrow;
820 struct kobject *edac_mci_kobj=&mci->edac_mci_kobj; 772 struct kobject *edac_mci_kobj = &mci->edac_mci_kobj;
821 773
822 debugf0("%s() idx=%d\n", __func__, mci->mc_idx); 774 debugf0("%s() idx=%d\n", __func__, mci->mc_idx);
823 memset(edac_mci_kobj, 0, sizeof(*edac_mci_kobj)); 775 memset(edac_mci_kobj, 0, sizeof(*edac_mci_kobj));
824 776
825 /* set the name of the mc<id> object */ 777 /* set the name of the mc<id> object */
826 err = kobject_set_name(edac_mci_kobj,"mc%d",mci->mc_idx); 778 err = kobject_set_name(edac_mci_kobj, "mc%d", mci->mc_idx);
827 if (err) 779 if (err)
828 return err; 780 return err;
829 781
@@ -850,7 +802,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
850 802
851 /* Only expose populated CSROWs */ 803 /* Only expose populated CSROWs */
852 if (csrow->nr_pages > 0) { 804 if (csrow->nr_pages > 0) {
853 err = edac_create_csrow_object(edac_mci_kobj,csrow,i); 805 err = edac_create_csrow_object(edac_mci_kobj, csrow, i);
854 if (err) 806 if (err)
855 goto fail1; 807 goto fail1;
856 } 808 }
@@ -859,8 +811,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
859 return 0; 811 return 0;
860 812
861 /* CSROW error: backout what has already been registered, */ 813 /* CSROW error: backout what has already been registered, */
862fail1: 814 fail1:
863 for ( i--; i >= 0; i--) { 815 for (i--; i >= 0; i--) {
864 if (csrow->nr_pages > 0) { 816 if (csrow->nr_pages > 0) {
865 init_completion(&csrow->kobj_complete); 817 init_completion(&csrow->kobj_complete);
866 kobject_unregister(&mci->csrows[i].kobj); 818 kobject_unregister(&mci->csrows[i].kobj);
@@ -868,7 +820,7 @@ fail1:
868 } 820 }
869 } 821 }
870 822
871fail0: 823 fail0:
872 init_completion(&mci->kobj_complete); 824 init_completion(&mci->kobj_complete);
873 kobject_unregister(edac_mci_kobj); 825 kobject_unregister(edac_mci_kobj);
874 wait_for_completion(&mci->kobj_complete); 826 wait_for_completion(&mci->kobj_complete);
@@ -898,5 +850,3 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
898 kobject_unregister(&mci->edac_mci_kobj); 850 kobject_unregister(&mci->edac_mci_kobj);
899 wait_for_completion(&mci->kobj_complete); 851 wait_for_completion(&mci->kobj_complete);
900} 852}
901
902
diff --git a/drivers/edac/edac_module.c b/drivers/edac/edac_module.c
index 38e4a71380aa..687d2ef2bbed 100644
--- a/drivers/edac/edac_module.c
+++ b/drivers/edac/edac_module.c
@@ -37,7 +37,7 @@ static int edac_class_valid = 0;
37/* 37/*
38 * edac_op_state_toString() 38 * edac_op_state_toString()
39 */ 39 */
40char * edac_op_state_toString(int opstate) 40char *edac_op_state_toString(int opstate)
41{ 41{
42 if (opstate == OP_RUNNING_POLL) 42 if (opstate == OP_RUNNING_POLL)
43 return "POLLED"; 43 return "POLLED";
@@ -60,7 +60,7 @@ char * edac_op_state_toString(int opstate)
60 */ 60 */
61struct sysdev_class *edac_get_edac_class(void) 61struct sysdev_class *edac_get_edac_class(void)
62{ 62{
63 struct sysdev_class *classptr=NULL; 63 struct sysdev_class *classptr = NULL;
64 64
65 if (edac_class_valid) 65 if (edac_class_valid)
66 classptr = &edac_class; 66 classptr = &edac_class;
@@ -133,7 +133,6 @@ static void edac_workqueue_teardown(void)
133 } 133 }
134} 134}
135 135
136
137/* 136/*
138 * edac_init 137 * edac_init
139 * module initialization entry point 138 * module initialization entry point
@@ -148,8 +147,8 @@ static int __init edac_init(void)
148 * Harvest and clear any boot/initialization PCI parity errors 147 * Harvest and clear any boot/initialization PCI parity errors
149 * 148 *
150 * FIXME: This only clears errors logged by devices present at time of 149 * FIXME: This only clears errors logged by devices present at time of
151 * module initialization. We should also do an initial clear 150 * module initialization. We should also do an initial clear
152 * of each newly hotplugged device. 151 * of each newly hotplugged device.
153 */ 152 */
154 edac_pci_clear_parity_errors(); 153 edac_pci_clear_parity_errors();
155 154
@@ -158,7 +157,7 @@ static int __init edac_init(void)
158 */ 157 */
159 if (edac_register_sysfs_edac_name()) { 158 if (edac_register_sysfs_edac_name()) {
160 edac_printk(KERN_ERR, EDAC_MC, 159 edac_printk(KERN_ERR, EDAC_MC,
161 "Error initializing 'edac' kobject\n"); 160 "Error initializing 'edac' kobject\n");
162 err = -ENODEV; 161 err = -ENODEV;
163 goto error; 162 goto error;
164 } 163 }
@@ -167,7 +166,7 @@ static int __init edac_init(void)
167 */ 166 */
168 if (edac_sysfs_memctrl_setup()) { 167 if (edac_sysfs_memctrl_setup()) {
169 edac_printk(KERN_ERR, EDAC_MC, 168 edac_printk(KERN_ERR, EDAC_MC,
170 "Error initializing sysfs code\n"); 169 "Error initializing sysfs code\n");
171 err = -ENODEV; 170 err = -ENODEV;
172 goto error_sysfs; 171 goto error_sysfs;
173 } 172 }
@@ -182,11 +181,11 @@ static int __init edac_init(void)
182 return 0; 181 return 0;
183 182
184 /* Error teardown stack */ 183 /* Error teardown stack */
185error_mem: 184 error_mem:
186 edac_sysfs_memctrl_teardown(); 185 edac_sysfs_memctrl_teardown();
187error_sysfs: 186 error_sysfs:
188 edac_unregister_sysfs_edac_name(); 187 edac_unregister_sysfs_edac_name();
189error: 188 error:
190 return err; 189 return err;
191} 190}
192 191
@@ -198,7 +197,7 @@ static void __exit edac_exit(void)
198{ 197{
199 debugf0("%s()\n", __func__); 198 debugf0("%s()\n", __func__);
200 199
201 /* tear down the various subsystems*/ 200 /* tear down the various subsystems */
202 edac_workqueue_teardown(); 201 edac_workqueue_teardown();
203 edac_sysfs_memctrl_teardown(); 202 edac_sysfs_memctrl_teardown();
204 edac_unregister_sysfs_edac_name(); 203 edac_unregister_sysfs_edac_name();
@@ -220,4 +219,3 @@ MODULE_DESCRIPTION("Core library routines for EDAC reporting");
220module_param(edac_debug_level, int, 0644); 219module_param(edac_debug_level, int, 0644);
221MODULE_PARM_DESC(edac_debug_level, "Debug level"); 220MODULE_PARM_DESC(edac_debug_level, "Debug level");
222#endif 221#endif
223
diff --git a/drivers/edac/edac_module.h b/drivers/edac/edac_module.h
index ffd25bdf87fc..0869fbaa733c 100644
--- a/drivers/edac/edac_module.h
+++ b/drivers/edac/edac_module.h
@@ -40,12 +40,10 @@ extern struct sysdev_class *edac_get_edac_class(void);
40/* edac core workqueue: single CPU mode */ 40/* edac core workqueue: single CPU mode */
41extern struct workqueue_struct *edac_workqueue; 41extern struct workqueue_struct *edac_workqueue;
42extern void edac_device_workq_setup(struct edac_device_ctl_info *edac_dev, 42extern void edac_device_workq_setup(struct edac_device_ctl_info *edac_dev,
43 unsigned msec); 43 unsigned msec);
44extern void edac_device_workq_teardown(struct edac_device_ctl_info *edac_dev); 44extern void edac_device_workq_teardown(struct edac_device_ctl_info *edac_dev);
45extern void edac_device_reset_delay_period( 45extern void edac_device_reset_delay_period(struct edac_device_ctl_info
46 struct edac_device_ctl_info *edac_dev, 46 *edac_dev, unsigned long value);
47 unsigned long value);
48
49 47
50/* 48/*
51 * EDAC PCI functions 49 * EDAC PCI functions
@@ -57,7 +55,7 @@ extern int edac_sysfs_pci_setup(void);
57extern void edac_sysfs_pci_teardown(void); 55extern void edac_sysfs_pci_teardown(void);
58extern int edac_pci_get_check_errors(void); 56extern int edac_pci_get_check_errors(void);
59extern int edac_pci_get_poll_msec(void); 57extern int edac_pci_get_poll_msec(void);
60#else /* CONFIG_PCI */ 58#else /* CONFIG_PCI */
61/* pre-process these away */ 59/* pre-process these away */
62#define edac_pci_do_parity_check() 60#define edac_pci_do_parity_check()
63#define edac_pci_clear_parity_errors() 61#define edac_pci_clear_parity_errors()
@@ -65,8 +63,6 @@ extern int edac_pci_get_poll_msec(void);
65#define edac_sysfs_pci_teardown() 63#define edac_sysfs_pci_teardown()
66#define edac_pci_get_check_errors() 64#define edac_pci_get_check_errors()
67#define edac_pci_get_poll_msec() 65#define edac_pci_get_poll_msec()
68#endif /* CONFIG_PCI */ 66#endif /* CONFIG_PCI */
69
70
71#endif /* __EDAC_MODULE_H__ */
72 67
68#endif /* __EDAC_MODULE_H__ */
diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
index 9f4aaaaa4ed7..abefd96680d7 100644
--- a/drivers/edac/edac_pci.c
+++ b/drivers/edac/edac_pci.c
@@ -46,9 +46,8 @@ static inline void edac_unlock_pci_list(void)
46 * structure. The chip driver will allocate one of these for each 46 * structure. The chip driver will allocate one of these for each
47 * edac_pci it is going to control/register with the EDAC CORE. 47 * edac_pci it is going to control/register with the EDAC CORE.
48 */ 48 */
49struct edac_pci_ctl_info * edac_pci_alloc_ctl_info( 49struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt,
50 unsigned int sz_pvt, 50 const char *edac_pci_name)
51 const char *edac_pci_name)
52{ 51{
53 struct edac_pci_ctl_info *pci; 52 struct edac_pci_ctl_info *pci;
54 void *pvt; 53 void *pvt;
@@ -67,10 +66,11 @@ struct edac_pci_ctl_info * edac_pci_alloc_ctl_info(
67 66
68 pci->op_state = OP_ALLOC; 67 pci->op_state = OP_ALLOC;
69 68
70 snprintf(pci->name, strlen(edac_pci_name)+1, "%s", edac_pci_name); 69 snprintf(pci->name, strlen(edac_pci_name) + 1, "%s", edac_pci_name);
71 70
72 return pci; 71 return pci;
73} 72}
73
74EXPORT_SYMBOL_GPL(edac_pci_alloc_ctl_info); 74EXPORT_SYMBOL_GPL(edac_pci_alloc_ctl_info);
75 75
76/* 76/*
@@ -81,13 +81,14 @@ void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci)
81{ 81{
82 kfree(pci); 82 kfree(pci);
83} 83}
84
84EXPORT_SYMBOL_GPL(edac_pci_free_ctl_info); 85EXPORT_SYMBOL_GPL(edac_pci_free_ctl_info);
85 86
86/* 87/*
87 * find_edac_pci_by_dev() 88 * find_edac_pci_by_dev()
88 * scans the edac_pci list for a specific 'struct device *' 89 * scans the edac_pci list for a specific 'struct device *'
89 */ 90 */
90static struct edac_pci_ctl_info * find_edac_pci_by_dev(struct device *dev) 91static struct edac_pci_ctl_info *find_edac_pci_by_dev(struct device *dev)
91{ 92{
92 struct edac_pci_ctl_info *pci; 93 struct edac_pci_ctl_info *pci;
93 struct list_head *item; 94 struct list_head *item;
@@ -139,17 +140,18 @@ static int add_edac_pci_to_global_list(struct edac_pci_ctl_info *pci)
139 list_add_tail_rcu(&pci->link, insert_before); 140 list_add_tail_rcu(&pci->link, insert_before);
140 return 0; 141 return 0;
141 142
142fail0: 143 fail0:
143 edac_printk(KERN_WARNING, EDAC_PCI, 144 edac_printk(KERN_WARNING, EDAC_PCI,
144 "%s (%s) %s %s already assigned %d\n", 145 "%s (%s) %s %s already assigned %d\n",
145 rover->dev->bus_id, dev_name(rover), 146 rover->dev->bus_id, dev_name(rover),
146 rover->mod_name, rover->ctl_name, rover->pci_idx); 147 rover->mod_name, rover->ctl_name, rover->pci_idx);
147 return 1; 148 return 1;
148 149
149fail1: 150 fail1:
150 edac_printk(KERN_WARNING, EDAC_PCI, 151 edac_printk(KERN_WARNING, EDAC_PCI,
151 "but in low-level driver: attempt to assign\n" 152 "but in low-level driver: attempt to assign\n"
152 "\tduplicate pci_idx %d in %s()\n", rover->pci_idx, __func__); 153 "\tduplicate pci_idx %d in %s()\n", rover->pci_idx,
154 __func__);
153 return 1; 155 return 1;
154} 156}
155 157
@@ -185,7 +187,7 @@ static void del_edac_pci_from_global_list(struct edac_pci_ctl_info *pci)
185 * 187 *
186 * Caller must hold pci_ctls_mutex. 188 * Caller must hold pci_ctls_mutex.
187 */ 189 */
188struct edac_pci_ctl_info * edac_pci_find(int idx) 190struct edac_pci_ctl_info *edac_pci_find(int idx)
189{ 191{
190 struct list_head *item; 192 struct list_head *item;
191 struct edac_pci_ctl_info *pci; 193 struct edac_pci_ctl_info *pci;
@@ -198,13 +200,14 @@ struct edac_pci_ctl_info * edac_pci_find(int idx)
198 if (pci->pci_idx == idx) 200 if (pci->pci_idx == idx)
199 return pci; 201 return pci;
200 202
201 /* not on list, so terminate early */ 203 /* not on list, so terminate early */
202 break; 204 break;
203 } 205 }
204 } 206 }
205 207
206 return NULL; 208 return NULL;
207} 209}
210
208EXPORT_SYMBOL_GPL(edac_pci_find); 211EXPORT_SYMBOL_GPL(edac_pci_find);
209 212
210/* 213/*
@@ -225,15 +228,14 @@ static void edac_pci_workq_function(void *ptr)
225 edac_lock_pci_list(); 228 edac_lock_pci_list();
226 229
227 if ((pci->op_state == OP_RUNNING_POLL) && 230 if ((pci->op_state == OP_RUNNING_POLL) &&
228 (pci->edac_check != NULL) && 231 (pci->edac_check != NULL) && (edac_pci_get_check_errors()))
229 (edac_pci_get_check_errors()))
230 pci->edac_check(pci); 232 pci->edac_check(pci);
231 233
232 edac_unlock_pci_list(); 234 edac_unlock_pci_list();
233 235
234 /* Reschedule */ 236 /* Reschedule */
235 queue_delayed_work(edac_workqueue, &pci->work, 237 queue_delayed_work(edac_workqueue, &pci->work,
236 msecs_to_jiffies(edac_pci_get_poll_msec())); 238 msecs_to_jiffies(edac_pci_get_poll_msec()));
237} 239}
238 240
239/* 241/*
@@ -242,7 +244,7 @@ static void edac_pci_workq_function(void *ptr)
242 * passing in the new delay period in msec 244 * passing in the new delay period in msec
243 */ 245 */
244static void edac_pci_workq_setup(struct edac_pci_ctl_info *pci, 246static void edac_pci_workq_setup(struct edac_pci_ctl_info *pci,
245 unsigned int msec) 247 unsigned int msec)
246{ 248{
247 debugf0("%s()\n", __func__); 249 debugf0("%s()\n", __func__);
248 250
@@ -252,7 +254,7 @@ static void edac_pci_workq_setup(struct edac_pci_ctl_info *pci,
252 INIT_WORK(&pci->work, edac_pci_workq_function, pci); 254 INIT_WORK(&pci->work, edac_pci_workq_function, pci);
253#endif 255#endif
254 queue_delayed_work(edac_workqueue, &pci->work, 256 queue_delayed_work(edac_workqueue, &pci->work,
255 msecs_to_jiffies(edac_pci_get_poll_msec())); 257 msecs_to_jiffies(edac_pci_get_poll_msec()));
256} 258}
257 259
258/* 260/*
@@ -272,7 +274,7 @@ static void edac_pci_workq_teardown(struct edac_pci_ctl_info *pci)
272 * edac_pci_reset_delay_period 274 * edac_pci_reset_delay_period
273 */ 275 */
274void edac_pci_reset_delay_period(struct edac_pci_ctl_info *pci, 276void edac_pci_reset_delay_period(struct edac_pci_ctl_info *pci,
275 unsigned long value) 277 unsigned long value)
276{ 278{
277 edac_lock_pci_list(); 279 edac_lock_pci_list();
278 280
@@ -282,6 +284,7 @@ void edac_pci_reset_delay_period(struct edac_pci_ctl_info *pci,
282 284
283 edac_unlock_pci_list(); 285 edac_unlock_pci_list();
284} 286}
287
285EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period); 288EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
286 289
287/* 290/*
@@ -324,22 +327,22 @@ int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx)
324 } 327 }
325 328
326 edac_pci_printk(pci, KERN_INFO, 329 edac_pci_printk(pci, KERN_INFO,
327 "Giving out device to module '%s' controller '%s':" 330 "Giving out device to module '%s' controller '%s':"
328 " DEV '%s' (%s)\n", 331 " DEV '%s' (%s)\n",
329 pci->mod_name, 332 pci->mod_name,
330 pci->ctl_name, 333 pci->ctl_name,
331 dev_name(pci), 334 dev_name(pci), edac_op_state_toString(pci->op_state));
332 edac_op_state_toString(pci->op_state));
333 335
334 edac_unlock_pci_list(); 336 edac_unlock_pci_list();
335 return 0; 337 return 0;
336 338
337fail1: 339 fail1:
338 del_edac_pci_from_global_list(pci); 340 del_edac_pci_from_global_list(pci);
339fail0: 341 fail0:
340 edac_unlock_pci_list(); 342 edac_unlock_pci_list();
341 return 1; 343 return 1;
342} 344}
345
343EXPORT_SYMBOL_GPL(edac_pci_add_device); 346EXPORT_SYMBOL_GPL(edac_pci_add_device);
344 347
345/* 348/*
@@ -355,7 +358,7 @@ EXPORT_SYMBOL_GPL(edac_pci_add_device);
355 * Pointer to removed edac_pci structure, 358 * Pointer to removed edac_pci structure,
356 * or NULL if device not found 359 * or NULL if device not found
357 */ 360 */
358struct edac_pci_ctl_info * edac_pci_del_device(struct device *dev) 361struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev)
359{ 362{
360 struct edac_pci_ctl_info *pci; 363 struct edac_pci_ctl_info *pci;
361 364
@@ -379,14 +382,12 @@ struct edac_pci_ctl_info * edac_pci_del_device(struct device *dev)
379 edac_unlock_pci_list(); 382 edac_unlock_pci_list();
380 383
381 edac_printk(KERN_INFO, EDAC_PCI, 384 edac_printk(KERN_INFO, EDAC_PCI,
382 "Removed device %d for %s %s: DEV %s\n", 385 "Removed device %d for %s %s: DEV %s\n",
383 pci->pci_idx, 386 pci->pci_idx, pci->mod_name, pci->ctl_name, dev_name(pci));
384 pci->mod_name,
385 pci->ctl_name,
386 dev_name(pci));
387 387
388 return pci; 388 return pci;
389} 389}
390
390EXPORT_SYMBOL_GPL(edac_pci_del_device); 391EXPORT_SYMBOL_GPL(edac_pci_del_device);
391 392
392void edac_pci_generic_check(struct edac_pci_ctl_info *pci) 393void edac_pci_generic_check(struct edac_pci_ctl_info *pci)
@@ -401,8 +402,8 @@ struct edac_pci_gen_data {
401 int edac_idx; 402 int edac_idx;
402}; 403};
403 404
404struct edac_pci_ctl_info * 405struct edac_pci_ctl_info *edac_pci_create_generic_ctl(struct device *dev,
405edac_pci_create_generic_ctl(struct device *dev, const char *mod_name) 406 const char *mod_name)
406{ 407{
407 struct edac_pci_ctl_info *pci; 408 struct edac_pci_ctl_info *pci;
408 struct edac_pci_gen_data *pdata; 409 struct edac_pci_gen_data *pdata;
@@ -430,6 +431,7 @@ edac_pci_create_generic_ctl(struct device *dev, const char *mod_name)
430 431
431 return pci; 432 return pci;
432} 433}
434
433EXPORT_SYMBOL_GPL(edac_pci_create_generic_ctl); 435EXPORT_SYMBOL_GPL(edac_pci_create_generic_ctl);
434 436
435void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci) 437void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci)
@@ -437,4 +439,5 @@ void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci)
437 edac_pci_del_device(pci->dev); 439 edac_pci_del_device(pci->dev);
438 edac_pci_free_ctl_info(pci); 440 edac_pci_free_ctl_info(pci);
439} 441}
442
440EXPORT_SYMBOL_GPL(edac_pci_release_generic_ctl); 443EXPORT_SYMBOL_GPL(edac_pci_release_generic_ctl);
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index a3f81d72c950..f471659a1c35 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -13,7 +13,6 @@
13#include "edac_core.h" 13#include "edac_core.h"
14#include "edac_module.h" 14#include "edac_module.h"
15 15
16
17#ifdef CONFIG_PCI 16#ifdef CONFIG_PCI
18 17
19#define EDAC_PCI_SYMLINK "device" 18#define EDAC_PCI_SYMLINK "device"
@@ -26,7 +25,7 @@ static atomic_t pci_parity_count = ATOMIC_INIT(0);
26static atomic_t pci_nonparity_count = ATOMIC_INIT(0); 25static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
27static int edac_pci_poll_msec = 1000; 26static int edac_pci_poll_msec = 1000;
28 27
29static struct kobject edac_pci_kobj; /* /sys/devices/system/edac/pci */ 28static struct kobject edac_pci_kobj; /* /sys/devices/system/edac/pci */
30static struct completion edac_pci_kobj_complete; 29static struct completion edac_pci_kobj_complete;
31static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0); 30static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
32 31
@@ -58,13 +57,13 @@ int edac_pci_get_poll_msec(void)
58/**************************** EDAC PCI sysfs instance *******************/ 57/**************************** EDAC PCI sysfs instance *******************/
59static ssize_t instance_pe_count_show(struct edac_pci_ctl_info *pci, char *data) 58static ssize_t instance_pe_count_show(struct edac_pci_ctl_info *pci, char *data)
60{ 59{
61 return sprintf(data,"%u\n", atomic_read(&pci->counters.pe_count)); 60 return sprintf(data, "%u\n", atomic_read(&pci->counters.pe_count));
62} 61}
63 62
64static ssize_t instance_npe_count_show(struct edac_pci_ctl_info *pci, 63static ssize_t instance_npe_count_show(struct edac_pci_ctl_info *pci,
65 char *data) 64 char *data)
66{ 65{
67 return sprintf(data,"%u\n", atomic_read(&pci->counters.npe_count)); 66 return sprintf(data, "%u\n", atomic_read(&pci->counters.npe_count));
68} 67}
69 68
70#define to_instance(k) container_of(k, struct edac_pci_ctl_info, kobj) 69#define to_instance(k) container_of(k, struct edac_pci_ctl_info, kobj)
@@ -83,36 +82,34 @@ static void edac_pci_instance_release(struct kobject *kobj)
83 82
84/* instance specific attribute structure */ 83/* instance specific attribute structure */
85struct instance_attribute { 84struct instance_attribute {
86 struct attribute attr; 85 struct attribute attr;
87 ssize_t (*show)(struct edac_pci_ctl_info *, char *); 86 ssize_t(*show) (struct edac_pci_ctl_info *, char *);
88 ssize_t (*store)(struct edac_pci_ctl_info *, const char *, size_t); 87 ssize_t(*store) (struct edac_pci_ctl_info *, const char *, size_t);
89}; 88};
90 89
91/* Function to 'show' fields from the edac_pci 'instance' structure */ 90/* Function to 'show' fields from the edac_pci 'instance' structure */
92static ssize_t edac_pci_instance_show(struct kobject *kobj, 91static ssize_t edac_pci_instance_show(struct kobject *kobj,
93 struct attribute *attr, 92 struct attribute *attr, char *buffer)
94 char *buffer)
95{ 93{
96 struct edac_pci_ctl_info *pci = to_instance(kobj); 94 struct edac_pci_ctl_info *pci = to_instance(kobj);
97 struct instance_attribute *instance_attr = to_instance_attr(attr); 95 struct instance_attribute *instance_attr = to_instance_attr(attr);
98 96
99 if (instance_attr->show) 97 if (instance_attr->show)
100 return instance_attr->show(pci, buffer); 98 return instance_attr->show(pci, buffer);
101 return -EIO; 99 return -EIO;
102} 100}
103 101
104
105/* Function to 'store' fields into the edac_pci 'instance' structure */ 102/* Function to 'store' fields into the edac_pci 'instance' structure */
106static ssize_t edac_pci_instance_store(struct kobject *kobj, 103static ssize_t edac_pci_instance_store(struct kobject *kobj,
107 struct attribute *attr, 104 struct attribute *attr,
108 const char *buffer, size_t count) 105 const char *buffer, size_t count)
109{ 106{
110 struct edac_pci_ctl_info *pci = to_instance(kobj); 107 struct edac_pci_ctl_info *pci = to_instance(kobj);
111 struct instance_attribute *instance_attr = to_instance_attr(attr); 108 struct instance_attribute *instance_attr = to_instance_attr(attr);
112 109
113 if (instance_attr->store) 110 if (instance_attr->store)
114 return instance_attr->store(pci, buffer, count); 111 return instance_attr->store(pci, buffer, count);
115 return -EIO; 112 return -EIO;
116} 113}
117 114
118static struct sysfs_ops pci_instance_ops = { 115static struct sysfs_ops pci_instance_ops = {
@@ -158,7 +155,7 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
158 err = kobject_register(&pci->kobj); 155 err = kobject_register(&pci->kobj);
159 if (err != 0) { 156 if (err != 0) {
160 debugf2("%s() failed to register instance pci%d\n", 157 debugf2("%s() failed to register instance pci%d\n",
161 __func__, idx); 158 __func__, idx);
162 return err; 159 return err;
163 } 160 }
164 161
@@ -182,7 +179,7 @@ edac_pci_delete_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
182static ssize_t edac_pci_int_show(void *ptr, char *buffer) 179static ssize_t edac_pci_int_show(void *ptr, char *buffer)
183{ 180{
184 int *value = ptr; 181 int *value = ptr;
185 return sprintf(buffer,"%d\n",*value); 182 return sprintf(buffer, "%d\n", *value);
186} 183}
187 184
188static ssize_t edac_pci_int_store(void *ptr, const char *buffer, size_t count) 185static ssize_t edac_pci_int_store(void *ptr, const char *buffer, size_t count)
@@ -190,7 +187,7 @@ static ssize_t edac_pci_int_store(void *ptr, const char *buffer, size_t count)
190 int *value = ptr; 187 int *value = ptr;
191 188
192 if (isdigit(*buffer)) 189 if (isdigit(*buffer))
193 *value = simple_strtoul(buffer,NULL,0); 190 *value = simple_strtoul(buffer, NULL, 0);
194 191
195 return count; 192 return count;
196} 193}
@@ -198,16 +195,16 @@ static ssize_t edac_pci_int_store(void *ptr, const char *buffer, size_t count)
198struct edac_pci_dev_attribute { 195struct edac_pci_dev_attribute {
199 struct attribute attr; 196 struct attribute attr;
200 void *value; 197 void *value;
201 ssize_t (*show)(void *,char *); 198 ssize_t(*show) (void *, char *);
202 ssize_t (*store)(void *, const char *,size_t); 199 ssize_t(*store) (void *, const char *, size_t);
203}; 200};
204 201
205/* Set of show/store abstract level functions for PCI Parity object */ 202/* Set of show/store abstract level functions for PCI Parity object */
206static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr, 203static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
207 char *buffer) 204 char *buffer)
208{ 205{
209 struct edac_pci_dev_attribute *edac_pci_dev; 206 struct edac_pci_dev_attribute *edac_pci_dev;
210 edac_pci_dev= (struct edac_pci_dev_attribute*)attr; 207 edac_pci_dev = (struct edac_pci_dev_attribute *)attr;
211 208
212 if (edac_pci_dev->show) 209 if (edac_pci_dev->show)
213 return edac_pci_dev->show(edac_pci_dev->value, buffer); 210 return edac_pci_dev->show(edac_pci_dev->value, buffer);
@@ -215,10 +212,11 @@ static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
215} 212}
216 213
217static ssize_t edac_pci_dev_store(struct kobject *kobj, 214static ssize_t edac_pci_dev_store(struct kobject *kobj,
218 struct attribute *attr, const char *buffer, size_t count) 215 struct attribute *attr, const char *buffer,
216 size_t count)
219{ 217{
220 struct edac_pci_dev_attribute *edac_pci_dev; 218 struct edac_pci_dev_attribute *edac_pci_dev;
221 edac_pci_dev= (struct edac_pci_dev_attribute*)attr; 219 edac_pci_dev = (struct edac_pci_dev_attribute *)attr;
222 220
223 if (edac_pci_dev->show) 221 if (edac_pci_dev->show)
224 return edac_pci_dev->store(edac_pci_dev->value, buffer, count); 222 return edac_pci_dev->store(edac_pci_dev->value, buffer, count);
@@ -226,8 +224,8 @@ static ssize_t edac_pci_dev_store(struct kobject *kobj,
226} 224}
227 225
228static struct sysfs_ops edac_pci_sysfs_ops = { 226static struct sysfs_ops edac_pci_sysfs_ops = {
229 .show = edac_pci_dev_show, 227 .show = edac_pci_dev_show,
230 .store = edac_pci_dev_store 228 .store = edac_pci_dev_store
231}; 229};
232 230
233#define EDAC_PCI_ATTR(_name,_mode,_show,_store) \ 231#define EDAC_PCI_ATTR(_name,_mode,_show,_store) \
@@ -247,14 +245,14 @@ static struct edac_pci_dev_attribute edac_pci_attr_##_name = { \
247}; 245};
248 246
249/* PCI Parity control files */ 247/* PCI Parity control files */
250EDAC_PCI_ATTR(check_pci_errors, S_IRUGO|S_IWUSR, edac_pci_int_show, 248EDAC_PCI_ATTR(check_pci_errors, S_IRUGO | S_IWUSR, edac_pci_int_show,
251 edac_pci_int_store); 249 edac_pci_int_store);
252EDAC_PCI_ATTR(edac_pci_log_pe, S_IRUGO|S_IWUSR, edac_pci_int_show, 250EDAC_PCI_ATTR(edac_pci_log_pe, S_IRUGO | S_IWUSR, edac_pci_int_show,
253 edac_pci_int_store); 251 edac_pci_int_store);
254EDAC_PCI_ATTR(edac_pci_log_npe, S_IRUGO|S_IWUSR, edac_pci_int_show, 252EDAC_PCI_ATTR(edac_pci_log_npe, S_IRUGO | S_IWUSR, edac_pci_int_show,
255 edac_pci_int_store); 253 edac_pci_int_store);
256EDAC_PCI_ATTR(edac_pci_panic_on_pe, S_IRUGO|S_IWUSR, edac_pci_int_show, 254EDAC_PCI_ATTR(edac_pci_panic_on_pe, S_IRUGO | S_IWUSR, edac_pci_int_show,
257 edac_pci_int_store); 255 edac_pci_int_store);
258EDAC_PCI_ATTR(pci_parity_count, S_IRUGO, edac_pci_int_show, NULL); 256EDAC_PCI_ATTR(pci_parity_count, S_IRUGO, edac_pci_int_show, NULL);
259EDAC_PCI_ATTR(pci_nonparity_count, S_IRUGO, edac_pci_int_show, NULL); 257EDAC_PCI_ATTR(pci_nonparity_count, S_IRUGO, edac_pci_int_show, NULL);
260 258
@@ -283,7 +281,7 @@ static void edac_pci_release(struct kobject *kobj)
283static struct kobj_type ktype_edac_pci = { 281static struct kobj_type ktype_edac_pci = {
284 .release = edac_pci_release, 282 .release = edac_pci_release,
285 .sysfs_ops = &edac_pci_sysfs_ops, 283 .sysfs_ops = &edac_pci_sysfs_ops,
286 .default_attrs = (struct attribute **) edac_pci_attr, 284 .default_attrs = (struct attribute **)edac_pci_attr,
287}; 285};
288 286
289/** 287/**
@@ -310,7 +308,7 @@ int edac_pci_register_main_kobj(void)
310 edac_pci_kobj.parent = &edac_class->kset.kobj; 308 edac_pci_kobj.parent = &edac_class->kset.kobj;
311 309
312 err = kobject_set_name(&edac_pci_kobj, "pci"); 310 err = kobject_set_name(&edac_pci_kobj, "pci");
313 if(err) 311 if (err)
314 return err; 312 return err;
315 313
316 /* Instanstiate the pci object */ 314 /* Instanstiate the pci object */
@@ -359,15 +357,12 @@ int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci)
359 edac_pci_unregister_main_kobj(); 357 edac_pci_unregister_main_kobj();
360 } 358 }
361 359
362
363 debugf0("%s() idx=%d\n", __func__, pci->pci_idx); 360 debugf0("%s() idx=%d\n", __func__, pci->pci_idx);
364 361
365 err = sysfs_create_link(edac_kobj, 362 err = sysfs_create_link(edac_kobj, &pci->dev->kobj, EDAC_PCI_SYMLINK);
366 &pci->dev->kobj,
367 EDAC_PCI_SYMLINK);
368 if (err) { 363 if (err) {
369 debugf0("%s() sysfs_create_link() returned err= %d\n", 364 debugf0("%s() sysfs_create_link() returned err= %d\n",
370 __func__, err); 365 __func__, err);
371 return err; 366 return err;
372 } 367 }
373 368
@@ -410,7 +405,7 @@ static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
410 } 405 }
411 406
412 status &= PCI_STATUS_DETECTED_PARITY | PCI_STATUS_SIG_SYSTEM_ERROR | 407 status &= PCI_STATUS_DETECTED_PARITY | PCI_STATUS_SIG_SYSTEM_ERROR |
413 PCI_STATUS_PARITY; 408 PCI_STATUS_PARITY;
414 409
415 if (status) 410 if (status)
416 /* reset only the bits we are interested in */ 411 /* reset only the bits we are interested in */
@@ -419,7 +414,7 @@ static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
419 return status; 414 return status;
420} 415}
421 416
422typedef void (*pci_parity_check_fn_t) (struct pci_dev *dev); 417typedef void (*pci_parity_check_fn_t) (struct pci_dev * dev);
423 418
424/* Clear any PCI parity errors logged by this device. */ 419/* Clear any PCI parity errors logged by this device. */
425static void edac_pci_dev_parity_clear(struct pci_dev *dev) 420static void edac_pci_dev_parity_clear(struct pci_dev *dev)
@@ -442,35 +437,35 @@ static void edac_pci_dev_parity_clear(struct pci_dev *dev)
442static void edac_pci_dev_parity_test(struct pci_dev *dev) 437static void edac_pci_dev_parity_test(struct pci_dev *dev)
443{ 438{
444 u16 status; 439 u16 status;
445 u8 header_type; 440 u8 header_type;
446 441
447 /* read the STATUS register on this device 442 /* read the STATUS register on this device
448 */ 443 */
449 status = get_pci_parity_status(dev, 0); 444 status = get_pci_parity_status(dev, 0);
450 445
451 debugf2("PCI STATUS= 0x%04x %s\n", status, dev->dev.bus_id ); 446 debugf2("PCI STATUS= 0x%04x %s\n", status, dev->dev.bus_id);
452 447
453 /* check the status reg for errors */ 448 /* check the status reg for errors */
454 if (status) { 449 if (status) {
455 if (status & (PCI_STATUS_SIG_SYSTEM_ERROR)) { 450 if (status & (PCI_STATUS_SIG_SYSTEM_ERROR)) {
456 edac_printk(KERN_CRIT, EDAC_PCI, 451 edac_printk(KERN_CRIT, EDAC_PCI,
457 "Signaled System Error on %s\n", 452 "Signaled System Error on %s\n",
458 pci_name(dev)); 453 pci_name(dev));
459 atomic_inc(&pci_nonparity_count); 454 atomic_inc(&pci_nonparity_count);
460 } 455 }
461 456
462 if (status & (PCI_STATUS_PARITY)) { 457 if (status & (PCI_STATUS_PARITY)) {
463 edac_printk(KERN_CRIT, EDAC_PCI, 458 edac_printk(KERN_CRIT, EDAC_PCI,
464 "Master Data Parity Error on %s\n", 459 "Master Data Parity Error on %s\n",
465 pci_name(dev)); 460 pci_name(dev));
466 461
467 atomic_inc(&pci_parity_count); 462 atomic_inc(&pci_parity_count);
468 } 463 }
469 464
470 if (status & (PCI_STATUS_DETECTED_PARITY)) { 465 if (status & (PCI_STATUS_DETECTED_PARITY)) {
471 edac_printk(KERN_CRIT, EDAC_PCI, 466 edac_printk(KERN_CRIT, EDAC_PCI,
472 "Detected Parity Error on %s\n", 467 "Detected Parity Error on %s\n",
473 pci_name(dev)); 468 pci_name(dev));
474 469
475 atomic_inc(&pci_parity_count); 470 atomic_inc(&pci_parity_count);
476 } 471 }
@@ -479,36 +474,35 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
479 /* read the device TYPE, looking for bridges */ 474 /* read the device TYPE, looking for bridges */
480 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type); 475 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
481 476
482 debugf2("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev->dev.bus_id ); 477 debugf2("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev->dev.bus_id);
483 478
484 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 479 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
485 /* On bridges, need to examine secondary status register */ 480 /* On bridges, need to examine secondary status register */
486 status = get_pci_parity_status(dev, 1); 481 status = get_pci_parity_status(dev, 1);
487 482
488 debugf2("PCI SEC_STATUS= 0x%04x %s\n", 483 debugf2("PCI SEC_STATUS= 0x%04x %s\n", status, dev->dev.bus_id);
489 status, dev->dev.bus_id );
490 484
491 /* check the secondary status reg for errors */ 485 /* check the secondary status reg for errors */
492 if (status) { 486 if (status) {
493 if (status & (PCI_STATUS_SIG_SYSTEM_ERROR)) { 487 if (status & (PCI_STATUS_SIG_SYSTEM_ERROR)) {
494 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge " 488 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
495 "Signaled System Error on %s\n", 489 "Signaled System Error on %s\n",
496 pci_name(dev)); 490 pci_name(dev));
497 atomic_inc(&pci_nonparity_count); 491 atomic_inc(&pci_nonparity_count);
498 } 492 }
499 493
500 if (status & (PCI_STATUS_PARITY)) { 494 if (status & (PCI_STATUS_PARITY)) {
501 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge " 495 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
502 "Master Data Parity Error on " 496 "Master Data Parity Error on "
503 "%s\n", pci_name(dev)); 497 "%s\n", pci_name(dev));
504 498
505 atomic_inc(&pci_parity_count); 499 atomic_inc(&pci_parity_count);
506 } 500 }
507 501
508 if (status & (PCI_STATUS_DETECTED_PARITY)) { 502 if (status & (PCI_STATUS_DETECTED_PARITY)) {
509 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge " 503 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
510 "Detected Parity Error on %s\n", 504 "Detected Parity Error on %s\n",
511 pci_name(dev)); 505 pci_name(dev));
512 506
513 atomic_inc(&pci_parity_count); 507 atomic_inc(&pci_parity_count);
514 } 508 }
@@ -529,7 +523,7 @@ static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn)
529 * and while we are looking at it have its reference count 523 * and while we are looking at it have its reference count
530 * bumped until we are done with it 524 * bumped until we are done with it
531 */ 525 */
532 while((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 526 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
533 fn(dev); 527 fn(dev);
534 } 528 }
535} 529}
@@ -590,6 +584,7 @@ void edac_pci_handle_pe(struct edac_pci_ctl_info *pci, const char *msg)
590 */ 584 */
591 edac_pci_do_parity_check(); 585 edac_pci_do_parity_check();
592} 586}
587
593EXPORT_SYMBOL_GPL(edac_pci_handle_pe); 588EXPORT_SYMBOL_GPL(edac_pci_handle_pe);
594 589
595void edac_pci_handle_npe(struct edac_pci_ctl_info *pci, const char *msg) 590void edac_pci_handle_npe(struct edac_pci_ctl_info *pci, const char *msg)
@@ -609,6 +604,7 @@ void edac_pci_handle_npe(struct edac_pci_ctl_info *pci, const char *msg)
609 */ 604 */
610 edac_pci_do_parity_check(); 605 edac_pci_do_parity_check();
611} 606}
607
612EXPORT_SYMBOL_GPL(edac_pci_handle_npe); 608EXPORT_SYMBOL_GPL(edac_pci_handle_npe);
613 609
614/* 610/*
@@ -616,9 +612,9 @@ EXPORT_SYMBOL_GPL(edac_pci_handle_npe);
616 */ 612 */
617module_param(check_pci_errors, int, 0644); 613module_param(check_pci_errors, int, 0644);
618MODULE_PARM_DESC(check_pci_errors, 614MODULE_PARM_DESC(check_pci_errors,
619 "Check for PCI bus parity errors: 0=off 1=on"); 615 "Check for PCI bus parity errors: 0=off 1=on");
620module_param(edac_pci_panic_on_pe, int, 0644); 616module_param(edac_pci_panic_on_pe, int, 0644);
621MODULE_PARM_DESC(edac_pci_panic_on_pe, 617MODULE_PARM_DESC(edac_pci_panic_on_pe,
622 "Panic on PCI Bus Parity error: 0=off 1=on"); 618 "Panic on PCI Bus Parity error: 0=off 1=on");
623 619
624#endif /* CONFIG_PCI */ 620#endif /* CONFIG_PCI */
diff --git a/drivers/edac/edac_stub.c b/drivers/edac/edac_stub.c
index 3d259c231507..77b98dd3cfa6 100644
--- a/drivers/edac/edac_stub.c
+++ b/drivers/edac/edac_stub.c
@@ -30,6 +30,7 @@ inline int edac_handler_set(void)
30 30
31 return atomic_read(&edac_handlers); 31 return atomic_read(&edac_handlers);
32} 32}
33
33EXPORT_SYMBOL(edac_handler_set); 34EXPORT_SYMBOL(edac_handler_set);
34 35
35/* 36/*
@@ -39,4 +40,5 @@ inline void edac_atomic_assert_error(void)
39{ 40{
40 edac_err_assert++; 41 edac_err_assert++;
41} 42}
43
42EXPORT_SYMBOL(edac_atomic_assert_error); 44EXPORT_SYMBOL(edac_atomic_assert_error);