Message ID | 20231014104942.856152-4-vamshigajjela@google.com |
---|---|
State | New |
Headers | show |
Series | serial core type consistency and overflow checks | expand |
On Sat, 14 Oct 2023, Vamshi Gajjela wrote: > From: VAMSHI GAJJELA <vamshigajjela@google.com> > > uart_fifo_timeout() returns unsigned value, hence the function > uart_poll_timeout has been modified to use an unsigned int type for > timeout values instead of a signed int. The return type of the function > has been changed from int to unsigned int for consistency with the type > of timeout values. The result of uart_fifo_timeout() is cast to u32, > indicating that the value is truncated. > > Signed-off-by: VAMSHI GAJJELA <vamshigajjela@google.com> > --- > include/linux/serial_core.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h > index b128513b009a..445a1ff7e502 100644 > --- a/include/linux/serial_core.h > +++ b/include/linux/serial_core.h > @@ -773,9 +773,9 @@ static inline unsigned long uart_fifo_timeout(struct uart_port *port) > } > > /* Base timer interval for polling */ > -static inline int uart_poll_timeout(struct uart_port *port) > +static inline unsigned int uart_poll_timeout(struct uart_port *port) This is in jiffies so why don't you return unsigned long instead also here? > { > - int timeout = uart_fifo_timeout(port); > + unsigned int timeout = (u32)uart_fifo_timeout(port); Use unsigned long and avoid casting entirely? > > return timeout > 6 ? (timeout / 2 - 2) : 1; > } >
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index b128513b009a..445a1ff7e502 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -773,9 +773,9 @@ static inline unsigned long uart_fifo_timeout(struct uart_port *port) } /* Base timer interval for polling */ -static inline int uart_poll_timeout(struct uart_port *port) +static inline unsigned int uart_poll_timeout(struct uart_port *port) { - int timeout = uart_fifo_timeout(port); + unsigned int timeout = (u32)uart_fifo_timeout(port); return timeout > 6 ? (timeout / 2 - 2) : 1; }