linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Vamshi Gajjela <vamshigajjela@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	ilpo.jarvinen@linux.intel.com, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, manugautam@google.com,
	Subhash Jadavani <sjadavani@google.com>,
	Channa Kadabi <kadabi@google.com>
Subject: Re: [PATCH 3/3] serial: core: Update uart_poll_timeout function to return unsigned int
Date: Mon, 16 Oct 2023 14:44:32 +0300 (EEST)	[thread overview]
Message-ID: <32aae753-4a3-9c1c-9e4c-95fd2da8d4@linux.intel.com> (raw)
In-Reply-To: <20231014104942.856152-4-vamshigajjela@google.com>

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;
>  }
> 

-- 
 i.


  reply	other threads:[~2023-10-16 11:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-14 10:49 [PATCH 0/3] serial core type consistency and overflow checks Vamshi Gajjela
2023-10-14 10:49 ` [PATCH 2/3] serial: core: Make local variable size to u64 Vamshi Gajjela
2023-10-16 11:39   ` Ilpo Järvinen
2023-10-18 14:16     ` VAMSHI GAJJELA
2023-10-14 10:49 ` [PATCH 3/3] serial: core: Update uart_poll_timeout function to return unsigned int Vamshi Gajjela
2023-10-16 11:44   ` Ilpo Järvinen [this message]
     [not found] ` <20231014104942.856152-2-vamshigajjela@google.com>
2023-10-16 10:33   ` [PATCH 1/3] serial: core: Potential overflow of frame_time Ilpo Järvinen
2023-10-18 13:45     ` VAMSHI GAJJELA

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32aae753-4a3-9c1c-9e4c-95fd2da8d4@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=kadabi@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=manugautam@google.com \
    --cc=sjadavani@google.com \
    --cc=vamshigajjela@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).