diff options
author | mananth <mananth> | 2003-10-15 12:41:58 +0000 |
---|---|---|
committer | mananth <mananth> | 2003-10-15 12:41:58 +0000 |
commit | 9c1078a845905f48a41138a3c16ed38d2677c478 (patch) | |
tree | f2f8cda5f74c3a8415253054987102696b7dc8ed | |
parent | 830c7ab7af0225feb2a49a1e154896bbada39ec9 (diff) | |
download | sysfsutils-9c1078a845905f48a41138a3c16ed38d2677c478.tar.gz |
Some miscellaneous patches
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | include/libsysfs.h | 9 | ||||
-rw-r--r-- | lib/sysfs_class.c | 4 | ||||
-rw-r--r-- | lib/sysfs_device.c | 7 | ||||
-rw-r--r-- | lib/sysfs_driver.c | 25 | ||||
-rw-r--r-- | test/get_driver.c | 2 |
6 files changed, 31 insertions, 20 deletions
@@ -1,4 +1,8 @@ +10/07/2003 - Ananth Mavinakayanahalli <ananth@in.ibm.com> + * Miscellaneous changes - renaming of some + functions, etc + 10/06/2003 - Ananth Mavinakayanahalli <ananth@in.ibm.com> * Pruned "test" routines * Corrected pci name decode in cmds diff --git a/include/libsysfs.h b/include/libsysfs.h index b6dbec8..1f8c0e9 100644 --- a/include/libsysfs.h +++ b/include/libsysfs.h @@ -195,8 +195,9 @@ extern void sysfs_close_driver(struct sysfs_driver *driver); extern struct sysfs_driver *sysfs_open_driver(const unsigned char *path); extern struct dlist *sysfs_get_driver_attributes(struct sysfs_driver *driver); extern struct dlist *sysfs_get_driver_links(struct sysfs_driver *driver); +extern void sysfs_close_driver_by_name(struct sysfs_driver *driver); extern struct sysfs_driver *sysfs_open_driver_by_name - (unsigned char *drv_name, unsigned char *bus, size_t bsize); + (const unsigned char *drv_name, const unsigned char *bus, size_t bsize); extern int sysfs_write_driver_attr(unsigned char *drv, unsigned char *attrib, unsigned char *value); @@ -212,7 +213,7 @@ extern struct sysfs_attribute *sysfs_get_device_attr (struct sysfs_device *dev, const unsigned char *name); extern struct dlist *sysfs_get_device_attributes(struct sysfs_device *device); extern struct sysfs_device *sysfs_open_device_by_id - (const unsigned char *bus_id, unsigned char *bus, size_t bsize); + (const unsigned char *bus_id, const unsigned char *bus, size_t bsize); extern int sysfs_write_device_attr(unsigned char *dev, unsigned char *attrib, unsigned char *value); @@ -242,10 +243,10 @@ extern struct sysfs_class *sysfs_open_class(const unsigned char *name); extern struct sysfs_class_device *sysfs_get_class_device (struct sysfs_class *class, unsigned char *name); extern struct sysfs_class_device *sysfs_open_class_device_by_name - (unsigned char *class, unsigned char *name); + (const unsigned char *class, unsigned char *name); extern struct dlist *sysfs_get_classdev_attributes (struct sysfs_class_device *cdev); -extern int sysfs_find_device_class(unsigned char *bus_id, +extern int sysfs_find_device_class(const unsigned char *bus_id, unsigned char *classname, size_t bsize); extern int sysfs_write_classdev_attr(unsigned char *dev, unsigned char *attrib, unsigned char *value); diff --git a/lib/sysfs_class.c b/lib/sysfs_class.c index 45ee15c..9f21190 100644 --- a/lib/sysfs_class.c +++ b/lib/sysfs_class.c @@ -310,7 +310,7 @@ struct sysfs_class_device *sysfs_get_class_device(struct sysfs_class *class, * @name: name of the class_device */ struct sysfs_class_device *sysfs_open_class_device_by_name - (unsigned char *classname, unsigned char *name) + (const unsigned char *classname, unsigned char *name) { struct sysfs_class *class = NULL; struct sysfs_class_device *cdev = NULL, *rcdev = NULL; @@ -367,7 +367,7 @@ struct dlist *sysfs_get_classdev_attributes(struct sysfs_class_device *cdev) * @bsize: size of buffer * returns 0 with success and -1 with error */ -int sysfs_find_device_class(unsigned char *bus_id, +int sysfs_find_device_class(const unsigned char *bus_id, unsigned char *classname, size_t bsize) { unsigned char class[SYSFS_NAME_LEN], clspath[SYSFS_NAME_LEN]; diff --git a/lib/sysfs_device.c b/lib/sysfs_device.c index 59d2f1d..7cad51b 100644 --- a/lib/sysfs_device.c +++ b/lib/sysfs_device.c @@ -345,10 +345,13 @@ struct dlist *sysfs_get_device_attributes(struct sysfs_device *device) * @bus: bus the device belongs to * @bsize: size of the bus buffer * returns struct sysfs_device if found, NULL otherwise - * NOTE: Use sysfs_close_device to close the device + * NOTE: + * 1. Use sysfs_close_device to close the device + * 2. Bus the device is on must be supplied + * Use sysfs_find_device_bus to get the bus name */ struct sysfs_device *sysfs_open_device_by_id(const unsigned char *bus_id, - unsigned char *bus, size_t bsize) + const unsigned char *bus, size_t bsize) { char sysfs_path[SYSFS_PATH_MAX], device_path[SYSFS_PATH_MAX]; struct sysfs_device *device = NULL; diff --git a/lib/sysfs_driver.c b/lib/sysfs_driver.c index fe19af9..d24532e 100644 --- a/lib/sysfs_driver.c +++ b/lib/sysfs_driver.c @@ -23,7 +23,7 @@ #include "libsysfs.h" #include "sysfs.h" -void sysfs_close_drv_dev(void *device) +void sysfs_close_driver_by_name_dev(void *device) { sysfs_close_device((struct sysfs_device *)device); } @@ -49,10 +49,10 @@ void sysfs_close_driver(struct sysfs_driver *driver) } /** - * sysfs_close_drv: closes driver and deletes device lists too + * sysfs_close_driver_by_name: closes driver and deletes device lists too * @driver: driver to close */ -void sysfs_close_drv(struct sysfs_driver *driver) +void sysfs_close_driver_by_name(struct sysfs_driver *driver) { if (driver != NULL) { if (driver->devices != NULL) @@ -145,11 +145,14 @@ struct dlist *sysfs_get_driver_links(struct sysfs_driver *driver) * @drv_name: driver to open * @bus: the driver bus * @bsize: size of bus buffer - * NOTE: Need to call sysfs_close_drv to free up memory * returns struct sysfs_driver if found, NULL otherwise + * NOTE: + * 1. Need to call sysfs_close_driver_by_name to free up memory + * 2. Bus the driver is registered with must be supplied. + * Use sysfs_find_driver_bus() to obtain the bus name */ -struct sysfs_driver *sysfs_open_driver_by_name(unsigned char *drv_name, - unsigned char *bus, size_t bsize) +struct sysfs_driver *sysfs_open_driver_by_name(const unsigned char *drv_name, + const unsigned char *bus, size_t bsize) { struct dlist *buslist = NULL, *drivers = NULL, *devices = NULL; struct sysfs_driver *driver = NULL; @@ -185,14 +188,14 @@ struct sysfs_driver *sysfs_open_driver_by_name(unsigned char *drv_name, if (device == NULL) { dprintf("Error opening device at %s\n", curlink->target); - sysfs_close_drv(driver); + sysfs_close_driver_by_name(driver); return NULL; } strcpy(device->driver_name, drv_name); if (driver->devices == NULL) driver->devices = dlist_new_with_delete (sizeof(struct sysfs_device), - sysfs_close_drv_dev); + sysfs_close_driver_by_name_dev); dlist_unshift(driver->devices, device); } } @@ -232,15 +235,15 @@ int sysfs_write_driver_attr(unsigned char *drv, unsigned char *attrib, if (attribute == NULL) { dprintf("Attribute %s not defined for driver %s\n", attrib, drv); - sysfs_close_drv(driver); + sysfs_close_driver_by_name(driver); return -1; } if ((sysfs_write_attribute(attribute, value)) < 0) { dprintf("Error setting %s to %s\n", attrib, value); - sysfs_close_drv(driver); + sysfs_close_driver_by_name(driver); return -1; } - sysfs_close_drv(driver); + sysfs_close_driver_by_name(driver); return 0; } diff --git a/test/get_driver.c b/test/get_driver.c index 0debdbe..8628486 100644 --- a/test/get_driver.c +++ b/test/get_driver.c @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) } else fprintf(stdout, "%s is presently not used by any device\n", argv[1]); - sysfs_close_drv(driver); + sysfs_close_driver_by_name(driver); free(bus); return 0; } |