summaryrefslogtreecommitdiff
path: root/libsysfs/sysfs_bus.c
diff options
context:
space:
mode:
authordsteklof@us.ibm.com <dsteklof@us.ibm.com>2003-12-19 18:29:10 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:09 -0700
commitbcbe2d8e7d4ccd975e79d0c7defbe1d64d1b129c (patch)
tree78cc968183dc45e80f96133e4cb1a1c94ca461bd /libsysfs/sysfs_bus.c
parent7591c18a8f3460d3e7cab85d02915c4b51638b5c (diff)
[PATCH] libsysfs 0.4.0 patch
Ananth released sysfsutils 0.4.0 last night, I'm sure you saw the email. Here's a patch with the latest changes from the pre-patch I already gave you. It includes sysfs_get_device_parent(), which you said you needed. I've run your test scripts and I've built scsi_id. Please play around with this and check it out. There are quite a few changes. Please do not access structure pointers, like sysfs_device's parent, directly like dev->parent. Please use the "get" function to retrieve. The functions load things on demand and refresh views under the covers.
Diffstat (limited to 'libsysfs/sysfs_bus.c')
-rw-r--r--libsysfs/sysfs_bus.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/libsysfs/sysfs_bus.c b/libsysfs/sysfs_bus.c
index 3e6c22bbb1..d9da0f84cf 100644
--- a/libsysfs/sysfs_bus.c
+++ b/libsysfs/sysfs_bus.c
@@ -121,16 +121,20 @@ struct dlist *sysfs_get_bus_devices(struct sysfs_bus *bus)
return NULL;
}
- dlist_for_each_data(devdir->links, curl, struct sysfs_link) {
- bdev = sysfs_open_device(curl->target);
- if (bdev == NULL) {
- dprintf("Error opening device at %s\n", curl->target);
- continue;
+ if (devdir->links != 0) {
+ dlist_for_each_data(devdir->links, curl, struct sysfs_link) {
+ bdev = sysfs_open_device_path(curl->target);
+ if (bdev == NULL) {
+ dprintf("Error opening device at %s\n",
+ curl->target);
+ continue;
+ }
+ if (bus->devices == NULL)
+ bus->devices = dlist_new_with_delete
+ (sizeof(struct sysfs_device),
+ sysfs_close_dev);
+ dlist_unshift(bus->devices, bdev);
}
- if (bus->devices == NULL)
- bus->devices = dlist_new_with_delete
- (sizeof(struct sysfs_device), sysfs_close_dev);
- dlist_unshift(bus->devices, bdev);
}
sysfs_close_directory(devdir);
@@ -165,16 +169,21 @@ struct dlist *sysfs_get_bus_drivers(struct sysfs_bus *bus)
sysfs_close_directory(drvdir);
return NULL;
}
- dlist_for_each_data(drvdir->subdirs, cursub, struct sysfs_directory) {
- driver = sysfs_open_driver(cursub->path);
- if (driver == NULL) {
- dprintf("Error opening driver at %s\n", cursub->path);
- continue;
+ if (drvdir->subdirs != NULL) {
+ dlist_for_each_data(drvdir->subdirs, cursub,
+ struct sysfs_directory) {
+ driver = sysfs_open_driver_path(cursub->path);
+ if (driver == NULL) {
+ dprintf("Error opening driver at %s\n",
+ cursub->path);
+ continue;
+ }
+ if (bus->drivers == NULL)
+ bus->drivers = dlist_new_with_delete
+ (sizeof(struct sysfs_driver),
+ sysfs_close_drv);
+ dlist_unshift(bus->drivers, driver);
}
- if (bus->drivers == NULL)
- bus->drivers = dlist_new_with_delete
- (sizeof(struct sysfs_driver), sysfs_close_drv);
- dlist_unshift(bus->drivers, driver);
}
sysfs_close_directory(drvdir);
return (bus->drivers);
@@ -347,10 +356,9 @@ struct sysfs_device *sysfs_open_bus_device(unsigned char *busname,
dprintf("Error getting sysfs mount point\n");
return NULL;
}
-
+
if (sysfs_trailing_slash(path) == 0)
strcat(path, "/");
-
strcat(path, SYSFS_BUS_NAME);
strcat(path, "/");
strcat(path, busname);
@@ -359,7 +367,7 @@ struct sysfs_device *sysfs_open_bus_device(unsigned char *busname,
strcat(path, "/");
strcat(path, dev_id);
- rdev = sysfs_open_device(path);
+ rdev = sysfs_open_device_path(path);
if (rdev == NULL) {
dprintf("Error getting device %s on bus %s\n",
dev_id, busname);