braille.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. size_t len;
  12. len = str_has_prefix(*str, "brl,");
  13. if (len) {
  14. *brl_options = "";
  15. *str += len;
  16. return 0;
  17. }
  18. len = str_has_prefix(*str, "brl=");
  19. if (len) {
  20. *brl_options = *str + len;
  21. *str = strchr(*brl_options, ',');
  22. if (!*str) {
  23. pr_err("need port name after brl=\n");
  24. return -EINVAL;
  25. }
  26. *((*str)++) = 0;
  27. }
  28. return 0;
  29. }
  30. int
  31. _braille_register_console(struct console *console, struct console_cmdline *c)
  32. {
  33. int rtn = 0;
  34. if (c->brl_options) {
  35. console->flags |= CON_BRL;
  36. rtn = braille_register_console(console, c->index, c->options,
  37. c->brl_options);
  38. }
  39. return rtn;
  40. }
  41. int
  42. _braille_unregister_console(struct console *console)
  43. {
  44. if (console->flags & CON_BRL)
  45. return braille_unregister_console(console);
  46. return 0;
  47. }