2 * Speakup kobject implementation
4 * Copyright (C) 2009 William Hubbs
6 * This code is based on kobject-example.c, which came with linux 2.6.x.
8 * Copyright (C) 2004-2007 Greg Kroah-Hartman <greg@kroah.com>
9 * Copyright (C) 2007 Novell Inc.
11 * Released under the GPL version 2 only.
14 #include <linux/slab.h> /* For kmalloc. */
15 #include <linux/kernel.h>
16 #include <linux/kobject.h>
17 #include <linux/string.h>
18 #include <linux/string_helpers.h>
19 #include <linux/sysfs.h>
20 #include <linux/ctype.h>
26 * This is called when a user reads the characters or chartab sys file.
28 static ssize_t
chars_chartab_show(struct kobject
*kobj
,
29 struct kobj_attribute
*attr
, char *buf
)
34 char *buf_pointer
= buf
;
35 size_t bufsize
= PAGE_SIZE
;
38 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
40 for (i
= 0; i
< 256; i
++) {
43 if (strcmp("characters", attr
->attr
.name
) == 0) {
44 len
= scnprintf(buf_pointer
, bufsize
, "%d\t%s\n",
45 i
, spk_characters
[i
]);
46 } else { /* show chartab entry */
47 if (IS_TYPE(i
, B_CTL
))
49 else if (IS_TYPE(i
, WDLM
))
51 else if (IS_TYPE(i
, A_PUNC
))
53 else if (IS_TYPE(i
, PUNC
))
55 else if (IS_TYPE(i
, NUM
))
57 else if (IS_TYPE(i
, A_CAP
))
59 else if (IS_TYPE(i
, ALPHA
))
61 else if (IS_TYPE(i
, B_CAPSYM
))
63 else if (IS_TYPE(i
, B_SYM
))
68 scnprintf(buf_pointer
, bufsize
, "%d\t%s\n", i
, cp
);
73 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
74 return buf_pointer
- buf
;
78 * Print informational messages or warnings after updating
79 * character descriptions or chartab entries.
81 static void report_char_chartab_status(int reset
, int received
, int used
,
82 int rejected
, int do_characters
)
84 char *object_type
[] = {
85 "character class entries",
86 "character descriptions",
92 pr_info("%s reset to defaults\n", object_type
[do_characters
]);
93 } else if (received
) {
94 len
= snprintf(buf
, sizeof(buf
),
95 " updated %d of %d %s\n",
96 used
, received
, object_type
[do_characters
]);
98 snprintf(buf
+ (len
- 1), sizeof(buf
) - (len
- 1),
99 " with %d reject%s\n",
100 rejected
, rejected
> 1 ? "s" : "");
106 * This is called when a user changes the characters or chartab parameters.
108 static ssize_t
chars_chartab_store(struct kobject
*kobj
,
109 struct kobj_attribute
*attr
, const char *buf
, size_t count
)
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. */
118 ssize_t retval
= count
;
120 unsigned long index
= 0;
126 int do_characters
= !strcmp(attr
->attr
.name
, "characters");
127 size_t desc_length
= 0;
130 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
133 while ((cp
< end
) && (*cp
== ' ' || *cp
== '\t'))
138 if ((*cp
== '\n') || strchr("dDrR", *cp
)) {
144 linefeed
= strchr(cp
, '\n');
156 index
= simple_strtoul(cp
, &temp
, 10);
163 while ((temp
< linefeed
) && (*temp
== ' ' || *temp
== '\t'))
166 desc_length
= linefeed
- temp
;
167 if (desc_length
> MAX_DESC_LEN
) {
173 desc
= kmalloc(desc_length
+ 1, GFP_ATOMIC
);
176 reset
= 1; /* just reset on error. */
184 for (i
= 0; i
< desc_length
; i
++)
186 outptr
[desc_length
] = '\0';
189 if (spk_characters
[index
] != spk_default_chars
[index
])
190 kfree(spk_characters
[index
]);
191 spk_characters
[index
] = desc
;
194 charclass
= spk_chartab_get_value(keyword
);
195 if (charclass
== 0) {
200 if (charclass
!= spk_chartab
[index
]) {
201 spk_chartab
[index
] = charclass
;
210 spk_reset_default_chars();
212 spk_reset_default_chartab();
215 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
216 report_char_chartab_status(reset
, received
, used
, rejected
,
222 * This is called when a user reads the keymap parameter.
224 static ssize_t
keymap_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
235 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
236 cp1
= spk_key_buf
+ SHIFT_TBL_SIZE
;
237 num_keys
= (int)(*cp1
);
238 nstates
= (int)cp1
[1];
239 cp
+= sprintf(cp
, "%d, %d, %d,\n", KEY_MAP_VER
, num_keys
, nstates
);
240 cp1
+= 2; /* now pointing at shift states */
241 /* dump num_keys+1 as first row is shift states + flags,
242 * each subsequent row is key + states */
243 for (n
= 0; n
<= num_keys
; n
++) {
244 for (i
= 0; i
<= nstates
; i
++) {
246 cp
+= sprintf(cp
, "%d,", (int)ch
);
247 *cp
++ = (i
< nstates
) ? SPACE
: '\n';
250 cp
+= sprintf(cp
, "0, %d\n", KEY_MAP_VER
);
251 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
252 return (int)(cp
-buf
);
256 * This is called when a user changes the keymap parameter.
258 static ssize_t
keymap_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
259 const char *buf
, size_t count
)
263 char *in_buff
= NULL
;
268 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
269 in_buff
= kmemdup(buf
, count
+ 1, GFP_ATOMIC
);
271 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
274 if (strchr("dDrR", *in_buff
)) {
275 spk_set_key_info(spk_key_defaults
, spk_key_buf
);
276 pr_info("keymap set to default values\n");
278 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
281 if (in_buff
[count
- 1] == '\n')
282 in_buff
[count
- 1] = '\0';
284 cp1
= (u_char
*)in_buff
;
285 for (i
= 0; i
< 3; i
++) {
286 cp
= spk_s2uchar(cp
, cp1
);
291 i
+= 2; /* 0 and last map ver */
292 if (cp1
[-3] != KEY_MAP_VER
|| cp1
[-1] > 10 ||
293 i
+SHIFT_TBL_SIZE
+4 >= sizeof(spk_key_buf
)) {
294 pr_warn("i %d %d %d %d\n", i
,
295 (int)cp1
[-3], (int)cp1
[-2], (int)cp1
[-1]);
297 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
301 cp
= spk_s2uchar(cp
, cp1
);
306 if (i
!= 0 || cp1
[-1] != KEY_MAP_VER
|| cp1
[-2] != 0) {
308 pr_warn("end %d %d %d %d\n", i
,
309 (int)cp1
[-3], (int)cp1
[-2], (int)cp1
[-1]);
311 if (spk_set_key_info(in_buff
, spk_key_buf
)) {
312 spk_set_key_info(spk_key_defaults
, spk_key_buf
);
314 pr_warn("set key failed\n");
318 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
323 * This is called when a user changes the value of the silent parameter.
325 static ssize_t
silent_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
326 const char *buf
, size_t count
)
329 struct vc_data
*vc
= vc_cons
[fg_console
].d
;
335 if (len
> 0 && len
< 3) {
340 if (ch
< '0' || ch
> '7') {
341 pr_warn("silent value '%c' not in range (0,7)\n", ch
);
344 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
356 spk_shut_up
&= ~shut
;
357 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
362 * This is called when a user reads the synth setting.
364 static ssize_t
synth_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
370 rv
= sprintf(buf
, "%s\n", "none");
372 rv
= sprintf(buf
, "%s\n", synth
->name
);
377 * This is called when a user requests to change synthesizers.
379 static ssize_t
synth_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
380 const char *buf
, size_t count
)
383 char new_synth_name
[10];
386 if (len
< 2 || len
> 9)
388 strncpy(new_synth_name
, buf
, len
);
389 if (new_synth_name
[len
- 1] == '\n')
391 new_synth_name
[len
] = '\0';
392 spk_strlwr(new_synth_name
);
393 if ((synth
!= NULL
) && (!strcmp(new_synth_name
, synth
->name
))) {
394 pr_warn("%s already in use\n", new_synth_name
);
395 } else if (synth_init(new_synth_name
) != 0) {
396 pr_warn("failed to init synth %s\n", new_synth_name
);
403 * This is called when text is sent to the synth via the synth_direct file.
405 static ssize_t
synth_direct_store(struct kobject
*kobj
,
406 struct kobj_attribute
*attr
, const char *buf
, size_t count
)
411 const char *ptr
= buf
;
418 bytes
= min_t(size_t, len
, 250);
419 strncpy(tmp
, ptr
, bytes
);
421 string_unescape_any_inplace(tmp
);
422 synth_printf("%s", tmp
);
430 * This function is called when a user reads the version.
432 static ssize_t
version_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
438 cp
+= sprintf(cp
, "Speakup version %s\n", SPEAKUP_VERSION
);
440 cp
+= sprintf(cp
, "%s synthesizer driver version %s\n",
441 synth
->name
, synth
->version
);
446 * This is called when a user reads the punctuation settings.
448 static ssize_t
punc_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
453 struct st_var_header
*p_header
;
454 struct punc_var_t
*var
;
455 struct st_bits_data
*pb
;
459 p_header
= spk_var_header_by_name(attr
->attr
.name
);
460 if (p_header
== NULL
) {
461 pr_warn("p_header is null, attr->attr.name is %s\n",
466 var
= spk_get_punc_var(p_header
->var_id
);
468 pr_warn("var is null, p_header->var_id is %i\n",
473 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
474 pb
= (struct st_bits_data
*) &spk_punc_info
[var
->value
];
476 for (i
= 33; i
< 128; i
++) {
477 if (!(spk_chartab
[i
]&mask
))
481 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
486 * This is called when a user changes the punctuation settings.
488 static ssize_t
punc_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
489 const char *buf
, size_t count
)
492 struct st_var_header
*p_header
;
493 struct punc_var_t
*var
;
501 p_header
= spk_var_header_by_name(attr
->attr
.name
);
502 if (p_header
== NULL
) {
503 pr_warn("p_header is null, attr->attr.name is %s\n",
508 var
= spk_get_punc_var(p_header
->var_id
);
510 pr_warn("var is null, p_header->var_id is %i\n",
515 strncpy(punc_buf
, buf
, x
);
517 while (x
&& punc_buf
[x
- 1] == '\n')
521 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
523 if (*punc_buf
== 'd' || *punc_buf
== 'r')
524 x
= spk_set_mask_bits(NULL
, var
->value
, 3);
526 x
= spk_set_mask_bits(punc_buf
, var
->value
, 3);
528 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
533 * This function is called when a user reads one of the variable parameters.
535 ssize_t
spk_var_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
539 struct st_var_header
*param
;
546 param
= spk_var_header_by_name(attr
->attr
.name
);
550 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
551 var
= (struct var_t
*) param
->data
;
552 switch (param
->var_type
) {
556 rv
= sprintf(buf
, "%i\n", var
->u
.n
.value
);
558 rv
= sprintf(buf
, "0\n");
564 for (cp
= (char *)param
->p_val
; (ch
= *cp
); cp
++) {
565 if (ch
>= ' ' && ch
< '~')
568 cp1
+= sprintf(cp1
, "\\""x%02x", ch
);
575 rv
= sprintf(buf
, "\"\"\n");
579 rv
= sprintf(buf
, "Bad parameter %s, type %i\n",
580 param
->name
, param
->var_type
);
583 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
586 EXPORT_SYMBOL_GPL(spk_var_show
);
589 * Used to reset either default_pitch or default_vol.
591 static inline void spk_reset_default_value(char *header_name
,
592 int *synth_default_value
, int idx
)
594 struct st_var_header
*param
;
596 if (synth
&& synth_default_value
) {
597 param
= spk_var_header_by_name(header_name
);
599 spk_set_num_var(synth_default_value
[idx
],
600 param
, E_NEW_DEFAULT
);
601 spk_set_num_var(0, param
, E_DEFAULT
);
602 pr_info("%s reset to default value\n", param
->name
);
608 * This function is called when a user echos a value to one of the
609 * variable parameters.
611 ssize_t
spk_var_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
612 const char *buf
, size_t count
)
614 struct st_var_header
*param
;
618 struct var_t
*var_data
;
622 param
= spk_var_header_by_name(attr
->attr
.name
);
625 if (param
->data
== NULL
)
629 string_unescape_any_inplace(cp
);
631 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
632 switch (param
->var_type
) {
635 if (*cp
== 'd' || *cp
== 'r' || *cp
== '\0')
637 else if (*cp
== '+' || *cp
== '-')
641 if (kstrtol(cp
, 10, &value
) == 0)
642 ret
= spk_set_num_var(value
, param
, len
);
644 pr_warn("overflow or parsing error has occured");
645 if (ret
== -ERANGE
) {
646 var_data
= param
->data
;
647 pr_warn("value for %s out of range, expect %d to %d\n",
649 var_data
->u
.n
.low
, var_data
->u
.n
.high
);
653 * If voice was just changed, we might need to reset our default
656 if (param
->var_id
== VOICE
&& synth
&&
657 (ret
== 0 || ret
== -ERESTART
)) {
658 var_data
= param
->data
;
659 value
= var_data
->u
.n
.value
;
660 spk_reset_default_value("pitch", synth
->default_pitch
,
662 spk_reset_default_value("vol", synth
->default_vol
,
668 if ((len
>= 1) && (cp
[len
- 1] == '\n'))
670 if ((len
>= 2) && (cp
[0] == '"') && (cp
[len
- 1] == '"')) {
675 ret
= spk_set_string_var(cp
, param
, len
);
677 pr_warn("value too long for %s\n",
681 pr_warn("%s unknown type %d\n",
682 param
->name
, (int)param
->var_type
);
685 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
687 if (ret
== -ERESTART
)
688 pr_info("%s reset to default value\n", param
->name
);
691 EXPORT_SYMBOL_GPL(spk_var_store
);
694 * Functions for reading and writing lists of i18n messages. Incomplete.
697 static ssize_t
message_show_helper(char *buf
, enum msg_index_t first
,
698 enum msg_index_t last
)
700 size_t bufsize
= PAGE_SIZE
;
701 char *buf_pointer
= buf
;
703 enum msg_index_t cursor
;
705 *buf_pointer
= '\0'; /* buf_pointer always looking at a NUL byte. */
707 for (cursor
= first
; cursor
<= last
; cursor
++, index
++) {
710 printed
= scnprintf(buf_pointer
, bufsize
, "%d\t%s\n",
711 index
, spk_msg_get(cursor
));
712 buf_pointer
+= printed
;
716 return buf_pointer
- buf
;
719 static void report_msg_status(int reset
, int received
, int used
,
720 int rejected
, char *groupname
)
726 pr_info("i18n messages from group %s reset to defaults\n",
728 } else if (received
) {
729 len
= snprintf(buf
, sizeof(buf
),
730 " updated %d of %d i18n messages from group %s\n",
731 used
, received
, groupname
);
733 snprintf(buf
+ (len
- 1), sizeof(buf
) - (len
- 1),
734 " with %d reject%s\n",
735 rejected
, rejected
> 1 ? "s" : "");
740 static ssize_t
message_store_helper(const char *buf
, size_t count
,
741 struct msg_group_t
*group
)
743 char *cp
= (char *) buf
;
744 char *end
= cp
+ count
;
745 char *linefeed
= NULL
;
747 ssize_t msg_stored
= 0;
748 ssize_t retval
= count
;
749 size_t desc_length
= 0;
750 unsigned long index
= 0;
755 enum msg_index_t firstmessage
= group
->start
;
756 enum msg_index_t lastmessage
= group
->end
;
757 enum msg_index_t curmessage
;
761 while ((cp
< end
) && (*cp
== ' ' || *cp
== '\t'))
766 if (strchr("dDrR", *cp
)) {
772 linefeed
= strchr(cp
, '\n');
784 index
= simple_strtoul(cp
, &temp
, 10);
786 while ((temp
< linefeed
) && (*temp
== ' ' || *temp
== '\t'))
789 desc_length
= linefeed
- temp
;
790 curmessage
= firstmessage
+ index
;
793 * Note the check (curmessage < firstmessage). It is not
794 * redundant. Suppose that the user gave us an index
795 * equal to ULONG_MAX - 1. If firstmessage > 1, then
796 * firstmessage + index < firstmessage!
799 if ((curmessage
< firstmessage
) || (curmessage
> lastmessage
)) {
805 msg_stored
= spk_msg_set(curmessage
, temp
, desc_length
);
806 if (msg_stored
< 0) {
808 if (msg_stored
== -ENOMEM
)
819 spk_reset_msg_group(group
);
821 report_msg_status(reset
, received
, used
, rejected
, group
->name
);
825 static ssize_t
message_show(struct kobject
*kobj
,
826 struct kobj_attribute
*attr
, char *buf
)
829 struct msg_group_t
*group
= spk_find_msg_group(attr
->attr
.name
);
833 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
834 retval
= message_show_helper(buf
, group
->start
, group
->end
);
835 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
839 static ssize_t
message_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
840 const char *buf
, size_t count
)
843 struct msg_group_t
*group
= spk_find_msg_group(attr
->attr
.name
);
846 retval
= message_store_helper(buf
, count
, group
);
851 * Declare the attributes.
853 static struct kobj_attribute keymap_attribute
=
854 __ATTR(keymap
, ROOT_W
, keymap_show
, keymap_store
);
855 static struct kobj_attribute silent_attribute
=
856 __ATTR(silent
, USER_W
, NULL
, silent_store
);
857 static struct kobj_attribute synth_attribute
=
858 __ATTR(synth
, USER_RW
, synth_show
, synth_store
);
859 static struct kobj_attribute synth_direct_attribute
=
860 __ATTR(synth_direct
, USER_W
, NULL
, synth_direct_store
);
861 static struct kobj_attribute version_attribute
=
864 static struct kobj_attribute delimiters_attribute
=
865 __ATTR(delimiters
, USER_RW
, punc_show
, punc_store
);
866 static struct kobj_attribute ex_num_attribute
=
867 __ATTR(ex_num
, USER_RW
, punc_show
, punc_store
);
868 static struct kobj_attribute punc_all_attribute
=
869 __ATTR(punc_all
, USER_RW
, punc_show
, punc_store
);
870 static struct kobj_attribute punc_most_attribute
=
871 __ATTR(punc_most
, USER_RW
, punc_show
, punc_store
);
872 static struct kobj_attribute punc_some_attribute
=
873 __ATTR(punc_some
, USER_RW
, punc_show
, punc_store
);
874 static struct kobj_attribute repeats_attribute
=
875 __ATTR(repeats
, USER_RW
, punc_show
, punc_store
);
877 static struct kobj_attribute attrib_bleep_attribute
=
878 __ATTR(attrib_bleep
, USER_RW
, spk_var_show
, spk_var_store
);
879 static struct kobj_attribute bell_pos_attribute
=
880 __ATTR(bell_pos
, USER_RW
, spk_var_show
, spk_var_store
);
881 static struct kobj_attribute bleep_time_attribute
=
882 __ATTR(bleep_time
, USER_RW
, spk_var_show
, spk_var_store
);
883 static struct kobj_attribute bleeps_attribute
=
884 __ATTR(bleeps
, USER_RW
, spk_var_show
, spk_var_store
);
885 static struct kobj_attribute cursor_time_attribute
=
886 __ATTR(cursor_time
, USER_RW
, spk_var_show
, spk_var_store
);
887 static struct kobj_attribute key_echo_attribute
=
888 __ATTR(key_echo
, USER_RW
, spk_var_show
, spk_var_store
);
889 static struct kobj_attribute no_interrupt_attribute
=
890 __ATTR(no_interrupt
, USER_RW
, spk_var_show
, spk_var_store
);
891 static struct kobj_attribute punc_level_attribute
=
892 __ATTR(punc_level
, USER_RW
, spk_var_show
, spk_var_store
);
893 static struct kobj_attribute reading_punc_attribute
=
894 __ATTR(reading_punc
, USER_RW
, spk_var_show
, spk_var_store
);
895 static struct kobj_attribute say_control_attribute
=
896 __ATTR(say_control
, USER_RW
, spk_var_show
, spk_var_store
);
897 static struct kobj_attribute say_word_ctl_attribute
=
898 __ATTR(say_word_ctl
, USER_RW
, spk_var_show
, spk_var_store
);
899 static struct kobj_attribute spell_delay_attribute
=
900 __ATTR(spell_delay
, USER_RW
, spk_var_show
, spk_var_store
);
903 * These attributes are i18n related.
905 static struct kobj_attribute announcements_attribute
=
906 __ATTR(announcements
, USER_RW
, message_show
, message_store
);
907 static struct kobj_attribute characters_attribute
=
908 __ATTR(characters
, USER_RW
, chars_chartab_show
, chars_chartab_store
);
909 static struct kobj_attribute chartab_attribute
=
910 __ATTR(chartab
, USER_RW
, chars_chartab_show
, chars_chartab_store
);
911 static struct kobj_attribute ctl_keys_attribute
=
912 __ATTR(ctl_keys
, USER_RW
, message_show
, message_store
);
913 static struct kobj_attribute colors_attribute
=
914 __ATTR(colors
, USER_RW
, message_show
, message_store
);
915 static struct kobj_attribute formatted_attribute
=
916 __ATTR(formatted
, USER_RW
, message_show
, message_store
);
917 static struct kobj_attribute function_names_attribute
=
918 __ATTR(function_names
, USER_RW
, message_show
, message_store
);
919 static struct kobj_attribute key_names_attribute
=
920 __ATTR(key_names
, USER_RW
, message_show
, message_store
);
921 static struct kobj_attribute states_attribute
=
922 __ATTR(states
, USER_RW
, message_show
, message_store
);
925 * Create groups of attributes so that we can create and destroy them all
928 static struct attribute
*main_attrs
[] = {
929 &keymap_attribute
.attr
,
930 &silent_attribute
.attr
,
931 &synth_attribute
.attr
,
932 &synth_direct_attribute
.attr
,
933 &version_attribute
.attr
,
934 &delimiters_attribute
.attr
,
935 &ex_num_attribute
.attr
,
936 &punc_all_attribute
.attr
,
937 &punc_most_attribute
.attr
,
938 &punc_some_attribute
.attr
,
939 &repeats_attribute
.attr
,
940 &attrib_bleep_attribute
.attr
,
941 &bell_pos_attribute
.attr
,
942 &bleep_time_attribute
.attr
,
943 &bleeps_attribute
.attr
,
944 &cursor_time_attribute
.attr
,
945 &key_echo_attribute
.attr
,
946 &no_interrupt_attribute
.attr
,
947 &punc_level_attribute
.attr
,
948 &reading_punc_attribute
.attr
,
949 &say_control_attribute
.attr
,
950 &say_word_ctl_attribute
.attr
,
951 &spell_delay_attribute
.attr
,
955 static struct attribute
*i18n_attrs
[] = {
956 &announcements_attribute
.attr
,
957 &characters_attribute
.attr
,
958 &chartab_attribute
.attr
,
959 &ctl_keys_attribute
.attr
,
960 &colors_attribute
.attr
,
961 &formatted_attribute
.attr
,
962 &function_names_attribute
.attr
,
963 &key_names_attribute
.attr
,
964 &states_attribute
.attr
,
969 * An unnamed attribute group will put all of the attributes directly in
970 * the kobject directory. If we specify a name, a subdirectory will be
971 * created for the attributes with the directory being the name of the
974 static struct attribute_group main_attr_group
= {
978 static struct attribute_group i18n_attr_group
= {
983 static struct kobject
*accessibility_kobj
;
984 struct kobject
*speakup_kobj
;
986 int speakup_kobj_init(void)
991 * Create a simple kobject with the name of "accessibility",
992 * located under /sys/
994 * As this is a simple directory, no uevent will be sent to
995 * userspace. That is why this function should not be used for
996 * any type of dynamic kobjects, where the name and number are
997 * not known ahead of time.
999 accessibility_kobj
= kobject_create_and_add("accessibility", NULL
);
1000 if (!accessibility_kobj
) {
1005 speakup_kobj
= kobject_create_and_add("speakup", accessibility_kobj
);
1006 if (!speakup_kobj
) {
1011 /* Create the files associated with this kobject */
1012 retval
= sysfs_create_group(speakup_kobj
, &main_attr_group
);
1016 retval
= sysfs_create_group(speakup_kobj
, &i18n_attr_group
);
1023 sysfs_remove_group(speakup_kobj
, &main_attr_group
);
1025 kobject_put(speakup_kobj
);
1027 kobject_put(accessibility_kobj
);
1032 void speakup_kobj_exit(void)
1034 sysfs_remove_group(speakup_kobj
, &i18n_attr_group
);
1035 sysfs_remove_group(speakup_kobj
, &main_attr_group
);
1036 kobject_put(speakup_kobj
);
1037 kobject_put(accessibility_kobj
);