[patch 1/2] staging: speakup: add function to convert dev name to number
Samuel Thibault
samuel.thibault at ens-lyon.org
Mon Jun 12 03:33:55 EDT 2017
Hello,
Okash Khawaja, on sam. 10 juin 2017 12:24:11 +0100, wrote:
> + if (strncmp(name, DEV_PREFIX_TTYS, strlen(DEV_PREFIX_TTYS)) == 0) {
...
> + }
> +
> + 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.
> +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.
> +
> + 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
More information about the Speakup
mailing list