serial: Fix upstat_t sparse warnings
PATCH 1/3 serial: Fix upstat_t sparse warnings
Commit 299245a145b2ad4cfb4c5432eb1264299f55e7e0,
serial: core: Privatize modem status enable flags, introduced the upstat_t type and matching bit definitions. The purpose is to produce sparse warnings if the wrong bit definitions are used (by warning of implicit integer conversions).
Fix implicit conversion to integer return type from uart_cts_enabled() and uart_dcd_enabled().
Fixes the following sparse warnings:drivers/tty/serial/serial_core.c:63:30: warning: incorrect type in return expression (different base types)drivers/tty/serial/serial_core.c:63:30: expected intdrivers/tty/serial/serial_core.c:63:30: got restricted upstat_tinclude/linux/serial_core.h:364:30: warning: incorrect type in return expression (different base types)include/linux/serial_core.h:364:30: expected boolinclude/linux/serial_core.h:364:30: got restricted upstat_tinclude/linux/serial_core.h:364:30: warning: incorrect type in return expression (different base types)include/linux/serial_core.h:364:30: expected boolinclude/linux/serial_core.h:364:30: got restricted upstat_t
--- drivers/tty/serial/serial_core.c | 2 +- include/linux/serial_core.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/serial_core.c +1 -1
@@ -61,7 +61,7 @@ static void uart_port_shutdown(struct tty_port *port);static int uart_dcd_enabled (struct uart_port *uport) { -return uport->status &UPSTAT_DCD_ENABLE ; +return !!(uport->status &UPSTAT_DCD_ENABLE ); }/*
include/linux/serial_core.h +1 -1
@@ -363,7 +363,7 @@ static inline int uart_tx_stopped(struct uart_port *port)static inline bool uart_cts_enabled (struct uart_port *uport) { -return uport->status &UPSTAT_CTS_ENABLE ; +return !!(uport->status &UPSTAT_CTS_ENABLE ); }/*
Signature · 1 line
2.1.1
PATCH 2/3 serial: Fix sparse warnings in uart_throttle()/uart_unthrottle()
The struct uart_port.flags field is type upf_t, as are the matching bit definitions. Change local mask variable to type upf_t.
Fixes sparse warnings:drivers/tty/serial/serial_core.c:620:22: warning: invalid assignment: |=drivers/tty/serial/serial_core.c:620:22: left side has type unsigned intdrivers/tty/serial/serial_core.c:620:22: right side has type restricted upf_tdrivers/tty/serial/serial_core.c:622:22: warning: invalid assignment: |=drivers/tty/serial/serial_core.c:622:22: left side has type unsigned intdrivers/tty/serial/serial_core.c:622:22: right side has type restricted upf_tdrivers/tty/serial/serial_core.c:624:17: warning: restricted upf_t degrades to integer drivers/tty/serial/serial_core.c:626:22: warning: invalid assignment: &=drivers/tty/serial/serial_core.c:626:22: left side has type unsigned intdrivers/tty/serial/serial_core.c:626:22: right side has type restricted upf_tdrivers/tty/serial/serial_core.c:629:20: warning: restricted upf_t degrades to integer drivers/tty/serial/serial_core.c:632:20: warning: restricted upf_t degrades to integer drivers/tty/serial/serial_core.c:643:22: warning: invalid assignment: |=drivers/tty/serial/serial_core.c:643:22: left side has type unsigned intdrivers/tty/serial/serial_core.c:643:22: right side has type restricted upf_tdrivers/tty/serial/serial_core.c:645:22: warning: invalid assignment: |=drivers/tty/serial/serial_core.c:645:22: left side has type unsigned intdrivers/tty/serial/serial_core.c:645:22: right side has type restricted upf_tdrivers/tty/serial/serial_core.c:647:17: warning: restricted upf_t degrades to integer drivers/tty/serial/serial_core.c:649:22: warning: invalid assignment: &=drivers/tty/serial/serial_core.c:649:22: left side has type unsigned intdrivers/tty/serial/serial_core.c:649:22: right side has type restricted upf_tdrivers/tty/serial/serial_core.c:652:20: warning: restricted upf_t degrades to integer drivers/tty/serial/serial_core.c:655:20: warning: restricted upf_t degrades to integer
--- drivers/tty/serial/serial_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/serial_core.c +2 -2
@@ -618,7 +618,7 @@ static void uart_throttle(struct tty_struct *tty) {struct uart_state *state = tty->driver_data;struct uart_port *port = state->uart_port; -uint32_t mask =0 ; +upf_t mask =0 ;if (I_IXOFF (tty)) mask |=UPF_SOFT_FLOW ;
@@ -641,7 +641,7 @@ static void uart_unthrottle(struct tty_struct *tty) {struct uart_state *state = tty->driver_data;struct uart_port *port = state->uart_port; -uint32_t mask =0 ; +upf_t mask =0 ;if (I_IXOFF (tty)) mask |=UPF_SOFT_FLOW ;
Signature · 1 line
2.1.1
PATCH 3/3 tty: Remove sparse lock annotations from tty_write_lock()/_unlock()
In reply to Peter Hurleysparse lock annotations cannot represent conditional acquire, such as mutex_lock_interruptible() or mutex_trylock(), and produce sparse warnings at _every_ correct call site.
Remove lock annotations from tty_write_lock() and tty_write_unlock().
Fixes sparse warnings:drivers/tty/tty_io.c:1083:13: warning: context imbalance in 'tty_write_unlock' - wrong count at exit drivers/tty/tty_io.c:1090:12: warning: context imbalance in 'tty_write_lock' - wrong count at exit drivers/tty/tty_io.c:1211:17: warning: context imbalance in 'tty_write_message' - unexpected unlock drivers/tty/tty_io.c:1233:16: warning: context imbalance in 'tty_write' - different lock contexts for basic block drivers/tty/tty_io.c:1285:5: warning: context imbalance in 'tty_send_xchar' - different lock contexts for basic block drivers/tty/tty_io.c:2653:12: warning: context imbalance in 'send_break' - different lock contexts for basic block
--- drivers/tty/tty_io.c | 2 -- 1 file changed, 2 deletions(-)
drivers/tty/tty_io.c +0 -2
@@ -1024,14 +1024,12 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count, }static void tty_write_unlock (struct tty_struct *tty) - __releases(&tty->atomic_write_lock) {mutex_unlock (&tty->atomic_write_lock);wake_up_interruptible_poll (&tty->write_wait,POLLOUT ); }static int tty_write_lock (struct tty_struct *tty,int ndelay) - __acquires(&tty->atomic_write_lock) {if (!mutex_trylock (&tty->atomic_write_lock)) {if (ndelay)
Signature · 1 line
2.1.1