提交 ede03d30 编写于 作者: A Alan Cox 提交者: David S. Miller

ser_gigaset: turn nonsense checks into WARN_ON

These checks do nothing useful to protect the code from races. On the
other hand if the old code has been masking a real bug we would like to
know about it.

The check for tiocmset is kept because it is valid for a tty driver to
have a NULL tiocmset method. That in itself is probably a mistake given
modern coding practices - but needs fixing in the tty layer.
Signed-off-by: NAlan Cox <alan@linux.intel.com>
Acked-by: NTilman Schmidt <tilman@imap.cc>
Signed-off-by: NPaul Bolle <pebolle@tiscali.nl>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 74375c05
...@@ -67,8 +67,7 @@ static int write_modem(struct cardstate *cs) ...@@ -67,8 +67,7 @@ static int write_modem(struct cardstate *cs)
struct sk_buff *skb = bcs->tx_skb; struct sk_buff *skb = bcs->tx_skb;
int sent = -EOPNOTSUPP; int sent = -EOPNOTSUPP;
if (!tty || !tty->ops || !skb) WARN_ON(!tty || !tty->ops || !skb);
return -EINVAL;
if (!skb->len) { if (!skb->len) {
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
...@@ -109,8 +108,7 @@ static int send_cb(struct cardstate *cs) ...@@ -109,8 +108,7 @@ static int send_cb(struct cardstate *cs)
unsigned long flags; unsigned long flags;
int sent = 0; int sent = 0;
if (!tty || !tty->ops) WARN_ON(!tty || !tty->ops);
return -EFAULT;
cb = cs->cmdbuf; cb = cs->cmdbuf;
if (!cb) if (!cb)
...@@ -432,7 +430,9 @@ static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, ...@@ -432,7 +430,9 @@ static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
struct tty_struct *tty = cs->hw.ser->tty; struct tty_struct *tty = cs->hw.ser->tty;
unsigned int set, clear; unsigned int set, clear;
if (!tty || !tty->ops || !tty->ops->tiocmset) WARN_ON(!tty || !tty->ops);
/* tiocmset is an optional tty driver method */
if (!tty->ops->tiocmset)
return -EINVAL; return -EINVAL;
set = new_state & ~old_state; set = new_state & ~old_state;
clear = old_state & ~new_state; clear = old_state & ~new_state;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册