From 42a8e397a80c277afb2aeb22232bc70114035bb1 Mon Sep 17 00:00:00 2001 From: Douglas Thompson Date: Thu, 19 Jul 2007 01:50:10 -0700 Subject: drivers/edac: add device sysfs attributes Added new controls for the edac_device and edac_mc sysfs folder. These can be initialized by the low level driver to provide misc controls into the low level driver for its use Signed-off-by: Douglas Thompson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/edac/edac_device_sysfs.c | 51 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'drivers/edac/edac_device_sysfs.c') diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c index 849d569dd2ce..32b2a8e53dc7 100644 --- a/drivers/edac/edac_device_sysfs.c +++ b/drivers/edac/edac_device_sysfs.c @@ -9,8 +9,6 @@ * */ -#include -#include #include #include "edac_core.h" @@ -621,6 +619,34 @@ static void edac_device_delete_instances(struct edac_device_ctl_info *edac_dev) /******************* edac_dev sysfs ctor/dtor code *************/ +/* + * edac_device_add_sysfs_attributes + * add some attributes to this instance's main kobject + */ +static int edac_device_add_sysfs_attributes( + struct edac_device_ctl_info *edac_dev) +{ + int err; + struct edac_dev_sysfs_attribute *sysfs_attrib; + + /* point to the start of the array and iterate over it + * adding each attribute listed to this mci instance's kobject + */ + sysfs_attrib = edac_dev->sysfs_attributes; + + while (sysfs_attrib->attr.name != NULL) { + err = sysfs_create_file(&edac_dev->kobj, + (struct attribute*) sysfs_attrib); + if (err) { + return err; + } + + sysfs_attrib++; + } + + return 0; +} + /* * edac_device_create_sysfs() Constructor * @@ -642,6 +668,18 @@ int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev) debugf0("%s() idx=%d\n", __func__, edac_dev->dev_idx); + /* If the low level driver requests some sysfs entries + * then go create them here + */ + if (edac_dev->sysfs_attributes != NULL) { + err = edac_device_add_sysfs_attributes(edac_dev); + if (err) { + debugf0("%s() failed to add sysfs attribs\n", + __func__); + goto err_unreg_object; + } + } + /* create a symlink from the edac device * to the platform 'device' being used for this */ @@ -650,7 +688,7 @@ int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev) if (err) { debugf0("%s() sysfs_create_link() returned err= %d\n", __func__, err); - return err; + goto err_unreg_object; } debugf0("%s() calling create-instances, idx=%d\n", @@ -659,14 +697,17 @@ int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev) /* Create the first level instance directories */ err = edac_device_create_instances(edac_dev); if (err) { - goto error0; + goto err_remove_link; } return 0; /* Error unwind stack */ +err_remove_link: + /* remove the sym link */ + sysfs_remove_link(&edac_dev->kobj, EDAC_DEVICE_SYMLINK); - error0: +err_unreg_object: edac_device_unregister_main_kobj(edac_dev); return err; -- cgit v1.2.1