Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / mm / damon / modules-common.c
blob7cf96574cde7585fedf7b0d9f3e4841aeda798e2
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Common Primitives for DAMON Modules
5 * Author: SeongJae Park <sj@kernel.org>
6 */
8 #include <linux/damon.h>
10 #include "modules-common.h"
13 * Allocate, set, and return a DAMON context for the physical address space.
14 * @ctxp: Pointer to save the point to the newly created context
15 * @targetp: Pointer to save the point to the newly created target
17 int damon_modules_new_paddr_ctx_target(struct damon_ctx **ctxp,
18 struct damon_target **targetp)
20 struct damon_ctx *ctx;
21 struct damon_target *target;
23 ctx = damon_new_ctx();
24 if (!ctx)
25 return -ENOMEM;
27 if (damon_select_ops(ctx, DAMON_OPS_PADDR)) {
28 damon_destroy_ctx(ctx);
29 return -EINVAL;
32 target = damon_new_target();
33 if (!target) {
34 damon_destroy_ctx(ctx);
35 return -ENOMEM;
37 damon_add_target(ctx, target);
39 *ctxp = ctx;
40 *targetp = target;
41 return 0;