All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vt: use msecs_to_jiffies for time conversion
@ 2015-02-09 15:54 Nicholas Mc Guire
  2015-02-10 12:28 ` David Herrmann
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Mc Guire @ 2015-02-09 15:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Daniel Vetter, Adam Borowski, Peter Hurley,
	David Herrmann, Imre Deak, Takashi Iwai, Peng Fan, linux-kernel,
	Nicholas Mc Guire

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 <hofrat@osadl.org>
---

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] vt: use msecs_to_jiffies for time conversion
  2015-02-09 15:54 [PATCH] vt: use msecs_to_jiffies for time conversion Nicholas Mc Guire
@ 2015-02-10 12:28 ` David Herrmann
  0 siblings, 0 replies; 2+ messages in thread
From: David Herrmann @ 2015-02-10 12:28 UTC (permalink / raw)
  To: Nicholas Mc Guire, Greg Kroah-Hartman
  Cc: Jiri Slaby, Daniel Vetter, Adam Borowski, Peter Hurley,
	Imre Deak, Takashi Iwai, Peng Fan, linux-kernel

Hi

On Mon, Feb 9, 2015 at 4:54 PM, Nicholas Mc Guire <hofrat@osadl.org> 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 <hofrat@osadl.org>

Looks good to me:

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-10 12:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-09 15:54 [PATCH] vt: use msecs_to_jiffies for time conversion Nicholas Mc Guire
2015-02-10 12:28 ` David Herrmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.