lkml.org 
[lkml]   [2002]   [Dec]   [20]   [last100]   RSS Feed
Views: [more markup]   [less markup]   [headers]   [forward]  
 
Messages in this thread
/
DateFri, 20 Dec 2002 10:16:27 -0800
Fromgeorge anzinger <>
SubjectRe: [PATCH] joydev: fix HZ->millisecond transformation
Vojtech Pavlik wrote:
> 
> On Fri, Dec 20, 2002 at 09:24:58AM -0800, george anzinger wrote:
> > Vojtech Pavlik wrote:
> > >
> > > On Fri, Dec 20, 2002 at 02:41:50AM -0800, george anzinger wrote:
> > > > Bjorn Helgaas wrote:
> > > > >
> > > > > * fix a problem with HZ->millisecond transformation on
> > > > >   non-x86 archs (from 2.5 change by vojtech@suse.cz)
> > > > >
> > > > > Applies to 2.4.20.
> > > > >
> > > > > diff -Nru a/drivers/input/joydev.c b/drivers/input/joydev.c
> > > > > --- a/drivers/input/joydev.c    Mon Dec 16 12:16:32 2002
> > > > > +++ b/drivers/input/joydev.c    Mon Dec 16 12:16:32 2002
> > > > > @@ -50,6 +50,8 @@
> > > > >  #define JOYDEV_MINORS          32
> > > > >  #define JOYDEV_BUFFER_SIZE     64
> > > > >
> > > > > +#define MSECS(t)       (1000 * ((t) / HZ) + 1000 * ((t) % HZ) / HZ)
> > > > Uh...
> > > > ^^^^^^^^^^^^^^^^
> > > > by definition this is zero, is it not?
> > >
> > > No, both parts of the equaition can be nonzero.
> >
> > I don't think so.  s%HZ has to be less than HZ.  Then
> > dividing that by HZ should result in zero.  Where is my
> > thinking flawed?
> 
> You first multiply it by 1000.

But then it should read: (1000 * (t)) % HZ) / HZ

But this is still zero.  There is no way that ((X % HZ) /
HZ) is other than zero, me thinks.

> 
> > > Though it might be easier to say (1000 * t) / HZ, now that I think about
> > > it.
> >
> > That overflows...  As does the other if HZ is less than 1000....
> 
> You're right, t can be all 32 bits.

What, exactly, is this code trying to do?  It looks like the
number is being passed to user space...
> 
> --
> Vojtech Pavlik
> SuSE Labs
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
George Anzinger   george@mvista.com
High-res-timers: 
http://sourceforge.net/projects/high-res-timers/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:31    [W:0.320 / U:0.210 seconds]
©2003-2008 Jasper Spaans