diff options
author | Joe Perches <joe@perches.com> | 2013-07-31 16:53:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-31 17:41:03 -0400 |
commit | bbeddf52adc1b4207674ab88686cbbe58c24f721 (patch) | |
tree | b5cc2fe8f140e340407e2daa8b1ab2ba63ae00f4 /kernel/printk | |
parent | d197c43d04decb6b1298fa3ef26ea04a9ca7c977 (diff) |
printk: move braille console support into separate braille.[ch] files
Create files with prototypes and static inlines for braille support. Make
braille_console functions return 1 on success.
Corrected CONFIG_A11Y_BRAILLE_CONSOLE=n _braille_console_setup
return value to NULL.
Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/printk')
-rw-r--r-- | kernel/printk/Makefile | 1 | ||||
-rw-r--r-- | kernel/printk/braille.c | 48 | ||||
-rw-r--r-- | kernel/printk/braille.h | 48 | ||||
-rw-r--r-- | kernel/printk/printk.c | 44 |
4 files changed, 110 insertions, 31 deletions
diff --git a/kernel/printk/Makefile b/kernel/printk/Makefile index 36d306d9273c..85405bdcf2b3 100644 --- a/kernel/printk/Makefile +++ b/kernel/printk/Makefile | |||
@@ -1 +1,2 @@ | |||
1 | obj-y = printk.o | 1 | obj-y = printk.o |
2 | obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o | ||
diff --git a/kernel/printk/braille.c b/kernel/printk/braille.c new file mode 100644 index 000000000000..b51087fb9ace --- /dev/null +++ b/kernel/printk/braille.c | |||
@@ -0,0 +1,48 @@ | |||
1 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
2 | |||
3 | #include <linux/kernel.h> | ||
4 | #include <linux/console.h> | ||
5 | #include <linux/string.h> | ||
6 | |||
7 | #include "console_cmdline.h" | ||
8 | #include "braille.h" | ||
9 | |||
10 | char *_braille_console_setup(char **str, char **brl_options) | ||
11 | { | ||
12 | if (!memcmp(*str, "brl,", 4)) { | ||
13 | *brl_options = ""; | ||
14 | *str += 4; | ||
15 | } else if (!memcmp(str, "brl=", 4)) { | ||
16 | *brl_options = *str + 4; | ||
17 | *str = strchr(*brl_options, ','); | ||
18 | if (!*str) | ||
19 | pr_err("need port name after brl=\n"); | ||
20 | else | ||
21 | *((*str)++) = 0; | ||
22 | } | ||
23 | |||
24 | return *str; | ||
25 | } | ||
26 | |||
27 | int | ||
28 | _braille_register_console(struct console *console, struct console_cmdline *c) | ||
29 | { | ||
30 | int rtn = 0; | ||
31 | |||
32 | if (c->brl_options) { | ||
33 | console->flags |= CON_BRL; | ||
34 | rtn = braille_register_console(console, c->index, c->options, | ||
35 | c->brl_options); | ||
36 | } | ||
37 | |||
38 | return rtn; | ||
39 | } | ||
40 | |||
41 | int | ||
42 | _braille_unregister_console(struct console *console) | ||
43 | { | ||
44 | if (console->flags & CON_BRL) | ||
45 | return braille_unregister_console(console); | ||
46 | |||
47 | return 0; | ||
48 | } | ||
diff --git a/kernel/printk/braille.h b/kernel/printk/braille.h new file mode 100644 index 000000000000..769d771145c8 --- /dev/null +++ b/kernel/printk/braille.h | |||
@@ -0,0 +1,48 @@ | |||
1 | #ifndef _PRINTK_BRAILLE_H | ||
2 | #define _PRINTK_BRAILLE_H | ||
3 | |||
4 | #ifdef CONFIG_A11Y_BRAILLE_CONSOLE | ||
5 | |||
6 | static inline void | ||
7 | braille_set_options(struct console_cmdline *c, char *brl_options) | ||
8 | { | ||
9 | c->brl_options = brl_options; | ||
10 | } | ||
11 | |||
12 | char * | ||
13 | _braille_console_setup(char **str, char **brl_options); | ||
14 | |||
15 | int | ||
16 | _braille_register_console(struct console *console, struct console_cmdline *c); | ||
17 | |||
18 | int | ||
19 | _braille_unregister_console(struct console *console); | ||
20 | |||
21 | #else | ||
22 | |||
23 | static inline void | ||
24 | braille_set_options(struct console_cmdline *c, char *brl_options) | ||
25 | { | ||
26 | } | ||
27 | |||
28 | static inline char * | ||
29 | _braille_console_setup(char **str, char **brl_options) | ||
30 | { | ||
31 | return NULL; | ||
32 | } | ||
33 | |||
34 | static inline int | ||
35 | _braille_register_console(struct console *console, struct console_cmdline *c) | ||
36 | { | ||
37 | return 0; | ||
38 | } | ||
39 | |||
40 | static inline int | ||
41 | _braille_unregister_console(struct console *console) | ||
42 | { | ||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | #endif | ||
47 | |||
48 | #endif | ||
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 4da2b2c7f67d..5a022e0c654c 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include <trace/events/printk.h> | 52 | #include <trace/events/printk.h> |
53 | 53 | ||
54 | #include "console_cmdline.h" | 54 | #include "console_cmdline.h" |
55 | #include "braille.h" | ||
55 | 56 | ||
56 | /* printk's without a loglevel use this.. */ | 57 | /* printk's without a loglevel use this.. */ |
57 | #define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL | 58 | #define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL |
@@ -1769,9 +1770,8 @@ static int __add_preferred_console(char *name, int idx, char *options, | |||
1769 | c = &console_cmdline[i]; | 1770 | c = &console_cmdline[i]; |
1770 | strlcpy(c->name, name, sizeof(c->name)); | 1771 | strlcpy(c->name, name, sizeof(c->name)); |
1771 | c->options = options; | 1772 | c->options = options; |
1772 | #ifdef CONFIG_A11Y_BRAILLE_CONSOLE | 1773 | braille_set_options(c, brl_options); |
1773 | c->brl_options = brl_options; | 1774 | |
1774 | #endif | ||
1775 | c->index = idx; | 1775 | c->index = idx; |
1776 | return 0; | 1776 | return 0; |
1777 | } | 1777 | } |
@@ -1784,20 +1784,8 @@ static int __init console_setup(char *str) | |||
1784 | char *s, *options, *brl_options = NULL; | 1784 | char *s, *options, *brl_options = NULL; |
1785 | int idx; | 1785 | int idx; |
1786 | 1786 | ||
1787 | #ifdef CONFIG_A11Y_BRAILLE_CONSOLE | 1787 | if (_braille_console_setup(&str, &brl_options)) |
1788 | if (!memcmp(str, "brl,", 4)) { | 1788 | return 1; |
1789 | brl_options = ""; | ||
1790 | str += 4; | ||
1791 | } else if (!memcmp(str, "brl=", 4)) { | ||
1792 | brl_options = str + 4; | ||
1793 | str = strchr(brl_options, ','); | ||
1794 | if (!str) { | ||
1795 | printk(KERN_ERR "need port name after brl=\n"); | ||
1796 | return 1; | ||
1797 | } | ||
1798 | *(str++) = 0; | ||
1799 | } | ||
1800 | #endif | ||
1801 | 1789 | ||
1802 | /* | 1790 | /* |
1803 | * Decode str into name, index, options. | 1791 | * Decode str into name, index, options. |
@@ -2291,16 +2279,10 @@ void register_console(struct console *newcon) | |||
2291 | continue; | 2279 | continue; |
2292 | if (newcon->index < 0) | 2280 | if (newcon->index < 0) |
2293 | newcon->index = console_cmdline[i].index; | 2281 | newcon->index = console_cmdline[i].index; |
2294 | #ifdef CONFIG_A11Y_BRAILLE_CONSOLE | 2282 | |
2295 | if (console_cmdline[i].brl_options) { | 2283 | if (_braille_register_console(newcon, &console_cmdline[i])) |
2296 | newcon->flags |= CON_BRL; | ||
2297 | braille_register_console(newcon, | ||
2298 | console_cmdline[i].index, | ||
2299 | console_cmdline[i].options, | ||
2300 | console_cmdline[i].brl_options); | ||
2301 | return; | 2284 | return; |
2302 | } | 2285 | |
2303 | #endif | ||
2304 | if (newcon->setup && | 2286 | if (newcon->setup && |
2305 | newcon->setup(newcon, console_cmdline[i].options) != 0) | 2287 | newcon->setup(newcon, console_cmdline[i].options) != 0) |
2306 | break; | 2288 | break; |
@@ -2388,13 +2370,13 @@ EXPORT_SYMBOL(register_console); | |||
2388 | int unregister_console(struct console *console) | 2370 | int unregister_console(struct console *console) |
2389 | { | 2371 | { |
2390 | struct console *a, *b; | 2372 | struct console *a, *b; |
2391 | int res = 1; | 2373 | int res; |
2392 | 2374 | ||
2393 | #ifdef CONFIG_A11Y_BRAILLE_CONSOLE | 2375 | res = _braille_unregister_console(console); |
2394 | if (console->flags & CON_BRL) | 2376 | if (res) |
2395 | return braille_unregister_console(console); | 2377 | return res; |
2396 | #endif | ||
2397 | 2378 | ||
2379 | res = 1; | ||
2398 | console_lock(); | 2380 | console_lock(); |
2399 | if (console_drivers == console) { | 2381 | if (console_drivers == console) { |
2400 | console_drivers=console->next; | 2382 | console_drivers=console->next; |