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

Revert "speakup: Generate speakupmap.h automatically"

This reverts commit 6646b95aab5f62c049f1416a3801dec5432c348b.

Stephen reports that it breaks the build for him so revert it for now.

Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Link: https://lore.kernel.org/r/20220520194637.03824f7f@canb.auug.org.au
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+66 -418
-4
drivers/accessibility/speakup/.gitignore
··· 1 - /makemapdata 2 - /mapdata.h 3 - /genmap 4 - /speakupmap.h
-28
drivers/accessibility/speakup/Makefile
··· 30 30 thread.o \ 31 31 varhandlers.o 32 32 speakup-$(CONFIG_SPEAKUP_SERIALIO) += serialio.o 33 - 34 - 35 - clean-files := mapdata.h speakupmap.h 36 - 37 - 38 - # Generate mapdata.h from headers 39 - hostprogs += makemapdata 40 - makemapdata-objs := makemapdata.o 41 - 42 - quiet_cmd_mkmap = MKMAP $@ 43 - cmd_mkmap = $(obj)/makemapdata > $@ 44 - 45 - $(obj)/mapdata.h: $(obj)/makemapdata 46 - $(call cmd,mkmap) 47 - 48 - 49 - # Generate speakupmap.map from mapdata.h 50 - hostprogs += genmap 51 - genmap-objs := genmap.o 52 - $(obj)/genmap.o: $(obj)/mapdata.h 53 - 54 - quiet_cmd_genmap = GENMAP $@ 55 - cmd_genmap = $(obj)/genmap $< > $@ 56 - 57 - $(obj)/speakupmap.h: $(obj)/speakupmap.map $(obj)/genmap 58 - $(call cmd,genmap) 59 - 60 - $(obj)/main.o: $(obj)/speakupmap.h
-162
drivers/accessibility/speakup/genmap.c
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 2 - /* genmap.c 3 - * originally written by: Kirk Reiser. 4 - * 5 - ** Copyright (C) 2002 Kirk Reiser. 6 - * Copyright (C) 2003 David Borowski. 7 - */ 8 - 9 - #include <stdlib.h> 10 - #include <stdio.h> 11 - #include <libgen.h> 12 - #include <string.h> 13 - #include <linux/version.h> 14 - #include <ctype.h> 15 - #include "utils.h" 16 - 17 - struct st_key_init { 18 - char *name; 19 - int value, shift; 20 - }; 21 - 22 - static unsigned char key_data[MAXKEYVAL][16], *kp; 23 - 24 - #include "mapdata.h" 25 - 26 - static const char delims[] = "\t\n "; 27 - static char *cp; 28 - static int map_ver = 119; /* an arbitrary number so speakup can check */ 29 - static int shift_table[17]; 30 - static int max_states = 1, flags; 31 - /* flags reserved for later, maybe for individual console maps */ 32 - 33 - static int get_shift_value(int state) 34 - { 35 - int i; 36 - 37 - for (i = 0; shift_table[i] != state; i++) { 38 - if (shift_table[i] == -1) { 39 - if (i >= 16) 40 - oops("too many shift states", NULL); 41 - shift_table[i] = state; 42 - max_states = i+1; 43 - break; 44 - } 45 - } 46 - return i; 47 - } 48 - 49 - int 50 - main(int argc, char *argv[]) 51 - { 52 - int value, shift_state, i, spk_val = 0, lock_val = 0; 53 - int max_key_used = 0, num_keys_used = 0; 54 - struct st_key *this; 55 - struct st_key_init *p_init; 56 - char buffer[256]; 57 - 58 - bzero(key_table, sizeof(key_table)); 59 - bzero(key_data, sizeof(key_data)); 60 - 61 - shift_table[0] = 0; 62 - for (i = 1; i <= 16; i++) 63 - shift_table[i] = -1; 64 - 65 - if (argc < 2) { 66 - fputs("usage: genmap filename\n", stderr); 67 - exit(1); 68 - } 69 - 70 - for (p_init = init_key_data; p_init->name[0] != '.'; p_init++) 71 - add_key(p_init->name, p_init->value, p_init->shift); 72 - 73 - open_input(".", argv[1]); 74 - while (fgets(buffer, sizeof(buffer), infile)) { 75 - lc++; 76 - value = shift_state = 0; 77 - 78 - cp = strtok(buffer, delims); 79 - if (*cp == '#') 80 - continue; 81 - 82 - while (cp) { 83 - if (*cp == '=') 84 - break; 85 - this = find_key(cp); 86 - if (this == NULL) 87 - oops("unknown key/modifier", cp); 88 - if (this->shift == is_shift) { 89 - if (value) 90 - oops("modifiers must come first", cp); 91 - shift_state += this->value; 92 - } else if (this->shift == is_input) 93 - value = this->value; 94 - else 95 - oops("bad modifier or key", cp); 96 - cp = strtok(0, delims); 97 - } 98 - if (!cp) 99 - oops("no = found", NULL); 100 - 101 - cp = strtok(0, delims); 102 - if (!cp) 103 - oops("no speakup function after =", NULL); 104 - 105 - this = find_key(cp); 106 - if (this == NULL || this->shift != is_spk) 107 - oops("invalid speakup function", cp); 108 - 109 - i = get_shift_value(shift_state); 110 - if (key_data[value][i]) { 111 - while (--cp > buffer) 112 - if (!*cp) 113 - *cp = ' '; 114 - oops("two functions on same key combination", cp); 115 - } 116 - key_data[value][i] = (char)this->value; 117 - if (value > max_key_used) 118 - max_key_used = value; 119 - } 120 - fclose(infile); 121 - 122 - this = find_key("spk_key"); 123 - if (this) 124 - spk_val = this->value; 125 - 126 - this = find_key("spk_lock"); 127 - if (this) 128 - lock_val = this->value; 129 - 130 - for (lc = 1; lc <= max_key_used; lc++) { 131 - kp = key_data[lc]; 132 - if (!memcmp(key_data[0], kp, 16)) 133 - continue; 134 - num_keys_used++; 135 - for (i = 0; i < max_states; i++) { 136 - if (kp[i] != spk_val && kp[i] != lock_val) 137 - continue; 138 - shift_state = shift_table[i]; 139 - if (shift_state&16) 140 - continue; 141 - shift_state = get_shift_value(shift_state+16); 142 - kp[shift_state] = kp[i]; 143 - /* fill in so we can process the key up, as spk bit will be set */ 144 - } 145 - } 146 - 147 - printf("\t%d, %d, %d,\n\t", map_ver, num_keys_used, max_states); 148 - for (i = 0; i < max_states; i++) 149 - printf("%d, ", shift_table[i]); 150 - printf("%d,", flags); 151 - for (lc = 1; lc <= max_key_used; lc++) { 152 - kp = key_data[lc]; 153 - if (!memcmp(key_data[0], kp, 16)) 154 - continue; 155 - printf("\n\t%d,", lc); 156 - for (i = 0; i < max_states; i++) 157 - printf(" %d,", (unsigned int)kp[i]); 158 - } 159 - printf("\n\t0, %d\n", map_ver); 160 - 161 - exit(0); 162 - }
-125
drivers/accessibility/speakup/makemapdata.c
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 2 - /* makemapdata.c 3 - * originally written by: Kirk Reiser. 4 - * 5 - ** Copyright (C) 2002 Kirk Reiser. 6 - * Copyright (C) 2003 David Borowski. 7 - */ 8 - 9 - #include <stdlib.h> 10 - #include <stdio.h> 11 - #include <libgen.h> 12 - #include <string.h> 13 - #include <linux/version.h> 14 - #include <ctype.h> 15 - #include "utils.h" 16 - 17 - static char buffer[256]; 18 - 19 - static int get_define(void) 20 - { 21 - char *c; 22 - 23 - while (fgets(buffer, sizeof(buffer)-1, infile)) { 24 - lc++; 25 - if (strncmp(buffer, "#define", 7)) 26 - continue; 27 - c = buffer + 7; 28 - while (*c == ' ' || *c == '\t') 29 - c++; 30 - def_name = c; 31 - while (*c && *c != ' ' && *c != '\t' && *c != '\n') 32 - c++; 33 - if (!*c || *c == '\n') 34 - continue; 35 - *c++ = '\0'; 36 - while (*c == ' ' || *c == '\t' || *c == '(') 37 - c++; 38 - def_val = c; 39 - while (*c && *c != '\n' && *c != ')') 40 - c++; 41 - *c++ = '\0'; 42 - return 1; 43 - } 44 - fclose(infile); 45 - infile = 0; 46 - return 0; 47 - } 48 - 49 - int 50 - main(int argc, char *argv[]) 51 - { 52 - int value, i; 53 - struct st_key *this; 54 - const char *dir_name; 55 - char *cp; 56 - 57 - dir_name = getenv("TOPDIR"); 58 - if (!dir_name) 59 - dir_name = "."; 60 - bzero(key_table, sizeof(key_table)); 61 - add_key("shift", 1, is_shift); 62 - add_key("altgr", 2, is_shift); 63 - add_key("ctrl", 4, is_shift); 64 - add_key("alt", 8, is_shift); 65 - add_key("spk", 16, is_shift); 66 - add_key("double", 32, is_shift); 67 - 68 - open_input(dir_name, "include/linux/input.h"); 69 - while (get_define()) { 70 - if (strncmp(def_name, "KEY_", 4)) 71 - continue; 72 - value = atoi(def_val); 73 - if (value > 0 && value < MAXKEYVAL) 74 - add_key(def_name, value, is_input); 75 - } 76 - 77 - open_input(dir_name, "include/uapi/linux/input-event-codes.h"); 78 - while (get_define()) { 79 - if (strncmp(def_name, "KEY_", 4)) 80 - continue; 81 - value = atoi(def_val); 82 - if (value > 0 && value < MAXKEYVAL) 83 - add_key(def_name, value, is_input); 84 - } 85 - 86 - open_input(dir_name, "drivers/accessibility/speakup/spk_priv_keyinfo.h"); 87 - while (get_define()) { 88 - if (strlen(def_val) > 5) { 89 - //if (def_val[0] == '(') 90 - // def_val++; 91 - cp = strchr(def_val, '+'); 92 - if (!cp) 93 - continue; 94 - if (cp[-1] == ' ') 95 - cp[-1] = '\0'; 96 - *cp++ = '\0'; 97 - this = find_key(def_val); 98 - while (*cp == ' ') 99 - cp++; 100 - if (!this || *cp < '0' || *cp > '9') 101 - continue; 102 - value = this->value+atoi(cp); 103 - } else if (!strncmp(def_val, "0x", 2)) 104 - sscanf(def_val+2, "%x", &value); 105 - else if (*def_val >= '0' && *def_val <= '9') 106 - value = atoi(def_val); 107 - else 108 - continue; 109 - add_key(def_name, value, is_spk); 110 - } 111 - 112 - printf("struct st_key_init init_key_data[] = {\n"); 113 - for (i = 0; i < HASHSIZE; i++) { 114 - this = &key_table[i]; 115 - if (!this->name) 116 - continue; 117 - do { 118 - printf("\t{ \"%s\", %d, %d, },\n", this->name, this->value, this->shift); 119 - this = this->next; 120 - } while (this); 121 - } 122 - printf("\t{ \".\", 0, 0 }\n};\n"); 123 - 124 - exit(0); 125 - }
+66
drivers/accessibility/speakup/speakupmap.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 119, 62, 6, 3 + 0, 16, 20, 17, 32, 48, 0, 4 + 2, 0, 78, 0, 0, 0, 0, 5 + 3, 0, 79, 0, 0, 0, 0, 6 + 4, 0, 76, 0, 0, 0, 0, 7 + 5, 0, 77, 0, 0, 0, 0, 8 + 6, 0, 74, 0, 0, 0, 0, 9 + 7, 0, 75, 0, 0, 0, 0, 10 + 9, 0, 5, 46, 0, 0, 0, 11 + 10, 0, 4, 0, 0, 0, 0, 12 + 11, 0, 0, 1, 0, 0, 0, 13 + 12, 0, 27, 0, 33, 0, 0, 14 + 19, 0, 47, 0, 0, 0, 0, 15 + 21, 0, 29, 17, 0, 0, 0, 16 + 22, 0, 15, 0, 0, 0, 0, 17 + 23, 0, 14, 0, 0, 0, 28, 18 + 24, 0, 16, 0, 0, 0, 0, 19 + 25, 0, 30, 18, 0, 0, 0, 20 + 28, 0, 3, 26, 0, 0, 0, 21 + 35, 0, 31, 0, 0, 0, 0, 22 + 36, 0, 12, 0, 0, 0, 0, 23 + 37, 0, 11, 0, 0, 0, 22, 24 + 38, 0, 13, 0, 0, 0, 0, 25 + 39, 0, 32, 7, 0, 0, 0, 26 + 40, 0, 23, 0, 0, 0, 0, 27 + 44, 0, 44, 0, 0, 0, 0, 28 + 49, 0, 24, 0, 0, 0, 0, 29 + 50, 0, 9, 19, 6, 0, 0, 30 + 51, 0, 8, 0, 0, 0, 36, 31 + 52, 0, 10, 20, 0, 0, 0, 32 + 53, 0, 25, 0, 0, 0, 0, 33 + 55, 46, 1, 0, 0, 0, 0, 34 + 58, 128, 128, 0, 0, 0, 0, 35 + 59, 0, 45, 0, 0, 0, 0, 36 + 60, 0, 40, 0, 0, 0, 0, 37 + 61, 0, 41, 0, 0, 0, 0, 38 + 62, 0, 42, 0, 0, 0, 0, 39 + 63, 0, 34, 0, 0, 0, 0, 40 + 64, 0, 35, 0, 0, 0, 0, 41 + 65, 0, 37, 0, 0, 0, 0, 42 + 66, 0, 38, 0, 0, 0, 0, 43 + 67, 0, 66, 0, 39, 0, 0, 44 + 68, 0, 67, 0, 0, 0, 0, 45 + 71, 15, 19, 0, 0, 0, 0, 46 + 72, 14, 29, 0, 0, 28, 0, 47 + 73, 16, 17, 0, 0, 0, 0, 48 + 74, 27, 33, 0, 0, 0, 0, 49 + 75, 12, 31, 0, 0, 0, 0, 50 + 76, 11, 21, 0, 0, 22, 0, 51 + 77, 13, 32, 0, 0, 0, 0, 52 + 78, 23, 43, 0, 0, 0, 0, 53 + 79, 9, 20, 0, 0, 0, 0, 54 + 80, 8, 30, 0, 0, 36, 0, 55 + 81, 10, 18, 0, 0, 0, 0, 56 + 82, 128, 128, 0, 0, 0, 0, 57 + 83, 24, 25, 0, 0, 0, 0, 58 + 87, 0, 68, 0, 0, 0, 0, 59 + 88, 0, 69, 0, 0, 0, 0, 60 + 96, 3, 26, 0, 0, 0, 0, 61 + 98, 4, 5, 0, 0, 0, 0, 62 + 99, 2, 0, 0, 0, 0, 0, 63 + 104, 0, 6, 0, 0, 0, 0, 64 + 109, 0, 7, 0, 0, 0, 0, 65 + 125, 128, 128, 0, 0, 0, 0, 66 + 0, 119
-99
drivers/accessibility/speakup/utils.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0+ */ 2 - /* utils.h 3 - * originally written by: Kirk Reiser. 4 - * 5 - ** Copyright (C) 2002 Kirk Reiser. 6 - * Copyright (C) 2003 David Borowski. 7 - */ 8 - 9 - #include <stdio.h> 10 - 11 - #define MAXKEYS 512 12 - #define MAXKEYVAL 160 13 - #define HASHSIZE 101 14 - #define is_shift -3 15 - #define is_spk -2 16 - #define is_input -1 17 - 18 - struct st_key { 19 - char *name; 20 - struct st_key *next; 21 - int value, shift; 22 - }; 23 - 24 - struct st_key key_table[MAXKEYS]; 25 - struct st_key *extra_keys = key_table+HASHSIZE; 26 - char *def_name, *def_val; 27 - FILE *infile; 28 - int lc; 29 - 30 - char filename[256]; 31 - 32 - static inline void open_input(const char *dir_name, const char *name) 33 - { 34 - snprintf(filename, sizeof(filename), "%s/%s", dir_name, name); 35 - infile = fopen(filename, "r"); 36 - if (infile == 0) { 37 - fprintf(stderr, "can't open %s\n", filename); 38 - exit(1); 39 - } 40 - lc = 0; 41 - } 42 - 43 - static inline int oops(const char *msg, const char *info) 44 - { 45 - if (info == NULL) 46 - info = ""; 47 - fprintf(stderr, "error: file %s line %d\n", filename, lc); 48 - fprintf(stderr, "%s %s\n", msg, info); 49 - exit(1); 50 - } 51 - 52 - static inline struct st_key *hash_name(char *name) 53 - { 54 - u_char *pn = (u_char *)name; 55 - int hash = 0; 56 - 57 - while (*pn) { 58 - hash = (hash * 17) & 0xfffffff; 59 - if (isupper(*pn)) 60 - *pn = tolower(*pn); 61 - hash += (int)*pn; 62 - pn++; 63 - } 64 - hash %= HASHSIZE; 65 - return &key_table[hash]; 66 - } 67 - 68 - static inline struct st_key *find_key(char *name) 69 - { 70 - struct st_key *this = hash_name(name); 71 - 72 - while (this) { 73 - if (this->name && !strcmp(name, this->name)) 74 - return this; 75 - this = this->next; 76 - } 77 - return this; 78 - } 79 - 80 - static inline struct st_key *add_key(char *name, int value, int shift) 81 - { 82 - struct st_key *this = hash_name(name); 83 - 84 - if (extra_keys-key_table >= MAXKEYS) 85 - oops("out of key table space, enlarge MAXKEYS", NULL); 86 - if (this->name != NULL) { 87 - while (this->next) { 88 - if (!strcmp(name, this->name)) 89 - oops("attempt to add duplicate key", name); 90 - this = this->next; 91 - } 92 - this->next = extra_keys++; 93 - this = this->next; 94 - } 95 - this->name = strdup(name); 96 - this->value = value; 97 - this->shift = shift; 98 - return this; 99 - }