From fd309a9d8e63e9176759d00630b65d772ae06e0c Mon Sep 17 00:00:00 2001 From: Douglas Thompson Date: Thu, 19 Jul 2007 01:50:25 -0700 Subject: drivers/edac: fix leaf sysfs attribute This patch fixes and enhances the driver level set of sysfs attributes that can be added to the 'block' level of an edac_device type of driver. There is a controller information structure, which contains one or more instances of device. Each instance will have one or more blocks of device specific counters. This patch fixes the ability to have more detailed attributes/controls for each of the 'blocks', providing for the addition of controls/attributes from the low level driver to user space via sysfs. Cc: Alan Cox alan@lxorguk.ukuu.org.uk Signed-off-by: Douglas Thompson Cc: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/edac/edac_device_sysfs.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (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 7a233e6e2b36..235b4c79355d 100644 --- a/drivers/edac/edac_device_sysfs.c +++ b/drivers/edac/edac_device_sysfs.c @@ -456,8 +456,10 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev, struct edac_device_instance *instance, int idx) { + int i; int err; struct edac_device_block *block; + struct edac_dev_sysfs_block_attribute *sysfs_attrib; block = &instance->blocks[idx]; @@ -480,7 +482,27 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev, return err; } + /* If there are driver level block attributes, then added them + * to the block kobject + */ + sysfs_attrib = block->block_attributes; + if (sysfs_attrib != NULL) { + for (i = 0; i < block->nr_attribs; i++) { + err = sysfs_create_file(&block->kobj, + (struct attribute *) &sysfs_attrib[i]); + if (err) + goto err_on_attrib; + + sysfs_attrib++; + } + } + return 0; + +err_on_attrib: + kobject_unregister(&block->kobj); + + return err; } /* -- cgit v1.2.3