summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau/include/nvif/log.h
blob: 64f6f8fc6141c517ffcc64a040b07fc457a42f30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* SPDX-License-Identifier: MIT */
/* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. */

#ifndef __NVIF_LOG_H__
#define __NVIF_LOG_H__

#ifdef CONFIG_DEBUG_FS

/**
 * nvif_log - structure for tracking logging buffers
 * @entry: an entry in a list of struct nvif_logs
 * @shutdown: pointer to function to call to clean up
 *
 * Structure used to track logging buffers so that they can be cleaned up
 * when the module exits.
 *
 * The @shutdown function is called when the module exits. It should free all
 * backing resources, such as logging buffers.
 */
struct nvif_log {
	struct list_head entry;
	void (*shutdown)(struct nvif_log *log);
};

/**
 * nvif_logs - linked list of nvif_log objects
 */
struct nvif_logs {
	struct list_head head;
};

#define NVIF_LOGS_DECLARE(logs) \
	struct nvif_logs logs = { LIST_HEAD_INIT(logs.head) }

static inline void nvif_log_shutdown(struct nvif_logs *logs)
{
	if (!list_empty(&logs->head)) {
		struct nvif_log *log, *n;

		list_for_each_entry_safe(log, n, &logs->head, entry) {
			/* shutdown() should also delete the log entry */
			log->shutdown(log);
		}
	}
}

extern struct nvif_logs gsp_logs;

#endif

#endif