return code for set termios.

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Tue, 25 May 1999 12:18:57 +0200 (MEST)


Hi,

The set_termios functions in serial drivers is declared to be a void.

I'm working on a serial driver that sometimes does and sometimes
doesn't support things like "50 baud". I'd like to return an error
instead of just printk-ing the error message, and hoping that the user
is monitoring his logs....

Why is this? Shouldn't we do something like:

diff -ur linux-2.2.9.clean/drivers/char/tty_ioctl.c linux/drivers/char/tty_ioctl.c
--- linux-2.2.9.clean/drivers/char/tty_ioctl.c Tue Jan 19 19:12:05 1999
+++ linux/drivers/char/tty_ioctl.c Tue May 25 11:39:34 1999
@@ -96,10 +96,11 @@
old->c_cc[i] : termios->c_cc[i];
}

-static void change_termios(struct tty_struct * tty, struct termios * new_termios)
+static int change_termios(struct tty_struct * tty, struct termios * new_termios)
{
int canon_change;
struct termios old_termios = *tty->termios;
+ int rv1, rv2;

cli();
*tty->termios = *new_termios;
@@ -136,10 +137,11 @@
}

if (tty->driver.set_termios)
- (*tty->driver.set_termios)(tty, &old_termios);
+ rv1 = (*tty->driver.set_termios)(tty, &old_termios);

if (tty->ldisc.set_termios)
- (*tty->ldisc.set_termios)(tty, &old_termios);
+ rv2 = (*tty->ldisc.set_termios)(tty, &old_termios);
+ return (!rv1 ? rv1:rv2);
}

static int set_termios(struct tty_struct * tty, unsigned long arg, int opt)
@@ -169,8 +171,7 @@
return -EINTR;
}

- change_termios(tty, &tmp_termios);
- return 0;
+ return change_termios(tty, &tmp_termios);
}

static int get_termio(struct tty_struct * tty, struct termio * termio)

(and then we should quickly add return codes to the set_termios
routines in the drivers. But the compiler will notify us of the
problematic rounines with "type mismatches" and "control reaches end
of non-void function" warnings.).

Regards,

Roger Wolff.

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
------ Microsoft SELLS you Windows, Linux GIVES you the whole house ------

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/