seq_info.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #include <linux/init.h>
  7. #include <linux/export.h>
  8. #include <sound/core.h>
  9. #include "seq_info.h"
  10. #include "seq_clientmgr.h"
  11. #include "seq_timer.h"
  12. static struct snd_info_entry *queues_entry;
  13. static struct snd_info_entry *clients_entry;
  14. static struct snd_info_entry *timer_entry;
  15. static struct snd_info_entry * __init
  16. create_info_entry(char *name, void (*read)(struct snd_info_entry *,
  17. struct snd_info_buffer *))
  18. {
  19. struct snd_info_entry *entry;
  20. entry = snd_info_create_module_entry(THIS_MODULE, name, snd_seq_root);
  21. if (entry == NULL)
  22. return NULL;
  23. entry->content = SNDRV_INFO_CONTENT_TEXT;
  24. entry->c.text.read = read;
  25. if (snd_info_register(entry) < 0) {
  26. snd_info_free_entry(entry);
  27. return NULL;
  28. }
  29. return entry;
  30. }
  31. void snd_seq_info_done(void)
  32. {
  33. snd_info_free_entry(queues_entry);
  34. snd_info_free_entry(clients_entry);
  35. snd_info_free_entry(timer_entry);
  36. }
  37. /* create all our /proc entries */
  38. int __init snd_seq_info_init(void)
  39. {
  40. queues_entry = create_info_entry("queues",
  41. snd_seq_info_queues_read);
  42. clients_entry = create_info_entry("clients",
  43. snd_seq_info_clients_read);
  44. timer_entry = create_info_entry("timer", snd_seq_info_timer_read);
  45. if (!queues_entry || !clients_entry || !timer_entry)
  46. goto error;
  47. return 0;
  48. error:
  49. snd_seq_info_done();
  50. return -ENOMEM;
  51. }