diff options
author | mananth <mananth> | 2005-12-05 06:45:26 +0000 |
---|---|---|
committer | mananth <mananth> | 2005-12-05 06:45:26 +0000 |
commit | 132c2d799c08ab9a63baea74e00e9391322737cd (patch) | |
tree | b34fac3ec897dcc07b3908be8c9cd2a07e992c2b | |
parent | 1b97581a08affe559b6094eec3549051373edecf (diff) | |
download | sysfsutils-132c2d799c08ab9a63baea74e00e9391322737cd.tar.gz |
Add support for the newer class:class_device representation
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | lib/sysfs_class.c | 22 |
2 files changed, 21 insertions, 4 deletions
@@ -1,3 +1,6 @@ +12/05/2005 - Ananth Mavinakayanahalli <ananth@in.ibm.com> + * Add support for class:class_device representation + 11/28/2005 - Ananth Mavinakayanahalli <ananth@in.ibm.com> * Remove stale brute force code to determine device's bus and device's driver - Thanks Kay for the patch diff --git a/lib/sysfs_class.c b/lib/sysfs_class.c index 5328f74..c74803a 100644 --- a/lib/sysfs_class.c +++ b/lib/sysfs_class.c @@ -96,15 +96,29 @@ static struct sysfs_class_device *alloc_class_device(void) */ static void set_classdev_classname(struct sysfs_class_device *cdev) { - char *c, *e; + char *c, *e, name[SYSFS_NAME_LEN]; int count = 0; + /* + * Newer driver core changes have a class:class_device representation. + * Check if this cdev belongs to the newer style subsystem and + * set the classname appropriately. + */ + memset(name, 0, SYSFS_NAME_LEN); + safestrcpy(name, cdev->name); + c = strchr(name, ':'); + if (c) { + safestrcpy(cdev->name, c+1); + *c = '\0'; + safestrcpy(cdev->classname, name); + return; + } + c = strstr(cdev->path, SYSFS_CLASS_NAME); - if (c == NULL) { + if (c == NULL) c = strstr(cdev->path, SYSFS_BLOCK_NAME); - } else { + else c = strstr(c, "/"); - } if (c == NULL) safestrcpy(cdev->classname, SYSFS_UNKNOWN); |