blob: 1d21ebacfdb83e906361aede35b76666c26f22cc [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{
Nicolas Ioossae6c33b2016-08-25 15:17:00 -070014 if (!strncmp(*str, "brl,", 4)) {
Joe Perchesbbeddf52013-07-31 13:53:45 -070015 *brl_options = "";
16 *str += 4;
Nicolas Ioossae6c33b2016-08-25 15:17:00 -070017 } else if (!strncmp(*str, "brl=", 4)) {
Joe Perchesbbeddf52013-07-31 13:53:45 -070018 *brl_options = *str + 4;
19 *str = strchr(*brl_options, ',');
Samuel Thibault2ed2b862017-03-26 22:47:36 +020020 if (!*str) {
Joe Perchesbbeddf52013-07-31 13:53:45 -070021 pr_err("need port name after brl=\n");
Samuel Thibault2ed2b862017-03-26 22:47:36 +020022 return -EINVAL;
23 }
24 *((*str)++) = 0;
25 }
Joe Perchesbbeddf52013-07-31 13:53:45 -070026
Samuel Thibault2ed2b862017-03-26 22:47:36 +020027 return 0;
Joe Perchesbbeddf52013-07-31 13:53:45 -070028}
29
30int
31_braille_register_console(struct console *console, struct console_cmdline *c)
32{
33 int rtn = 0;
34
35 if (c->brl_options) {
36 console->flags |= CON_BRL;
37 rtn = braille_register_console(console, c->index, c->options,
38 c->brl_options);
39 }
40
41 return rtn;
42}
43
44int
45_braille_unregister_console(struct console *console)
46{
47 if (console->flags & CON_BRL)
48 return braille_unregister_console(console);
49
50 return 0;
51}