Skip to content

Commit

Permalink
serial: Fix upstat_t sparse warnings
Browse files Browse the repository at this point in the history
Commit 299245a,
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 int
drivers/tty/serial/serial_core.c:63:30:    got restricted upstat_t
include/linux/serial_core.h:364:30: warning: incorrect type in return expression (different base types)
include/linux/serial_core.h:364:30:    expected bool
include/linux/serial_core.h:364:30:    got restricted upstat_t
include/linux/serial_core.h:364:30: warning: incorrect type in return expression (different base types)
include/linux/serial_core.h:364:30:    expected bool
include/linux/serial_core.h:364:30:    got restricted upstat_t

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Peter Hurley authored and Greg Kroah-Hartman committed Nov 6, 2014
1 parent fda2b41 commit d4260b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/tty/serial/serial_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion include/linux/serial_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,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);
}

/*
Expand Down

0 comments on commit d4260b5

Please sign in to comment.