summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormananth <mananth>2003-08-29 11:18:39 +0000
committermananth <mananth>2003-08-29 11:18:39 +0000
commitb3f3a30f9553e0400660191dbb772438aa849a1d (patch)
tree504e78333a673e6b65f854e088884b342912f49f /lib
parent1422dedd5c721400e07de988a407aeefbecafea3 (diff)
downloadsysfsutils-b3f3a30f9553e0400660191dbb772438aa849a1d.tar.gz
Changed sysfs_driver to contain a dlist of devices
Diffstat (limited to 'lib')
-rw-r--r--lib/sysfs_bus.c6
-rw-r--r--lib/sysfs_class.c14
-rw-r--r--lib/sysfs_driver.c5
3 files changed, 22 insertions, 3 deletions
diff --git a/lib/sysfs_bus.c b/lib/sysfs_bus.c
index 7e03b4a..d1eafcc 100644
--- a/lib/sysfs_bus.c
+++ b/lib/sysfs_bus.c
@@ -262,7 +262,11 @@ static void link_bus_devices_to_drivers(struct sysfs_bus *bus)
dev->bus_id)) != 0) {
strncpy(dev->driver_name, drv->name,
SYSFS_NAME_LEN);
- drv->device = dev;
+ if (drv->devices == NULL)
+ drv->devices = dlist_new
+ (sizeof(struct
+ sysfs_device));
+ dlist_unshift(drv->devices, dev);
}
}
}
diff --git a/lib/sysfs_class.c b/lib/sysfs_class.c
index 710d55c..3b34c79 100644
--- a/lib/sysfs_class.c
+++ b/lib/sysfs_class.c
@@ -180,8 +180,18 @@ struct sysfs_class_device *sysfs_open_class_device(const unsigned char *path)
drv = sysfs_open_driver(curl->target);
if (drv != NULL) {
cdev->driver = drv;
- if (cdev->sysdevice != NULL)
- drv->device = cdev->sysdevice;
+ if (cdev->sysdevice != NULL) {
+ strncpy(cdev->sysdevice->name,
+ drv->name,
+ SYSFS_NAME_LEN);
+ if (drv->devices == NULL)
+ drv->devices =
+ dlist_new
+ (sizeof(struct
+ sysfs_device));
+ dlist_unshift(drv->devices,
+ cdev->sysdevice);
+ }
}
}
}
diff --git a/lib/sysfs_driver.c b/lib/sysfs_driver.c
index f890b22..04b2b17 100644
--- a/lib/sysfs_driver.c
+++ b/lib/sysfs_driver.c
@@ -30,6 +30,11 @@
void sysfs_close_driver(struct sysfs_driver *driver)
{
if (driver != NULL) {
+ if (driver->devices != NULL) {
+ dlist_for_each(driver->devices)
+ dlist_shift(driver->devices);
+ dlist_destroy(driver->devices);
+ }
if (driver->directory != NULL)
sysfs_close_directory(driver->directory);
free(driver);