Discussion:
[patch 1/2] staging: speakup: add function to convert dev name to number
Okash Khawaja
2017-06-10 11:24:11 UTC
Permalink
The function converts strings like ttyS0 and ttyUSB0 to dev_t like
(4, 64) and (188, 0). Subsequent patch in this set will call it to
convert user-supplied device into device number. The function does
some basic sanity checks on the string passed in. It currently supports
ttyS*, ttyUSB* and, for selected synths, lp*.

In order to do this, the patch also introduces a string member variable
named 'dev' to struct spk_synth. 'dev' represents the device name -
ttyUSB0 etc - which needs conversion to dev_t.

Signed-off-by: Okash Khawaja <***@gmail.com>

---
drivers/staging/speakup/spk_priv.h | 2
drivers/staging/speakup/spk_ttyio.c | 108 ++++++++++++++++++++++++++++++++++++
drivers/staging/speakup/spk_types.h | 1
3 files changed, 111 insertions(+)

--- a/drivers/staging/speakup/spk_priv.h
+++ b/drivers/staging/speakup/spk_priv.h
@@ -40,6 +40,8 @@

#define KT_SPKUP 15
#define SPK_SYNTH_TIMEOUT 100000 /* in micro-seconds */
+#define SYNTH_DEFAULT_DEV "ttyS0"
+#define SYNTH_DEFAULT_SER 0

const struct old_serial_port *spk_serial_init(int index);
void spk_stop_serial_interrupt(void);
--- a/drivers/staging/speakup/spk_ttyio.c
+++ b/drivers/staging/speakup/spk_ttyio.c
@@ -7,6 +7,13 @@
#include "spk_types.h"
#include "spk_priv.h"

