diff options
| author | Takashi Iwai <tiwai@suse.de> | 2015-02-04 05:48:52 -0500 |
|---|---|---|
| committer | Borislav Petkov <bp@suse.de> | 2015-02-23 07:07:41 -0500 |
| commit | 4e8d230de9c1dff8e587ae769e46fcddb3d98f1c (patch) | |
| tree | 3a94888ddd239d04aab3ff1458cd3f3f4afa08f3 /drivers/edac | |
| parent | 2c1946b6d6290c74c6ad8d0915590d64f33a034d (diff) | |
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>
Diffstat (limited to 'drivers/edac')
| -rw-r--r-- | drivers/edac/edac_core.h | 4 | ||||
| -rw-r--r-- | drivers/edac/edac_mc.c | 12 | ||||
| -rw-r--r-- | drivers/edac/edac_mc_sysfs.c | 4 | ||||
| -rw-r--r-- | drivers/edac/edac_module.h | 3 |
4 files changed, 15 insertions, 8 deletions
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h index 6c9f381e8fe6..ad42587c3f4d 100644 --- a/drivers/edac/edac_core.h +++ b/drivers/edac/edac_core.h | |||
| @@ -446,7 +446,9 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, | |||
| 446 | unsigned n_layers, | 446 | unsigned n_layers, |
| 447 | struct edac_mc_layer *layers, | 447 | struct edac_mc_layer *layers, |
| 448 | unsigned sz_pvt); | 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 | extern void edac_mc_free(struct mem_ctl_info *mci); | 452 | extern void edac_mc_free(struct mem_ctl_info *mci); |
| 451 | extern struct mem_ctl_info *edac_mc_find(int idx); | 453 | extern struct mem_ctl_info *edac_mc_find(int idx); |
| 452 | extern struct mem_ctl_info *find_mci_by_dev(struct device *dev); | 454 | extern struct mem_ctl_info *find_mci_by_dev(struct device *dev); |
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c index 1747906f10ce..af3be1914dbb 100644 --- a/drivers/edac/edac_mc.c +++ b/drivers/edac/edac_mc.c | |||
| @@ -710,9 +710,10 @@ struct mem_ctl_info *edac_mc_find(int idx) | |||
| 710 | EXPORT_SYMBOL(edac_mc_find); | 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 | 713 | * edac_mc_add_mc_with_groups: Insert the 'mci' structure into the mci |
| 714 | * create sysfs entries associated with mci structure | 714 | * global list and create sysfs entries associated with mci structure |
| 715 | * @mci: pointer to the mci structure to be added to the list | 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 | * Return: | 718 | * Return: |
| 718 | * 0 Success | 719 | * 0 Success |
| @@ -720,7 +721,8 @@ EXPORT_SYMBOL(edac_mc_find); | |||
| 720 | */ | 721 | */ |
| 721 | 722 | ||
| 722 | /* FIXME - should a warning be printed if no error detection? correction? */ | 723 | /* FIXME - should a warning be printed if no error detection? correction? */ |
| 723 | int edac_mc_add_mc(struct mem_ctl_info *mci) | 724 | int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci, |
| 725 | const struct attribute_group **groups) | ||
| 724 | { | 726 | { |
| 725 | int ret = -EINVAL; | 727 | int ret = -EINVAL; |
| 726 | edac_dbg(0, "\n"); | 728 | edac_dbg(0, "\n"); |
| @@ -771,7 +773,7 @@ int edac_mc_add_mc(struct mem_ctl_info *mci) | |||
| 771 | 773 | ||
| 772 | mci->bus = &mc_bus[mci->mc_idx]; | 774 | mci->bus = &mc_bus[mci->mc_idx]; |
| 773 | 775 | ||
| 774 | if (edac_create_sysfs_mci_device(mci)) { | 776 | if (edac_create_sysfs_mci_device(mci, groups)) { |
| 775 | edac_mc_printk(mci, KERN_WARNING, | 777 | edac_mc_printk(mci, KERN_WARNING, |
| 776 | "failed to create sysfs device\n"); | 778 | "failed to create sysfs device\n"); |
| 777 | goto fail1; | 779 | goto fail1; |
| @@ -805,7 +807,7 @@ fail0: | |||
| 805 | mutex_unlock(&mem_ctls_mutex); | 807 | mutex_unlock(&mem_ctls_mutex); |
| 806 | return ret; | 808 | return ret; |
| 807 | } | 809 | } |
| 808 | EXPORT_SYMBOL_GPL(edac_mc_add_mc); | 810 | EXPORT_SYMBOL_GPL(edac_mc_add_mc_with_groups); |
| 809 | 811 | ||
| 810 | /** | 812 | /** |
| 811 | * edac_mc_del_mc: Remove sysfs entries for specified mci structure and | 813 | * edac_mc_del_mc: Remove sysfs entries for specified mci structure and |
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 0bcd64234a03..3a283819970b 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c | |||
| @@ -974,7 +974,8 @@ nomem: | |||
| 974 | * 0 Success | 974 | * 0 Success |
| 975 | * !0 Failure | 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 | int i, err; | 980 | int i, err; |
| 980 | 981 | ||
| @@ -998,6 +999,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | |||
| 998 | 999 | ||
| 999 | mci->dev.parent = mci_pdev; | 1000 | mci->dev.parent = mci_pdev; |
| 1000 | mci->dev.bus = mci->bus; | 1001 | mci->dev.bus = mci->bus; |
| 1002 | mci->dev.groups = groups; | ||
| 1001 | dev_set_name(&mci->dev, "mc%d", mci->mc_idx); | 1003 | dev_set_name(&mci->dev, "mc%d", mci->mc_idx); |
| 1002 | dev_set_drvdata(&mci->dev, mci); | 1004 | dev_set_drvdata(&mci->dev, mci); |
| 1003 | pm_runtime_forbid(&mci->dev); | 1005 | pm_runtime_forbid(&mci->dev); |
diff --git a/drivers/edac/edac_module.h b/drivers/edac/edac_module.h index f2118bfcf8df..26ecc52e073d 100644 --- a/drivers/edac/edac_module.h +++ b/drivers/edac/edac_module.h | |||
| @@ -22,7 +22,8 @@ | |||
| 22 | /* on edac_mc_sysfs.c */ | 22 | /* on edac_mc_sysfs.c */ |
| 23 | int edac_mc_sysfs_init(void); | 23 | int edac_mc_sysfs_init(void); |
| 24 | void edac_mc_sysfs_exit(void); | 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 | extern void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci); | 27 | extern void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci); |
| 27 | void edac_unregister_sysfs(struct mem_ctl_info *mci); | 28 | void edac_unregister_sysfs(struct mem_ctl_info *mci); |
| 28 | extern int edac_get_log_ue(void); | 29 | extern int edac_get_log_ue(void); |
