[patch 2/6] staging: speakup: Add serial_out method

Samuel Thibault samuel.thibault at ens-lyon.org
Sat Feb 25 22:27:00 EST 2017


So I sent a lot of mails :)

A lot of them are asking to add yet more methods.  I'm starting thinking
that it's tedious to change that in each and every driver, which is kind
of dumb anyway since it's just the same everywhere.

So I'd say before doing all that stuff, rework what we thought about
adding methods: instead of adding spk_serial_out directly in struct
spk_synth

- in spk_types.h, just before struct spk_synth, define

struct spk_io_ops {
	int (*serial_out)(struct spk_synth *synth, const char ch);
}

- in struct spk_synth, add

	struct spk_io_ops *io_ops;

- in serialio.c, add

	struct spk_io_ops spk_serial_io_ops {
		.serial_out = spk_serial_out,
	}

- in ttyio.c, add

	struct spk_io_ops spk_ttyio_io_ops {
		.serial_out = spk_ttyio_serial_out,
	}

- and in drivers, instead of defining

	.serial_out = spk_serial_out

rather define

	.io_ops = &spk_serial_io_ops


And then you can add the serial_in, serial_in_nowait, tiocmset,
send_xchar methods to spk_io_ops instead of spk_synth, thus making
switching between serial and tty much less tedious.

Note: we need to keep probe, release, and synth_immediate as spk_synth
methods since they vary among synth drivers.

Samuel


More information about the Speakup mailing list