/* called by: speakup_init() */ int synth_init(char *synth_name) { int i; int ret = 0; struct spk_synth *synth = NULL; if (synth_name == NULL) return 0; if (strcmp(synth_name, "none") == 0) { mutex_lock(&spk_mutex); synth_release(); mutex_unlock(&spk_mutex); return 0; } mutex_lock(&spk_mutex); /* First, check if we already have it loaded. */ for (i = 0; synths[i] != NULL && i < MAXSYNTHS; i++) if (strcmp(synths[i]->name, synth_name) == 0) synth = synths[i]; /* If we got one, initialize it now. */ if (synth) ret = do_synth_init(synth); else ret = -ENODEV; mutex_unlock(&spk_mutex); return ret; }
int synth_init(char *synth_name) { int i; int ret = 0; struct spk_synth *synth = NULL; if (synth_name == NULL) return 0; if (strcmp(synth_name, "none") == 0) { mutex_lock(&spk_mutex); synth_release(); mutex_unlock(&spk_mutex); return 0; } mutex_lock(&spk_mutex); for (i = 0; synths[i] != NULL && i < MAXSYNTHS; i++) if (strcmp(synths[i]->name, synth_name) == 0) synth = synths[i]; if (synth) ret = do_synth_init(synth); else ret = -ENODEV; mutex_unlock(&spk_mutex); return ret; }
void synth_remove(struct spk_synth *in_synth) { int i; mutex_lock(&spk_mutex); if (synth == in_synth) synth_release(); for (i = 0; synths[i] != NULL; i++) { if (in_synth == synths[i]) break; } for ( ; synths[i] != NULL; i++) /* compress table */ synths[i] = synths[i+1]; module_status = 0; mutex_unlock(&spk_mutex); }
/* called by: synth_add() */ static int do_synth_init(struct spk_synth *in_synth) { struct var_t *var; synth_release(); if (in_synth->checkval != SYNTH_CHECK) return -EINVAL; synth = in_synth; synth->alive = 0; pr_warn("synth probe\n"); if (synth->probe(synth) < 0) { pr_warn("%s: device probe failed\n", in_synth->name); synth = NULL; return -ENODEV; } synth_time_vars[0].u.n.value = synth_time_vars[0].u.n.default_val = synth->delay; synth_time_vars[1].u.n.value = synth_time_vars[1].u.n.default_val = synth->trigger; synth_time_vars[2].u.n.value = synth_time_vars[2].u.n.default_val = synth->jiffies; synth_time_vars[3].u.n.value = synth_time_vars[3].u.n.default_val = synth->full; synth_printf("%s", synth->init); for (var = synth->vars; (var->var_id >= 0) && (var->var_id < MAXVARS); var++) speakup_register_var(var); if (!quiet_boot) synth_printf("%s found\n", synth->long_name); if (synth->attributes.name && sysfs_create_group(speakup_kobj, &(synth->attributes)) < 0) return -ENOMEM; synth_flags = synth->flags; wake_up_interruptible_all(&speakup_event); if (speakup_task) wake_up_process(speakup_task); return 0; }