blob: 61d41ca418441a15945b376964f6f3ed07ac84b8 [file] [log] [blame]
Joe Perchesbbeddf52013-07-31 13:53:45 -07001#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2
3#include <linux/kernel.h>
4#include <linux/console.h>
Samuel Thibault2ed2b862017-03-26 22:47:36 +02005#include <linux/errno.h>
Joe Perchesbbeddf52013-07-31 13:53:45 -07006#include <linux/string.h>
7
8#include "console_cmdline.h"
9#include "braille.h"
10
Samuel Thibault2ed2b862017-03-26 22:47:36 +020011int _braille_console_setup(char **str, char **brl_options)
Joe Perchesbbeddf52013-07-31 13:53:45 -070012{
Nicolas Ioossae6c33b2016-08-25 15:17:00 -070013 if (!strncmp(*str, "brl,", 4)) {
Joe Perchesbbeddf52013-07-31 13:53:45 -070014 *brl_options = "";
15 *str += 4;
Nicolas Ioossae6c33b2016-08-25 15:17:00 -070016 } else if (!strncmp(*str, "brl=", 4)) {
Joe Perchesbbeddf52013-07-31 13:53:45 -070017 *brl_options = *str + 4;
18 *str = strchr(*brl_options, ',');
Samuel Thibault2ed2b862017-03-26 22:47:36 +020019 if (!*str) {
Joe Perchesbbeddf52013-07-31 13:53:45 -070020 pr_err("need port name after brl=\n");
Samuel Thibault2ed2b862017-03-26 22:47:36 +020021 return -EINVAL;
22 }
23 *((*str)++) = 0;
24 }
Joe Perchesbbeddf52013-07-31 13:53:45 -070025
Samuel Thibault2ed2b862017-03-26 22:47:36 +020026 return 0;
Joe Perchesbbeddf52013-07-31 13:53:45 -070027}
28
29int
30_braille_register_console(struct console *console, struct console_cmdline *c)
31{
32 int rtn = 0;
33
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
40 return rtn;
41}
42
43int
44_braille_unregister_console(struct console *console)
45{
46 if (console->flags & CON_BRL)
47 return braille_unregister_console(console);
48
49 return 0;
50}