openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/sysfsutils/2.1.0-r5/sysfsutils-2.1.0/lib/sysfs_driver.c
struct sysfs_driver* sysfs_open_driver(const char* bus_name,
                                       const char* drv_name)
{
    char path[SYSFS_PATH_MAX];
    struct sysfs_driver* driver = NULL;

    if (!drv_name || !bus_name)
    {
        errno = EINVAL;
        return NULL;
    }

    memset(path, 0, SYSFS_PATH_MAX);
    if (get_driver_path(bus_name, drv_name, path, SYSFS_PATH_MAX))
    {
        dprintf("Error getting to driver %s\n", drv_name);
        return NULL;
    }
    driver = sysfs_open_driver_path(path);
    if (!driver)
    {
        dprintf("Error opening driver at %s\n", path);
        return NULL;
    }
    return driver;
}
/**
 * sysfs_open_driver: open driver by name, given its bus
 * @bus_name: Name of the bus
 * @drv_name: Name of the driver
 * Returns the sysfs_driver reference on success and NULL on failure
 */
open driver by name, given its bus
@bus_name: Name of the bus
@drv_name: Name of the driver
Returns the sysfs_driver reference on success and NULL on failure
open driver by name given its bus @bus_name : Name of the bus @drv_name : Name of the driver Returns the sysfs_driver reference on success and NULL on failure
struct sysfs_driver* sysfs_open_driver(const char* bus_name,
                                       const char* drv_name)
{
    char path[SYSFS_PATH_MAX];
    struct sysfs_driver* driver = NULL;
    if (!drv_name || !bus_name)
    {
        errno = EINVAL;
        return NULL;
    }
    memset(path, 0, SYSFS_PATH_MAX);
    if (get_driver_path(bus_name, drv_name, path, SYSFS_PATH_MAX))
    {
        dprintf("Error getting to driver %s\n", drv_name);
        return NULL;
    }
    driver = sysfs_open_driver_path(path);
    if (!driver)
    {
        dprintf("Error opening driver at %s\n", path);
        return NULL;
    }
    return driver;
}
struct sysfs_driver * sysfs_open_driver ( const char * bus_name , const char * drv_name ) { char path [ SYSFS_PATH_MAX ] ; struct sysfs_driver * driver = NULL ; if ( ! drv_name || ! bus_name ) { errno = EINVAL ; return NULL ; } memset ( path , 0 , SYSFS_PATH_MAX ) ; if ( get_driver_path ( bus_name , drv_name , path , SYSFS_PATH_MAX ) ) { dprintf ( " \n " , drv_name ) ; return NULL ; } driver = sysfs_open_driver_path ( path ) ; if ( ! driver ) { dprintf ( " \n " , path ) ; return NULL ; } return driver ; }
sysfs_open_driver: open driver by name, given its bus
 @bus_name: Name of the bus
 @drv_name: Name of the driver
 Returns the sysfs_driver reference on success and NULL on failure
sysfs_open_driver : open driver by name given its bus @bus_name : Name of the bus @drv_name : Name of the driver Returns the sysfs_driver reference on success and NULL on failure