openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libnl/1_3.4.0-r0/libnl-3.4.0/lib/cache_mngt.c
int nl_cache_mngt_register(struct nl_cache_ops* ops)
{
    if (!ops->co_name || !ops->co_obj_ops)
        return -NLE_INVAL;

    /* oo_keygen() also needs oo_compare() */
    BUG_ON(ops->co_obj_ops->oo_keygen && !ops->co_obj_ops->oo_compare);

    nl_write_lock(&cache_ops_lock);
    if (__nl_cache_ops_lookup(ops->co_name))
    {
        nl_write_unlock(&cache_ops_lock);
        return -NLE_EXIST;
    }

    ops->co_refcnt = 0;
    ops->co_next = cache_ops;
    cache_ops = ops;
    nl_write_unlock(&cache_ops_lock);

    NL_DBG(1, "Registered cache operations %s\n", ops->co_name);

    return 0;
}
/**
 * Register a set of cache operations
 * @arg ops		cache operations
 *
 * Called by users of caches to announce the avaibility of
 * a certain cache type.
 *
 * @return 0 on success or a negative error code.
 */
Register a set of cache operations
@arg ops             cache operations

Called by users of caches to announce the avaibility of
a certain cache type.

@return 0 on success or a negative error code.
Register a set of cache operations @arg ops cache operations Called by users of caches to announce the avaibility of a certain cache type . @return 0 on success or a negative error code .
int nl_cache_mngt_register(struct nl_cache_ops* ops)
{
    if (!ops->co_name || !ops->co_obj_ops)
        return -NLE_INVAL;
    BUG_ON(ops->co_obj_ops->oo_keygen && !ops->co_obj_ops->oo_compare);
    nl_write_lock(&cache_ops_lock);
    if (__nl_cache_ops_lookup(ops->co_name))
    {
        nl_write_unlock(&cache_ops_lock);
        return -NLE_EXIST;
    }
    ops->co_refcnt = 0;
    ops->co_next = cache_ops;
    cache_ops = ops;
    nl_write_unlock(&cache_ops_lock);
    NL_DBG(1, "Registered cache operations %s\n", ops->co_name);
    return 0;
}
int nl_cache_mngt_register ( struct nl_cache_ops * ops ) { if ( ! ops -> co_name || ! ops -> co_obj_ops ) return - NLE_INVAL ; BUG_ON ( ops -> co_obj_ops -> oo_keygen && ! ops -> co_obj_ops -> oo_compare ) ; nl_write_lock ( & cache_ops_lock ) ; if ( __nl_cache_ops_lookup ( ops -> co_name ) ) { nl_write_unlock ( & cache_ops_lock ) ; return - NLE_EXIST ; } ops -> co_refcnt = 0 ; ops -> co_next = cache_ops ; cache_ops = ops ; nl_write_unlock ( & cache_ops_lock ) ; NL_DBG ( 1 , " \n " , ops -> co_name ) ; return 0 ; }
Register a set of cache operations
 @arg ops             cache operations
Register a set of cache operations @arg ops cache operations
/* oo_keygen() also needs oo_compare() */