diff mbox series

[2/3] serial: core: Make local variable size to u64

Message ID 20231014104942.856152-3-vamshigajjela@google.com
State New
Headers show
Series serial core type consistency and overflow checks | expand

Commit Message

VAMSHI GAJJELA Oct. 14, 2023, 10:49 a.m. UTC
From: VAMSHI GAJJELA <vamshigajjela@google.com>

The variable size has been changed from u32 to u64 to accommodate a
larger range of values without the need for explicit typecasting.

Signed-off-by: VAMSHI GAJJELA <vamshigajjela@google.com>
---
 drivers/tty/serial/serial_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

VAMSHI GAJJELA Oct. 18, 2023, 2:16 p.m. UTC | #1
On Mon, Oct 16, 2023 at 5:09 PM Ilpo Järvinen
<ilpo.jarvinen@linux.intel.com> wrote:
>
> On Sat, 14 Oct 2023, Vamshi Gajjela wrote:
>
> > From: VAMSHI GAJJELA <vamshigajjela@google.com>
> >
> > The variable size has been changed from u32 to u64 to accommodate a
> > larger range of values without the need for explicit typecasting.
>
> Don't use too broad/generic terminology in shortlog (on [PATCH] line in
> subject) or changelog but explicitly mention the variable names please.
name of the variable is "size", may be now I will rename the variable
to "frame_size" in v2
>
> > Signed-off-by: VAMSHI GAJJELA <vamshigajjela@google.com>
> > ---
> >  drivers/tty/serial/serial_core.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> > index 7bdc21d5e13b..fb4696d17a8b 100644
> > --- a/drivers/tty/serial/serial_core.c
> > +++ b/drivers/tty/serial/serial_core.c
> > @@ -410,10 +410,10 @@ void
> >  uart_update_timeout(struct uart_port *port, unsigned int cflag,
> >                   unsigned int baud)
> >  {
> > -     unsigned int size = tty_get_frame_size(cflag);
> > +     u64 size = tty_get_frame_size(cflag);
> >       u64 frame_time;
> >
> > -     frame_time = (u64)size * NSEC_PER_SEC;
> > +     frame_time = size * NSEC_PER_SEC;
> >       port->frame_time = DIV64_U64_ROUND_UP(frame_time, baud);
> >  }
> >  EXPORT_SYMBOL(uart_update_timeout);
>
> This is actually a good cleanup all by itself unrelated to the other
> change but you need to adapt the changelog to reflect why this is helpful
> instead wording it based on the other change.
I shall submit this as a separate patch. As mentioned in 1/3 patch
I will also add a cast u32 before assigning the value to port->frametime
along with variable name and size change.

>
> --
>  i.
>
diff mbox series

Patch

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 7bdc21d5e13b..fb4696d17a8b 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -410,10 +410,10 @@  void
 uart_update_timeout(struct uart_port *port, unsigned int cflag,
 		    unsigned int baud)
 {
-	unsigned int size = tty_get_frame_size(cflag);
+	u64 size = tty_get_frame_size(cflag);
 	u64 frame_time;
 
-	frame_time = (u64)size * NSEC_PER_SEC;
+	frame_time = size * NSEC_PER_SEC;
 	port->frame_time = DIV64_U64_ROUND_UP(frame_time, baud);
 }
 EXPORT_SYMBOL(uart_update_timeout);