xref: /openbmc/linux/sound/core/seq/seq_info.c (revision b08918fb)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *   ALSA sequencer /proc interface
4  *   Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
5  */
6 
7 #include <linux/init.h>
8 #include <linux/export.h>
9 #include <sound/core.h>
10 
11 #include "seq_info.h"
12 #include "seq_clientmgr.h"
13 #include "seq_timer.h"
14 
15 static struct snd_info_entry *queues_entry;
16 static struct snd_info_entry *clients_entry;
17 static struct snd_info_entry *timer_entry;
18 
19 
20 static struct snd_info_entry * __init
21 create_info_entry(char *name, void (*read)(struct snd_info_entry *,
22 					   struct snd_info_buffer *))
23 {
24 	struct snd_info_entry *entry;
25 
26 	entry = snd_info_create_module_entry(THIS_MODULE, name, snd_seq_root);
27 	if (entry == NULL)
28 		return NULL;
29 	entry->content = SNDRV_INFO_CONTENT_TEXT;
30 	entry->c.text.read = read;
31 	if (snd_info_register(entry) < 0) {
32 		snd_info_free_entry(entry);
33 		return NULL;
34 	}
35 	return entry;
36 }
37 
38 void snd_seq_info_done(void)
39 {
40 	snd_info_free_entry(queues_entry);
41 	snd_info_free_entry(clients_entry);
42 	snd_info_free_entry(timer_entry);
43 }
44 
45 /* create all our /proc entries */
46 int __init snd_seq_info_init(void)
47 {
48 	queues_entry = create_info_entry("queues",
49 					 snd_seq_info_queues_read);
50 	clients_entry = create_info_entry("clients",
51 					  snd_seq_info_clients_read);
52 	timer_entry = create_info_entry("timer", snd_seq_info_timer_read);
53 	if (!queues_entry || !clients_entry || !timer_entry)
54 		goto error;
55 	return 0;
56 
57  error:
58 	snd_seq_info_done();
59 	return -ENOMEM;
60 }
61