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_class.c
struct dlist* sysfs_get_class_devices(struct sysfs_class* cls)
{
    char path[SYSFS_PATH_MAX];
    struct dlist *dirlist, *linklist;

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

    /*
     * Post linux-2.6.14, we have nested classes and links under
     * /sys/class/xxx/. are also valid class devices
     */
    safestrcpy(path, cls->path);
    dirlist = read_dir_subdirs(path);
    if (dirlist)
    {
        add_cdevs_to_classlist(cls, dirlist);
        sysfs_close_list(dirlist);
    }

    linklist = read_dir_links(path);
    if (linklist)
    {
        add_cdevs_to_classlist(cls, linklist);
        sysfs_close_list(linklist);
    }

    return cls->devices;
}
/**
 * sysfs_get_class_devices: get all class devices in the given class
 * @cls: sysfs_class whose devices list is needed
 *
 * Returns a dlist of sysfs_class_device * on success and NULL on failure
 */
get all class devices in the given class
@cls: sysfs_class whose devices list is needed

Returns a dlist of sysfs_class_device * on success and NULL on failure
get all class devices in the given class @cls : sysfs_class whose devices list is needed Returns a dlist of sysfs_class_device * on success and NULL on failure
struct dlist* sysfs_get_class_devices(struct sysfs_class* cls)
{
    char path[SYSFS_PATH_MAX];
    struct dlist *dirlist, *linklist;
    if (!cls)
    {
        errno = EINVAL;
        return NULL;
    }
    safestrcpy(path, cls->path);
    dirlist = read_dir_subdirs(path);
    if (dirlist)
    {
        add_cdevs_to_classlist(cls, dirlist);
        sysfs_close_list(dirlist);
    }
    linklist = read_dir_links(path);
    if (linklist)
    {
        add_cdevs_to_classlist(cls, linklist);
        sysfs_close_list(linklist);
    }
    return cls->devices;
}
struct dlist * sysfs_get_class_devices ( struct sysfs_class * cls ) { char path [ SYSFS_PATH_MAX ] ; struct dlist * dirlist , * linklist ; if ( ! cls ) { errno = EINVAL ; return NULL ; } safestrcpy ( path , cls -> path ) ; dirlist = read_dir_subdirs ( path ) ; if ( dirlist ) { add_cdevs_to_classlist ( cls , dirlist ) ; sysfs_close_list ( dirlist ) ; } linklist = read_dir_links ( path ) ; if ( linklist ) { add_cdevs_to_classlist ( cls , linklist ) ; sysfs_close_list ( linklist ) ; } return cls -> devices ; }
sysfs_get_class_devices: get all class devices in the given class
 @cls: sysfs_class whose devices list is needed
sysfs_get_class_devices : get all class devices in the given class @cls : sysfs_class whose devices list is needed
/*
     * Post linux-2.6.14, we have nested classes and links under
     * /sys/class/xxx/. are also valid class devices
     */