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_attr.c
static struct sysfs_attribute* add_attribute(void* dev, const char* path)
{
    struct sysfs_attribute* attr;

    attr = sysfs_open_attribute(path);
    if (!attr)
    {
        dprintf("Error opening attribute %s\n", path);
        return NULL;
    }
    if (attr->method & SYSFS_METHOD_SHOW)
    {
        if (sysfs_read_attribute(attr))
        {
            dprintf("Error reading attribute %s\n", path);
            sysfs_close_attribute(attr);
            return NULL;
        }
    }

    if (!((struct sysfs_device*)dev)->attrlist)
    {
        ((struct sysfs_device*)dev)->attrlist = dlist_new_with_delete(
            sizeof(struct sysfs_attribute), sysfs_del_attribute);
    }
    dlist_unshift_sorted(((struct sysfs_device*)dev)->attrlist, attr,
                         sort_list);

    return attr;
}
/**
 * add_attribute: open and add attribute at path to given directory
 * @dev: device whose attribute is to be added
 * @path: path to attribute
 * returns pointer to attr added with success and NULL with error.
 */
open and add attribute at path to given directory
@dev: device whose attribute is to be added
@path: path to attribute
returns pointer to attr added with success and NULL with error.
open and add attribute at path to given directory @dev : device whose attribute is to be added @path : path to attribute returns pointer to attr added with success and NULL with error .
static struct sysfs_attribute* add_attribute(void* dev, const char* path)
{
    struct sysfs_attribute* attr;
    attr = sysfs_open_attribute(path);
    if (!attr)
    {
        dprintf("Error opening attribute %s\n", path);
        return NULL;
    }
    if (attr->method & SYSFS_METHOD_SHOW)
    {
        if (sysfs_read_attribute(attr))
        {
            dprintf("Error reading attribute %s\n", path);
            sysfs_close_attribute(attr);
            return NULL;
        }
    }
    if (!((struct sysfs_device*)dev)->attrlist)
    {
        ((struct sysfs_device*)dev)->attrlist = dlist_new_with_delete(
            sizeof(struct sysfs_attribute), sysfs_del_attribute);
    }
    dlist_unshift_sorted(((struct sysfs_device*)dev)->attrlist, attr,
                         sort_list);
    return attr;
}
static struct sysfs_attribute * add_attribute ( void * dev , const char * path ) { struct sysfs_attribute * attr ; attr = sysfs_open_attribute ( path ) ; if ( ! attr ) { dprintf ( " \n " , path ) ; return NULL ; } if ( attr -> method & SYSFS_METHOD_SHOW ) { if ( sysfs_read_attribute ( attr ) ) { dprintf ( " \n " , path ) ; sysfs_close_attribute ( attr ) ; return NULL ; } } if ( ! ( ( struct sysfs_device * ) dev ) -> attrlist ) { ( ( struct sysfs_device * ) dev ) -> attrlist = dlist_new_with_delete ( sizeof ( struct sysfs_attribute ) , sysfs_del_attribute ) ; } dlist_unshift_sorted ( ( ( struct sysfs_device * ) dev ) -> attrlist , attr , sort_list ) ; return attr ; }
add_attribute: open and add attribute at path to given directory
 @dev: device whose attribute is to be added
 @path: path to attribute
 returns pointer to attr added with success and NULL with error.
add_attribute : open and add attribute at path to given directory @dev : device whose attribute is to be added @path : path to attribute returns pointer to attr added with success and NULL with error .