chiark / gitweb /
[PATCH] fix up some duplicated function compiler warnings in libsysfs
[elogind.git] / libsysfs / sysfs_bus.c
index 19fc275d842e30ecbde602ca620b35ce0e84d911..639acef4eeddf6108c63199aa1eba11c2ce94ece 100644 (file)
 
 static void sysfs_close_dev(void *dev)
 {
-               sysfs_close_device((struct sysfs_device *)dev);
+        sysfs_close_device((struct sysfs_device *)dev);
 }
 
 static void sysfs_close_drv(void *drv)
 {
-               sysfs_close_driver((struct sysfs_driver *)drv);
+        sysfs_close_driver((struct sysfs_driver *)drv);
 }
 
 /*
@@ -112,7 +112,10 @@ static struct sysfs_directory *open_bus_dir(const unsigned char *name)
                return NULL;
        }
 
-       strcat(buspath, SYSFS_BUS_DIR);
+       if (sysfs_trailing_slash(buspath) == 0)
+               strcat(buspath, "/");
+               
+       strcat(buspath, SYSFS_BUS_NAME);
        strcat(buspath, "/");
        strcat(buspath, name);
        busdir = sysfs_open_directory(buspath);
@@ -406,10 +409,13 @@ struct sysfs_device *sysfs_open_bus_device(unsigned char *busname,
                return NULL;
        }
 
-       strcat(path, SYSFS_BUS_DIR);
+       if (sysfs_trailing_slash(path) == 0)
+               strcat(path, "/");
+       strcat(path, SYSFS_BUS_NAME);
        strcat(path, "/");
        strcat(path, busname);
-       strcat(path, SYSFS_DEVICES_DIR);
+       strcat(path, "/");
+       strcat(path, SYSFS_DEVICES_NAME);
        strcat(path, "/");
        strcat(path, dev_id);
 
@@ -423,48 +429,6 @@ struct sysfs_device *sysfs_open_bus_device(unsigned char *busname,
        return rdev;
 }
 
-/**
- * sysfs_find_device_bus: locates the bus a device is on.
- * @dev_id: device id.
- * @busname: buffer to copy name to
- * @bsize: buffer size
- * returns 0 with success or -1 with error
- */
-int sysfs_find_device_bus(const unsigned char *dev_id, unsigned char *busname, 
-                                                               size_t bsize)
-{
-       unsigned char subsys[SYSFS_NAME_LEN], *bus = NULL, *curdev = NULL; 
-       struct dlist *buslist = NULL, *device_list = NULL;
-
-       if (dev_id == NULL || busname == NULL) {
-               errno = EINVAL;
-               return -1;
-       }
-       
-       strcpy(subsys, SYSFS_BUS_DIR);  /* subsys = /bus */
-       buslist = sysfs_open_subsystem_list(subsys);
-       if (buslist != NULL) {
-               dlist_for_each_data(buslist, bus, char) {
-                       device_list = sysfs_open_bus_devices_list(bus);
-                       if (device_list != NULL) {
-                               dlist_for_each_data(device_list, 
-                                               curdev, char) {
-                                       if (strcmp(dev_id, curdev) == 0) {
-                                               strncpy(busname, 
-                                                       bus, bsize);
-                                               sysfs_close_list(device_list);
-                                               sysfs_close_list(buslist);
-                                               return 0;
-                                       }
-                               }
-                       sysfs_close_list(device_list);
-                       }
-               }
-               sysfs_close_list(buslist);
-       }
-       return -1;
-}
-
 /**
  * sysfs_find_driver_bus: locates the bus the driver is on.
  * @driver: name of the driver to locate
@@ -484,15 +448,17 @@ int sysfs_find_driver_bus(const unsigned char *driver, unsigned char *busname,
        }
 
        memset(subsys, 0, SYSFS_PATH_MAX);
-       strcpy(subsys, SYSFS_BUS_DIR);
+       strcpy(subsys, SYSFS_BUS_NAME);
        buslist = sysfs_open_subsystem_list(subsys);
        if (buslist != NULL) {
                dlist_for_each_data(buslist, bus, char) {
                        memset(subsys, 0, SYSFS_PATH_MAX);
-                       strcpy(subsys, SYSFS_BUS_DIR);
+                       strcat(subsys, "/");
+                       strcpy(subsys, SYSFS_BUS_NAME);
                        strcat(subsys, "/");
                        strcat(subsys, bus);
-                       strcat(subsys, SYSFS_DRIVERS_DIR);
+                       strcat(subsys, "/");
+                       strcat(subsys, SYSFS_DRIVERS_NAME);
                        drivers = sysfs_open_subsystem_list(subsys);
                        if (drivers != NULL) {
                                dlist_for_each_data(drivers, curdrv, char) {