summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormananth <mananth>2003-10-15 12:08:36 +0000
committermananth <mananth>2003-10-15 12:08:36 +0000
commitfbf43094427c2cc5fc4cbe01869dc295c863bdd7 (patch)
tree9fe070a1507c3f680387b0dd5a0ce18cd8f0a7ff
parent440328f85e7cd4c6a819c99044989ba36e5cabee (diff)
downloadsysfsutils-fbf43094427c2cc5fc4cbe01869dc295c863bdd7.tar.gz
Simplify sysfs_open_bus_device()
-rw-r--r--ChangeLog3
-rw-r--r--lib/sysfs_bus.c32
2 files changed, 17 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 6c8c26d..e453a9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
+09/04/2003 - Ananth Mavinakayanahalli <ananth@in.ibm.com>
+ * Simplify sysfs_open_bus_device
+
08/29/2003 - Ananth Mavinakayanahalli <ananth@in.ibm.com>
* Removed "bus_name" from struct sysfs_device
* Updated NEWS, TODO and docs/libsysfs.txt files
diff --git a/lib/sysfs_bus.c b/lib/sysfs_bus.c
index d1eafcc..2b169f8 100644
--- a/lib/sysfs_bus.c
+++ b/lib/sysfs_bus.c
@@ -392,36 +392,32 @@ struct sysfs_attribute *sysfs_get_bus_attribute(struct sysfs_bus *bus,
struct sysfs_device *sysfs_open_bus_device(unsigned char *busname,
unsigned char *dev_id)
{
- struct sysfs_bus *bus = NULL;
- struct sysfs_device *dev = NULL, *rdev = NULL;
+ struct sysfs_device *rdev = NULL;
+ char path[SYSFS_PATH_MAX];
if (busname == NULL || dev_id == NULL) {
errno = EINVAL;
return NULL;
}
- bus = sysfs_open_bus(busname);
- if (bus == NULL) {
- dprintf("Error opening bus %s\n", busname);
+ memset(path, 0, SYSFS_PATH_MAX);
+ if (sysfs_get_mnt_path(path, SYSFS_PATH_MAX) != 0) {
+ dprintf("Error getting sysfs mount point\n");
return NULL;
}
- dev = sysfs_get_bus_device(bus, dev_id);
- if (dev == NULL) {
- dprintf("Error getting device %s on bus %s\n", dev_id,
- busname);
- sysfs_close_bus(bus);
- return NULL;
- }
- rdev = sysfs_open_device(dev->directory->path);
+ strcat(path, "/bus/");
+ strcat(path, busname);
+ strcat(path, "/devices/");
+ strcat(path, dev_id);
+
+ rdev = sysfs_open_device(path);
if (rdev == NULL) {
- dprintf("Error getting device %s on bus %s\n", dev_id,
- busname);
- sysfs_close_bus(bus);
+ dprintf("Error getting device %s on bus %s\n",
+ dev_id, busname);
return NULL;
}
- sysfs_close_bus(bus);
-
+
return rdev;
}