aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thunderbolt/configfs.c
blob: dc6bc363dfe8052d7f94c6e3dca3efe9fe9771be (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
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: GPL-2.0
/*
 * ConfigFS support
 *
 * Copyright (C) 2026, Intel Corporation
 * Author: Mika Westerberg <mika.westerberg@linux.intel.com>
 */

#include <linux/configfs.h>
#include <linux/export.h>

#include "tb.h"

static const struct config_item_type tb_root_group_type = {
	.ct_owner = THIS_MODULE,
};

static struct configfs_subsystem tb_configfs = {
	.su_group = {
		.cg_item = {
			.ci_namebuf = "thunderbolt",
			.ci_type = &tb_root_group_type,
		},
	},
};

/**
 * tb_configfs_register_group() - Register Thunderbolt ConfigFS group
 * @group: Group to register.
 *
 * Registers the new @group under Thunderbolt subsystem ConfigFS.
 *
 * Return: 0% in case of success, negative errno otherwise.
 */
int tb_configfs_register_group(struct config_group *group)
{
	return configfs_register_group(&tb_configfs.su_group, group);
}
EXPORT_SYMBOL_GPL(tb_configfs_register_group);

/**
 * tb_configfs_unregister_group() - Unregister previously registered group
 * @group: Group to unregister.
 */
void tb_configfs_unregister_group(struct config_group *group)
{
	configfs_unregister_group(group);
}
EXPORT_SYMBOL_GPL(tb_configfs_unregister_group);

int tb_configfs_init(void)
{
	config_group_init(&tb_configfs.su_group);
	mutex_init(&tb_configfs.su_mutex);
	return configfs_register_subsystem(&tb_configfs);
}

void tb_configfs_exit(void)
{
	configfs_unregister_subsystem(&tb_configfs);
}