summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sysfs_device.c4
-rw-r--r--lib/sysfs_driver.c16
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/sysfs_device.c b/lib/sysfs_device.c
index 3b2030d..e14d12a 100644
--- a/lib/sysfs_device.c
+++ b/lib/sysfs_device.c
@@ -372,8 +372,10 @@ struct sysfs_root_device *sysfs_open_root_device(const unsigned char *name)
*/
struct dlist *sysfs_get_device_attributes(struct sysfs_device *device)
{
- if (device == NULL)
+ if (device == NULL) {
+ errno = EINVAL;
return NULL;
+ }
if (device->directory == NULL) {
device->directory = sysfs_open_directory(device->path);
diff --git a/lib/sysfs_driver.c b/lib/sysfs_driver.c
index 6a7cf68..44434ee 100644
--- a/lib/sysfs_driver.c
+++ b/lib/sysfs_driver.c
@@ -197,12 +197,15 @@ struct dlist *sysfs_get_driver_links(struct sysfs_driver *driver)
errno = EINVAL;
return NULL;
}
- if (driver->directory == NULL) {
+
+ if (driver->directory == NULL)
if ((open_driver_dir(driver)) == 1)
return NULL;
+
+ if (driver->directory->links == NULL)
if ((sysfs_read_dir_links(driver->directory)) != 0)
return NULL;
- }
+
return(driver->directory->links);
}
@@ -224,12 +227,11 @@ struct dlist *sysfs_get_driver_devices(struct sysfs_driver *driver)
if (driver->devices != NULL)
return (driver->devices);
- if (driver->directory == NULL) {
- if ((open_driver_dir(driver)) == 1)
- return NULL;
- if ((sysfs_read_dir_links(driver->directory)) != 0)
- return NULL;
+ if (driver->directory == NULL || driver->directory->links == NULL) {
+ struct dlist *list = NULL;
+ list = sysfs_get_driver_links(driver);
}
+
if (driver->directory->links != NULL) {
dlist_for_each_data(driver->directory->links, curlink,
struct sysfs_link) {