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_module* sysfs_get_driver_module(struct sysfs_driver* drv)
{
    char path[SYSFS_PATH_MAX], mod_path[SYSFS_PATH_MAX];

    if (!drv)
    {
        errno = EINVAL;
        return NULL;
    }

    memset(path, 0, SYSFS_PATH_MAX);
    safestrcpy(path, drv->path);
    safestrcat(path, "/");
    safestrcat(path, SYSFS_MODULE_NAME);
    if (!sysfs_path_is_link(path))
    {
        memset(mod_path, 0, SYSFS_PATH_MAX);
        if (!sysfs_get_link(path, mod_path, SYSFS_PATH_MAX))
            drv->module = sysfs_open_module_path(mod_path);
    }
    return drv->module;
}
/**
 * sysfs_get_driver_module: gets the module being used by this driver
 * @drv: sysfs_driver whose "module" is needed
 * Returns sysfs_module on success and NULL on failure
 */
gets the module being used by this driver
@drv: sysfs_driver whose "module" is needed
Returns sysfs_module on success and NULL on failure
gets the module being used by this driver @drv : sysfs_driver whose " module " is needed Returns sysfs_module on success and NULL on failure
struct sysfs_module* sysfs_get_driver_module(struct sysfs_driver* drv)
{
    char path[SYSFS_PATH_MAX], mod_path[SYSFS_PATH_MAX];
    if (!drv)
    {
        errno = EINVAL;
        return NULL;
    }
    memset(path, 0, SYSFS_PATH_MAX);
    safestrcpy(path, drv->path);
    safestrcat(path, "/");
    safestrcat(path, SYSFS_MODULE_NAME);
    if (!sysfs_path_is_link(path))
    {
        memset(mod_path, 0, SYSFS_PATH_MAX);
        if (!sysfs_get_link(path, mod_path, SYSFS_PATH_MAX))
            drv->module = sysfs_open_module_path(mod_path);
    }
    return drv->module;
}
struct sysfs_module * sysfs_get_driver_module ( struct sysfs_driver * drv ) { char path [ SYSFS_PATH_MAX ] , mod_path [ SYSFS_PATH_MAX ] ; if ( ! drv ) { errno = EINVAL ; return NULL ; } memset ( path , 0 , SYSFS_PATH_MAX ) ; safestrcpy ( path , drv -> path ) ; safestrcat ( path , " " ) ; safestrcat ( path , SYSFS_MODULE_NAME ) ; if ( ! sysfs_path_is_link ( path ) ) { memset ( mod_path , 0 , SYSFS_PATH_MAX ) ; if ( ! sysfs_get_link ( path , mod_path , SYSFS_PATH_MAX ) ) drv -> module = sysfs_open_module_path ( mod_path ) ; } return drv -> module ; }
sysfs_get_driver_module: gets the module being used by this driver
 @drv: sysfs_driver whose "module" is needed
 Returns sysfs_module on success and NULL on failure
sysfs_get_driver_module : gets the module being used by this driver @drv : sysfs_driver whose " module " is needed Returns sysfs_module on success and NULL on failure