-/**
- * sysfs_open_driver_attr: read the user supplied driver attribute
- * @bus: bus on which to look
- * @drv: driver whose attribute has to be read
- * @attrib: Attribute to be read
- * Returns struct sysfs_attribute on success and NULL on failure
- *
- * NOTE:
- * A call to sysfs_close_attribute() is required to close the
- * attribute returned and to free memory
- */
-struct sysfs_attribute *sysfs_open_driver_attr(const char *bus,
- const char *drv, const char *attrib)
-{
- struct sysfs_attribute *attribute = NULL;
- char path[SYSFS_PATH_MAX];
-
- if (bus == NULL || drv == NULL || attrib == NULL) {
- errno = EINVAL;
- return NULL;
- }
-
- memset(path, 0, SYSFS_PATH_MAX);
- if ((get_driver_path(bus, drv, path, SYSFS_PATH_MAX)) != 0) {
- dprintf("Error getting to driver %s\n", drv);
- return NULL;
- }
- safestrcat(path, "/");
- safestrcat(path, attrib);
- attribute = sysfs_open_attribute(path);
- if (attribute == NULL) {
- dprintf("Error opening attribute %s for driver %s\n",
- attrib, drv);
- return NULL;
- }
- if ((sysfs_read_attribute(attribute)) != 0) {
- dprintf("Error reading attribute %s for driver %s\n",
- attrib, drv);
- sysfs_close_attribute(attribute);
- return NULL;
- }
- return attribute;
-}
-