^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/console.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "console_cmdline.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "braille.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) int _braille_console_setup(char **str, char **brl_options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) size_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) len = str_has_prefix(*str, "brl,");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) if (len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *brl_options = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *str += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) len = str_has_prefix(*str, "brl=");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) if (len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *brl_options = *str + len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) *str = strchr(*brl_options, ',');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) if (!*str) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) pr_err("need port name after brl=\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) *((*str)++) = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) _braille_register_console(struct console *console, struct console_cmdline *c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int rtn = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) if (c->brl_options) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) console->flags |= CON_BRL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) rtn = braille_register_console(console, c->index, c->options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) c->brl_options);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) return rtn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) _braille_unregister_console(struct console *console)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) if (console->flags & CON_BRL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) return braille_unregister_console(console);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }