1 // SPDX-License-Identifier: GPL-2.0
3 * Speakup kobject implementation
5 * Copyright (C) 2009 William Hubbs
7 * This code is based on kobject-example.c, which came with linux 2.6.x.
9 * Copyright (C) 2004-2007 Greg Kroah-Hartman <greg@kroah.com>
10 * Copyright (C) 2007 Novell Inc.
12 * Released under the GPL version 2 only.
15 #include <linux/slab.h> /* For kmalloc. */
16 #include <linux/kernel.h>
17 #include <linux/kobject.h>
18 #include <linux/string.h>
19 #include <linux/string_helpers.h>
20 #include <linux/sysfs.h>
21 #include <linux/ctype.h>
27 * This is called when a user reads the characters or chartab sys file.
29 static ssize_t
chars_chartab_show(struct kobject
*kobj
,
30 struct kobj_attribute
*attr
, char *buf
)
35 char *buf_pointer
= buf
;
36 size_t bufsize
= PAGE_SIZE
;
39 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
41 for (i
= 0; i
< 256; i
++) {
44 if (strcmp("characters", attr
->attr
.name
) == 0) {
45 len
= scnprintf(buf_pointer
, bufsize
, "%d\t%s\n",
46 i
, spk_characters
[i
]);
47 } else { /* show chartab entry */
48 if (IS_TYPE(i
, B_CTL
))
50 else if (IS_TYPE(i
, WDLM
))
52 else if (IS_TYPE(i
, A_PUNC
))
54 else if (IS_TYPE(i
, PUNC
))
56 else if (IS_TYPE(i
, NUM
))
58 else if (IS_TYPE(i
, A_CAP
))
60 else if (IS_TYPE(i
, ALPHA
))
62 else if (IS_TYPE(i
, B_CAPSYM
))
64 else if (IS_TYPE(i
, B_SYM
))
69 scnprintf(buf_pointer
, bufsize
, "%d\t%s\n", i
, cp
);
74 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
75 return buf_pointer
- buf
;
79 * Print informational messages or warnings after updating
80 * character descriptions or chartab entries.
82 static void report_char_chartab_status(int reset
, int received
, int used
,
83 int rejected
, int do_characters
)
85 static char const *object_type
[] = {
86 "character class entries",
87 "character descriptions",
93 pr_info("%s reset to defaults\n", object_type
[do_characters
]);
94 } else if (received
) {
95 len
= snprintf(buf
, sizeof(buf
),
96 " updated %d of %d %s\n",
97 used
, received
, object_type
[do_characters
]);
99 snprintf(buf
+ (len
- 1), sizeof(buf
) - (len
- 1),
100 " with %d reject%s\n",
101 rejected
, rejected
> 1 ? "s" : "");
107 * This is called when a user changes the characters or chartab parameters.
109 static ssize_t
chars_chartab_store(struct kobject
*kobj
,
110 struct kobj_attribute
*attr
,
111 const char *buf
, size_t count
)
113 char *cp
= (char *)buf
;
114 char *end
= cp
+ count
; /* the null at the end of the buffer */
115 char *linefeed
= NULL
;
116 char keyword
[MAX_DESC_LEN
+ 1];
117 char *outptr
= NULL
; /* Will hold keyword or desc. */
120 ssize_t retval
= count
;
122 unsigned long index
= 0;
128 int do_characters
= !strcmp(attr
->attr
.name
, "characters");
129 size_t desc_length
= 0;
132 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
134 while ((cp
< end
) && (*cp
== ' ' || *cp
== '\t'))
139 if ((*cp
== '\n') || strchr("dDrR", *cp
)) {
145 linefeed
= strchr(cp
, '\n');
158 * Do not replace with kstrtoul:
159 * here we need temp to be updated
161 index
= simple_strtoul(cp
, &temp
, 10);
168 while ((temp
< linefeed
) && (*temp
== ' ' || *temp
== '\t'))
171 desc_length
= linefeed
- temp
;
172 if (desc_length
> MAX_DESC_LEN
) {
178 desc
= kmalloc(desc_length
+ 1, GFP_ATOMIC
);
181 reset
= 1; /* just reset on error. */
189 for (i
= 0; i
< desc_length
; i
++)
191 outptr
[desc_length
] = '\0';
194 if (spk_characters
[index
] != spk_default_chars
[index
])
195 kfree(spk_characters
[index
]);
196 spk_characters
[index
] = desc
;
199 charclass
= spk_chartab_get_value(keyword
);
200 if (charclass
== 0) {
205 if (charclass
!= spk_chartab
[index
]) {
206 spk_chartab
[index
] = charclass
;
215 spk_reset_default_chars();
217 spk_reset_default_chartab();
220 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
221 report_char_chartab_status(reset
, received
, used
, rejected
,
227 * This is called when a user reads the keymap parameter.
229 static ssize_t
keymap_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
241 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
242 cp1
= spk_key_buf
+ SHIFT_TBL_SIZE
;
243 num_keys
= (int)(*cp1
);
244 nstates
= (int)cp1
[1];
245 cp
+= sprintf(cp
, "%d, %d, %d,\n", KEY_MAP_VER
, num_keys
, nstates
);
246 cp1
+= 2; /* now pointing at shift states */
247 /* dump num_keys+1 as first row is shift states + flags,
248 * each subsequent row is key + states
250 for (n
= 0; n
<= num_keys
; n
++) {
251 for (i
= 0; i
<= nstates
; i
++) {
253 cp
+= sprintf(cp
, "%d,", (int)ch
);
254 *cp
++ = (i
< nstates
) ? SPACE
: '\n';
257 cp
+= sprintf(cp
, "0, %d\n", KEY_MAP_VER
);
258 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
259 return (int)(cp
- buf
);
263 * This is called when a user changes the keymap parameter.
265 static ssize_t
keymap_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
266 const char *buf
, size_t count
)
270 char *in_buff
= NULL
;
275 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
276 in_buff
= kmemdup(buf
, count
+ 1, GFP_ATOMIC
);
278 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
281 if (strchr("dDrR", *in_buff
)) {
282 spk_set_key_info(spk_key_defaults
, spk_key_buf
);
283 pr_info("keymap set to default values\n");
285 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
288 if (in_buff
[count
- 1] == '\n')
289 in_buff
[count
- 1] = '\0';
291 cp1
= (u_char
*)in_buff
;
292 for (i
= 0; i
< 3; i
++) {
293 cp
= spk_s2uchar(cp
, cp1
);
296 i
= (int)cp1
[-2] + 1;
297 i
*= (int)cp1
[-1] + 1;
298 i
+= 2; /* 0 and last map ver */
299 if (cp1
[-3] != KEY_MAP_VER
|| cp1
[-1] > 10 ||
300 i
+ SHIFT_TBL_SIZE
+ 4 >= sizeof(spk_key_buf
)) {
301 pr_warn("i %d %d %d %d\n", i
,
302 (int)cp1
[-3], (int)cp1
[-2], (int)cp1
[-1]);
304 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
308 cp
= spk_s2uchar(cp
, cp1
);
313 if (i
!= 0 || cp1
[-1] != KEY_MAP_VER
|| cp1
[-2] != 0) {
315 pr_warn("end %d %d %d %d\n", i
,
316 (int)cp1
[-3], (int)cp1
[-2], (int)cp1
[-1]);
318 if (spk_set_key_info(in_buff
, spk_key_buf
)) {
319 spk_set_key_info(spk_key_defaults
, spk_key_buf
);
321 pr_warn("set key failed\n");
325 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
330 * This is called when a user changes the value of the silent parameter.
332 static ssize_t
silent_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
333 const char *buf
, size_t count
)
336 struct vc_data
*vc
= vc_cons
[fg_console
].d
;
342 if (len
> 0 && len
< 3) {
347 if (ch
< '0' || ch
> '7') {
348 pr_warn("silent value '%c' not in range (0,7)\n", ch
);
351 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
363 spk_shut_up
&= ~shut
;
364 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
369 * This is called when a user reads the synth setting.
371 static ssize_t
synth_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
377 rv
= sprintf(buf
, "%s\n", "none");
379 rv
= sprintf(buf
, "%s\n", synth
->name
);
384 * This is called when a user requests to change synthesizers.
386 static ssize_t
synth_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
387 const char *buf
, size_t count
)
390 char new_synth_name
[10];
393 if (len
< 2 || len
> 9)
395 memcpy(new_synth_name
, buf
, len
);
396 if (new_synth_name
[len
- 1] == '\n')
398 new_synth_name
[len
] = '\0';
399 spk_strlwr(new_synth_name
);
400 if (synth
&& !strcmp(new_synth_name
, synth
->name
)) {
401 pr_warn("%s already in use\n", new_synth_name
);
402 } else if (synth_init(new_synth_name
) != 0) {
403 pr_warn("failed to init synth %s\n", new_synth_name
);
410 * This is called when text is sent to the synth via the synth_direct file.
412 static ssize_t
synth_direct_store(struct kobject
*kobj
,
413 struct kobj_attribute
*attr
,
414 const char *buf
, size_t count
)
419 const char *ptr
= buf
;
426 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
428 bytes
= min_t(size_t, len
, 250);
429 strncpy(tmp
, ptr
, bytes
);
431 string_unescape_any_inplace(tmp
);
432 synth_printf("%s", tmp
);
436 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
441 * This function is called when a user reads the version.
443 static ssize_t
version_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
449 cp
+= sprintf(cp
, "Speakup version %s\n", SPEAKUP_VERSION
);
451 cp
+= sprintf(cp
, "%s synthesizer driver version %s\n",
452 synth
->name
, synth
->version
);
457 * This is called when a user reads the punctuation settings.
459 static ssize_t
punc_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
464 struct st_var_header
*p_header
;
465 struct punc_var_t
*var
;
466 struct st_bits_data
*pb
;
470 p_header
= spk_var_header_by_name(attr
->attr
.name
);
472 pr_warn("p_header is null, attr->attr.name is %s\n",
477 var
= spk_get_punc_var(p_header
->var_id
);
479 pr_warn("var is null, p_header->var_id is %i\n",
484 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
485 pb
= (struct st_bits_data
*)&spk_punc_info
[var
->value
];
487 for (i
= 33; i
< 128; i
++) {
488 if (!(spk_chartab
[i
] & mask
))
492 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
497 * This is called when a user changes the punctuation settings.
499 static ssize_t
punc_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
500 const char *buf
, size_t count
)
503 struct st_var_header
*p_header
;
504 struct punc_var_t
*var
;
512 p_header
= spk_var_header_by_name(attr
->attr
.name
);
514 pr_warn("p_header is null, attr->attr.name is %s\n",
519 var
= spk_get_punc_var(p_header
->var_id
);
521 pr_warn("var is null, p_header->var_id is %i\n",
526 memcpy(punc_buf
, buf
, x
);
528 while (x
&& punc_buf
[x
- 1] == '\n')
532 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
534 if (*punc_buf
== 'd' || *punc_buf
== 'r')
535 x
= spk_set_mask_bits(NULL
, var
->value
, 3);
537 x
= spk_set_mask_bits(punc_buf
, var
->value
, 3);
539 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
544 * This function is called when a user reads one of the variable parameters.
546 ssize_t
spk_var_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
550 struct st_var_header
*param
;
557 param
= spk_var_header_by_name(attr
->attr
.name
);
561 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
562 var
= (struct var_t
*)param
->data
;
563 switch (param
->var_type
) {
567 rv
= sprintf(buf
, "%i\n", var
->u
.n
.value
);
569 rv
= sprintf(buf
, "0\n");
575 for (cp
= (char *)param
->p_val
; (ch
= *cp
); cp
++) {
576 if (ch
>= ' ' && ch
< '~')
579 cp1
+= sprintf(cp1
, "\\x%02x", ch
);
586 rv
= sprintf(buf
, "\"\"\n");
590 rv
= sprintf(buf
, "Bad parameter %s, type %i\n",
591 param
->name
, param
->var_type
);
594 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
597 EXPORT_SYMBOL_GPL(spk_var_show
);
600 * Used to reset either default_pitch or default_vol.
602 static inline void spk_reset_default_value(char *header_name
,
603 int *synth_default_value
, int idx
)
605 struct st_var_header
*param
;
607 if (synth
&& synth_default_value
) {
608 param
= spk_var_header_by_name(header_name
);
610 spk_set_num_var(synth_default_value
[idx
],
611 param
, E_NEW_DEFAULT
);
612 spk_set_num_var(0, param
, E_DEFAULT
);
613 pr_info("%s reset to default value\n", param
->name
);
619 * This function is called when a user echos a value to one of the
620 * variable parameters.
622 ssize_t
spk_var_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
623 const char *buf
, size_t count
)
625 struct st_var_header
*param
;
629 struct var_t
*var_data
;
633 param
= spk_var_header_by_name(attr
->attr
.name
);
640 string_unescape_any_inplace(cp
);
642 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
643 switch (param
->var_type
) {
646 if (*cp
== 'd' || *cp
== 'r' || *cp
== '\0')
648 else if (*cp
== '+' || *cp
== '-')
652 if (kstrtol(cp
, 10, &value
) == 0)
653 ret
= spk_set_num_var(value
, param
, len
);
655 pr_warn("overflow or parsing error has occurred");
656 if (ret
== -ERANGE
) {
657 var_data
= param
->data
;
658 pr_warn("value for %s out of range, expect %d to %d\n",
660 var_data
->u
.n
.low
, var_data
->u
.n
.high
);
664 * If voice was just changed, we might need to reset our default
667 if (param
->var_id
== VOICE
&& synth
&&
668 (ret
== 0 || ret
== -ERESTART
)) {
669 var_data
= param
->data
;
670 value
= var_data
->u
.n
.value
;
671 spk_reset_default_value("pitch", synth
->default_pitch
,
673 spk_reset_default_value("vol", synth
->default_vol
,
679 if ((len
>= 1) && (cp
[len
- 1] == '\n'))
681 if ((len
>= 2) && (cp
[0] == '"') && (cp
[len
- 1] == '"')) {
686 ret
= spk_set_string_var(cp
, param
, len
);
688 pr_warn("value too long for %s\n",
692 pr_warn("%s unknown type %d\n",
693 param
->name
, (int)param
->var_type
);
696 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
698 if (ret
== -ERESTART
)
699 pr_info("%s reset to default value\n", param
->name
);
702 EXPORT_SYMBOL_GPL(spk_var_store
);
705 * Functions for reading and writing lists of i18n messages. Incomplete.
708 static ssize_t
message_show_helper(char *buf
, enum msg_index_t first
,
709 enum msg_index_t last
)
711 size_t bufsize
= PAGE_SIZE
;
712 char *buf_pointer
= buf
;
714 enum msg_index_t cursor
;
716 *buf_pointer
= '\0'; /* buf_pointer always looking at a NUL byte. */
718 for (cursor
= first
; cursor
<= last
; cursor
++, index
++) {
721 printed
= scnprintf(buf_pointer
, bufsize
, "%d\t%s\n",
722 index
, spk_msg_get(cursor
));
723 buf_pointer
+= printed
;
727 return buf_pointer
- buf
;
730 static void report_msg_status(int reset
, int received
, int used
,
731 int rejected
, char *groupname
)
737 pr_info("i18n messages from group %s reset to defaults\n",
739 } else if (received
) {
740 len
= snprintf(buf
, sizeof(buf
),
741 " updated %d of %d i18n messages from group %s\n",
742 used
, received
, groupname
);
744 snprintf(buf
+ (len
- 1), sizeof(buf
) - (len
- 1),
745 " with %d reject%s\n",
746 rejected
, rejected
> 1 ? "s" : "");
751 static ssize_t
message_store_helper(const char *buf
, size_t count
,
752 struct msg_group_t
*group
)
754 char *cp
= (char *)buf
;
755 char *end
= cp
+ count
;
756 char *linefeed
= NULL
;
758 ssize_t msg_stored
= 0;
759 ssize_t retval
= count
;
760 size_t desc_length
= 0;
761 unsigned long index
= 0;
766 enum msg_index_t firstmessage
= group
->start
;
767 enum msg_index_t lastmessage
= group
->end
;
768 enum msg_index_t curmessage
;
771 while ((cp
< end
) && (*cp
== ' ' || *cp
== '\t'))
776 if (strchr("dDrR", *cp
)) {
782 linefeed
= strchr(cp
, '\n');
795 * Do not replace with kstrtoul:
796 * here we need temp to be updated
798 index
= simple_strtoul(cp
, &temp
, 10);
800 while ((temp
< linefeed
) && (*temp
== ' ' || *temp
== '\t'))
803 desc_length
= linefeed
- temp
;
804 curmessage
= firstmessage
+ index
;
807 * Note the check (curmessage < firstmessage). It is not
808 * redundant. Suppose that the user gave us an index
809 * equal to ULONG_MAX - 1. If firstmessage > 1, then
810 * firstmessage + index < firstmessage!
813 if ((curmessage
< firstmessage
) || (curmessage
> lastmessage
)) {
819 msg_stored
= spk_msg_set(curmessage
, temp
, desc_length
);
820 if (msg_stored
< 0) {
822 if (msg_stored
== -ENOMEM
)
833 spk_reset_msg_group(group
);
835 report_msg_status(reset
, received
, used
, rejected
, group
->name
);
839 static ssize_t
message_show(struct kobject
*kobj
,
840 struct kobj_attribute
*attr
, char *buf
)
843 struct msg_group_t
*group
= spk_find_msg_group(attr
->attr
.name
);
849 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
850 retval
= message_show_helper(buf
, group
->start
, group
->end
);
851 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
855 static ssize_t
message_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
856 const char *buf
, size_t count
)
858 struct msg_group_t
*group
= spk_find_msg_group(attr
->attr
.name
);
863 return message_store_helper(buf
, count
, group
);
867 * Declare the attributes.
869 static struct kobj_attribute keymap_attribute
=
871 static struct kobj_attribute silent_attribute
=
873 static struct kobj_attribute synth_attribute
=
875 static struct kobj_attribute synth_direct_attribute
=
876 __ATTR_WO(synth_direct
);
877 static struct kobj_attribute version_attribute
=
880 static struct kobj_attribute delimiters_attribute
=
881 __ATTR(delimiters
, 0644, punc_show
, punc_store
);
882 static struct kobj_attribute ex_num_attribute
=
883 __ATTR(ex_num
, 0644, punc_show
, punc_store
);
884 static struct kobj_attribute punc_all_attribute
=
885 __ATTR(punc_all
, 0644, punc_show
, punc_store
);
886 static struct kobj_attribute punc_most_attribute
=
887 __ATTR(punc_most
, 0644, punc_show
, punc_store
);
888 static struct kobj_attribute punc_some_attribute
=
889 __ATTR(punc_some
, 0644, punc_show
, punc_store
);
890 static struct kobj_attribute repeats_attribute
=
891 __ATTR(repeats
, 0644, punc_show
, punc_store
);
893 static struct kobj_attribute attrib_bleep_attribute
=
894 __ATTR(attrib_bleep
, 0644, spk_var_show
, spk_var_store
);
895 static struct kobj_attribute bell_pos_attribute
=
896 __ATTR(bell_pos
, 0644, spk_var_show
, spk_var_store
);
897 static struct kobj_attribute bleep_time_attribute
=
898 __ATTR(bleep_time
, 0644, spk_var_show
, spk_var_store
);
899 static struct kobj_attribute bleeps_attribute
=
900 __ATTR(bleeps
, 0644, spk_var_show
, spk_var_store
);
901 static struct kobj_attribute cursor_time_attribute
=
902 __ATTR(cursor_time
, 0644, spk_var_show
, spk_var_store
);
903 static struct kobj_attribute key_echo_attribute
=
904 __ATTR(key_echo
, 0644, spk_var_show
, spk_var_store
);
905 static struct kobj_attribute no_interrupt_attribute
=
906 __ATTR(no_interrupt
, 0644, spk_var_show
, spk_var_store
);
907 static struct kobj_attribute punc_level_attribute
=
908 __ATTR(punc_level
, 0644, spk_var_show
, spk_var_store
);
909 static struct kobj_attribute reading_punc_attribute
=
910 __ATTR(reading_punc
, 0644, spk_var_show
, spk_var_store
);
911 static struct kobj_attribute say_control_attribute
=
912 __ATTR(say_control
, 0644, spk_var_show
, spk_var_store
);
913 static struct kobj_attribute say_word_ctl_attribute
=
914 __ATTR(say_word_ctl
, 0644, spk_var_show
, spk_var_store
);
915 static struct kobj_attribute spell_delay_attribute
=
916 __ATTR(spell_delay
, 0644, spk_var_show
, spk_var_store
);
919 * These attributes are i18n related.
921 static struct kobj_attribute announcements_attribute
=
922 __ATTR(announcements
, 0644, message_show
, message_store
);
923 static struct kobj_attribute characters_attribute
=
924 __ATTR(characters
, 0644, chars_chartab_show
,
925 chars_chartab_store
);
926 static struct kobj_attribute chartab_attribute
=
927 __ATTR(chartab
, 0644, chars_chartab_show
,
928 chars_chartab_store
);
929 static struct kobj_attribute ctl_keys_attribute
=
930 __ATTR(ctl_keys
, 0644, message_show
, message_store
);
931 static struct kobj_attribute colors_attribute
=
932 __ATTR(colors
, 0644, message_show
, message_store
);
933 static struct kobj_attribute formatted_attribute
=
934 __ATTR(formatted
, 0644, message_show
, message_store
);
935 static struct kobj_attribute function_names_attribute
=
936 __ATTR(function_names
, 0644, message_show
, message_store
);
937 static struct kobj_attribute key_names_attribute
=
938 __ATTR(key_names
, 0644, message_show
, message_store
);
939 static struct kobj_attribute states_attribute
=
940 __ATTR(states
, 0644, message_show
, message_store
);
943 * Create groups of attributes so that we can create and destroy them all
946 static struct attribute
*main_attrs
[] = {
947 &keymap_attribute
.attr
,
948 &silent_attribute
.attr
,
949 &synth_attribute
.attr
,
950 &synth_direct_attribute
.attr
,
951 &version_attribute
.attr
,
952 &delimiters_attribute
.attr
,
953 &ex_num_attribute
.attr
,
954 &punc_all_attribute
.attr
,
955 &punc_most_attribute
.attr
,
956 &punc_some_attribute
.attr
,
957 &repeats_attribute
.attr
,
958 &attrib_bleep_attribute
.attr
,
959 &bell_pos_attribute
.attr
,
960 &bleep_time_attribute
.attr
,
961 &bleeps_attribute
.attr
,
962 &cursor_time_attribute
.attr
,
963 &key_echo_attribute
.attr
,
964 &no_interrupt_attribute
.attr
,
965 &punc_level_attribute
.attr
,
966 &reading_punc_attribute
.attr
,
967 &say_control_attribute
.attr
,
968 &say_word_ctl_attribute
.attr
,
969 &spell_delay_attribute
.attr
,
973 static struct attribute
*i18n_attrs
[] = {
974 &announcements_attribute
.attr
,
975 &characters_attribute
.attr
,
976 &chartab_attribute
.attr
,
977 &ctl_keys_attribute
.attr
,
978 &colors_attribute
.attr
,
979 &formatted_attribute
.attr
,
980 &function_names_attribute
.attr
,
981 &key_names_attribute
.attr
,
982 &states_attribute
.attr
,
987 * An unnamed attribute group will put all of the attributes directly in
988 * the kobject directory. If we specify a name, a subdirectory will be
989 * created for the attributes with the directory being the name of the
992 static const struct attribute_group main_attr_group
= {
996 static const struct attribute_group i18n_attr_group
= {
1001 static struct kobject
*accessibility_kobj
;
1002 struct kobject
*speakup_kobj
;
1004 int speakup_kobj_init(void)
1009 * Create a simple kobject with the name of "accessibility",
1010 * located under /sys/
1012 * As this is a simple directory, no uevent will be sent to
1013 * userspace. That is why this function should not be used for
1014 * any type of dynamic kobjects, where the name and number are
1015 * not known ahead of time.
1017 accessibility_kobj
= kobject_create_and_add("accessibility", NULL
);
1018 if (!accessibility_kobj
) {
1023 speakup_kobj
= kobject_create_and_add("speakup", accessibility_kobj
);
1024 if (!speakup_kobj
) {
1029 /* Create the files associated with this kobject */
1030 retval
= sysfs_create_group(speakup_kobj
, &main_attr_group
);
1034 retval
= sysfs_create_group(speakup_kobj
, &i18n_attr_group
);
1041 sysfs_remove_group(speakup_kobj
, &main_attr_group
);
1043 kobject_put(speakup_kobj
);
1045 kobject_put(accessibility_kobj
);
1050 void speakup_kobj_exit(void)
1052 sysfs_remove_group(speakup_kobj
, &i18n_attr_group
);
1053 sysfs_remove_group(speakup_kobj
, &main_attr_group
);
1054 kobject_put(speakup_kobj
);
1055 kobject_put(accessibility_kobj
);