/* * Used for static resources and when a kunit_resource * has been created by * kunit_alloc_resource(). When an init function is supplied, @data is passed * into the init function; otherwise, we simply set the resource data field to * the data value passed in. Doesn't initialize res->should_kfree.
*/ int __kunit_add_resource(struct kunit *test,
kunit_resource_init_t init,
kunit_resource_free_t free, struct kunit_resource *res, void *data)
{ int ret = 0; unsignedlong flags;
res->free = free;
kref_init(&res->refcount);
if (init) {
ret = init(res, data); if (ret) return ret;
} else {
res->data = data;
}
spin_lock_irqsave(&test->lock, flags);
list_add_tail(&res->node, &test->resources); /* refcount for list is established by kref_init() */
spin_unlock_irqrestore(&test->lock, flags);
res = kunit_find_resource(test, __kunit_action_match, &match_ctx); if (res) { /* Remove the free function so we don't run the action. */
res->free = NULL;
kunit_remove_resource(test, res);
kunit_put_resource(res);
}
}
EXPORT_SYMBOL_GPL(kunit_remove_action);
res = kunit_find_resource(test, __kunit_action_match, &match_ctx); if (res) {
kunit_remove_resource(test, res); /* We have to put() this here, else free won't be called. */
kunit_put_resource(res);
}
}
EXPORT_SYMBOL_GPL(kunit_release_action);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.