diff options
author | David Howells <dhowells@redhat.com> | 2008-07-22 06:18:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 16:03:28 -0400 |
commit | 4a56122297ac7a4a3bf09fb66c0a365a13abe707 (patch) | |
tree | 2b748f15c805c3e6e8e5cb6a349e807edf52d909 /drivers/char | |
parent | 781cff5cb2bc8d714270accf88db23a855de9816 (diff) |
Fix the (i)Stallion driver's putchar() and break_ctl() ops
Fix the Stallion driver's putchar() and break_ctl() ops and iStallion's
putchar() to return values.
Is it actually possible for putchar() or break_ctl() to be called with tty ==
NULL or can the check be discarded?
Should stl_write() be returning 0 if tty->driver_data is NULL or tx.buf is
NULL? Is this even possible?
I've made Stallion's functions return -EINVAL as stli_breakctl() if the checks
fail.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/stallion.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index 0243efb0be95..de5a725c3cc0 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c | |||
@@ -1025,7 +1025,7 @@ static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count | |||
1025 | 1025 | ||
1026 | /*****************************************************************************/ | 1026 | /*****************************************************************************/ |
1027 | 1027 | ||
1028 | static void stl_putchar(struct tty_struct *tty, unsigned char ch) | 1028 | static int stl_putchar(struct tty_struct *tty, unsigned char ch) |
1029 | { | 1029 | { |
1030 | struct stlport *portp; | 1030 | struct stlport *portp; |
1031 | unsigned int len; | 1031 | unsigned int len; |
@@ -1034,12 +1034,12 @@ static void stl_putchar(struct tty_struct *tty, unsigned char ch) | |||
1034 | pr_debug("stl_putchar(tty=%p,ch=%x)\n", tty, ch); | 1034 | pr_debug("stl_putchar(tty=%p,ch=%x)\n", tty, ch); |
1035 | 1035 | ||
1036 | if (tty == NULL) | 1036 | if (tty == NULL) |
1037 | return; | 1037 | return -EINVAL; |
1038 | portp = tty->driver_data; | 1038 | portp = tty->driver_data; |
1039 | if (portp == NULL) | 1039 | if (portp == NULL) |
1040 | return; | 1040 | return -EINVAL; |
1041 | if (portp->tx.buf == NULL) | 1041 | if (portp->tx.buf == NULL) |
1042 | return; | 1042 | return -EINVAL; |
1043 | 1043 | ||
1044 | head = portp->tx.head; | 1044 | head = portp->tx.head; |
1045 | tail = portp->tx.tail; | 1045 | tail = portp->tx.tail; |
@@ -1053,6 +1053,7 @@ static void stl_putchar(struct tty_struct *tty, unsigned char ch) | |||
1053 | head = portp->tx.buf; | 1053 | head = portp->tx.buf; |
1054 | } | 1054 | } |
1055 | portp->tx.head = head; | 1055 | portp->tx.head = head; |
1056 | return 0; | ||
1056 | } | 1057 | } |
1057 | 1058 | ||
1058 | /*****************************************************************************/ | 1059 | /*****************************************************************************/ |
@@ -1460,19 +1461,20 @@ static void stl_hangup(struct tty_struct *tty) | |||
1460 | 1461 | ||
1461 | /*****************************************************************************/ | 1462 | /*****************************************************************************/ |
1462 | 1463 | ||
1463 | static void stl_breakctl(struct tty_struct *tty, int state) | 1464 | static int stl_breakctl(struct tty_struct *tty, int state) |
1464 | { | 1465 | { |
1465 | struct stlport *portp; | 1466 | struct stlport *portp; |
1466 | 1467 | ||
1467 | pr_debug("stl_breakctl(tty=%p,state=%d)\n", tty, state); | 1468 | pr_debug("stl_breakctl(tty=%p,state=%d)\n", tty, state); |
1468 | 1469 | ||
1469 | if (tty == NULL) | 1470 | if (tty == NULL) |
1470 | return; | 1471 | return -EINVAL; |
1471 | portp = tty->driver_data; | 1472 | portp = tty->driver_data; |
1472 | if (portp == NULL) | 1473 | if (portp == NULL) |
1473 | return; | 1474 | return -EINVAL; |
1474 | 1475 | ||
1475 | stl_sendbreak(portp, ((state == -1) ? 1 : 2)); | 1476 | stl_sendbreak(portp, ((state == -1) ? 1 : 2)); |
1477 | return 0; | ||
1476 | } | 1478 | } |
1477 | 1479 | ||
1478 | /*****************************************************************************/ | 1480 | /*****************************************************************************/ |