2015-02-09 15:58:36

by Nicholas Mc Guire

[permalink] [raw]
Subject: [PATCH] vt: use msecs_to_jiffies for time conversion

Converting milliseconds to jiffies by "val * HZ / 1000" is technically
OK but msecs_to_jiffies(val) is the cleaner solution and handles all
corner cases correctly. This is a minor API consolidation only and
should make things more readable.

Signed-off-by: Nicholas Mc Guire <[email protected]>
---

Patch was compile tested with x86_64_defconfig
(implies CONFIG_HW_CONSOLE=y and CONFIG_VT=y)

Patch is against 3.19.0-rc7 (localversion-next is -next-20150209)

drivers/tty/vt/vt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 6e00572..ea7ba03 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1573,7 +1573,7 @@ static void setterm_command(struct vc_data *vc)
case 11: /* set bell duration in msec */
if (vc->vc_npar >= 1)
vc->vc_bell_duration = (vc->vc_par[1] < 2000) ?
- vc->vc_par[1] * HZ / 1000 : 0;
+ msecs_to_jiffies(vc->vc_par[1]) : 0;
else
vc->vc_bell_duration = DEFAULT_BELL_DURATION;
break;
--
1.7.10.4


2015-02-10 12:28:15

by David Herrmann

[permalink] [raw]
Subject: Re: [PATCH] vt: use msecs_to_jiffies for time conversion

Hi

On Mon, Feb 9, 2015 at 4:54 PM, Nicholas Mc Guire <[email protected]> wrote:
> Converting milliseconds to jiffies by "val * HZ / 1000" is technically
> OK but msecs_to_jiffies(val) is the cleaner solution and handles all
> corner cases correctly. This is a minor API consolidation only and
> should make things more readable.
>
> Signed-off-by: Nicholas Mc Guire <[email protected]>

Looks good to me:

Reviewed-by: David Herrmann <[email protected]>

Thanks
David

> ---
>
> Patch was compile tested with x86_64_defconfig
> (implies CONFIG_HW_CONSOLE=y and CONFIG_VT=y)
>
> Patch is against 3.19.0-rc7 (localversion-next is -next-20150209)
>
> drivers/tty/vt/vt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 6e00572..ea7ba03 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -1573,7 +1573,7 @@ static void setterm_command(struct vc_data *vc)
> case 11: /* set bell duration in msec */
> if (vc->vc_npar >= 1)
> vc->vc_bell_duration = (vc->vc_par[1] < 2000) ?
> - vc->vc_par[1] * HZ / 1000 : 0;
> + msecs_to_jiffies(vc->vc_par[1]) : 0;
> else
> vc->vc_bell_duration = DEFAULT_BELL_DURATION;
> break;
> --
> 1.7.10.4
>