Commit 8a21ff77 authored by Okash Khawaja's avatar Okash Khawaja Committed by Greg Kroah-Hartman

staging: speakup: make ttyio synths use device name

This patch introduces new module parameter, dev, which takes a string
representing the device that the external synth is connected to, e.g.
ttyS0, ttyUSB0 etc. This is then used to communicate with the synth.
That way, speakup can support more than ttyS*. As of this patch, it
only supports ttyS*, ttyUSB* and selected synths for lp*. dev parameter
is only available for tty-migrated synths.

Users will either use dev or ser as both serve same purpose. This patch
maintains backward compatility by allowing ser to be specified. When
both are specified, whichever is non-default, i.e. not ttyS0, is used.
If both are non-default then dev is used.
Signed-off-by: default avatarOkash Khawaja <okash.khawaja@gmail.com>
Reviewed-by: default avatarSamuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a5525dc0
...@@ -96,6 +96,7 @@ static struct spk_synth synth_acntsa = { ...@@ -96,6 +96,7 @@ static struct spk_synth synth_acntsa = {
.trigger = 50, .trigger = 50,
.jiffies = 30, .jiffies = 30,
.full = 40000, .full = 40000,
.dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START, .startup = SYNTH_START,
.checkval = SYNTH_CHECK, .checkval = SYNTH_CHECK,
.vars = vars, .vars = vars,
...@@ -135,9 +136,11 @@ static int synth_probe(struct spk_synth *synth) ...@@ -135,9 +136,11 @@ static int synth_probe(struct spk_synth *synth)
} }
module_param_named(ser, synth_acntsa.ser, int, 0444); module_param_named(ser, synth_acntsa.ser, int, 0444);
module_param_named(dev, synth_acntsa.dev_name, charp, S_IRUGO);
module_param_named(start, synth_acntsa.startup, short, 0444); module_param_named(start, synth_acntsa.startup, short, 0444);
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_acntsa); module_spk_synth(synth_acntsa);
......
...@@ -105,6 +105,7 @@ static struct spk_synth synth_apollo = { ...@@ -105,6 +105,7 @@ static struct spk_synth synth_apollo = {
.trigger = 50, .trigger = 50,
.jiffies = 50, .jiffies = 50,
.full = 40000, .full = 40000,
.dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START, .startup = SYNTH_START,
.checkval = SYNTH_CHECK, .checkval = SYNTH_CHECK,
.vars = vars, .vars = vars,
...@@ -199,9 +200,11 @@ static void do_catch_up(struct spk_synth *synth) ...@@ -199,9 +200,11 @@ static void do_catch_up(struct spk_synth *synth)
} }
module_param_named(ser, synth_apollo.ser, int, 0444); module_param_named(ser, synth_apollo.ser, int, 0444);
module_param_named(dev, synth_apollo.dev_name, charp, S_IRUGO);
module_param_named(start, synth_apollo.startup, short, 0444); module_param_named(start, synth_apollo.startup, short, 0444);
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_apollo); module_spk_synth(synth_apollo);
......
...@@ -100,6 +100,7 @@ static struct spk_synth synth_audptr = { ...@@ -100,6 +100,7 @@ static struct spk_synth synth_audptr = {
.trigger = 50, .trigger = 50,
.jiffies = 30, .jiffies = 30,
.full = 18000, .full = 18000,
.dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START, .startup = SYNTH_START,
.checkval = SYNTH_CHECK, .checkval = SYNTH_CHECK,
.vars = vars, .vars = vars,
...@@ -162,9 +163,11 @@ static int synth_probe(struct spk_synth *synth) ...@@ -162,9 +163,11 @@ static int synth_probe(struct spk_synth *synth)
} }
module_param_named(ser, synth_audptr.ser, int, 0444); module_param_named(ser, synth_audptr.ser, int, 0444);
module_param_named(dev, synth_audptr.dev_name, charp, S_IRUGO);
module_param_named(start, synth_audptr.startup, short, 0444); module_param_named(start, synth_audptr.startup, short, 0444);
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_audptr); module_spk_synth(synth_audptr);
......
...@@ -93,6 +93,7 @@ static struct spk_synth synth_bns = { ...@@ -93,6 +93,7 @@ static struct spk_synth synth_bns = {
.trigger = 50, .trigger = 50,
.jiffies = 50, .jiffies = 50,
.full = 40000, .full = 40000,
.dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START, .startup = SYNTH_START,
.checkval = SYNTH_CHECK, .checkval = SYNTH_CHECK,
.vars = vars, .vars = vars,
...@@ -119,9 +120,11 @@ static struct spk_synth synth_bns = { ...@@ -119,9 +120,11 @@ static struct spk_synth synth_bns = {
}; };
module_param_named(ser, synth_bns.ser, int, 0444); module_param_named(ser, synth_bns.ser, int, 0444);
module_param_named(dev, synth_bns.dev_name, charp, S_IRUGO);
module_param_named(start, synth_bns.startup, short, 0444); module_param_named(start, synth_bns.startup, short, 0444);
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_bns); module_spk_synth(synth_bns);
......
...@@ -120,6 +120,7 @@ static struct spk_synth synth_decext = { ...@@ -120,6 +120,7 @@ static struct spk_synth synth_decext = {
.jiffies = 50, .jiffies = 50,
.full = 40000, .full = 40000,
.flags = SF_DEC, .flags = SF_DEC,
.dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START, .startup = SYNTH_START,
.checkval = SYNTH_CHECK, .checkval = SYNTH_CHECK,
.vars = vars, .vars = vars,
...@@ -226,9 +227,11 @@ static void synth_flush(struct spk_synth *synth) ...@@ -226,9 +227,11 @@ static void synth_flush(struct spk_synth *synth)
} }
module_param_named(ser, synth_decext.ser, int, 0444); module_param_named(ser, synth_decext.ser, int, 0444);
module_param_named(dev, synth_decext.dev_name, charp, S_IRUGO);
module_param_named(start, synth_decext.startup, short, 0444); module_param_named(start, synth_decext.startup, short, 0444);
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_decext); module_spk_synth(synth_decext);
......
...@@ -124,6 +124,7 @@ static struct spk_synth synth_dectlk = { ...@@ -124,6 +124,7 @@ static struct spk_synth synth_dectlk = {
.trigger = 50, .trigger = 50,
.jiffies = 50, .jiffies = 50,
.full = 40000, .full = 40000,
.dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START, .startup = SYNTH_START,
.checkval = SYNTH_CHECK, .checkval = SYNTH_CHECK,
.vars = vars, .vars = vars,
...@@ -298,9 +299,11 @@ static void synth_flush(struct spk_synth *synth) ...@@ -298,9 +299,11 @@ static void synth_flush(struct spk_synth *synth)
} }
module_param_named(ser, synth_dectlk.ser, int, 0444); module_param_named(ser, synth_dectlk.ser, int, 0444);
module_param_named(dev, synth_dectlk.dev_name, charp, S_IRUGO);
module_param_named(start, synth_dectlk.startup, short, 0444); module_param_named(start, synth_dectlk.startup, short, 0444);
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_dectlk); module_spk_synth(synth_dectlk);
......
...@@ -95,6 +95,7 @@ static struct spk_synth synth_dummy = { ...@@ -95,6 +95,7 @@ static struct spk_synth synth_dummy = {
.trigger = 50, .trigger = 50,
.jiffies = 50, .jiffies = 50,
.full = 40000, .full = 40000,
.dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START, .startup = SYNTH_START,
.checkval = SYNTH_CHECK, .checkval = SYNTH_CHECK,
.vars = vars, .vars = vars,
...@@ -121,9 +122,11 @@ static struct spk_synth synth_dummy = { ...@@ -121,9 +122,11 @@ static struct spk_synth synth_dummy = {
}; };
module_param_named(ser, synth_dummy.ser, int, 0444); module_param_named(ser, synth_dummy.ser, int, 0444);
module_param_named(dev, synth_dummy.dev_name, charp, S_IRUGO);
module_param_named(start, synth_dummy.startup, short, 0444); module_param_named(start, synth_dummy.startup, short, 0444);
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_dummy); module_spk_synth(synth_dummy);
......
...@@ -107,6 +107,7 @@ static struct spk_synth synth_ltlk = { ...@@ -107,6 +107,7 @@ static struct spk_synth synth_ltlk = {
.trigger = 50, .trigger = 50,
.jiffies = 50, .jiffies = 50,
.full = 40000, .full = 40000,
.dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START, .startup = SYNTH_START,
.checkval = SYNTH_CHECK, .checkval = SYNTH_CHECK,
.vars = vars, .vars = vars,
...@@ -166,9 +167,11 @@ static int synth_probe(struct spk_synth *synth) ...@@ -166,9 +167,11 @@ static int synth_probe(struct spk_synth *synth)
} }
module_param_named(ser, synth_ltlk.ser, int, 0444); module_param_named(ser, synth_ltlk.ser, int, 0444);
module_param_named(dev, synth_ltlk.dev_name, charp, S_IRUGO);
module_param_named(start, synth_ltlk.startup, short, 0444); module_param_named(start, synth_ltlk.startup, short, 0444);
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_ltlk); module_spk_synth(synth_ltlk);
......
...@@ -98,6 +98,7 @@ static struct spk_synth synth_spkout = { ...@@ -98,6 +98,7 @@ static struct spk_synth synth_spkout = {
.trigger = 50, .trigger = 50,
.jiffies = 50, .jiffies = 50,
.full = 40000, .full = 40000,
.dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START, .startup = SYNTH_START,
.checkval = SYNTH_CHECK, .checkval = SYNTH_CHECK,
.vars = vars, .vars = vars,
...@@ -130,9 +131,11 @@ static void synth_flush(struct spk_synth *synth) ...@@ -130,9 +131,11 @@ static void synth_flush(struct spk_synth *synth)
} }
module_param_named(ser, synth_spkout.ser, int, 0444); module_param_named(ser, synth_spkout.ser, int, 0444);
module_param_named(dev, synth_spkout.dev_name, charp, S_IRUGO);
module_param_named(start, synth_spkout.startup, short, 0444); module_param_named(start, synth_spkout.startup, short, 0444);
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_spkout); module_spk_synth(synth_spkout);
......
...@@ -92,6 +92,7 @@ static struct spk_synth synth_txprt = { ...@@ -92,6 +92,7 @@ static struct spk_synth synth_txprt = {
.trigger = 50, .trigger = 50,
.jiffies = 50, .jiffies = 50,
.full = 40000, .full = 40000,
.dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START, .startup = SYNTH_START,
.checkval = SYNTH_CHECK, .checkval = SYNTH_CHECK,
.vars = vars, .vars = vars,
...@@ -118,9 +119,11 @@ static struct spk_synth synth_txprt = { ...@@ -118,9 +119,11 @@ static struct spk_synth synth_txprt = {
}; };
module_param_named(ser, synth_txprt.ser, int, 0444); module_param_named(ser, synth_txprt.ser, int, 0444);
module_param_named(dev, synth_txprt.dev_name, charp, S_IRUGO);
module_param_named(start, synth_txprt.startup, short, 0444); module_param_named(start, synth_txprt.startup, short, 0444);
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_txprt); module_spk_synth(synth_txprt);
......
...@@ -147,11 +147,12 @@ static inline void get_termios(struct tty_struct *tty, struct ktermios *out_term ...@@ -147,11 +147,12 @@ static inline void get_termios(struct tty_struct *tty, struct ktermios *out_term
up_read(&tty->termios_rwsem); up_read(&tty->termios_rwsem);
} }
static int spk_ttyio_initialise_ldisc(int ser) static int spk_ttyio_initialise_ldisc(struct spk_synth *synth)
{ {
int ret = 0; int ret = 0;
struct tty_struct *tty; struct tty_struct *tty;
struct ktermios tmp_termios; struct ktermios tmp_termios;
dev_t dev;
ret = tty_register_ldisc(N_SPEAKUP, &spk_ttyio_ldisc_ops); ret = tty_register_ldisc(N_SPEAKUP, &spk_ttyio_ldisc_ops);
if (ret) { if (ret) {
...@@ -159,13 +160,11 @@ static int spk_ttyio_initialise_ldisc(int ser) ...@@ -159,13 +160,11 @@ static int spk_ttyio_initialise_ldisc(int ser)
return ret; return ret;
} }
if (ser < 0 || ser > (255 - 64)) { ret = get_dev_to_use(synth, &dev);
pr_err("speakup: Invalid ser param. Must be between 0 and 191 inclusive.\n"); if (ret)
return -EINVAL; return ret;
}
/* TODO: support more than ttyS* */ tty = tty_open_by_driver(dev, NULL, NULL);
tty = tty_open_by_driver(MKDEV(4, (ser + 64)), NULL, NULL);
if (IS_ERR(tty)) if (IS_ERR(tty))
return PTR_ERR(tty); return PTR_ERR(tty);
...@@ -277,7 +276,7 @@ static void spk_ttyio_flush_buffer(void) ...@@ -277,7 +276,7 @@ static void spk_ttyio_flush_buffer(void)
int spk_ttyio_synth_probe(struct spk_synth *synth) int spk_ttyio_synth_probe(struct spk_synth *synth)
{ {
int rv = spk_ttyio_initialise_ldisc(synth->ser); int rv = spk_ttyio_initialise_ldisc(synth);
if (rv) if (rv)
return rv; return rv;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment