mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									d197c43d04
								
							
						
					
					
						commit
						bbeddf52ad
					
				
					 5 changed files with 117 additions and 33 deletions
				
			
		| 
						 | 
					@ -359,6 +359,9 @@ int braille_register_console(struct console *console, int index,
 | 
				
			||||||
		char *console_options, char *braille_options)
 | 
							char *console_options, char *braille_options)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!(console->flags & CON_BRL))
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
	if (!console_options)
 | 
						if (!console_options)
 | 
				
			||||||
		/* Only support VisioBraille for now */
 | 
							/* Only support VisioBraille for now */
 | 
				
			||||||
		console_options = "57600o8";
 | 
							console_options = "57600o8";
 | 
				
			||||||
| 
						 | 
					@ -374,15 +377,17 @@ int braille_register_console(struct console *console, int index,
 | 
				
			||||||
	braille_co = console;
 | 
						braille_co = console;
 | 
				
			||||||
	register_keyboard_notifier(&keyboard_notifier_block);
 | 
						register_keyboard_notifier(&keyboard_notifier_block);
 | 
				
			||||||
	register_vt_notifier(&vt_notifier_block);
 | 
						register_vt_notifier(&vt_notifier_block);
 | 
				
			||||||
	return 0;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int braille_unregister_console(struct console *console)
 | 
					int braille_unregister_console(struct console *console)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (braille_co != console)
 | 
						if (braille_co != console)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
						if (!(console->flags & CON_BRL))
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
	unregister_keyboard_notifier(&keyboard_notifier_block);
 | 
						unregister_keyboard_notifier(&keyboard_notifier_block);
 | 
				
			||||||
	unregister_vt_notifier(&vt_notifier_block);
 | 
						unregister_vt_notifier(&vt_notifier_block);
 | 
				
			||||||
	braille_co = NULL;
 | 
						braille_co = NULL;
 | 
				
			||||||
	return 0;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1 +1,2 @@
 | 
				
			||||||
obj-y	= printk.o
 | 
					obj-y	= printk.o
 | 
				
			||||||
 | 
					obj-$(CONFIG_A11Y_BRAILLE_CONSOLE)	+= braille.o
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										48
									
								
								kernel/printk/braille.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								kernel/printk/braille.c
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,48 @@
 | 
				
			||||||
 | 
					#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <linux/kernel.h>
 | 
				
			||||||
 | 
					#include <linux/console.h>
 | 
				
			||||||
 | 
					#include <linux/string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "console_cmdline.h"
 | 
				
			||||||
 | 
					#include "braille.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char *_braille_console_setup(char **str, char **brl_options)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (!memcmp(*str, "brl,", 4)) {
 | 
				
			||||||
 | 
							*brl_options = "";
 | 
				
			||||||
 | 
							*str += 4;
 | 
				
			||||||
 | 
						} else if (!memcmp(str, "brl=", 4)) {
 | 
				
			||||||
 | 
							*brl_options = *str + 4;
 | 
				
			||||||
 | 
							*str = strchr(*brl_options, ',');
 | 
				
			||||||
 | 
							if (!*str)
 | 
				
			||||||
 | 
								pr_err("need port name after brl=\n");
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								*((*str)++) = 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return *str;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					_braille_register_console(struct console *console, struct console_cmdline *c)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int rtn = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (c->brl_options) {
 | 
				
			||||||
 | 
							console->flags |= CON_BRL;
 | 
				
			||||||
 | 
							rtn = braille_register_console(console, c->index, c->options,
 | 
				
			||||||
 | 
										       c->brl_options);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return rtn;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					_braille_unregister_console(struct console *console)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (console->flags & CON_BRL)
 | 
				
			||||||
 | 
							return braille_unregister_console(console);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										48
									
								
								kernel/printk/braille.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								kernel/printk/braille.h
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,48 @@
 | 
				
			||||||
 | 
					#ifndef _PRINTK_BRAILLE_H
 | 
				
			||||||
 | 
					#define _PRINTK_BRAILLE_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline void
 | 
				
			||||||
 | 
					braille_set_options(struct console_cmdline *c, char *brl_options)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						c->brl_options = brl_options;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char *
 | 
				
			||||||
 | 
					_braille_console_setup(char **str, char **brl_options);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					_braille_register_console(struct console *console, struct console_cmdline *c);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					_braille_unregister_console(struct console *console);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline void
 | 
				
			||||||
 | 
					braille_set_options(struct console_cmdline *c, char *brl_options)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline char *
 | 
				
			||||||
 | 
					_braille_console_setup(char **str, char **brl_options)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return NULL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline int
 | 
				
			||||||
 | 
					_braille_register_console(struct console *console, struct console_cmdline *c)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline int
 | 
				
			||||||
 | 
					_braille_unregister_console(struct console *console)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -52,6 +52,7 @@
 | 
				
			||||||
#include <trace/events/printk.h>
 | 
					#include <trace/events/printk.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "console_cmdline.h"
 | 
					#include "console_cmdline.h"
 | 
				
			||||||
 | 
					#include "braille.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* printk's without a loglevel use this.. */
 | 
					/* printk's without a loglevel use this.. */
 | 
				
			||||||
#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL
 | 
					#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL
 | 
				
			||||||
| 
						 | 
					@ -1769,9 +1770,8 @@ static int __add_preferred_console(char *name, int idx, char *options,
 | 
				
			||||||
	c = &console_cmdline[i];
 | 
						c = &console_cmdline[i];
 | 
				
			||||||
	strlcpy(c->name, name, sizeof(c->name));
 | 
						strlcpy(c->name, name, sizeof(c->name));
 | 
				
			||||||
	c->options = options;
 | 
						c->options = options;
 | 
				
			||||||
#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
 | 
						braille_set_options(c, brl_options);
 | 
				
			||||||
	c->brl_options = brl_options;
 | 
					
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	c->index = idx;
 | 
						c->index = idx;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1784,20 +1784,8 @@ static int __init console_setup(char *str)
 | 
				
			||||||
	char *s, *options, *brl_options = NULL;
 | 
						char *s, *options, *brl_options = NULL;
 | 
				
			||||||
	int idx;
 | 
						int idx;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
 | 
						if (_braille_console_setup(&str, &brl_options))
 | 
				
			||||||
	if (!memcmp(str, "brl,", 4)) {
 | 
					 | 
				
			||||||
		brl_options = "";
 | 
					 | 
				
			||||||
		str += 4;
 | 
					 | 
				
			||||||
	} else if (!memcmp(str, "brl=", 4)) {
 | 
					 | 
				
			||||||
		brl_options = str + 4;
 | 
					 | 
				
			||||||
		str = strchr(brl_options, ',');
 | 
					 | 
				
			||||||
		if (!str) {
 | 
					 | 
				
			||||||
			printk(KERN_ERR "need port name after brl=\n");
 | 
					 | 
				
			||||||
		return 1;
 | 
							return 1;
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		*(str++) = 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Decode str into name, index, options.
 | 
						 * Decode str into name, index, options.
 | 
				
			||||||
| 
						 | 
					@ -2291,16 +2279,10 @@ void register_console(struct console *newcon)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		if (newcon->index < 0)
 | 
							if (newcon->index < 0)
 | 
				
			||||||
			newcon->index = console_cmdline[i].index;
 | 
								newcon->index = console_cmdline[i].index;
 | 
				
			||||||
#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
 | 
					
 | 
				
			||||||
		if (console_cmdline[i].brl_options) {
 | 
							if (_braille_register_console(newcon, &console_cmdline[i]))
 | 
				
			||||||
			newcon->flags |= CON_BRL;
 | 
					 | 
				
			||||||
			braille_register_console(newcon,
 | 
					 | 
				
			||||||
					console_cmdline[i].index,
 | 
					 | 
				
			||||||
					console_cmdline[i].options,
 | 
					 | 
				
			||||||
					console_cmdline[i].brl_options);
 | 
					 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
					
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		if (newcon->setup &&
 | 
							if (newcon->setup &&
 | 
				
			||||||
		    newcon->setup(newcon, console_cmdline[i].options) != 0)
 | 
							    newcon->setup(newcon, console_cmdline[i].options) != 0)
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
| 
						 | 
					@ -2388,13 +2370,13 @@ EXPORT_SYMBOL(register_console);
 | 
				
			||||||
int unregister_console(struct console *console)
 | 
					int unregister_console(struct console *console)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
        struct console *a, *b;
 | 
					        struct console *a, *b;
 | 
				
			||||||
	int res = 1;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
 | 
						res = _braille_unregister_console(console);
 | 
				
			||||||
	if (console->flags & CON_BRL)
 | 
						if (res)
 | 
				
			||||||
		return braille_unregister_console(console);
 | 
							return res;
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						res = 1;
 | 
				
			||||||
	console_lock();
 | 
						console_lock();
 | 
				
			||||||
	if (console_drivers == console) {
 | 
						if (console_drivers == console) {
 | 
				
			||||||
		console_drivers=console->next;
 | 
							console_drivers=console->next;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue