Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Joe Perches and committed by
Linus Torvalds
bbeddf52 d197c43d

+117 -33
+7 -2
drivers/accessibility/braille/braille_console.c
··· 359 359 char *console_options, char *braille_options) 360 360 { 361 361 int ret; 362 + 363 + if (!(console->flags & CON_BRL)) 364 + return 0; 362 365 if (!console_options) 363 366 /* Only support VisioBraille for now */ 364 367 console_options = "57600o8"; ··· 377 374 braille_co = console; 378 375 register_keyboard_notifier(&keyboard_notifier_block); 379 376 register_vt_notifier(&vt_notifier_block); 380 - return 0; 377 + return 1; 381 378 } 382 379 383 380 int braille_unregister_console(struct console *console) 384 381 { 385 382 if (braille_co != console) 386 383 return -EINVAL; 384 + if (!(console->flags & CON_BRL)) 385 + return 0; 387 386 unregister_keyboard_notifier(&keyboard_notifier_block); 388 387 unregister_vt_notifier(&vt_notifier_block); 389 388 braille_co = NULL; 390 - return 0; 389 + return 1; 391 390 }
+1
kernel/printk/Makefile
··· 1 1 obj-y = printk.o 2 + obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o
+48
kernel/printk/braille.c
··· 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 + }
+48
kernel/printk/braille.h
··· 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
+13 -31
kernel/printk/printk.c
··· 52 52 #include <trace/events/printk.h> 53 53 54 54 #include "console_cmdline.h" 55 + #include "braille.h" 55 56 56 57 /* printk's without a loglevel use this.. */ 57 58 #define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL ··· 1770 1769 c = &console_cmdline[i]; 1771 1770 strlcpy(c->name, name, sizeof(c->name)); 1772 1771 c->options = options; 1773 - #ifdef CONFIG_A11Y_BRAILLE_CONSOLE 1774 - c->brl_options = brl_options; 1775 - #endif 1772 + braille_set_options(c, brl_options); 1773 + 1776 1774 c->index = idx; 1777 1775 return 0; 1778 1776 } ··· 1784 1784 char *s, *options, *brl_options = NULL; 1785 1785 int idx; 1786 1786 1787 - #ifdef CONFIG_A11Y_BRAILLE_CONSOLE 1788 - if (!memcmp(str, "brl,", 4)) { 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 1787 + if (_braille_console_setup(&str, &brl_options)) 1788 + return 1; 1801 1789 1802 1790 /* 1803 1791 * Decode str into name, index, options. ··· 2279 2291 continue; 2280 2292 if (newcon->index < 0) 2281 2293 newcon->index = console_cmdline[i].index; 2282 - #ifdef CONFIG_A11Y_BRAILLE_CONSOLE 2283 - if (console_cmdline[i].brl_options) { 2284 - newcon->flags |= CON_BRL; 2285 - braille_register_console(newcon, 2286 - console_cmdline[i].index, 2287 - console_cmdline[i].options, 2288 - console_cmdline[i].brl_options); 2294 + 2295 + if (_braille_register_console(newcon, &console_cmdline[i])) 2289 2296 return; 2290 - } 2291 - #endif 2297 + 2292 2298 if (newcon->setup && 2293 2299 newcon->setup(newcon, console_cmdline[i].options) != 0) 2294 2300 break; ··· 2370 2388 int unregister_console(struct console *console) 2371 2389 { 2372 2390 struct console *a, *b; 2373 - int res = 1; 2391 + int res; 2374 2392 2375 - #ifdef CONFIG_A11Y_BRAILLE_CONSOLE 2376 - if (console->flags & CON_BRL) 2377 - return braille_unregister_console(console); 2378 - #endif 2393 + res = _braille_unregister_console(console); 2394 + if (res) 2395 + return res; 2379 2396 2397 + res = 1; 2380 2398 console_lock(); 2381 2399 if (console_drivers == console) { 2382 2400 console_drivers=console->next;