+/* Supported device types */
+#define DEV_PREFIX_TTYS "ttyS"
+#define DEV_PREFIX_TTYUSB "ttyUSB"
+#define DEV_PREFIX_LP "lp"
+
+const char *lp_supported[] = { "acntsa", "bns", "dummy", "txprt" };
+
struct spk_ldisc_data {
char buf;
struct semaphore sem;
@@ -16,6 +23,107 @@ struct spk_ldisc_data {
static struct spk_synth *spk_ttyio_synth;
static struct tty_struct *speakup_tty;

+static int name_to_dev(const char *name, dev_t *dev_no)
+{
+ int maj = -1, min = -1;
+
+ if (strncmp(name, DEV_PREFIX_TTYS, strlen(DEV_PREFIX_TTYS)) == 0) {
+ if (kstrtoint(name + strlen(DEV_PREFIX_TTYS), 10, &min)) {
+ pr_err("speakup: Invalid ser param. Must be \
+ between 0 and 191 inclusive.\n");
+ return -EINVAL;
+ }
+ maj = 4;
+
+ if (min < 0 || min > 191) {
+ pr_err("speakup: Invalid ser param. Must be \
+ between 0 and 191 inclusive.\n");
+ return -EINVAL;
+ }
+ min = min + 64;
+ }
+
+ if (strncmp(name, DEV_PREFIX_TTYUSB, strlen(DEV_PREFIX_TTYUSB)) == 0) {
+ if (kstrtoint(name + strlen(DEV_PREFIX_TTYUSB), 10, &min)) {
+ pr_err("speakup: Invalid ttyUSB number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ maj = 188;
+
+ if (min < 0) {
+ pr_err("speakup: Invalid ttyUSB number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ }
+
+ if (strncmp(name, DEV_PREFIX_LP, strlen(DEV_PREFIX_LP)) == 0) {
+ if (kstrtoint(name + strlen(DEV_PREFIX_LP), 10, &min)) {
+ pr_warn("speakup: Invalid lp number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ maj = 6;
+
+ if (min < 0) {
+ pr_warn("speakup: Invalid lp number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ }
+
+ if (maj == -1 || min == -1)
+ return -EINVAL;
+
+ /* if here, maj and min must be valid */
+ *dev_no = MKDEV(maj, min);
+
+ return 0;
+}
+
+int ser_to_dev(int ser, dev_t *dev_no)
+{
+ if (ser < 0 || ser > (255 - 64)) {
+ pr_err("speakup: Invalid ser param. \
+ Must be between 0 and 191 inclusive.\n");
+
+ return -EINVAL;
+ }
+
+ *dev_no = MKDEV(4, (64 + ser));
+ return 0;
+}
+
+static int get_dev_to_use(struct spk_synth *synth, dev_t *dev_no)
+{
+ /* use ser only when dev is not specified */
+ if (strcmp(synth->dev, SYNTH_DEFAULT_DEV) || synth->ser == SYNTH_DEFAULT_SER) {
+ /* for /dev/lp* check if synth is supported */
+ if (strncmp(synth->dev, DEV_PREFIX_LP, strlen(DEV_PREFIX_LP)) == 0) {
+ int i, len = sizeof(lp_supported) / sizeof(*lp_supported);
+
+ for (i = 0; i < len; i++) {
+ if (strcmp(synth->name, lp_supported[i]) == 0)
+ break;
+ }
+
+ if (i >= len) {
+ pr_err("speakup: lp* is only supported on: ");
+ for (i = 0; i < len; i++)
+ pr_cont("%s ", lp_supported[i]);
+ pr_cont("\n");
+
+ return -ENOTSUPP;
+ }
+ }
+
+ return name_to_dev(synth->dev, dev_no);
+ }
+
+ return ser_to_dev(synth->ser, dev_no);
+}
+
static int spk_ttyio_ldisc_open(struct tty_struct *tty)
{
struct spk_ldisc_data *ldisc_data;
--- a/drivers/staging/speakup/spk_types.h
+++ b/drivers/staging/speakup/spk_types.h
@@ -169,6 +169,7 @@ struct spk_synth {
int jiffies;
int full;
int ser;
+ char *dev;
short flags;
short startup;
const int checkval; /* for validating a proper synth module */
Okash Khawaja
2017-06-10 11:24:12 UTC
Permalink
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: Okash Khawaja <***@gmail.com>

---
drivers/staging/speakup/speakup_acntsa.c | 3 +++
drivers/staging/speakup/speakup_apollo.c | 3 +++
drivers/staging/speakup/speakup_audptr.c | 3 +++
drivers/staging/speakup/speakup_bns.c | 3 +++
drivers/staging/speakup/speakup_decext.c | 3 +++
drivers/staging/speakup/speakup_dectlk.c | 3 +++
drivers/staging/speakup/speakup_dummy.c | 3 +++
drivers/staging/speakup/speakup_ltlk.c | 3 +++
drivers/staging/speakup/speakup_spkout.c | 3 +++
drivers/staging/speakup/speakup_txprt.c | 3 +++
drivers/staging/speakup/spk_ttyio.c | 15 +++++++--------
11 files changed, 37 insertions(+), 8 deletions(-)

--- a/drivers/staging/speakup/speakup_acntsa.c
+++ b/drivers/staging/speakup/speakup_acntsa.c
@@ -96,6 +96,7 @@ static struct spk_synth synth_acntsa = {
.trigger = 50,
.jiffies = 30,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -135,9 +136,11 @@ static int synth_probe(struct spk_synth
}

module_param_named(ser, synth_acntsa.ser, int, 0444);
+module_param_named(dev, synth_acntsa.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_acntsa);
--- a/drivers/staging/speakup/speakup_apollo.c
+++ b/drivers/staging/speakup/speakup_apollo.c
@@ -105,6 +105,7 @@ static struct spk_synth synth_apollo = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -199,9 +200,11 @@ static void do_catch_up(struct spk_synth
}

module_param_named(ser, synth_apollo.ser, int, 0444);
+module_param_named(dev, synth_apollo.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_apollo);
--- a/drivers/staging/speakup/speakup_audptr.c
+++ b/drivers/staging/speakup/speakup_audptr.c
@@ -100,6 +100,7 @@ static struct spk_synth synth_audptr = {
.trigger = 50,
.jiffies = 30,
.full = 18000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -162,9 +163,11 @@ static int synth_probe(struct spk_synth
}

module_param_named(ser, synth_audptr.ser, int, 0444);
+module_param_named(dev, synth_audptr.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_audptr);
--- a/drivers/staging/speakup/speakup_bns.c
+++ b/drivers/staging/speakup/speakup_bns.c
@@ -93,6 +93,7 @@ static struct spk_synth synth_bns = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -119,9 +120,11 @@ static struct spk_synth synth_bns = {
};

module_param_named(ser, synth_bns.ser, int, 0444);
+module_param_named(dev, synth_bns.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_bns);
--- a/drivers/staging/speakup/speakup_decext.c
+++ b/drivers/staging/speakup/speakup_decext.c
@@ -120,6 +120,7 @@ static struct spk_synth synth_decext = {
.jiffies = 50,
.full = 40000,
.flags = SF_DEC,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -226,9 +227,11 @@ static void synth_flush(struct spk_synth
}

module_param_named(ser, synth_decext.ser, int, 0444);
+module_param_named(dev, synth_decext.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_decext);
--- a/drivers/staging/speakup/speakup_dectlk.c
+++ b/drivers/staging/speakup/speakup_dectlk.c
@@ -124,6 +124,7 @@ static struct spk_synth synth_dectlk = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -298,9 +299,11 @@ static void synth_flush(struct spk_synth
}

module_param_named(ser, synth_dectlk.ser, int, 0444);
+module_param_named(dev, synth_dectlk.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_dectlk);
--- a/drivers/staging/speakup/speakup_dummy.c
+++ b/drivers/staging/speakup/speakup_dummy.c
@@ -95,6 +95,7 @@ static struct spk_synth synth_dummy = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -121,9 +122,11 @@ static struct spk_synth synth_dummy = {
};

module_param_named(ser, synth_dummy.ser, int, 0444);
+module_param_named(dev, synth_dummy.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_dummy);
--- a/drivers/staging/speakup/speakup_ltlk.c
+++ b/drivers/staging/speakup/speakup_ltlk.c
@@ -107,6 +107,7 @@ static struct spk_synth synth_ltlk = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -166,9 +167,11 @@ static int synth_probe(struct spk_synth
}

module_param_named(ser, synth_ltlk.ser, int, 0444);
+module_param_named(dev, synth_ltlk.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_ltlk);
--- a/drivers/staging/speakup/speakup_spkout.c
+++ b/drivers/staging/speakup/speakup_spkout.c
@@ -98,6 +98,7 @@ static struct spk_synth synth_spkout = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -130,9 +131,11 @@ static void synth_flush(struct spk_synth
}

module_param_named(ser, synth_spkout.ser, int, 0444);
+module_param_named(dev, synth_spkout.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_spkout);
--- a/drivers/staging/speakup/speakup_txprt.c
+++ b/drivers/staging/speakup/speakup_txprt.c
@@ -92,6 +92,7 @@ static struct spk_synth synth_txprt = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -118,9 +119,11 @@ static struct spk_synth synth_txprt = {
};

module_param_named(ser, synth_txprt.ser, int, 0444);
+module_param_named(dev, synth_txprt.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_txprt);
--- a/drivers/staging/speakup/spk_ttyio.c
+++ b/drivers/staging/speakup/spk_ttyio.c
@@ -212,11 +212,12 @@ static inline void get_termios(struct tt
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;
struct tty_struct *tty;
struct ktermios tmp_termios;
+ dev_t dev;

ret = tty_register_ldisc(N_SPEAKUP, &spk_ttyio_ldisc_ops);
if (ret) {
@@ -224,13 +225,11 @@ static int spk_ttyio_initialise_ldisc(in
return ret;
}

- if (ser < 0 || ser > (255 - 64)) {
- pr_err("speakup: Invalid ser param. Must be between 0 and 191 inclusive.\n");
- return -EINVAL;
- }
+ ret = get_dev_to_use(synth, &dev);
+ if (ret)
+ return ret;

- /* TODO: support more than ttyS* */
- tty = tty_open_by_driver(MKDEV(4, (ser + 64)), NULL, NULL);
+ tty = tty_open_by_driver(dev, NULL, NULL);
if (IS_ERR(tty))
return PTR_ERR(tty);

@@ -341,7 +340,7 @@ static void spk_ttyio_flush_buffer(void)

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)
return rv;
Samuel Thibault
2017-06-12 07:35:29 UTC
Permalink
Post by Okash Khawaja
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.
---
drivers/staging/speakup/speakup_acntsa.c | 3 +++
drivers/staging/speakup/speakup_apollo.c | 3 +++
drivers/staging/speakup/speakup_audptr.c | 3 +++
drivers/staging/speakup/speakup_bns.c | 3 +++
drivers/staging/speakup/speakup_decext.c | 3 +++
drivers/staging/speakup/speakup_dectlk.c | 3 +++
drivers/staging/speakup/speakup_dummy.c | 3 +++
drivers/staging/speakup/speakup_ltlk.c | 3 +++
drivers/staging/speakup/speakup_spkout.c | 3 +++
drivers/staging/speakup/speakup_txprt.c | 3 +++
drivers/staging/speakup/spk_ttyio.c | 15 +++++++--------
11 files changed, 37 insertions(+), 8 deletions(-)
--- a/drivers/staging/speakup/speakup_acntsa.c
+++ b/drivers/staging/speakup/speakup_acntsa.c
@@ -96,6 +96,7 @@ static struct spk_synth synth_acntsa = {
.trigger = 50,
.jiffies = 30,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -135,9 +136,11 @@ static int synth_probe(struct spk_synth
}
module_param_named(ser, synth_acntsa.ser, int, 0444);
+module_param_named(dev, synth_acntsa.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_acntsa);
--- a/drivers/staging/speakup/speakup_apollo.c
+++ b/drivers/staging/speakup/speakup_apollo.c
@@ -105,6 +105,7 @@ static struct spk_synth synth_apollo = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -199,9 +200,11 @@ static void do_catch_up(struct spk_synth
}
module_param_named(ser, synth_apollo.ser, int, 0444);
+module_param_named(dev, synth_apollo.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_apollo);
--- a/drivers/staging/speakup/speakup_audptr.c
+++ b/drivers/staging/speakup/speakup_audptr.c
@@ -100,6 +100,7 @@ static struct spk_synth synth_audptr = {
.trigger = 50,
.jiffies = 30,
.full = 18000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -162,9 +163,11 @@ static int synth_probe(struct spk_synth
}
module_param_named(ser, synth_audptr.ser, int, 0444);
+module_param_named(dev, synth_audptr.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_audptr);
--- a/drivers/staging/speakup/speakup_bns.c
+++ b/drivers/staging/speakup/speakup_bns.c
@@ -93,6 +93,7 @@ static struct spk_synth synth_bns = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -119,9 +120,11 @@ static struct spk_synth synth_bns = {
};
module_param_named(ser, synth_bns.ser, int, 0444);
+module_param_named(dev, synth_bns.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_bns);
--- a/drivers/staging/speakup/speakup_decext.c
+++ b/drivers/staging/speakup/speakup_decext.c
@@ -120,6 +120,7 @@ static struct spk_synth synth_decext = {
.jiffies = 50,
.full = 40000,
.flags = SF_DEC,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -226,9 +227,11 @@ static void synth_flush(struct spk_synth
}
module_param_named(ser, synth_decext.ser, int, 0444);
+module_param_named(dev, synth_decext.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_decext);
--- a/drivers/staging/speakup/speakup_dectlk.c
+++ b/drivers/staging/speakup/speakup_dectlk.c
@@ -124,6 +124,7 @@ static struct spk_synth synth_dectlk = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -298,9 +299,11 @@ static void synth_flush(struct spk_synth
}
module_param_named(ser, synth_dectlk.ser, int, 0444);
+module_param_named(dev, synth_dectlk.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_dectlk);
--- a/drivers/staging/speakup/speakup_dummy.c
+++ b/drivers/staging/speakup/speakup_dummy.c
@@ -95,6 +95,7 @@ static struct spk_synth synth_dummy = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -121,9 +122,11 @@ static struct spk_synth synth_dummy = {
};
module_param_named(ser, synth_dummy.ser, int, 0444);
+module_param_named(dev, synth_dummy.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_dummy);
--- a/drivers/staging/speakup/speakup_ltlk.c
+++ b/drivers/staging/speakup/speakup_ltlk.c
@@ -107,6 +107,7 @@ static struct spk_synth synth_ltlk = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -166,9 +167,11 @@ static int synth_probe(struct spk_synth
}
module_param_named(ser, synth_ltlk.ser, int, 0444);
+module_param_named(dev, synth_ltlk.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_ltlk);
--- a/drivers/staging/speakup/speakup_spkout.c
+++ b/drivers/staging/speakup/speakup_spkout.c
@@ -98,6 +98,7 @@ static struct spk_synth synth_spkout = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -130,9 +131,11 @@ static void synth_flush(struct spk_synth
}
module_param_named(ser, synth_spkout.ser, int, 0444);
+module_param_named(dev, synth_spkout.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_spkout);
--- a/drivers/staging/speakup/speakup_txprt.c
+++ b/drivers/staging/speakup/speakup_txprt.c
@@ -92,6 +92,7 @@ static struct spk_synth synth_txprt = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -118,9 +119,11 @@ static struct spk_synth synth_txprt = {
};
module_param_named(ser, synth_txprt.ser, int, 0444);
+module_param_named(dev, synth_txprt.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
module_spk_synth(synth_txprt);
--- a/drivers/staging/speakup/spk_ttyio.c
+++ b/drivers/staging/speakup/spk_ttyio.c
@@ -212,11 +212,12 @@ static inline void get_termios(struct tt
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;
struct tty_struct *tty;
struct ktermios tmp_termios;
+ dev_t dev;
ret = tty_register_ldisc(N_SPEAKUP, &spk_ttyio_ldisc_ops);
if (ret) {
@@ -224,13 +225,11 @@ static int spk_ttyio_initialise_ldisc(in
return ret;
}
- if (ser < 0 || ser > (255 - 64)) {
- pr_err("speakup: Invalid ser param. Must be between 0 and 191 inclusive.\n");
- return -EINVAL;
- }
+ ret = get_dev_to_use(synth, &dev);
+ if (ret)
+ return ret;
- /* TODO: support more than ttyS* */
- tty = tty_open_by_driver(MKDEV(4, (ser + 64)), NULL, NULL);
+ tty = tty_open_by_driver(dev, NULL, NULL);
if (IS_ERR(tty))
return PTR_ERR(tty);
@@ -341,7 +340,7 @@ static void spk_ttyio_flush_buffer(void)
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)
return rv;
--
Samuel
$ du temp.iso
2,0T temp.iso
$ ls temp.iso -l
-r-xr-xr-x 1 samy thibault 16E 2003-03-22 14:44 temp.iso*
-+- je vous dirai pas la marque de mon disque dur, na :p -+-
Okash Khawaja
2017-06-10 11:29:29 UTC
Permalink
Hi,
These patches extend speakup support to ttyS* and lp*. They introduce a
new module param dev whose purpose is similar to ser but instead of
taking serial port number as argument, it takes strings like ttyS0 or
ttyUSB0. First patch just adds functionality to convert such strings
into dev_t. Second patch makes use of that functionlity.
I have updated the speakup-decext repo [1] to latest, including bns
migration and support for more than ttyS*. Please do test with 'dev'
module param.

One thing I noticed in my testing is that when loading with incorrect
'dev' value several times in a row, it eventually succeeds in loading.
That seems like an existing issue with synths[] array which caches
already loaded synths. I am investigating it now.

[1] https://github.com/bytefire/speakup-decext

Cheers!
Okash
Gregory Nowak
2017-06-14 04:50:35 UTC
Permalink
Okash and list, I tried building the modules from your repo, and am
running into a compilation error. I'll describe what I did. I'm
building on the same machine and in the same environment that I used
for my previous speakup testing. This is on a devuan 1.0 system.

1. git clone https://github.com/bytefire/speakup-decext
The repo cloned without issues.

2. Since the speakup-decext.txt file still mentions using the 4.10.9
kernel tree, I used the source I already had built previously, and
just got rid of drivers/staging/speakup.

3. Move speakup2.tgz to drivers/staging, and extract it. All went ok.

4. cd to the root of the kernel source, and run make modules:

CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CC [M] drivers/staging/speakup/speakup_acntpc.o
drivers/staging/speakup/speakup_acntpc.c:313:42: error: expected )
before int
module_param_hw_named(port, port_forced, int, ioport, 0444);
^
scripts/Makefile.build:300: recipe for target
'drivers/staging/speakup/speakup_acntpc.o' failed
make[3]: *** [drivers/staging/speakup/speakup_acntpc.o] Error 1
scripts/Makefile.build:553: recipe for target
'drivers/staging/speakup' failed
make[2]: *** [drivers/staging/speakup] Error 2
scripts/Makefile.build:553: recipe for target 'drivers/staging' failed
make[1]: *** [drivers/staging] Error 2
Makefile:988: recipe for target 'drivers' failed
make: *** [drivers] Error 2

What I find strange here is that the acntpc driver is for the internal
isa card, so it shouldn't have been effected by the serial changes,
correct?

I don't need the acntpc module, so I could just remove it from the
config, and go on. However, others who build a kernel using debian's
default kernel config will have the module included, and will probably
run into this. Thanks.

Greg
Post by Okash Khawaja
Hi,
These patches extend speakup support to ttyS* and lp*. They introduce a
new module param dev whose purpose is similar to ser but instead of
taking serial port number as argument, it takes strings like ttyS0 or
ttyUSB0. First patch just adds functionality to convert such strings
into dev_t. Second patch makes use of that functionlity.
I have updated the speakup-decext repo [1] to latest, including bns
migration and support for more than ttyS*. Please do test with 'dev'
module param.
One thing I noticed in my testing is that when loading with incorrect
'dev' value several times in a row, it eventually succeeds in loading.
That seems like an existing issue with synths[] array which caches
already loaded synths. I am investigating it now.
[1] https://github.com/bytefire/speakup-decext
Cheers!
Okash
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.

--
Free domains: http://www.eu.org/ or mail dns-***@EU.org
Okash Khawaja
2017-06-15 07:33:22 UTC
Permalink
Hey Greg,

Thanks for that. You're right, acntpc shouldn't have been affected. I will investigate this today.

Cheers,
Okash
Post by Gregory Nowak
Okash and list, I tried building the modules from your repo, and am
running into a compilation error. I'll describe what I did. I'm
building on the same machine and in the same environment that I used
for my previous speakup testing. This is on a devuan 1.0 system.
1. git clone https://github.com/bytefire/speakup-decext
The repo cloned without issues.
2. Since the speakup-decext.txt file still mentions using the 4.10.9
kernel tree, I used the source I already had built previously, and
just got rid of drivers/staging/speakup.
3. Move speakup2.tgz to drivers/staging, and extract it. All went ok.
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CC [M] drivers/staging/speakup/speakup_acntpc.o
drivers/staging/speakup/speakup_acntpc.c:313:42: error: expected )
before int
module_param_hw_named(port, port_forced, int, ioport, 0444);
^
scripts/Makefile.build:300: recipe for target
'drivers/staging/speakup/speakup_acntpc.o' failed
make[3]: *** [drivers/staging/speakup/speakup_acntpc.o] Error 1
scripts/Makefile.build:553: recipe for target
'drivers/staging/speakup' failed
make[2]: *** [drivers/staging/speakup] Error 2
scripts/Makefile.build:553: recipe for target 'drivers/staging' failed
make[1]: *** [drivers/staging] Error 2
Makefile:988: recipe for target 'drivers' failed
make: *** [drivers] Error 2
What I find strange here is that the acntpc driver is for the internal
isa card, so it shouldn't have been effected by the serial changes,
correct?
I don't need the acntpc module, so I could just remove it from the
config, and go on. However, others who build a kernel using debian's
default kernel config will have the module included, and will probably
run into this. Thanks.
Greg
Post by Okash Khawaja
Hi,
These patches extend speakup support to ttyS* and lp*. They introduce a
new module param dev whose purpose is similar to ser but instead of
taking serial port number as argument, it takes strings like ttyS0 or
ttyUSB0. First patch just adds functionality to convert such strings
into dev_t. Second patch makes use of that functionlity.
I have updated the speakup-decext repo [1] to latest, including bns
migration and support for more than ttyS*. Please do test with 'dev'
module param.
One thing I noticed in my testing is that when loading with incorrect
'dev' value several times in a row, it eventually succeeds in loading.
That seems like an existing issue with synths[] array which caches
already loaded synths. I am investigating it now.
[1] https://github.com/bytefire/speakup-decext
Cheers!
Okash
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.
--
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
Okash Khawaja
2017-06-18 09:53:24 UTC
Permalink
Hi all and Greg,

I could compile acntpc on local machine which inlcudes these changes.
But I didn't investigate this further because of the changes being made
to this patch set. I will update the repo with latest changes and also
make sure that acntpc compilation is fixed.

Thanks,
Okash
Post by Gregory Nowak
Okash and list, I tried building the modules from your repo, and am
running into a compilation error. I'll describe what I did. I'm
building on the same machine and in the same environment that I used
for my previous speakup testing. This is on a devuan 1.0 system.
1. git clone https://github.com/bytefire/speakup-decext
The repo cloned without issues.
2. Since the speakup-decext.txt file still mentions using the 4.10.9
kernel tree, I used the source I already had built previously, and
just got rid of drivers/staging/speakup.
3. Move speakup2.tgz to drivers/staging, and extract it. All went ok.
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CC [M] drivers/staging/speakup/speakup_acntpc.o
drivers/staging/speakup/speakup_acntpc.c:313:42: error: expected )
before int
module_param_hw_named(port, port_forced, int, ioport, 0444);
^
scripts/Makefile.build:300: recipe for target
'drivers/staging/speakup/speakup_acntpc.o' failed
make[3]: *** [drivers/staging/speakup/speakup_acntpc.o] Error 1
scripts/Makefile.build:553: recipe for target
'drivers/staging/speakup' failed
make[2]: *** [drivers/staging/speakup] Error 2
scripts/Makefile.build:553: recipe for target 'drivers/staging' failed
make[1]: *** [drivers/staging] Error 2
Makefile:988: recipe for target 'drivers' failed
make: *** [drivers] Error 2
What I find strange here is that the acntpc driver is for the internal
isa card, so it shouldn't have been effected by the serial changes,
correct?
I don't need the acntpc module, so I could just remove it from the
config, and go on. However, others who build a kernel using debian's
default kernel config will have the module included, and will probably
run into this. Thanks.
Greg
Post by Okash Khawaja
Hi,
These patches extend speakup support to ttyS* and lp*. They introduce a
new module param dev whose purpose is similar to ser but instead of
taking serial port number as argument, it takes strings like ttyS0 or
ttyUSB0. First patch just adds functionality to convert such strings
into dev_t. Second patch makes use of that functionlity.
I have updated the speakup-decext repo [1] to latest, including bns
migration and support for more than ttyS*. Please do test with 'dev'
module param.
One thing I noticed in my testing is that when loading with incorrect
'dev' value several times in a row, it eventually succeeds in loading.
That seems like an existing issue with synths[] array which caches
already loaded synths. I am investigating it now.
[1] https://github.com/bytefire/speakup-decext
Cheers!
Okash
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.
--
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
Gregory Nowak
2017-06-18 23:45:18 UTC
Permalink
Ok, perhaps I should have tried with a fresh kernel source, or a version
higher than 4.10.9. I'll try again once the speakup-decext repo is
updated with the latest changes. Thanks.

Greg
Post by Okash Khawaja
Hi all and Greg,
I could compile acntpc on local machine which inlcudes these changes.
But I didn't investigate this further because of the changes being made
to this patch set. I will update the repo with latest changes and also
make sure that acntpc compilation is fixed.
Thanks,
Okash
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.

--
Free domains: http://www.eu.org/ or mail dns-***@EU.org
Okash Khawaja
2017-06-21 08:11:13 UTC
Permalink
Hi,

I've updated the test repo [1] upto the latest patch. This includes
support for ttyUSB* and lp*.

Greg, I've tested it with 4.10.9 and made sure acntpc compiles.

Thanks,
Okash

[1] https://github.com/bytefire/speakup-decext
Post by Gregory Nowak
Ok, perhaps I should have tried with a fresh kernel source, or a version
higher than 4.10.9. I'll try again once the speakup-decext repo is
updated with the latest changes. Thanks.
Greg
Post by Okash Khawaja
Hi all and Greg,
I could compile acntpc on local machine which inlcudes these changes.
But I didn't investigate this further because of the changes being made
to this patch set. I will update the repo with latest changes and also
make sure that acntpc compilation is fixed.
Thanks,
Okash
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.
--
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
Gregory Nowak
2017-06-21 22:23:35 UTC
Permalink
Thanks, much appreciated. I should be able to get to it during the
weekend, and will report back once I do.

Greg
Post by Okash Khawaja
Hi,
I've updated the test repo [1] upto the latest patch. This includes
support for ttyUSB* and lp*.
Greg, I've tested it with 4.10.9 and made sure acntpc compiles.
Thanks,
Okash
[1] https://github.com/bytefire/speakup-decext
Post by Gregory Nowak
Ok, perhaps I should have tried with a fresh kernel source, or a version
higher than 4.10.9. I'll try again once the speakup-decext repo is
updated with the latest changes. Thanks.
Greg
Post by Okash Khawaja
Hi all and Greg,
I could compile acntpc on local machine which inlcudes these changes.
But I didn't investigate this further because of the changes being made
to this patch set. I will update the repo with latest changes and also
make sure that acntpc compilation is fixed.
Thanks,
Okash
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.
--
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.

--
Free domains: http://www.eu.org/ or mail dns-***@EU.org
Okash Khawaja
2017-06-21 22:37:13 UTC
Permalink
Please note that tty-export.patch has been updated.
Post by Gregory Nowak
Thanks, much appreciated. I should be able to get to it during the
weekend, and will report back once I do.
Greg
Post by Okash Khawaja
Hi,
I've updated the test repo [1] upto the latest patch. This includes
support for ttyUSB* and lp*.
Greg, I've tested it with 4.10.9 and made sure acntpc compiles.
Thanks,
Okash
[1] https://github.com/bytefire/speakup-decext
Post by Gregory Nowak
Ok, perhaps I should have tried with a fresh kernel source, or a version
higher than 4.10.9. I'll try again once the speakup-decext repo is
updated with the latest changes. Thanks.
Greg
Post by Okash Khawaja
Hi all and Greg,
I could compile acntpc on local machine which inlcudes these changes.
But I didn't investigate this further because of the changes being made
to this patch set. I will update the repo with latest changes and also
make sure that acntpc compilation is fixed.
Thanks,
Okash
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.
--
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.
--
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
Gregory Nowak
2017-06-21 23:48:39 UTC
Permalink
Ok. I just replaced drivers/staging/speakup last time. I'll start with
a fresh source tree.

Greg
Post by Okash Khawaja
Please note that tty-export.patch has been updated.
Post by Gregory Nowak
Thanks, much appreciated. I should be able to get to it during the
weekend, and will report back once I do.
Greg
Post by Okash Khawaja
Hi,
I've updated the test repo [1] upto the latest patch. This includes
support for ttyUSB* and lp*.
Greg, I've tested it with 4.10.9 and made sure acntpc compiles.
Thanks,
Okash
[1] https://github.com/bytefire/speakup-decext
Post by Gregory Nowak
Ok, perhaps I should have tried with a fresh kernel source, or a version
higher than 4.10.9. I'll try again once the speakup-decext repo is
updated with the latest changes. Thanks.
Greg
Post by Okash Khawaja
Hi all and Greg,
I could compile acntpc on local machine which inlcudes these changes.
But I didn't investigate this further because of the changes being made
to this patch set. I will update the repo with latest changes and also
make sure that acntpc compilation is fixed.
Thanks,
Okash
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.
--
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.
--
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.

--
Free domains: http://www.eu.org/ or mail dns-***@EU.org
Gregory Nowak
2017-06-26 22:35:08 UTC
Permalink
Okash and list,
the first good news is that acntpc does indeed compile. The second good news
is that the bns driver works fine just like it did before using
dev=ttyS0, and dev=ttyUSB0.

The bad news is that the bns driver doesn't work using dev=lp0 with
the braille blazer (blazer) connected to the parallel port using a
bidirectional cable, and set to speak whatever comes in through the
parallel port. When I booted up, the modules ppdev, parport, and
parport_pc were already loaded. When I loaded speakup_bns, I got this:
modprobe: ERROR: could not insert 'speakup_bns': No such device

The dmesg output showed:

[ 381.404108] speakup_bns: module is from the staging directory, the
quality is unknown, you have been warned.
[ 381.405251] synth probe
[ 381.405260] bns: device probe failed

At that point, I noticed that /dev/lp0 was missing. I fixed that by
modprobe lp, and tried speakup_bns again with the same results as
before. I then tried echoing data to /dev/lp0:
echo hello >/dev/lp0
and:
echo "hello" >/dev/lp0

both just came back with the prompt, and no speech from the
blazer. Trying:
cat /dev/lp0
came back with input/output error, which I expected. Leaving
everything connected and setup exactly as it was, I rebooted into
windows, and setup the windows screenreader to use the bns driver
through the parallel port. This resulted in speech from the blazer. I
just realized as I type this that I didn't enable echo's escape
processing, and try issuing a \n or a \r\n. The blazer almost certainly
needs one of those to speak what was just sent to it. I'll try that,
and will report back if the results are different. Also, I believe the
bns driver expects to read stuff back from the device before it
loads. It obviously won't be able to read anything back when using the
parallel port. I assume this was taken into account?

Finally, I also have a usb to parallel converter here. Just to see
what happens, I hooked it up, and it showed up as /dev/usb/lp0 using
the usblp module. Echoing the same things as before to that produced
the same results; shell prompt with no speech from the blazer. Using
cat however just sat there with no input coming, which isn't what I
expected. Since I wasn't sure if dev=/dev/usb/lp0 would be processed,
I created a softlink linking /dev/usb/lp0 to /dev/lp1, and passed
dev=lp1 to the speakup_bns module. The results were exactly the same
as with the built-in parallel port.

I'll try echoing \n and \r\n to the blazer, and will report back if
that produces speech. Is there some way to debug the bns driver to see
what it is sending, and getting back? Thanks for reading, and thanks
Okash for your work. The serial and usb support works, and that's
awesome. It would be nice if the parallel port worked too, but not a
huge deal if it doesn't when all is said and done.

Greg
Post by Okash Khawaja
Hi,
I've updated the test repo [1] upto the latest patch. This includes
support for ttyUSB* and lp*.
Greg, I've tested it with 4.10.9 and made sure acntpc compiles.
Thanks,
Okash
[1] https://github.com/bytefire/speakup-decext
Post by Gregory Nowak
Ok, perhaps I should have tried with a fresh kernel source, or a version
higher than 4.10.9. I'll try again once the speakup-decext repo is
updated with the latest changes. Thanks.
Greg
Post by Okash Khawaja
Hi all and Greg,
I could compile acntpc on local machine which inlcudes these changes.
But I didn't investigate this further because of the changes being made
to this patch set. I will update the repo with latest changes and also
make sure that acntpc compilation is fixed.
Thanks,
Okash
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.
--
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
_______________________________________________
Speakup mailing list
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.

--
Free domains: http://www.eu.org/ or mail dns-***@EU.org
Samuel Thibault
2017-06-26 22:46:09 UTC
Permalink
Hello,
Using cat however just sat there with no input coming, which isn't
what I expected.
Indeed, that's a bug that should be reported to the USB lp driver
maintainer.
Since I wasn't sure if dev=/dev/usb/lp0 would be processed, I created
a softlink linking /dev/usb/lp0 to /dev/lp1,
The speakup module does not read /dev, it uses the tty names.

Could you tell us the content of /proc/tty/drivers?

Perhaps it should then be dev=usb/lp0
I'll try echoing \n and \r\n to the blazer, and will report back if
that produces speech. Is there some way to debug the bns driver to see
what it is sending, and getting back?
In the case at stake, it's not even the bns driver which is reporting
the error, but the ttyio code itself. You can try to put printk() calls
in the ttyio probe function, to check which path it is following.

Samuel
Gregory Nowak
2017-06-27 03:55:29 UTC
Permalink
Post by Samuel Thibault
Using cat however just sat there with no input coming, which isn't
what I expected.
Indeed, that's a bug that should be reported to the USB lp driver
maintainer.
Are the chips in those converters able to recognize if they're
connected to a bidirectional device, and block reads if they aren't?
The converter I'm using is ieee1284 capable. If the chip in that
converter can't recognize if the connected device is bidirectional or
not, then I'm thinking it's better to allow reads in case the device
is bidirectional
Post by Samuel Thibault
Since I wasn't sure if dev=/dev/usb/lp0 would be processed, I created
a softlink linking /dev/usb/lp0 to /dev/lp1,
The speakup module does not read /dev, it uses the tty names.
Could you tell us the content of /proc/tty/drivers?
/dev/tty /dev/tty 5 0 system:/dev/tty
/dev/console /dev/console 5 1 system:console
/dev/ptmx /dev/ptmx 5 2 system
/dev/vc/0 /dev/vc/0 4 0 system:vtmaster
serial /dev/ttyS 4 64-95 serial
pty_slave /dev/pts 136 0-1048575 pty:slave
pty_master /dev/ptm 128 0-1048575 pty:master
unknown /dev/tty 4 1-63 console

Greg
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.

--
Free domains: http://www.eu.org/ or mail dns-***@EU.org
Samuel Thibault
2017-06-27 07:02:05 UTC
Permalink
Post by Gregory Nowak
Are the chips in those converters able to recognize if they're
connected to a bidirectional device, and block reads if they aren't?
The converter I'm using is ieee1284 capable. If the chip in that
converter can't recognize if the connected device is bidirectional or
not, then I'm thinking it's better to allow reads in case the device
is bidirectional
Ah, yes. I don't know.
Post by Gregory Nowak
Post by Samuel Thibault
Since I wasn't sure if dev=/dev/usb/lp0 would be processed, I created
a softlink linking /dev/usb/lp0 to /dev/lp1,
The speakup module does not read /dev, it uses the tty names.
Could you tell us the content of /proc/tty/drivers?
/dev/tty /dev/tty 5 0 system:/dev/tty
/dev/console /dev/console 5 1 system:console
/dev/ptmx /dev/ptmx 5 2 system
/dev/vc/0 /dev/vc/0 4 0 system:vtmaster
serial /dev/ttyS 4 64-95 serial
pty_slave /dev/pts 136 0-1048575 pty:slave
pty_master /dev/ptm 128 0-1048575 pty:master
unknown /dev/tty 4 1-63 console
So no lp indeed. No wonder it's not recognized.

Samuel
Okash Khawaja
2017-06-27 09:06:20 UTC
Permalink
Post by Samuel Thibault
Hello,
Using cat however just sat there with no input coming, which isn't
what I expected.
Indeed, that's a bug that should be reported to the USB lp driver
maintainer.
Since I wasn't sure if dev=/dev/usb/lp0 would be processed, I created
a softlink linking /dev/usb/lp0 to /dev/lp1,
The speakup module does not read /dev, it uses the tty names.
Could you tell us the content of /proc/tty/drivers?
Perhaps it should then be dev=usb/lp0
I'll try echoing \n and \r\n to the blazer, and will report back if
that produces speech. Is there some way to debug the bns driver to see
what it is sending, and getting back?
In the case at stake, it's not even the bns driver which is reporting
the error, but the ttyio code itself. You can try to put printk() calls
in the ttyio probe function, to check which path it is following.
Yes it's probably from spk_ttyio code failing to find a tty driver for
device whose name starts with "lp". spk_ttyio calls into a function in
tty which scans tty_drivers list for a driver which deals with lp
devices. If no such driver is registered with tty layer - which would be
the case if lp doesn't show as tty device, as Samuel pointed out in
the other email - then ENODEV is returned.

Thanks,
Okash

Samuel Thibault
2017-06-26 23:07:47 UTC
Permalink
Post by Gregory Nowak
[ 381.404108] speakup_bns: module is from the staging directory, the
quality is unknown, you have been warned.
[ 381.405251] synth probe
[ 381.405260] bns: device probe failed
At that point, I noticed that /dev/lp0 was missing. I fixed that by
modprobe lp, and tried speakup_bns again with the same results as
before.
Mmm, Okash, did you have the opportunity to test ttyio with lp?
Contrary to what I expected, it seems like it doesn't actually expose a
tty layer, it doesn't seem to show up in /proc/tty/drivers, and stty -a
< /dev/lp0 fails. So I'm afraid perhaps we can't actually use ttyio for
parallel port access, and thus we have to use the parport interface.
I'd say that's not a priority, though, and we should focus on making
ttyUSB0 work for now.

Samuel
Gregory Nowak
2017-06-26 23:39:21 UTC
Permalink
Post by Samuel Thibault
I'd say that's not a priority, though, and we should focus on making
ttyUSB0 work for now.
Agreed. Like I said, would be nice, but not a big deal.

Greg
--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.

--
Free domains: http://www.eu.org/ or mail dns-***@EU.org
Okash Khawaja
2017-06-27 08:57:13 UTC
Permalink
Hi,
Post by Samuel Thibault
Post by Gregory Nowak
[ 381.404108] speakup_bns: module is from the staging directory, the
quality is unknown, you have been warned.
[ 381.405251] synth probe
[ 381.405260] bns: device probe failed
At that point, I noticed that /dev/lp0 was missing. I fixed that by
modprobe lp, and tried speakup_bns again with the same results as
before.
Mmm, Okash, did you have the opportunity to test ttyio with lp?
No I didn't test with lp. But from what you've mentioned below, would
you say we remove lp support from the patches until parport is
implemented?
Post by Samuel Thibault
Contrary to what I expected, it seems like it doesn't actually expose a
tty layer, it doesn't seem to show up in /proc/tty/drivers, and stty -a
< /dev/lp0 fails. So I'm afraid perhaps we can't actually use ttyio for
parallel port access, and thus we have to use the parport interface.
I'd say that's not a priority, though, and we should focus on making
ttyUSB0 work for now.
Thanks,
Okash
Samuel Thibault
2017-06-27 08:58:09 UTC
Permalink
Post by Okash Khawaja
Post by Samuel Thibault
Post by Gregory Nowak
[ 381.404108] speakup_bns: module is from the staging directory, the
quality is unknown, you have been warned.
[ 381.405251] synth probe
[ 381.405260] bns: device probe failed
At that point, I noticed that /dev/lp0 was missing. I fixed that by
modprobe lp, and tried speakup_bns again with the same results as
before.
Mmm, Okash, did you have the opportunity to test ttyio with lp?
No I didn't test with lp. But from what you've mentioned below, would
you say we remove lp support from the patches until parport is
implemented?
Yes :/

Samuel
Samuel Thibault
2017-06-12 07:33:55 UTC
Permalink
Hello,
Post by Okash Khawaja
+ if (strncmp(name, DEV_PREFIX_TTYS, strlen(DEV_PREFIX_TTYS)) == 0) {
...
Post by Okash Khawaja
+ }
+
+ if (strncmp(name, DEV_PREFIX_TTYUSB, strlen(DEV_PREFIX_TTYUSB)) == 0) {
You can use "else if" here and below, not much optimization, but clearer
for the reader.
Post by Okash Khawaja
+static int get_dev_to_use(struct spk_synth *synth, dev_t *dev_no)
+{
+ /* use ser only when dev is not specified */
+ if (strcmp(synth->dev, SYNTH_DEFAULT_DEV) || synth->ser == SYNTH_DEFAULT_SER) {
+ /* for /dev/lp* check if synth is supported */
+ if (strncmp(synth->dev, DEV_PREFIX_LP, strlen(DEV_PREFIX_LP)) == 0) {
+ int i, len = sizeof(lp_supported) / sizeof(*lp_supported);
Use the ARRAY_SIZE() macro.
Post by Okash Khawaja
+
+ for (i = 0; i < len; i++) {
+ if (strcmp(synth->name, lp_supported[i]) == 0)
+ break;
+ }
+
+ if (i >= len) {
+ pr_err("speakup: lp* is only supported on: ");
+ for (i = 0; i < len; i++)
+ pr_cont("%s ", lp_supported[i]);
Really for nitpicking: rather put space before %s, after removing the
space after ':', so that we don't have a trailing space.

Samuel
Okash Khawaja
2017-06-12 12:17:56 UTC
Permalink
The function converts strings like ttyS0 and ttyUSB0 to dev_t like
(4, 64) and (188, 0). Subsequent patch in this set will call it to
convert user-supplied device into device number. The function does
some basic sanity checks on the string passed in. It currently supports
ttyS*, ttyUSB* and, for selected synths, lp*.

In order to do this, the patch also introduces a string member variable
named 'dev' to struct spk_synth. 'dev' represents the device name -
ttyUSB0 etc - which needs conversion to dev_t.

Signed-off-by: Okash Khawaja <***@gmail.com>

---
drivers/staging/speakup/spk_priv.h | 2
drivers/staging/speakup/spk_ttyio.c | 105 ++++++++++++++++++++++++++++++++++++
drivers/staging/speakup/spk_types.h | 1
3 files changed, 108 insertions(+)

--- a/drivers/staging/speakup/spk_priv.h
+++ b/drivers/staging/speakup/spk_priv.h
@@ -40,6 +40,8 @@

#define KT_SPKUP 15
#define SPK_SYNTH_TIMEOUT 100000 /* in micro-seconds */
+#define SYNTH_DEFAULT_DEV "ttyS0"
+#define SYNTH_DEFAULT_SER 0

const struct old_serial_port *spk_serial_init(int index);
void spk_stop_serial_interrupt(void);
--- a/drivers/staging/speakup/spk_ttyio.c
+++ b/drivers/staging/speakup/spk_ttyio.c
@@ -7,6 +7,13 @@
#include "spk_types.h"
#include "spk_priv.h"

+/* Supported device types */
+#define DEV_PREFIX_TTYS "ttyS"
+#define DEV_PREFIX_TTYUSB "ttyUSB"
+#define DEV_PREFIX_LP "lp"
+
+const char *lp_supported[] = { "acntsa", "bns", "dummy", "txprt" };
+
struct spk_ldisc_data {
char buf;
struct semaphore sem;
@@ -16,6 +23,104 @@ struct spk_ldisc_data {
static struct spk_synth *spk_ttyio_synth;
static struct tty_struct *speakup_tty;

+static int name_to_dev(const char *name, dev_t *dev_no)
+{
+ int maj = -1, min = -1;
+
+ if (strncmp(name, DEV_PREFIX_TTYS, strlen(DEV_PREFIX_TTYS)) == 0) {
+ if (kstrtoint(name + strlen(DEV_PREFIX_TTYS), 10, &min)) {
+ pr_err("speakup: Invalid ser param. Must be \
+ between 0 and 191 inclusive.\n");
+ return -EINVAL;
+ }
+ maj = 4;
+
+ if (min < 0 || min > 191) {
+ pr_err("speakup: Invalid ser param. Must be \
+ between 0 and 191 inclusive.\n");
+ return -EINVAL;
+ }
+ min = min + 64;
+ } else if (strncmp(name, DEV_PREFIX_TTYUSB, strlen(DEV_PREFIX_TTYUSB))
+ == 0) {
+ if (kstrtoint(name + strlen(DEV_PREFIX_TTYUSB), 10, &min)) {
+ pr_err("speakup: Invalid ttyUSB number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ maj = 188;
+
+ if (min < 0) {
+ pr_err("speakup: Invalid ttyUSB number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ } else if (strncmp(name, DEV_PREFIX_LP, strlen(DEV_PREFIX_LP)) == 0) {
+ if (kstrtoint(name + strlen(DEV_PREFIX_LP), 10, &min)) {
+ pr_warn("speakup: Invalid lp number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ maj = 6;
+
+ if (min < 0) {
+ pr_warn("speakup: Invalid lp number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ }
+
+ if (maj == -1 || min == -1)
+ return -EINVAL;
+
+ /* if here, maj and min must be valid */
+ *dev_no = MKDEV(maj, min);
+
+ return 0;
+}
+
+int ser_to_dev(int ser, dev_t *dev_no)
+{
+ if (ser < 0 || ser > (255 - 64)) {
+ pr_err("speakup: Invalid ser param. \
+ Must be between 0 and 191 inclusive.\n");
+
+ return -EINVAL;
+ }
+
+ *dev_no = MKDEV(4, (64 + ser));
+ return 0;
+}
+
+static int get_dev_to_use(struct spk_synth *synth, dev_t *dev_no)
+{
+ /* use ser only when dev is not specified */
+ if (strcmp(synth->dev, SYNTH_DEFAULT_DEV) || synth->ser == SYNTH_DEFAULT_SER) {
+ /* for /dev/lp* check if synth is supported */
+ if (strncmp(synth->dev, DEV_PREFIX_LP, strlen(DEV_PREFIX_LP)) == 0) {
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(lp_supported); i++) {
+ if (strcmp(synth->name, lp_supported[i]) == 0)
+ break;
+ }
+
+ if (i >= ARRAY_SIZE(lp_supported)) {
+ pr_err("speakup: lp* is only supported on:");
+ for (i = 0; i < ARRAY_SIZE(lp_supported); i++)
+ pr_cont(" %s", lp_supported[i]);
+ pr_cont("\n");
+
+ return -ENOTSUPP;
+ }
+ }
+
+ return name_to_dev(synth->dev, dev_no);
+ }
+
+ return ser_to_dev(synth->ser, dev_no);
+}
+
static int spk_ttyio_ldisc_open(struct tty_struct *tty)
{
struct spk_ldisc_data *ldisc_data;
--- a/drivers/staging/speakup/spk_types.h
+++ b/drivers/staging/speakup/spk_types.h
@@ -169,6 +169,7 @@ struct spk_synth {
int jiffies;
int full;
int ser;
+ char *dev;
short flags;
short startup;
const int checkval; /* for validating a proper synth module */
Okash Khawaja
2017-06-13 14:23:57 UTC
Permalink
Post by Okash Khawaja
The function converts strings like ttyS0 and ttyUSB0 to dev_t like
(4, 64) and (188, 0). Subsequent patch in this set will call it to
convert user-supplied device into device number. The function does
some basic sanity checks on the string passed in. It currently supports
ttyS*, ttyUSB* and, for selected synths, lp*.
In order to do this, the patch also introduces a string member variable
named 'dev' to struct spk_synth. 'dev' represents the device name -
ttyUSB0 etc - which needs conversion to dev_t.
Sorry should have marked it as v2 :)

Okash
Samuel Thibault
2017-06-13 13:24:07 UTC
Permalink
Post by Okash Khawaja
The function converts strings like ttyS0 and ttyUSB0 to dev_t like
(4, 64) and (188, 0). Subsequent patch in this set will call it to
convert user-supplied device into device number. The function does
some basic sanity checks on the string passed in. It currently supports
ttyS*, ttyUSB* and, for selected synths, lp*.
In order to do this, the patch also introduces a string member variable
named 'dev' to struct spk_synth. 'dev' represents the device name -
ttyUSB0 etc - which needs conversion to dev_t.
---
drivers/staging/speakup/spk_priv.h | 2
drivers/staging/speakup/spk_ttyio.c | 105 ++++++++++++++++++++++++++++++++++++
drivers/staging/speakup/spk_types.h | 1
3 files changed, 108 insertions(+)
--- a/drivers/staging/speakup/spk_priv.h
+++ b/drivers/staging/speakup/spk_priv.h
@@ -40,6 +40,8 @@
#define KT_SPKUP 15
#define SPK_SYNTH_TIMEOUT 100000 /* in micro-seconds */
+#define SYNTH_DEFAULT_DEV "ttyS0"
+#define SYNTH_DEFAULT_SER 0
const struct old_serial_port *spk_serial_init(int index);
void spk_stop_serial_interrupt(void);
--- a/drivers/staging/speakup/spk_ttyio.c
+++ b/drivers/staging/speakup/spk_ttyio.c
@@ -7,6 +7,13 @@
#include "spk_types.h"
#include "spk_priv.h"
+/* Supported device types */
+#define DEV_PREFIX_TTYS "ttyS"
+#define DEV_PREFIX_TTYUSB "ttyUSB"
+#define DEV_PREFIX_LP "lp"
+
+const char *lp_supported[] = { "acntsa", "bns", "dummy", "txprt" };
+
struct spk_ldisc_data {
char buf;
struct semaphore sem;
@@ -16,6 +23,104 @@ struct spk_ldisc_data {
static struct spk_synth *spk_ttyio_synth;
static struct tty_struct *speakup_tty;
+static int name_to_dev(const char *name, dev_t *dev_no)
+{
+ int maj = -1, min = -1;
+
+ if (strncmp(name, DEV_PREFIX_TTYS, strlen(DEV_PREFIX_TTYS)) == 0) {
+ if (kstrtoint(name + strlen(DEV_PREFIX_TTYS), 10, &min)) {
+ pr_err("speakup: Invalid ser param. Must be \
+ between 0 and 191 inclusive.\n");
+ return -EINVAL;
+ }
+ maj = 4;
+
+ if (min < 0 || min > 191) {
+ pr_err("speakup: Invalid ser param. Must be \
+ between 0 and 191 inclusive.\n");
+ return -EINVAL;
+ }
+ min = min + 64;
+ } else if (strncmp(name, DEV_PREFIX_TTYUSB, strlen(DEV_PREFIX_TTYUSB))
+ == 0) {
+ if (kstrtoint(name + strlen(DEV_PREFIX_TTYUSB), 10, &min)) {
+ pr_err("speakup: Invalid ttyUSB number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ maj = 188;
+
+ if (min < 0) {
+ pr_err("speakup: Invalid ttyUSB number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ } else if (strncmp(name, DEV_PREFIX_LP, strlen(DEV_PREFIX_LP)) == 0) {
+ if (kstrtoint(name + strlen(DEV_PREFIX_LP), 10, &min)) {
+ pr_warn("speakup: Invalid lp number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ maj = 6;
+
+ if (min < 0) {
+ pr_warn("speakup: Invalid lp number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ }
+
+ if (maj == -1 || min == -1)
+ return -EINVAL;
+
+ /* if here, maj and min must be valid */
+ *dev_no = MKDEV(maj, min);
+
+ return 0;
+}
+
+int ser_to_dev(int ser, dev_t *dev_no)
+{
+ if (ser < 0 || ser > (255 - 64)) {
+ pr_err("speakup: Invalid ser param. \
+ Must be between 0 and 191 inclusive.\n");
+
+ return -EINVAL;
+ }
+
+ *dev_no = MKDEV(4, (64 + ser));
+ return 0;
+}
+
+static int get_dev_to_use(struct spk_synth *synth, dev_t *dev_no)
+{
+ /* use ser only when dev is not specified */
+ if (strcmp(synth->dev, SYNTH_DEFAULT_DEV) || synth->ser == SYNTH_DEFAULT_SER) {
+ /* for /dev/lp* check if synth is supported */
+ if (strncmp(synth->dev, DEV_PREFIX_LP, strlen(DEV_PREFIX_LP)) == 0) {
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(lp_supported); i++) {
+ if (strcmp(synth->name, lp_supported[i]) == 0)
+ break;
+ }
+
+ if (i >= ARRAY_SIZE(lp_supported)) {
+ pr_err("speakup: lp* is only supported on:");
+ for (i = 0; i < ARRAY_SIZE(lp_supported); i++)
+ pr_cont(" %s", lp_supported[i]);
+ pr_cont("\n");
+
+ return -ENOTSUPP;
+ }
+ }
+
+ return name_to_dev(synth->dev, dev_no);
+ }
+
+ return ser_to_dev(synth->ser, dev_no);
+}
+
static int spk_ttyio_ldisc_open(struct tty_struct *tty)
{
struct spk_ldisc_data *ldisc_data;
--- a/drivers/staging/speakup/spk_types.h
+++ b/drivers/staging/speakup/spk_types.h
@@ -169,6 +169,7 @@ struct spk_synth {
int jiffies;
int full;
int ser;
+ char *dev;
short flags;
short startup;
const int checkval; /* for validating a proper synth module */
--
Samuel
J'ai beaucoup de mal a lire fcola quand il y a toutes les annonces de howto :
les annonces interessantes sont noyees dans les howto. Ca serait pas mal
de degager toute cette pollution dans un autre groupe.
JLM in Guide du linuxien pervers : "Cachez ces doc que je ne saurais voir"
o***@gmail.com
2017-06-13 22:37:03 UTC
Permalink
The function converts strings like ttyS0 and ttyUSB0 to dev_t like
(4, 64) and (188, 0). Subsequent patch in this set will call it to
convert user-supplied device into device number. The function does
some basic sanity checks on the string passed in. It currently supports
ttyS*, ttyUSB* and, for selected synths, lp*.

In order to do this, the patch also introduces a string member variable
named 'dev' to struct spk_synth. 'dev' represents the device name -
ttyUSB0 etc - which needs conversion to dev_t.

Signed-off-by: Okash Khawaja <***@gmail.com>
Reviewed-by: Samuel Thibault <***@ens-lyon.org>

---
drivers/staging/speakup/spk_priv.h | 2
drivers/staging/speakup/spk_ttyio.c | 105 ++++++++++++++++++++++++++++++++++++
drivers/staging/speakup/spk_types.h | 1
3 files changed, 108 insertions(+)

--- a/drivers/staging/speakup/spk_priv.h
+++ b/drivers/staging/speakup/spk_priv.h
@@ -40,6 +40,8 @@

#define KT_SPKUP 15
#define SPK_SYNTH_TIMEOUT 100000 /* in micro-seconds */
+#define SYNTH_DEFAULT_DEV "ttyS0"
+#define SYNTH_DEFAULT_SER 0

const struct old_serial_port *spk_serial_init(int index);
void spk_stop_serial_interrupt(void);
--- a/drivers/staging/speakup/spk_ttyio.c
+++ b/drivers/staging/speakup/spk_ttyio.c
@@ -7,6 +7,13 @@
#include "spk_types.h"
#include "spk_priv.h"

+/* Supported device types */
+#define DEV_PREFIX_TTYS "ttyS"
+#define DEV_PREFIX_TTYUSB "ttyUSB"
+#define DEV_PREFIX_LP "lp"
+
+const char *lp_supported[] = { "acntsa", "bns", "dummy", "txprt" };
+
struct spk_ldisc_data {
char buf;
struct semaphore sem;
@@ -16,6 +23,104 @@ struct spk_ldisc_data {
static struct spk_synth *spk_ttyio_synth;
static struct tty_struct *speakup_tty;

+static int name_to_dev(const char *name, dev_t *dev_no)
+{
+ int maj = -1, min = -1;
+
+ if (strncmp(name, DEV_PREFIX_TTYS, strlen(DEV_PREFIX_TTYS)) == 0) {
+ if (kstrtoint(name + strlen(DEV_PREFIX_TTYS), 10, &min)) {
+ pr_err("speakup: Invalid ser param. Must be \
+ between 0 and 191 inclusive.\n");
+ return -EINVAL;
+ }
+ maj = 4;
+
+ if (min < 0 || min > 191) {
+ pr_err("speakup: Invalid ser param. Must be \
+ between 0 and 191 inclusive.\n");
+ return -EINVAL;
+ }
+ min = min + 64;
+ } else if (strncmp(name, DEV_PREFIX_TTYUSB, strlen(DEV_PREFIX_TTYUSB))
+ == 0) {
+ if (kstrtoint(name + strlen(DEV_PREFIX_TTYUSB), 10, &min)) {
+ pr_err("speakup: Invalid ttyUSB number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ maj = 188;
+
+ if (min < 0) {
+ pr_err("speakup: Invalid ttyUSB number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ } else if (strncmp(name, DEV_PREFIX_LP, strlen(DEV_PREFIX_LP)) == 0) {
+ if (kstrtoint(name + strlen(DEV_PREFIX_LP), 10, &min)) {
+ pr_warn("speakup: Invalid lp number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ maj = 6;
+
+ if (min < 0) {
+ pr_warn("speakup: Invalid lp number. \
+ Must be a number from 0 onwards\n");
+ return -EINVAL;
+ }
+ }
+
+ if (maj == -1 || min == -1)
+ return -EINVAL;
+
+ /* if here, maj and min must be valid */
+ *dev_no = MKDEV(maj, min);
+
+ return 0;
+}
+
+int ser_to_dev(int ser, dev_t *dev_no)
+{
+ if (ser < 0 || ser > (255 - 64)) {
+ pr_err("speakup: Invalid ser param. \
+ Must be between 0 and 191 inclusive.\n");
+
+ return -EINVAL;
+ }
+
+ *dev_no = MKDEV(4, (64 + ser));
+ return 0;
+}
+
+static int get_dev_to_use(struct spk_synth *synth, dev_t *dev_no)
+{
+ /* use ser only when dev is not specified */
+ if (strcmp(synth->dev, SYNTH_DEFAULT_DEV) || synth->ser == SYNTH_DEFAULT_SER) {
+ /* for /dev/lp* check if synth is supported */
+ if (strncmp(synth->dev, DEV_PREFIX_LP, strlen(DEV_PREFIX_LP)) == 0) {
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(lp_supported); i++) {
+ if (strcmp(synth->name, lp_supported[i]) == 0)
+ break;
+ }
+
+ if (i >= ARRAY_SIZE(lp_supported)) {
+ pr_err("speakup: lp* is only supported on:");
+ for (i = 0; i < ARRAY_SIZE(lp_supported); i++)
+ pr_cont(" %s", lp_supported[i]);
+ pr_cont("\n");
+
+ return -ENOTSUPP;
+ }
+ }
+
+ return name_to_dev(synth->dev, dev_no);
+ }
+
+ return ser_to_dev(synth->ser, dev_no);
+}
+
static int spk_ttyio_ldisc_open(struct tty_struct *tty)
{
struct spk_ldisc_data *ldisc_data;
--- a/drivers/staging/speakup/spk_types.h
+++ b/drivers/staging/speakup/spk_types.h
@@ -169,6 +169,7 @@ struct spk_synth {
int jiffies;
int full;
int ser;
+ char *dev;
short flags;
short startup;
const int checkval; /* for validating a proper synth module */
Samuel Thibault
2017-06-14 11:26:09 UTC
Permalink
Ah, no, nevermind, you just need the major/minor. So why not just take
that as the input here, and not a string?
Because real users don't know about major/minor numbers.

Samuel
Samuel Thibault
2017-06-14 12:18:19 UTC
Permalink
Post by Samuel Thibault
Ah, no, nevermind, you just need the major/minor. So why not just take
that as the input here, and not a string?
Because real users don't know about major/minor numbers.
I'm not disagreeing, it's just that the kernel doesn't know about
"device names" either :)
Well, it does for the console= parameter, for instance. I know it's not
actually related with major/minor numbering, but it's still meant to
designate the same thing.
And trying to have the kernel do the mapping based on strings like this
is not ok, sorry.
So what is the solution? Users would find it completely crazy to have
to provide major/minor numbers.

Samuel
Samuel Thibault
2017-06-14 12:46:12 UTC
Permalink
On Wed, Jun 14, 2017 at 3:18 PM, Samuel Thibault
Post by Samuel Thibault
And trying to have the kernel do the mapping based on strings like this
is not ok, sorry.
So what is the solution? Users would find it completely crazy to have
to provide major/minor numbers.
Shouldn't udev take care of major/minor and alike stuff in user space?
We want speakup to get initialized before udev etc., just like the early
console.

Samuel
Okash Khawaja
2017-06-15 06:52:51 UTC
Permalink
Hi,
The console stuff is odd though, but that is each driver defining the
name for itself, major/minor does not apply. Also, a separate driver is
not having to figure this all out. I wonder if we could just add a tty
core function for this as it does know the name of everything that has
been registered with it, right?
I can start working on a patch for this. I'm still new to the tty code
so will follow up with any questions I might have.

Thanks,
Okash
Okash Khawaja
2017-06-17 10:16:44 UTC
Permalink
Hi,
Post by Okash Khawaja
The console stuff is odd though, but that is each driver defining the
name for itself, major/minor does not apply. Also, a separate driver is
not having to figure this all out. I wonder if we could just add a tty
core function for this as it does know the name of everything that has
been registered with it, right?
I can start working on a patch for this. I'm still new to the tty code
so will follow up with any questions I might have.
I've put together this function for converting device name to number.
It traverses tty_drivers list looking for corresponding dev name and
index. Is this the right approach?

Thanks,
Okash
Okash Khawaja
2017-06-17 10:57:54 UTC
Permalink
Post by Okash Khawaja
Hi,
Post by Okash Khawaja
The console stuff is odd though, but that is each driver defining the
name for itself, major/minor does not apply. Also, a separate driver is
not having to figure this all out. I wonder if we could just add a tty
core function for this as it does know the name of everything that has
been registered with it, right?
I can start working on a patch for this. I'm still new to the tty code
so will follow up with any questions I might have.
I've put together this function for converting device name to number.
It traverses tty_drivers list looking for corresponding dev name and
index. Is this the right approach?
Yes, this looks great, nice job! It is a lot simpler than your previous
function, and now you are not limited to just a subset off the different
serial ports in the system.
Keep up the good work, it's really appreciated.
Great, thanks. I'll re-send the full patch set as v2.

Okash
Okash Khawaja
2017-06-15 08:17:12 UTC
Permalink
Hi,

On Wed, Jun 14, 2017 at 9:23 AM, Dan Carpenter <***@oracle.com> wrote:
[...]
Could you call it "dev_name" instead? I normally expect "dev" to be a
device struct.
Thanks for the feedback. Will keep these in mind for next version of the patch.

Okash
o***@gmail.com
2017-06-13 22:37:04 UTC
Permalink
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: Okash Khawaja <***@gmail.com>
Reviewed-by: Samuel Thibault <***@ens-lyon.org>

---
drivers/staging/speakup/speakup_acntsa.c | 3 +++
drivers/staging/speakup/speakup_apollo.c | 3 +++
drivers/staging/speakup/speakup_audptr.c | 3 +++
drivers/staging/speakup/speakup_bns.c | 3 +++
drivers/staging/speakup/speakup_decext.c | 3 +++
drivers/staging/speakup/speakup_dectlk.c | 3 +++
drivers/staging/speakup/speakup_dummy.c | 3 +++
drivers/staging/speakup/speakup_ltlk.c | 3 +++
drivers/staging/speakup/speakup_spkout.c | 3 +++
drivers/staging/speakup/speakup_txprt.c | 3 +++
drivers/staging/speakup/spk_ttyio.c | 15 +++++++--------
11 files changed, 37 insertions(+), 8 deletions(-)

--- a/drivers/staging/speakup/speakup_acntsa.c
+++ b/drivers/staging/speakup/speakup_acntsa.c
@@ -96,6 +96,7 @@ static struct spk_synth synth_acntsa = {
.trigger = 50,
.jiffies = 30,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -135,9 +136,11 @@ static int synth_probe(struct spk_synth
}

module_param_named(ser, synth_acntsa.ser, int, 0444);
+module_param_named(dev, synth_acntsa.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_acntsa);
--- a/drivers/staging/speakup/speakup_apollo.c
+++ b/drivers/staging/speakup/speakup_apollo.c
@@ -105,6 +105,7 @@ static struct spk_synth synth_apollo = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -199,9 +200,11 @@ static void do_catch_up(struct spk_synth
}

module_param_named(ser, synth_apollo.ser, int, 0444);
+module_param_named(dev, synth_apollo.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_apollo);
--- a/drivers/staging/speakup/speakup_audptr.c
+++ b/drivers/staging/speakup/speakup_audptr.c
@@ -100,6 +100,7 @@ static struct spk_synth synth_audptr = {
.trigger = 50,
.jiffies = 30,
.full = 18000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -162,9 +163,11 @@ static int synth_probe(struct spk_synth
}

module_param_named(ser, synth_audptr.ser, int, 0444);
+module_param_named(dev, synth_audptr.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_audptr);
--- a/drivers/staging/speakup/speakup_bns.c
+++ b/drivers/staging/speakup/speakup_bns.c
@@ -93,6 +93,7 @@ static struct spk_synth synth_bns = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -119,9 +120,11 @@ static struct spk_synth synth_bns = {
};

module_param_named(ser, synth_bns.ser, int, 0444);
+module_param_named(dev, synth_bns.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_bns);
--- a/drivers/staging/speakup/speakup_decext.c
+++ b/drivers/staging/speakup/speakup_decext.c
@@ -120,6 +120,7 @@ static struct spk_synth synth_decext = {
.jiffies = 50,
.full = 40000,
.flags = SF_DEC,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -226,9 +227,11 @@ static void synth_flush(struct spk_synth
}

module_param_named(ser, synth_decext.ser, int, 0444);
+module_param_named(dev, synth_decext.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_decext);
--- a/drivers/staging/speakup/speakup_dectlk.c
+++ b/drivers/staging/speakup/speakup_dectlk.c
@@ -124,6 +124,7 @@ static struct spk_synth synth_dectlk = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -298,9 +299,11 @@ static void synth_flush(struct spk_synth
}

module_param_named(ser, synth_dectlk.ser, int, 0444);
+module_param_named(dev, synth_dectlk.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_dectlk);
--- a/drivers/staging/speakup/speakup_dummy.c
+++ b/drivers/staging/speakup/speakup_dummy.c
@@ -95,6 +95,7 @@ static struct spk_synth synth_dummy = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -121,9 +122,11 @@ static struct spk_synth synth_dummy = {
};

module_param_named(ser, synth_dummy.ser, int, 0444);
+module_param_named(dev, synth_dummy.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_dummy);
--- a/drivers/staging/speakup/speakup_ltlk.c
+++ b/drivers/staging/speakup/speakup_ltlk.c
@@ -107,6 +107,7 @@ static struct spk_synth synth_ltlk = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -166,9 +167,11 @@ static int synth_probe(struct spk_synth
}

module_param_named(ser, synth_ltlk.ser, int, 0444);
+module_param_named(dev, synth_ltlk.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_ltlk);
--- a/drivers/staging/speakup/speakup_spkout.c
+++ b/drivers/staging/speakup/speakup_spkout.c
@@ -98,6 +98,7 @@ static struct spk_synth synth_spkout = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -130,9 +131,11 @@ static void synth_flush(struct spk_synth
}

module_param_named(ser, synth_spkout.ser, int, 0444);
+module_param_named(dev, synth_spkout.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_spkout);
--- a/drivers/staging/speakup/speakup_txprt.c
+++ b/drivers/staging/speakup/speakup_txprt.c
@@ -92,6 +92,7 @@ static struct spk_synth synth_txprt = {
.trigger = 50,
.jiffies = 50,
.full = 40000,
+ .dev = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -118,9 +119,11 @@ static struct spk_synth synth_txprt = {
};

module_param_named(ser, synth_txprt.ser, int, 0444);
+module_param_named(dev, synth_txprt.dev, charp, S_IRUGO);
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(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");

module_spk_synth(synth_txprt);
--- a/drivers/staging/speakup/spk_ttyio.c
+++ b/drivers/staging/speakup/spk_ttyio.c
@@ -209,11 +209,12 @@ static inline void get_termios(struct tt
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;
struct tty_struct *tty;
struct ktermios tmp_termios;
+ dev_t dev;

ret = tty_register_ldisc(N_SPEAKUP, &spk_ttyio_ldisc_ops);
if (ret) {
@@ -221,13 +222,11 @@ static int spk_ttyio_initialise_ldisc(in
return ret;
}

- if (ser < 0 || ser > (255 - 64)) {
- pr_err("speakup: Invalid ser param. Must be between 0 and 191 inclusive.\n");
- return -EINVAL;
- }
+ ret = get_dev_to_use(synth, &dev);
+ if (ret)
+ return ret;

- /* TODO: support more than ttyS* */
- tty = tty_open_by_driver(MKDEV(4, (ser + 64)), NULL, NULL);
+ tty = tty_open_by_driver(dev, NULL, NULL);
if (IS_ERR(tty))
return PTR_ERR(tty);

@@ -338,7 +337,7 @@ static void spk_ttyio_flush_buffer(void)

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)
return rv;
Loading...