Lines Matching refs:res

51  *	static int kunit_kmalloc_init(struct kunit_resource *res, void *context)
54 * res->data = kmalloc(params->size, params->gfp);
56 * if (!res->data)
62 * static void kunit_kmalloc_free(struct kunit_resource *res)
64 * kfree(res->data);
98 * @res: resource
100 static inline void kunit_get_resource(struct kunit_resource *res)
102 kref_get(&res->refcount);
111 struct kunit_resource *res = container_of(kref, struct kunit_resource,
114 if (res->free)
115 res->free(res);
117 /* 'res' is valid here, as if should_kfree is set, res->free may not free
118 * 'res' itself, just res->data
120 if (res->should_kfree)
121 kfree(res);
134 * @res: resource
136 static inline void kunit_put_resource(struct kunit_resource *res)
138 kref_put(&res->refcount, kunit_release_resource);
144 * res->should_kfree is not initialised.
150 * @res: The resource.
156 struct kunit_resource *res,
166 * @res: The resource.
172 struct kunit_resource *res,
175 res->should_kfree = false;
176 return __kunit_add_resource(test, init, free, res, data);
187 * @res: The resource.
194 struct kunit_resource *res,
209 res->name = name;
210 res->should_kfree = false;
212 return __kunit_add_resource(test, init, free, res, data);
243 struct kunit_resource *res;
246 res = kzalloc(sizeof(*res), internal_gfp);
247 if (!res)
250 res->should_kfree = true;
252 ret = __kunit_add_resource(test, init, free, res, context);
258 kunit_get_resource(res);
259 return res;
286 struct kunit_resource *res;
288 res = kzalloc(sizeof(*res), internal_gfp);
289 if (!res)
292 res->should_kfree = true;
293 if (!__kunit_add_resource(test, init, free, res, context))
294 return res->data;
300 struct kunit_resource *res,
306 * @res: The resource.
310 struct kunit_resource *res,
313 return res->name && strcmp(res->name, match_name) == 0;
327 struct kunit_resource *res, *found = NULL;
332 list_for_each_entry_reverse(res, &test->resources, node) {
333 if (match(test, res, (void *)match_data)) {
334 found = res;
382 * @res: The resource to be removed.
388 void kunit_remove_resource(struct kunit *test, struct kunit_resource *res);