summaryrefslogtreecommitdiff
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
parent1422dedd5c721400e07de988a407aeefbecafea3 (diff)
downloadsysfsutils-b3f3a30f9553e0400660191dbb772438aa849a1d.tar.gz
Changed sysfs_driver to contain a dlist of devices
-rw-r--r--ChangeLog3
-rw-r--r--include/libsysfs.h1
-rw-r--r--lib/sysfs_bus.c6
-rw-r--r--lib/sysfs_class.c14
-rw-r--r--lib/sysfs_driver.c5
5 files changed, 25 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index f1b7bca..67c9cae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
08/28/2003 - Ananth Mavinakayanahalli <ananth@in.ibm.com>
+ * Changed sysfs_driver to contain a dlist of devices
+
+08/28/2003 - Ananth Mavinakayanahalli <ananth@in.ibm.com>
* Removed sysfs_driver reference from sysfs_device struct
* Fixed a few bugs in the commands.
diff --git a/include/libsysfs.h b/include/libsysfs.h
index 5dcbcaa..5f8659b 100644
--- a/include/libsysfs.h
+++ b/include/libsysfs.h
@@ -70,7 +70,6 @@ struct sysfs_directory {
};
struct sysfs_driver {
- struct sysfs_device *device;
struct dlist *devices;
unsigned char name[SYSFS_NAME_LEN];
unsigned char path[SYSFS_PATH_MAX];
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);