提交 4a561222 编写于 作者: D David Howells 提交者: Linus Torvalds

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: NDavid Howells <dhowells@redhat.com>
Signed-off-by: NAlan Cox <alan@redhat.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 781cff5c
...@@ -1025,7 +1025,7 @@ static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count ...@@ -1025,7 +1025,7 @@ static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count
/*****************************************************************************/ /*****************************************************************************/
static void stl_putchar(struct tty_struct *tty, unsigned char ch) static int stl_putchar(struct tty_struct *tty, unsigned char ch)
{ {
struct stlport *portp; struct stlport *portp;
unsigned int len; unsigned int len;
...@@ -1034,12 +1034,12 @@ static void stl_putchar(struct tty_struct *tty, unsigned char ch) ...@@ -1034,12 +1034,12 @@ static void stl_putchar(struct tty_struct *tty, unsigned char ch)
pr_debug("stl_putchar(tty=%p,ch=%x)\n", tty, ch); pr_debug("stl_putchar(tty=%p,ch=%x)\n", tty, ch);
if (tty == NULL) if (tty == NULL)
return; return -EINVAL;
portp = tty->driver_data; portp = tty->driver_data;
if (portp == NULL) if (portp == NULL)
return; return -EINVAL;
if (portp->tx.buf == NULL) if (portp->tx.buf == NULL)
return; return -EINVAL;
head = portp->tx.head; head = portp->tx.head;
tail = portp->tx.tail; tail = portp->tx.tail;
...@@ -1053,6 +1053,7 @@ static void stl_putchar(struct tty_struct *tty, unsigned char ch) ...@@ -1053,6 +1053,7 @@ static void stl_putchar(struct tty_struct *tty, unsigned char ch)
head = portp->tx.buf; head = portp->tx.buf;
} }
portp->tx.head = head; portp->tx.head = head;
return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -1460,19 +1461,20 @@ static void stl_hangup(struct tty_struct *tty) ...@@ -1460,19 +1461,20 @@ static void stl_hangup(struct tty_struct *tty)
/*****************************************************************************/ /*****************************************************************************/
static void stl_breakctl(struct tty_struct *tty, int state) static int stl_breakctl(struct tty_struct *tty, int state)
{ {
struct stlport *portp; struct stlport *portp;
pr_debug("stl_breakctl(tty=%p,state=%d)\n", tty, state); pr_debug("stl_breakctl(tty=%p,state=%d)\n", tty, state);
if (tty == NULL) if (tty == NULL)
return; return -EINVAL;
portp = tty->driver_data; portp = tty->driver_data;
if (portp == NULL) if (portp == NULL)
return; return -EINVAL;
stl_sendbreak(portp, ((state == -1) ? 1 : 2)); stl_sendbreak(portp, ((state == -1) ? 1 : 2));
return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册