blob: 17a9591e54ffdf3e3cc0bb0ed738c5bf57ba666a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Joe Perchesbbeddf52013-07-31 13:53:45 -07002#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3
4#include <linux/kernel.h>
5#include <linux/console.h>
Samuel Thibault2ed2b862017-03-26 22:47:36 +02006#include <linux/errno.h>
Joe Perchesbbeddf52013-07-31 13:53:45 -07007#include <linux/string.h>
8
9#include "console_cmdline.h"
10#include "braille.h"
11
Samuel Thibault2ed2b862017-03-26 22:47:36 +020012int _braille_console_setup(char **str, char **brl_options)
Joe Perchesbbeddf52013-07-31 13:53:45 -070013{
Chuhong Yuan35c35492019-08-09 15:10:34 +080014 size_t len;
15
16 len = str_has_prefix(*str, "brl,");
17 if (len) {
Joe Perchesbbeddf52013-07-31 13:53:45 -070018 *brl_options = "";
Chuhong Yuan35c35492019-08-09 15:10:34 +080019 *str += len;
20 return 0;
21 }
22
23 len = str_has_prefix(*str, "brl=");
24 if (len) {
25 *brl_options = *str + len;
Joe Perchesbbeddf52013-07-31 13:53:45 -070026 *str = strchr(*brl_options, ',');
Samuel Thibault2ed2b862017-03-26 22:47:36 +020027 if (!*str) {
Joe Perchesbbeddf52013-07-31 13:53:45 -070028 pr_err("need port name after brl=\n");
Samuel Thibault2ed2b862017-03-26 22:47:36 +020029 return -EINVAL;
30 }
31 *((*str)++) = 0;
32 }
Joe Perchesbbeddf52013-07-31 13:53:45 -070033
Samuel Thibault2ed2b862017-03-26 22:47:36 +020034 return 0;
Joe Perchesbbeddf52013-07-31 13:53:45 -070035}
36
37int
38_braille_register_console(struct console *console, struct console_cmdline *c)
39{
40 int rtn = 0;
41
42 if (c->brl_options) {
43 console->flags |= CON_BRL;
44 rtn = braille_register_console(console, c->index, c->options,
45 c->brl_options);
46 }
47
48 return rtn;
49}
50
51int
52_braille_unregister_console(struct console *console)
53{
54 if (console->flags & CON_BRL)
55 return braille_unregister_console(console);
56
57 return 0;
58}