William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Speakup kobject implementation |
| 3 | * |
| 4 | * Copyright (C) 2009 William Hubbs |
| 5 | * |
| 6 | * This code is based on kobject-example.c, which came with linux 2.6.x. |
| 7 | * |
| 8 | * Copyright (C) 2004-2007 Greg Kroah-Hartman <greg@kroah.com> |
| 9 | * Copyright (C) 2007 Novell Inc. |
| 10 | * |
| 11 | * Released under the GPL version 2 only. |
| 12 | * |
| 13 | */ |
| 14 | #include <linux/slab.h> /* For kmalloc. */ |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/kobject.h> |
| 17 | #include <linux/string.h> |
Andy Shevchenko | 576d742 | 2013-04-30 15:27:31 -0700 | [diff] [blame] | 18 | #include <linux/string_helpers.h> |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 19 | #include <linux/sysfs.h> |
| 20 | #include <linux/ctype.h> |
| 21 | |
| 22 | #include "speakup.h" |
| 23 | #include "spk_priv.h" |
| 24 | |
| 25 | /* |
| 26 | * This is called when a user reads the characters or chartab sys file. |
| 27 | */ |
| 28 | static ssize_t chars_chartab_show(struct kobject *kobj, |
| 29 | struct kobj_attribute *attr, char *buf) |
| 30 | { |
| 31 | int i; |
| 32 | int len = 0; |
| 33 | char *cp; |
| 34 | char *buf_pointer = buf; |
| 35 | size_t bufsize = PAGE_SIZE; |
| 36 | unsigned long flags; |
| 37 | |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 38 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 39 | *buf_pointer = '\0'; |
| 40 | for (i = 0; i < 256; i++) { |
| 41 | if (bufsize <= 1) |
| 42 | break; |
| 43 | if (strcmp("characters", attr->attr.name) == 0) { |
| 44 | len = scnprintf(buf_pointer, bufsize, "%d\t%s\n", |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 45 | i, spk_characters[i]); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 46 | } else { /* show chartab entry */ |
| 47 | if (IS_TYPE(i, B_CTL)) |
| 48 | cp = "B_CTL"; |
| 49 | else if (IS_TYPE(i, WDLM)) |
| 50 | cp = "WDLM"; |
| 51 | else if (IS_TYPE(i, A_PUNC)) |
| 52 | cp = "A_PUNC"; |
| 53 | else if (IS_TYPE(i, PUNC)) |
| 54 | cp = "PUNC"; |
| 55 | else if (IS_TYPE(i, NUM)) |
| 56 | cp = "NUM"; |
| 57 | else if (IS_TYPE(i, A_CAP)) |
| 58 | cp = "A_CAP"; |
| 59 | else if (IS_TYPE(i, ALPHA)) |
| 60 | cp = "ALPHA"; |
| 61 | else if (IS_TYPE(i, B_CAPSYM)) |
| 62 | cp = "B_CAPSYM"; |
| 63 | else if (IS_TYPE(i, B_SYM)) |
| 64 | cp = "B_SYM"; |
| 65 | else |
| 66 | cp = "0"; |
| 67 | len = |
| 68 | scnprintf(buf_pointer, bufsize, "%d\t%s\n", i, cp); |
| 69 | } |
| 70 | bufsize -= len; |
| 71 | buf_pointer += len; |
| 72 | } |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 73 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 74 | return buf_pointer - buf; |
| 75 | } |
| 76 | |
| 77 | /* |
| 78 | * Print informational messages or warnings after updating |
| 79 | * character descriptions or chartab entries. |
| 80 | */ |
| 81 | static void report_char_chartab_status(int reset, int received, int used, |
| 82 | int rejected, int do_characters) |
| 83 | { |
Ebru Akagunduz | 333c474 | 2014-10-04 13:36:27 +0300 | [diff] [blame] | 84 | static char const *object_type[] = { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 85 | "character class entries", |
| 86 | "character descriptions", |
| 87 | }; |
| 88 | int len; |
| 89 | char buf[80]; |
| 90 | |
| 91 | if (reset) { |
| 92 | pr_info("%s reset to defaults\n", object_type[do_characters]); |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 93 | } else if (received) { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 94 | len = snprintf(buf, sizeof(buf), |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 95 | " updated %d of %d %s\n", |
| 96 | used, received, object_type[do_characters]); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 97 | if (rejected) |
| 98 | snprintf(buf + (len - 1), sizeof(buf) - (len - 1), |
| 99 | " with %d reject%s\n", |
| 100 | rejected, rejected > 1 ? "s" : ""); |
| 101 | printk(buf); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | /* |
| 106 | * This is called when a user changes the characters or chartab parameters. |
| 107 | */ |
| 108 | static ssize_t chars_chartab_store(struct kobject *kobj, |
| 109 | struct kobj_attribute *attr, const char *buf, size_t count) |
| 110 | { |
| 111 | char *cp = (char *) buf; |
| 112 | char *end = cp + count; /* the null at the end of the buffer */ |
| 113 | char *linefeed = NULL; |
| 114 | char keyword[MAX_DESC_LEN + 1]; |
| 115 | char *outptr = NULL; /* Will hold keyword or desc. */ |
| 116 | char *temp = NULL; |
| 117 | char *desc = NULL; |
| 118 | ssize_t retval = count; |
| 119 | unsigned long flags; |
| 120 | unsigned long index = 0; |
| 121 | int charclass = 0; |
| 122 | int received = 0; |
| 123 | int used = 0; |
| 124 | int rejected = 0; |
| 125 | int reset = 0; |
| 126 | int do_characters = !strcmp(attr->attr.name, "characters"); |
| 127 | size_t desc_length = 0; |
| 128 | int i; |
| 129 | |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 130 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 131 | while (cp < end) { |
| 132 | |
| 133 | while ((cp < end) && (*cp == ' ' || *cp == '\t')) |
| 134 | cp++; |
| 135 | |
| 136 | if (cp == end) |
| 137 | break; |
| 138 | if ((*cp == '\n') || strchr("dDrR", *cp)) { |
| 139 | reset = 1; |
| 140 | break; |
| 141 | } |
| 142 | received++; |
| 143 | |
| 144 | linefeed = strchr(cp, '\n'); |
| 145 | if (!linefeed) { |
| 146 | rejected++; |
| 147 | break; |
| 148 | } |
| 149 | |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 150 | if (!isdigit(*cp)) { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 151 | rejected++; |
| 152 | cp = linefeed + 1; |
| 153 | continue; |
| 154 | } |
| 155 | |
| 156 | index = simple_strtoul(cp, &temp, 10); |
| 157 | if (index > 255) { |
| 158 | rejected++; |
| 159 | cp = linefeed + 1; |
| 160 | continue; |
| 161 | } |
| 162 | |
| 163 | while ((temp < linefeed) && (*temp == ' ' || *temp == '\t')) |
| 164 | temp++; |
| 165 | |
| 166 | desc_length = linefeed - temp; |
| 167 | if (desc_length > MAX_DESC_LEN) { |
| 168 | rejected++; |
| 169 | cp = linefeed + 1; |
| 170 | continue; |
| 171 | } |
| 172 | if (do_characters) { |
| 173 | desc = kmalloc(desc_length + 1, GFP_ATOMIC); |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 174 | if (!desc) { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 175 | retval = -ENOMEM; |
| 176 | reset = 1; /* just reset on error. */ |
| 177 | break; |
| 178 | } |
| 179 | outptr = desc; |
| 180 | } else { |
| 181 | outptr = keyword; |
| 182 | } |
| 183 | |
| 184 | for (i = 0; i < desc_length; i++) |
| 185 | outptr[i] = temp[i]; |
| 186 | outptr[desc_length] = '\0'; |
| 187 | |
| 188 | if (do_characters) { |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 189 | if (spk_characters[index] != spk_default_chars[index]) |
| 190 | kfree(spk_characters[index]); |
| 191 | spk_characters[index] = desc; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 192 | used++; |
| 193 | } else { |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 194 | charclass = spk_chartab_get_value(keyword); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 195 | if (charclass == 0) { |
| 196 | rejected++; |
| 197 | cp = linefeed + 1; |
| 198 | continue; |
| 199 | } |
| 200 | if (charclass != spk_chartab[index]) { |
| 201 | spk_chartab[index] = charclass; |
| 202 | used++; |
| 203 | } |
| 204 | } |
| 205 | cp = linefeed + 1; |
| 206 | } |
| 207 | |
| 208 | if (reset) { |
| 209 | if (do_characters) |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 210 | spk_reset_default_chars(); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 211 | else |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 212 | spk_reset_default_chartab(); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 213 | } |
| 214 | |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 215 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 216 | report_char_chartab_status(reset, received, used, rejected, |
| 217 | do_characters); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 218 | return retval; |
| 219 | } |
| 220 | |
| 221 | /* |
| 222 | * This is called when a user reads the keymap parameter. |
| 223 | */ |
| 224 | static ssize_t keymap_show(struct kobject *kobj, struct kobj_attribute *attr, |
| 225 | char *buf) |
| 226 | { |
| 227 | char *cp = buf; |
| 228 | int i; |
| 229 | int n; |
| 230 | int num_keys; |
| 231 | int nstates; |
| 232 | u_char *cp1; |
| 233 | u_char ch; |
| 234 | unsigned long flags; |
Domagoj Trsan | 8e69a81 | 2014-09-09 20:04:34 +0200 | [diff] [blame] | 235 | |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 236 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 237 | cp1 = spk_key_buf + SHIFT_TBL_SIZE; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 238 | num_keys = (int)(*cp1); |
| 239 | nstates = (int)cp1[1]; |
| 240 | cp += sprintf(cp, "%d, %d, %d,\n", KEY_MAP_VER, num_keys, nstates); |
| 241 | cp1 += 2; /* now pointing at shift states */ |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 242 | /* dump num_keys+1 as first row is shift states + flags, |
Aleksei Fedotov | 13d825e | 2015-08-14 22:34:37 +0300 | [diff] [blame] | 243 | * each subsequent row is key + states |
| 244 | */ |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 245 | for (n = 0; n <= num_keys; n++) { |
| 246 | for (i = 0; i <= nstates; i++) { |
| 247 | ch = *cp1++; |
| 248 | cp += sprintf(cp, "%d,", (int)ch); |
| 249 | *cp++ = (i < nstates) ? SPACE : '\n'; |
| 250 | } |
| 251 | } |
| 252 | cp += sprintf(cp, "0, %d\n", KEY_MAP_VER); |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 253 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
Sandhya Bankar | a04c28d | 2016-09-22 15:27:30 +0530 | [diff] [blame] | 254 | return (int)(cp - buf); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | /* |
| 258 | * This is called when a user changes the keymap parameter. |
| 259 | */ |
| 260 | static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr, |
| 261 | const char *buf, size_t count) |
| 262 | { |
| 263 | int i; |
| 264 | ssize_t ret = count; |
| 265 | char *in_buff = NULL; |
| 266 | char *cp; |
| 267 | u_char *cp1; |
| 268 | unsigned long flags; |
| 269 | |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 270 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
Thomas Meyer | 1aa5eb6 | 2011-11-12 13:11:18 +0100 | [diff] [blame] | 271 | in_buff = kmemdup(buf, count + 1, GFP_ATOMIC); |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 272 | if (!in_buff) { |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 273 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 274 | return -ENOMEM; |
| 275 | } |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 276 | if (strchr("dDrR", *in_buff)) { |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 277 | spk_set_key_info(spk_key_defaults, spk_key_buf); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 278 | pr_info("keymap set to default values\n"); |
| 279 | kfree(in_buff); |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 280 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 281 | return count; |
| 282 | } |
| 283 | if (in_buff[count - 1] == '\n') |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 284 | in_buff[count - 1] = '\0'; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 285 | cp = in_buff; |
| 286 | cp1 = (u_char *)in_buff; |
| 287 | for (i = 0; i < 3; i++) { |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 288 | cp = spk_s2uchar(cp, cp1); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 289 | cp1++; |
| 290 | } |
Sandhya Bankar | a04c28d | 2016-09-22 15:27:30 +0530 | [diff] [blame] | 291 | i = (int)cp1[-2] + 1; |
| 292 | i *= (int)cp1[-1] + 1; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 293 | i += 2; /* 0 and last map ver */ |
| 294 | if (cp1[-3] != KEY_MAP_VER || cp1[-1] > 10 || |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 295 | i+SHIFT_TBL_SIZE+4 >= sizeof(spk_key_buf)) { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 296 | pr_warn("i %d %d %d %d\n", i, |
| 297 | (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]); |
| 298 | kfree(in_buff); |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 299 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 300 | return -EINVAL; |
| 301 | } |
| 302 | while (--i >= 0) { |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 303 | cp = spk_s2uchar(cp, cp1); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 304 | cp1++; |
| 305 | if (!(*cp)) |
| 306 | break; |
| 307 | } |
| 308 | if (i != 0 || cp1[-1] != KEY_MAP_VER || cp1[-2] != 0) { |
| 309 | ret = -EINVAL; |
| 310 | pr_warn("end %d %d %d %d\n", i, |
| 311 | (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]); |
| 312 | } else { |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 313 | if (spk_set_key_info(in_buff, spk_key_buf)) { |
| 314 | spk_set_key_info(spk_key_defaults, spk_key_buf); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 315 | ret = -EINVAL; |
| 316 | pr_warn("set key failed\n"); |
| 317 | } |
| 318 | } |
| 319 | kfree(in_buff); |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 320 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 321 | return ret; |
| 322 | } |
| 323 | |
| 324 | /* |
| 325 | * This is called when a user changes the value of the silent parameter. |
| 326 | */ |
| 327 | static ssize_t silent_store(struct kobject *kobj, struct kobj_attribute *attr, |
| 328 | const char *buf, size_t count) |
| 329 | { |
| 330 | int len; |
| 331 | struct vc_data *vc = vc_cons[fg_console].d; |
| 332 | char ch = 0; |
| 333 | char shut; |
| 334 | unsigned long flags; |
| 335 | |
| 336 | len = strlen(buf); |
roel kluin | e7bf352 | 2011-01-03 11:59:48 -0800 | [diff] [blame] | 337 | if (len > 0 && len < 3) { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 338 | ch = buf[0]; |
| 339 | if (ch == '\n') |
| 340 | ch = '0'; |
| 341 | } |
| 342 | if (ch < '0' || ch > '7') { |
| 343 | pr_warn("silent value '%c' not in range (0,7)\n", ch); |
| 344 | return -EINVAL; |
| 345 | } |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 346 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 347 | if (ch&2) { |
| 348 | shut = 1; |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 349 | spk_do_flush(); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 350 | } else { |
| 351 | shut = 0; |
| 352 | } |
Sandhya Bankar | a04c28d | 2016-09-22 15:27:30 +0530 | [diff] [blame] | 353 | if (ch & 4) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 354 | shut |= 0x40; |
Sandhya Bankar | a04c28d | 2016-09-22 15:27:30 +0530 | [diff] [blame] | 355 | if (ch & 1) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 356 | spk_shut_up |= shut; |
| 357 | else |
| 358 | spk_shut_up &= ~shut; |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 359 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 360 | return count; |
| 361 | } |
| 362 | |
| 363 | /* |
| 364 | * This is called when a user reads the synth setting. |
| 365 | */ |
| 366 | static ssize_t synth_show(struct kobject *kobj, struct kobj_attribute *attr, |
| 367 | char *buf) |
| 368 | { |
| 369 | int rv; |
| 370 | |
Shraddha Barke | a90624c | 2015-09-11 11:32:28 +0530 | [diff] [blame] | 371 | if (!synth) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 372 | rv = sprintf(buf, "%s\n", "none"); |
| 373 | else |
| 374 | rv = sprintf(buf, "%s\n", synth->name); |
| 375 | return rv; |
| 376 | } |
| 377 | |
| 378 | /* |
| 379 | * This is called when a user requests to change synthesizers. |
| 380 | */ |
| 381 | static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr, |
| 382 | const char *buf, size_t count) |
| 383 | { |
| 384 | int len; |
| 385 | char new_synth_name[10]; |
| 386 | |
| 387 | len = strlen(buf); |
| 388 | if (len < 2 || len > 9) |
| 389 | return -EINVAL; |
| 390 | strncpy(new_synth_name, buf, len); |
| 391 | if (new_synth_name[len - 1] == '\n') |
| 392 | len--; |
| 393 | new_synth_name[len] = '\0'; |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 394 | spk_strlwr(new_synth_name); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 395 | if ((synth != NULL) && (!strcmp(new_synth_name, synth->name))) { |
| 396 | pr_warn("%s already in use\n", new_synth_name); |
| 397 | } else if (synth_init(new_synth_name) != 0) { |
| 398 | pr_warn("failed to init synth %s\n", new_synth_name); |
| 399 | return -ENODEV; |
| 400 | } |
| 401 | return count; |
| 402 | } |
| 403 | |
| 404 | /* |
| 405 | * This is called when text is sent to the synth via the synth_direct file. |
| 406 | */ |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 407 | static ssize_t synth_direct_store(struct kobject *kobj, |
| 408 | struct kobj_attribute *attr, const char *buf, size_t count) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 409 | { |
| 410 | u_char tmp[256]; |
| 411 | int len; |
| 412 | int bytes; |
| 413 | const char *ptr = buf; |
Pavel Andrianov | 77795318 | 2016-09-05 16:17:47 +0300 | [diff] [blame] | 414 | unsigned long flags; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 415 | |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 416 | if (!synth) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 417 | return -EPERM; |
| 418 | |
| 419 | len = strlen(buf); |
Pavel Andrianov | 77795318 | 2016-09-05 16:17:47 +0300 | [diff] [blame] | 420 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 421 | while (len > 0) { |
| 422 | bytes = min_t(size_t, len, 250); |
| 423 | strncpy(tmp, ptr, bytes); |
| 424 | tmp[bytes] = '\0'; |
Andy Shevchenko | 576d742 | 2013-04-30 15:27:31 -0700 | [diff] [blame] | 425 | string_unescape_any_inplace(tmp); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 426 | synth_printf("%s", tmp); |
| 427 | ptr += bytes; |
| 428 | len -= bytes; |
| 429 | } |
Pavel Andrianov | 77795318 | 2016-09-05 16:17:47 +0300 | [diff] [blame] | 430 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 431 | return count; |
| 432 | } |
| 433 | |
| 434 | /* |
| 435 | * This function is called when a user reads the version. |
| 436 | */ |
| 437 | static ssize_t version_show(struct kobject *kobj, struct kobj_attribute *attr, |
| 438 | char *buf) |
| 439 | { |
| 440 | char *cp; |
| 441 | |
| 442 | cp = buf; |
| 443 | cp += sprintf(cp, "Speakup version %s\n", SPEAKUP_VERSION); |
| 444 | if (synth) |
| 445 | cp += sprintf(cp, "%s synthesizer driver version %s\n", |
| 446 | synth->name, synth->version); |
| 447 | return cp - buf; |
| 448 | } |
| 449 | |
| 450 | /* |
| 451 | * This is called when a user reads the punctuation settings. |
| 452 | */ |
| 453 | static ssize_t punc_show(struct kobject *kobj, struct kobj_attribute *attr, |
| 454 | char *buf) |
| 455 | { |
| 456 | int i; |
| 457 | char *cp = buf; |
| 458 | struct st_var_header *p_header; |
| 459 | struct punc_var_t *var; |
| 460 | struct st_bits_data *pb; |
| 461 | short mask; |
| 462 | unsigned long flags; |
| 463 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 464 | p_header = spk_var_header_by_name(attr->attr.name); |
Shraddha Barke | a90624c | 2015-09-11 11:32:28 +0530 | [diff] [blame] | 465 | if (!p_header) { |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 466 | pr_warn("p_header is null, attr->attr.name is %s\n", |
| 467 | attr->attr.name); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 468 | return -EINVAL; |
| 469 | } |
| 470 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 471 | var = spk_get_punc_var(p_header->var_id); |
Shraddha Barke | a90624c | 2015-09-11 11:32:28 +0530 | [diff] [blame] | 472 | if (!var) { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 473 | pr_warn("var is null, p_header->var_id is %i\n", |
| 474 | p_header->var_id); |
| 475 | return -EINVAL; |
| 476 | } |
| 477 | |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 478 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 479 | pb = (struct st_bits_data *) &spk_punc_info[var->value]; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 480 | mask = pb->mask; |
| 481 | for (i = 33; i < 128; i++) { |
| 482 | if (!(spk_chartab[i]&mask)) |
| 483 | continue; |
| 484 | *cp++ = (char)i; |
| 485 | } |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 486 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 487 | return cp-buf; |
| 488 | } |
| 489 | |
| 490 | /* |
| 491 | * This is called when a user changes the punctuation settings. |
| 492 | */ |
| 493 | static ssize_t punc_store(struct kobject *kobj, struct kobj_attribute *attr, |
| 494 | const char *buf, size_t count) |
| 495 | { |
| 496 | int x; |
| 497 | struct st_var_header *p_header; |
| 498 | struct punc_var_t *var; |
| 499 | char punc_buf[100]; |
| 500 | unsigned long flags; |
| 501 | |
| 502 | x = strlen(buf); |
| 503 | if (x < 1 || x > 99) |
| 504 | return -EINVAL; |
| 505 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 506 | p_header = spk_var_header_by_name(attr->attr.name); |
Shraddha Barke | a90624c | 2015-09-11 11:32:28 +0530 | [diff] [blame] | 507 | if (!p_header) { |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 508 | pr_warn("p_header is null, attr->attr.name is %s\n", |
| 509 | attr->attr.name); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 510 | return -EINVAL; |
| 511 | } |
| 512 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 513 | var = spk_get_punc_var(p_header->var_id); |
Shraddha Barke | a90624c | 2015-09-11 11:32:28 +0530 | [diff] [blame] | 514 | if (!var) { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 515 | pr_warn("var is null, p_header->var_id is %i\n", |
| 516 | p_header->var_id); |
| 517 | return -EINVAL; |
| 518 | } |
| 519 | |
| 520 | strncpy(punc_buf, buf, x); |
| 521 | |
| 522 | while (x && punc_buf[x - 1] == '\n') |
| 523 | x--; |
| 524 | punc_buf[x] = '\0'; |
| 525 | |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 526 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 527 | |
| 528 | if (*punc_buf == 'd' || *punc_buf == 'r') |
Sachin Kamat | aee175f | 2013-05-22 14:37:24 +0530 | [diff] [blame] | 529 | x = spk_set_mask_bits(NULL, var->value, 3); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 530 | else |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 531 | x = spk_set_mask_bits(punc_buf, var->value, 3); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 532 | |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 533 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 534 | return count; |
| 535 | } |
| 536 | |
| 537 | /* |
| 538 | * This function is called when a user reads one of the variable parameters. |
| 539 | */ |
| 540 | ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr, |
| 541 | char *buf) |
| 542 | { |
| 543 | int rv = 0; |
| 544 | struct st_var_header *param; |
| 545 | struct var_t *var; |
| 546 | char *cp1; |
| 547 | char *cp; |
| 548 | char ch; |
| 549 | unsigned long flags; |
| 550 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 551 | param = spk_var_header_by_name(attr->attr.name); |
Shraddha Barke | a90624c | 2015-09-11 11:32:28 +0530 | [diff] [blame] | 552 | if (!param) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 553 | return -EINVAL; |
| 554 | |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 555 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 556 | var = (struct var_t *) param->data; |
| 557 | switch (param->var_type) { |
| 558 | case VAR_NUM: |
| 559 | case VAR_TIME: |
| 560 | if (var) |
| 561 | rv = sprintf(buf, "%i\n", var->u.n.value); |
| 562 | else |
| 563 | rv = sprintf(buf, "0\n"); |
| 564 | break; |
| 565 | case VAR_STRING: |
| 566 | if (var) { |
| 567 | cp1 = buf; |
| 568 | *cp1++ = '"'; |
| 569 | for (cp = (char *)param->p_val; (ch = *cp); cp++) { |
| 570 | if (ch >= ' ' && ch < '~') |
| 571 | *cp1++ = ch; |
| 572 | else |
Panir.Nyan | 25c0486 | 2014-12-24 04:07:32 +0000 | [diff] [blame] | 573 | cp1 += sprintf(cp1, "\\x%02x", ch); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 574 | } |
| 575 | *cp1++ = '"'; |
| 576 | *cp1++ = '\n'; |
| 577 | *cp1 = '\0'; |
| 578 | rv = cp1-buf; |
| 579 | } else { |
| 580 | rv = sprintf(buf, "\"\"\n"); |
| 581 | } |
| 582 | break; |
| 583 | default: |
| 584 | rv = sprintf(buf, "Bad parameter %s, type %i\n", |
| 585 | param->name, param->var_type); |
| 586 | break; |
| 587 | } |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 588 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 589 | return rv; |
| 590 | } |
| 591 | EXPORT_SYMBOL_GPL(spk_var_show); |
| 592 | |
| 593 | /* |
Raphael S.Carvalho | b71600b | 2013-09-02 19:20:18 -0300 | [diff] [blame] | 594 | * Used to reset either default_pitch or default_vol. |
| 595 | */ |
| 596 | static inline void spk_reset_default_value(char *header_name, |
| 597 | int *synth_default_value, int idx) |
| 598 | { |
| 599 | struct st_var_header *param; |
| 600 | |
| 601 | if (synth && synth_default_value) { |
| 602 | param = spk_var_header_by_name(header_name); |
| 603 | if (param) { |
| 604 | spk_set_num_var(synth_default_value[idx], |
| 605 | param, E_NEW_DEFAULT); |
| 606 | spk_set_num_var(0, param, E_DEFAULT); |
| 607 | pr_info("%s reset to default value\n", param->name); |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | /* |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 613 | * This function is called when a user echos a value to one of the |
| 614 | * variable parameters. |
| 615 | */ |
| 616 | ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, |
| 617 | const char *buf, size_t count) |
| 618 | { |
| 619 | struct st_var_header *param; |
| 620 | int ret; |
| 621 | int len; |
| 622 | char *cp; |
| 623 | struct var_t *var_data; |
Ashvini Varatharaj | a8eecad | 2013-10-19 20:58:26 +0530 | [diff] [blame] | 624 | long value; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 625 | unsigned long flags; |
| 626 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 627 | param = spk_var_header_by_name(attr->attr.name); |
Shraddha Barke | a90624c | 2015-09-11 11:32:28 +0530 | [diff] [blame] | 628 | if (!param) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 629 | return -EINVAL; |
Shraddha Barke | a90624c | 2015-09-11 11:32:28 +0530 | [diff] [blame] | 630 | if (!param->data) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 631 | return 0; |
| 632 | ret = 0; |
Andy Shevchenko | 576d742 | 2013-04-30 15:27:31 -0700 | [diff] [blame] | 633 | cp = (char *)buf; |
| 634 | string_unescape_any_inplace(cp); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 635 | |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 636 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 637 | switch (param->var_type) { |
| 638 | case VAR_NUM: |
| 639 | case VAR_TIME: |
| 640 | if (*cp == 'd' || *cp == 'r' || *cp == '\0') |
| 641 | len = E_DEFAULT; |
| 642 | else if (*cp == '+' || *cp == '-') |
| 643 | len = E_INC; |
| 644 | else |
| 645 | len = E_SET; |
Ashvini Varatharaj | a8eecad | 2013-10-19 20:58:26 +0530 | [diff] [blame] | 646 | if (kstrtol(cp, 10, &value) == 0) |
| 647 | ret = spk_set_num_var(value, param, len); |
| 648 | else |
Hayato Suzuki | ea143c4 | 2014-04-16 20:57:14 +0900 | [diff] [blame] | 649 | pr_warn("overflow or parsing error has occurred"); |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 650 | if (ret == -ERANGE) { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 651 | var_data = param->data; |
| 652 | pr_warn("value for %s out of range, expect %d to %d\n", |
Raphael S.Carvalho | b71600b | 2013-09-02 19:20:18 -0300 | [diff] [blame] | 653 | param->name, |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 654 | var_data->u.n.low, var_data->u.n.high); |
| 655 | } |
Raphael S.Carvalho | b71600b | 2013-09-02 19:20:18 -0300 | [diff] [blame] | 656 | |
| 657 | /* |
| 658 | * If voice was just changed, we might need to reset our default |
| 659 | * pitch and volume. |
| 660 | */ |
Christopher Brannon | faf487b | 2013-09-11 10:05:27 -0700 | [diff] [blame] | 661 | if (param->var_id == VOICE && synth && |
| 662 | (ret == 0 || ret == -ERESTART)) { |
| 663 | var_data = param->data; |
| 664 | value = var_data->u.n.value; |
Raphael S.Carvalho | b71600b | 2013-09-02 19:20:18 -0300 | [diff] [blame] | 665 | spk_reset_default_value("pitch", synth->default_pitch, |
| 666 | value); |
| 667 | spk_reset_default_value("vol", synth->default_vol, |
| 668 | value); |
| 669 | } |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 670 | break; |
| 671 | case VAR_STRING: |
Raphael S.Carvalho | b71600b | 2013-09-02 19:20:18 -0300 | [diff] [blame] | 672 | len = strlen(cp); |
| 673 | if ((len >= 1) && (cp[len - 1] == '\n')) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 674 | --len; |
Raphael S.Carvalho | b71600b | 2013-09-02 19:20:18 -0300 | [diff] [blame] | 675 | if ((len >= 2) && (cp[0] == '"') && (cp[len - 1] == '"')) { |
| 676 | ++cp; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 677 | len -= 2; |
| 678 | } |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 679 | cp[len] = '\0'; |
Raphael S.Carvalho | b71600b | 2013-09-02 19:20:18 -0300 | [diff] [blame] | 680 | ret = spk_set_string_var(cp, param, len); |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 681 | if (ret == -E2BIG) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 682 | pr_warn("value too long for %s\n", |
Raphael S.Carvalho | b71600b | 2013-09-02 19:20:18 -0300 | [diff] [blame] | 683 | param->name); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 684 | break; |
| 685 | default: |
| 686 | pr_warn("%s unknown type %d\n", |
| 687 | param->name, (int)param->var_type); |
| 688 | break; |
| 689 | } |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 690 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 691 | |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 692 | if (ret == -ERESTART) |
Raphael S.Carvalho | b71600b | 2013-09-02 19:20:18 -0300 | [diff] [blame] | 693 | pr_info("%s reset to default value\n", param->name); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 694 | return count; |
| 695 | } |
| 696 | EXPORT_SYMBOL_GPL(spk_var_store); |
| 697 | |
| 698 | /* |
| 699 | * Functions for reading and writing lists of i18n messages. Incomplete. |
| 700 | */ |
| 701 | |
| 702 | static ssize_t message_show_helper(char *buf, enum msg_index_t first, |
| 703 | enum msg_index_t last) |
| 704 | { |
| 705 | size_t bufsize = PAGE_SIZE; |
| 706 | char *buf_pointer = buf; |
| 707 | int printed; |
| 708 | enum msg_index_t cursor; |
| 709 | int index = 0; |
| 710 | *buf_pointer = '\0'; /* buf_pointer always looking at a NUL byte. */ |
| 711 | |
| 712 | for (cursor = first; cursor <= last; cursor++, index++) { |
| 713 | if (bufsize <= 1) |
| 714 | break; |
| 715 | printed = scnprintf(buf_pointer, bufsize, "%d\t%s\n", |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 716 | index, spk_msg_get(cursor)); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 717 | buf_pointer += printed; |
| 718 | bufsize -= printed; |
| 719 | } |
| 720 | |
| 721 | return buf_pointer - buf; |
| 722 | } |
| 723 | |
| 724 | static void report_msg_status(int reset, int received, int used, |
| 725 | int rejected, char *groupname) |
| 726 | { |
| 727 | int len; |
| 728 | char buf[160]; |
| 729 | |
| 730 | if (reset) { |
| 731 | pr_info("i18n messages from group %s reset to defaults\n", |
| 732 | groupname); |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 733 | } else if (received) { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 734 | len = snprintf(buf, sizeof(buf), |
| 735 | " updated %d of %d i18n messages from group %s\n", |
| 736 | used, received, groupname); |
| 737 | if (rejected) |
| 738 | snprintf(buf + (len - 1), sizeof(buf) - (len - 1), |
| 739 | " with %d reject%s\n", |
| 740 | rejected, rejected > 1 ? "s" : ""); |
| 741 | printk(buf); |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | static ssize_t message_store_helper(const char *buf, size_t count, |
| 746 | struct msg_group_t *group) |
| 747 | { |
| 748 | char *cp = (char *) buf; |
| 749 | char *end = cp + count; |
| 750 | char *linefeed = NULL; |
| 751 | char *temp = NULL; |
| 752 | ssize_t msg_stored = 0; |
| 753 | ssize_t retval = count; |
| 754 | size_t desc_length = 0; |
| 755 | unsigned long index = 0; |
| 756 | int received = 0; |
| 757 | int used = 0; |
| 758 | int rejected = 0; |
| 759 | int reset = 0; |
| 760 | enum msg_index_t firstmessage = group->start; |
| 761 | enum msg_index_t lastmessage = group->end; |
| 762 | enum msg_index_t curmessage; |
| 763 | |
| 764 | while (cp < end) { |
| 765 | |
| 766 | while ((cp < end) && (*cp == ' ' || *cp == '\t')) |
| 767 | cp++; |
| 768 | |
| 769 | if (cp == end) |
| 770 | break; |
| 771 | if (strchr("dDrR", *cp)) { |
| 772 | reset = 1; |
| 773 | break; |
| 774 | } |
| 775 | received++; |
| 776 | |
| 777 | linefeed = strchr(cp, '\n'); |
| 778 | if (!linefeed) { |
| 779 | rejected++; |
| 780 | break; |
| 781 | } |
| 782 | |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 783 | if (!isdigit(*cp)) { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 784 | rejected++; |
| 785 | cp = linefeed + 1; |
| 786 | continue; |
| 787 | } |
| 788 | |
| 789 | index = simple_strtoul(cp, &temp, 10); |
| 790 | |
| 791 | while ((temp < linefeed) && (*temp == ' ' || *temp == '\t')) |
| 792 | temp++; |
| 793 | |
| 794 | desc_length = linefeed - temp; |
| 795 | curmessage = firstmessage + index; |
| 796 | |
| 797 | /* |
| 798 | * Note the check (curmessage < firstmessage). It is not |
| 799 | * redundant. Suppose that the user gave us an index |
| 800 | * equal to ULONG_MAX - 1. If firstmessage > 1, then |
| 801 | * firstmessage + index < firstmessage! |
| 802 | */ |
| 803 | |
| 804 | if ((curmessage < firstmessage) || (curmessage > lastmessage)) { |
| 805 | rejected++; |
| 806 | cp = linefeed + 1; |
| 807 | continue; |
| 808 | } |
| 809 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 810 | msg_stored = spk_msg_set(curmessage, temp, desc_length); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 811 | if (msg_stored < 0) { |
| 812 | retval = msg_stored; |
| 813 | if (msg_stored == -ENOMEM) |
| 814 | reset = 1; |
| 815 | break; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 816 | } |
| 817 | |
Yeliz Taneroglu | 1f74d5f | 2014-10-03 14:04:25 +0300 | [diff] [blame] | 818 | used++; |
| 819 | |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 820 | cp = linefeed + 1; |
| 821 | } |
| 822 | |
| 823 | if (reset) |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 824 | spk_reset_msg_group(group); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 825 | |
| 826 | report_msg_status(reset, received, used, rejected, group->name); |
| 827 | return retval; |
| 828 | } |
| 829 | |
| 830 | static ssize_t message_show(struct kobject *kobj, |
| 831 | struct kobj_attribute *attr, char *buf) |
| 832 | { |
| 833 | ssize_t retval = 0; |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 834 | struct msg_group_t *group = spk_find_msg_group(attr->attr.name); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 835 | unsigned long flags; |
| 836 | |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 837 | BUG_ON(!group); |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 838 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 839 | retval = message_show_helper(buf, group->start, group->end); |
William Hubbs | c2d7f74 | 2013-05-13 00:02:53 -0500 | [diff] [blame] | 840 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 841 | return retval; |
| 842 | } |
| 843 | |
| 844 | static ssize_t message_store(struct kobject *kobj, struct kobj_attribute *attr, |
| 845 | const char *buf, size_t count) |
| 846 | { |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 847 | struct msg_group_t *group = spk_find_msg_group(attr->attr.name); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 848 | |
William Hubbs | f1c6b7f | 2010-10-12 11:39:30 -0500 | [diff] [blame] | 849 | BUG_ON(!group); |
Haneen Mohammed | f7d6354 | 2015-03-08 00:03:51 +0300 | [diff] [blame] | 850 | return message_store_helper(buf, count, group); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 851 | } |
| 852 | |
| 853 | /* |
| 854 | * Declare the attributes. |
| 855 | */ |
| 856 | static struct kobj_attribute keymap_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 857 | __ATTR_RW(keymap); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 858 | static struct kobj_attribute silent_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 859 | __ATTR_WO(silent); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 860 | static struct kobj_attribute synth_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 861 | __ATTR_RW(synth); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 862 | static struct kobj_attribute synth_direct_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 863 | __ATTR_WO(synth_direct); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 864 | static struct kobj_attribute version_attribute = |
| 865 | __ATTR_RO(version); |
| 866 | |
| 867 | static struct kobj_attribute delimiters_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 868 | __ATTR(delimiters, S_IWUSR | S_IRUGO, punc_show, punc_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 869 | static struct kobj_attribute ex_num_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 870 | __ATTR(ex_num, S_IWUSR | S_IRUGO, punc_show, punc_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 871 | static struct kobj_attribute punc_all_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 872 | __ATTR(punc_all, S_IWUSR | S_IRUGO, punc_show, punc_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 873 | static struct kobj_attribute punc_most_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 874 | __ATTR(punc_most, S_IWUSR | S_IRUGO, punc_show, punc_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 875 | static struct kobj_attribute punc_some_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 876 | __ATTR(punc_some, S_IWUSR | S_IRUGO, punc_show, punc_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 877 | static struct kobj_attribute repeats_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 878 | __ATTR(repeats, S_IWUSR | S_IRUGO, punc_show, punc_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 879 | |
| 880 | static struct kobj_attribute attrib_bleep_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 881 | __ATTR(attrib_bleep, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 882 | static struct kobj_attribute bell_pos_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 883 | __ATTR(bell_pos, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 884 | static struct kobj_attribute bleep_time_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 885 | __ATTR(bleep_time, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 886 | static struct kobj_attribute bleeps_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 887 | __ATTR(bleeps, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 888 | static struct kobj_attribute cursor_time_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 889 | __ATTR(cursor_time, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 890 | static struct kobj_attribute key_echo_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 891 | __ATTR(key_echo, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 892 | static struct kobj_attribute no_interrupt_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 893 | __ATTR(no_interrupt, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 894 | static struct kobj_attribute punc_level_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 895 | __ATTR(punc_level, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 896 | static struct kobj_attribute reading_punc_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 897 | __ATTR(reading_punc, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 898 | static struct kobj_attribute say_control_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 899 | __ATTR(say_control, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 900 | static struct kobj_attribute say_word_ctl_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 901 | __ATTR(say_word_ctl, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 902 | static struct kobj_attribute spell_delay_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 903 | __ATTR(spell_delay, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 904 | |
| 905 | /* |
| 906 | * These attributes are i18n related. |
| 907 | */ |
| 908 | static struct kobj_attribute announcements_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 909 | __ATTR(announcements, S_IWUSR | S_IRUGO, message_show, message_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 910 | static struct kobj_attribute characters_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 911 | __ATTR(characters, S_IWUSR | S_IRUGO, chars_chartab_show, |
Roxana Blaj | 225557b | 2014-09-15 14:58:44 +0300 | [diff] [blame] | 912 | chars_chartab_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 913 | static struct kobj_attribute chartab_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 914 | __ATTR(chartab, S_IWUSR | S_IRUGO, chars_chartab_show, |
Roxana Blaj | 225557b | 2014-09-15 14:58:44 +0300 | [diff] [blame] | 915 | chars_chartab_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 916 | static struct kobj_attribute ctl_keys_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 917 | __ATTR(ctl_keys, S_IWUSR | S_IRUGO, message_show, message_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 918 | static struct kobj_attribute colors_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 919 | __ATTR(colors, S_IWUSR | S_IRUGO, message_show, message_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 920 | static struct kobj_attribute formatted_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 921 | __ATTR(formatted, S_IWUSR | S_IRUGO, message_show, message_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 922 | static struct kobj_attribute function_names_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 923 | __ATTR(function_names, S_IWUSR | S_IRUGO, message_show, message_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 924 | static struct kobj_attribute key_names_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 925 | __ATTR(key_names, S_IWUSR | S_IRUGO, message_show, message_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 926 | static struct kobj_attribute states_attribute = |
Dilek Uzulmez | e81e31f | 2016-02-22 21:56:01 +0200 | [diff] [blame] | 927 | __ATTR(states, S_IWUSR | S_IRUGO, message_show, message_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 928 | |
| 929 | /* |
| 930 | * Create groups of attributes so that we can create and destroy them all |
| 931 | * at once. |
| 932 | */ |
| 933 | static struct attribute *main_attrs[] = { |
| 934 | &keymap_attribute.attr, |
| 935 | &silent_attribute.attr, |
| 936 | &synth_attribute.attr, |
| 937 | &synth_direct_attribute.attr, |
| 938 | &version_attribute.attr, |
| 939 | &delimiters_attribute.attr, |
| 940 | &ex_num_attribute.attr, |
| 941 | &punc_all_attribute.attr, |
| 942 | &punc_most_attribute.attr, |
| 943 | &punc_some_attribute.attr, |
| 944 | &repeats_attribute.attr, |
| 945 | &attrib_bleep_attribute.attr, |
| 946 | &bell_pos_attribute.attr, |
| 947 | &bleep_time_attribute.attr, |
| 948 | &bleeps_attribute.attr, |
| 949 | &cursor_time_attribute.attr, |
| 950 | &key_echo_attribute.attr, |
| 951 | &no_interrupt_attribute.attr, |
| 952 | &punc_level_attribute.attr, |
| 953 | &reading_punc_attribute.attr, |
| 954 | &say_control_attribute.attr, |
| 955 | &say_word_ctl_attribute.attr, |
| 956 | &spell_delay_attribute.attr, |
| 957 | NULL, |
| 958 | }; |
| 959 | |
| 960 | static struct attribute *i18n_attrs[] = { |
| 961 | &announcements_attribute.attr, |
| 962 | &characters_attribute.attr, |
| 963 | &chartab_attribute.attr, |
| 964 | &ctl_keys_attribute.attr, |
| 965 | &colors_attribute.attr, |
| 966 | &formatted_attribute.attr, |
| 967 | &function_names_attribute.attr, |
| 968 | &key_names_attribute.attr, |
| 969 | &states_attribute.attr, |
| 970 | NULL, |
| 971 | }; |
| 972 | |
| 973 | /* |
| 974 | * An unnamed attribute group will put all of the attributes directly in |
| 975 | * the kobject directory. If we specify a name, a subdirectory will be |
| 976 | * created for the attributes with the directory being the name of the |
| 977 | * attribute group. |
| 978 | */ |
Bhumika Goyal | c4610f6 | 2016-09-29 20:52:00 +0530 | [diff] [blame] | 979 | static const struct attribute_group main_attr_group = { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 980 | .attrs = main_attrs, |
| 981 | }; |
| 982 | |
Bhumika Goyal | c4610f6 | 2016-09-29 20:52:00 +0530 | [diff] [blame] | 983 | static const struct attribute_group i18n_attr_group = { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 984 | .attrs = i18n_attrs, |
| 985 | .name = "i18n", |
| 986 | }; |
| 987 | |
| 988 | static struct kobject *accessibility_kobj; |
| 989 | struct kobject *speakup_kobj; |
| 990 | |
| 991 | int speakup_kobj_init(void) |
| 992 | { |
| 993 | int retval; |
| 994 | |
| 995 | /* |
| 996 | * Create a simple kobject with the name of "accessibility", |
| 997 | * located under /sys/ |
| 998 | * |
| 999 | * As this is a simple directory, no uevent will be sent to |
| 1000 | * userspace. That is why this function should not be used for |
| 1001 | * any type of dynamic kobjects, where the name and number are |
| 1002 | * not known ahead of time. |
| 1003 | */ |
| 1004 | accessibility_kobj = kobject_create_and_add("accessibility", NULL); |
William Hubbs | 7959d55 | 2010-12-16 13:26:58 -0600 | [diff] [blame] | 1005 | if (!accessibility_kobj) { |
| 1006 | retval = -ENOMEM; |
| 1007 | goto out; |
| 1008 | } |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 1009 | |
| 1010 | speakup_kobj = kobject_create_and_add("speakup", accessibility_kobj); |
| 1011 | if (!speakup_kobj) { |
Vasiliy Kulikov | 6a56486 | 2010-10-17 18:51:53 +0400 | [diff] [blame] | 1012 | retval = -ENOMEM; |
| 1013 | goto err_acc; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | /* Create the files associated with this kobject */ |
| 1017 | retval = sysfs_create_group(speakup_kobj, &main_attr_group); |
| 1018 | if (retval) |
Vasiliy Kulikov | 6a56486 | 2010-10-17 18:51:53 +0400 | [diff] [blame] | 1019 | goto err_speakup; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 1020 | |
| 1021 | retval = sysfs_create_group(speakup_kobj, &i18n_attr_group); |
| 1022 | if (retval) |
Vasiliy Kulikov | 6a56486 | 2010-10-17 18:51:53 +0400 | [diff] [blame] | 1023 | goto err_group; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 1024 | |
William Hubbs | 7959d55 | 2010-12-16 13:26:58 -0600 | [diff] [blame] | 1025 | goto out; |
Vasiliy Kulikov | 6a56486 | 2010-10-17 18:51:53 +0400 | [diff] [blame] | 1026 | |
| 1027 | err_group: |
| 1028 | sysfs_remove_group(speakup_kobj, &main_attr_group); |
| 1029 | err_speakup: |
| 1030 | kobject_put(speakup_kobj); |
| 1031 | err_acc: |
| 1032 | kobject_put(accessibility_kobj); |
William Hubbs | 7959d55 | 2010-12-16 13:26:58 -0600 | [diff] [blame] | 1033 | out: |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 1034 | return retval; |
| 1035 | } |
| 1036 | |
| 1037 | void speakup_kobj_exit(void) |
| 1038 | { |
Vasiliy Kulikov | 6a56486 | 2010-10-17 18:51:53 +0400 | [diff] [blame] | 1039 | sysfs_remove_group(speakup_kobj, &i18n_attr_group); |
| 1040 | sysfs_remove_group(speakup_kobj, &main_attr_group); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 1041 | kobject_put(speakup_kobj); |
| 1042 | kobject_put(accessibility_kobj); |
| 1043 | } |