Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

EDAC: Allow to pass driver-specific attribute groups

Add edac_mc_add_mc_with_groups() for initializing the mem_ctl_info
object with the optional attribute groups. This allows drivers to
pass additional sysfs entries without manual (and racy)
device_create_file() and co calls.

edac_mc_add_mc() is kept as is, just calling edac_mc_add_with_groups()
with NULL groups.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: http://lkml.kernel.org/r/1423046938-18111-3-git-send-email-tiwai@suse.de
Signed-off-by: Borislav Petkov <bp@suse.de>

authored by

Takashi Iwai and committed by
Borislav Petkov
4e8d230d 2c1946b6

+15 -8
+3 -1
drivers/edac/edac_core.h
··· 446 446 unsigned n_layers, 447 447 struct edac_mc_layer *layers, 448 448 unsigned sz_pvt); 449 - extern int edac_mc_add_mc(struct mem_ctl_info *mci); 449 + extern int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci, 450 + const struct attribute_group **groups); 451 + #define edac_mc_add_mc(mci) edac_mc_add_mc_with_groups(mci, NULL) 450 452 extern void edac_mc_free(struct mem_ctl_info *mci); 451 453 extern struct mem_ctl_info *edac_mc_find(int idx); 452 454 extern struct mem_ctl_info *find_mci_by_dev(struct device *dev);
+7 -5
drivers/edac/edac_mc.c
··· 710 710 EXPORT_SYMBOL(edac_mc_find); 711 711 712 712 /** 713 - * edac_mc_add_mc: Insert the 'mci' structure into the mci global list and 714 - * create sysfs entries associated with mci structure 713 + * edac_mc_add_mc_with_groups: Insert the 'mci' structure into the mci 714 + * global list and create sysfs entries associated with mci structure 715 715 * @mci: pointer to the mci structure to be added to the list 716 + * @groups: optional attribute groups for the driver-specific sysfs entries 716 717 * 717 718 * Return: 718 719 * 0 Success ··· 721 720 */ 722 721 723 722 /* FIXME - should a warning be printed if no error detection? correction? */ 724 - int edac_mc_add_mc(struct mem_ctl_info *mci) 723 + int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci, 724 + const struct attribute_group **groups) 725 725 { 726 726 int ret = -EINVAL; 727 727 edac_dbg(0, "\n"); ··· 773 771 774 772 mci->bus = &mc_bus[mci->mc_idx]; 775 773 776 - if (edac_create_sysfs_mci_device(mci)) { 774 + if (edac_create_sysfs_mci_device(mci, groups)) { 777 775 edac_mc_printk(mci, KERN_WARNING, 778 776 "failed to create sysfs device\n"); 779 777 goto fail1; ··· 807 805 mutex_unlock(&mem_ctls_mutex); 808 806 return ret; 809 807 } 810 - EXPORT_SYMBOL_GPL(edac_mc_add_mc); 808 + EXPORT_SYMBOL_GPL(edac_mc_add_mc_with_groups); 811 809 812 810 /** 813 811 * edac_mc_del_mc: Remove sysfs entries for specified mci structure and
+3 -1
drivers/edac/edac_mc_sysfs.c
··· 974 974 * 0 Success 975 975 * !0 Failure 976 976 */ 977 - int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) 977 + int edac_create_sysfs_mci_device(struct mem_ctl_info *mci, 978 + const struct attribute_group **groups) 978 979 { 979 980 int i, err; 980 981 ··· 999 998 1000 999 mci->dev.parent = mci_pdev; 1001 1000 mci->dev.bus = mci->bus; 1001 + mci->dev.groups = groups; 1002 1002 dev_set_name(&mci->dev, "mc%d", mci->mc_idx); 1003 1003 dev_set_drvdata(&mci->dev, mci); 1004 1004 pm_runtime_forbid(&mci->dev);
+2 -1
drivers/edac/edac_module.h
··· 22 22 /* on edac_mc_sysfs.c */ 23 23 int edac_mc_sysfs_init(void); 24 24 void edac_mc_sysfs_exit(void); 25 - extern int edac_create_sysfs_mci_device(struct mem_ctl_info *mci); 25 + extern int edac_create_sysfs_mci_device(struct mem_ctl_info *mci, 26 + const struct attribute_group **groups); 26 27 extern void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci); 27 28 void edac_unregister_sysfs(struct mem_ctl_info *mci); 28 29 extern int edac_get_log_ue(void);