Re: [RFC][PATCH] USB touch screen driver, all-in-one

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 21 March 2006 07.39, Lanslott Gish wrote:
> On 3/17/06, Lanslott Gish <[email protected]> wrote:
> > On 3/16/06, Daniel Ritz <[email protected]> wrote:
> > that just can't be right. you probably mean
> > +       *y = pkt[3] | ((pkt[4] & 0x0F) << 8);
> >
> > otherwise you mask out bits 4-7. but you want to limit it to 12 bits...
> > (btw. no need for the & 0xFF mask since *pkt is char)
> >
> >
> > you are right, sorry for my fault. the truely way is
> >
> > +       *x = (pkt[1] & 0xFF) | ((pkt[2] & 0x0F) << 8);
> > +       *y = (pkt[3] & 0xFF) | ((pkt[4] & 0x0F) << 8);
> >
> > still need 12 bits( 0x0FFF) and the masks to avoid get negative.
> >

ok, ok, there is a bug. but the mask is still not needed. the
real bug is that pkt is of type char instead of unsigned char.
so a simple cast would be enough:
	 +       *x = (unsigned char) pkt[1] | ((pkt[2] & 0x0F) << 8);

but i changed the whole thing to unsigned char all over the place.
it's better anyway.

rgds
-daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux