braille.c 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // SPDX-License-Identifier: GPL-2.0
  2. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  3. #include <linux/kernel.h>
  4. #include <linux/console.h>
  5. #include <linux/errno.h>
  6. #include <linux/string.h>
  7. #include "console_cmdline.h"
  8. #include "braille.h"
  9. int _braille_console_setup(char **str, char **brl_options)
  10. {
  11. if (!strncmp(*str, "brl,", 4)) {
  12. *brl_options = "";
  13. *str += 4;
  14. } else if (!strncmp(*str, "brl=", 4)) {
  15. *brl_options = *str + 4;
  16. *str = strchr(*brl_options, ',');
  17. if (!*str) {
  18. pr_err("need port name after brl=\n");
  19. return -EINVAL;
  20. }
  21. *((*str)++) = 0;
  22. }
  23. return 0;
  24. }
  25. int
  26. _braille_register_console(struct console *console, struct console_cmdline *c)
  27. {
  28. int rtn = 0;
  29. if (c->brl_options) {
  30. console->flags |= CON_BRL;
  31. rtn = braille_register_console(console, c->index, c->options,
  32. c->brl_options);
  33. }
  34. return rtn;
  35. }
  36. int
  37. _braille_unregister_console(struct console *console)
  38. {
  39. if (console->flags & CON_BRL)
  40. return braille_unregister_console(console);
  41. return 0;
  42. }