summaryrefslogtreecommitdiff
path: root/lib/sysfs_device.c
diff options
context:
space:
mode:
authormananth <mananth>2004-02-04 10:51:50 +0000
committermananth <mananth>2004-02-04 10:51:50 +0000
commit6cbd7ae67a04b1f0c3269ab3aae2d8ee0efa5a89 (patch)
treeab728dfb40bed686bf802e7e92545e02ea8131b6 /lib/sysfs_device.c
parent06d8ed8e147b05fd41c4ba0a36b7c67760d181a9 (diff)
downloadsysfsutils-6cbd7ae67a04b1f0c3269ab3aae2d8ee0efa5a89.tar.gz
Sorting support, removed unneeded functions and other cosmetic changes
Diffstat (limited to 'lib/sysfs_device.c')
-rw-r--r--lib/sysfs_device.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/sysfs_device.c b/lib/sysfs_device.c
index 6365276..3b2030d 100644
--- a/lib/sysfs_device.c
+++ b/lib/sysfs_device.c
@@ -24,12 +24,12 @@
#include "sysfs.h"
/**
- * get_device_bus: retrieves the bus name the device is on, checks path to
- * bus' link to make sure it has correct device.
+ * sysfs_get_device_bus: retrieves the bus name the device is on, checks path
+ * to bus' link to make sure it has correct device.
* @dev: device to get busname.
* returns 0 with success and -1 with error.
*/
-static int get_device_bus(struct sysfs_device *dev)
+int sysfs_get_device_bus(struct sysfs_device *dev)
{
unsigned char subsys[SYSFS_NAME_LEN], path[SYSFS_PATH_MAX];
unsigned char target[SYSFS_PATH_MAX], *bus = NULL, *c = NULL;
@@ -209,8 +209,8 @@ struct sysfs_device *sysfs_open_device_path(const unsigned char *path)
*/
strncpy(dev->name, dev->bus_id, SYSFS_NAME_LEN);
- if (get_device_bus(dev) != 0)
- strcpy(dev->bus, SYSFS_UNKNOWN);
+ if (sysfs_get_device_bus(dev) != 0)
+ dprintf("Could not get device bus\n");
return dev;
}
@@ -255,7 +255,8 @@ static struct sysfs_device *sysfs_open_device_tree(const unsigned char *path)
rootdev->children = dlist_new_with_delete
(sizeof(struct sysfs_device),
sysfs_close_dev_tree);
- dlist_unshift(rootdev->children, new);
+ dlist_unshift_sorted(rootdev->children,
+ new, sort_list);
}
}
@@ -311,7 +312,7 @@ struct dlist *sysfs_get_root_devices(struct sysfs_root_device *root)
root->devices = dlist_new_with_delete
(sizeof(struct sysfs_device),
sysfs_close_dev_tree);
- dlist_unshift(root->devices, dev);
+ dlist_unshift_sorted(root->devices, dev, sort_list);
}
return root->devices;