Re: [RFC][PATCH] USB touch screen driver, all-in-one
From: Daniel Ritz
Date: Tue Mar 21 2006 - 15:19:04 EST
On Tuesday 21 March 2006 07.39, Lanslott Gish wrote:
> On 3/17/06, Lanslott Gish <lanslott.gish@xxxxxxxxx> wrote:
> > On 3/16/06, Daniel Ritz <daniel.ritz-ml@xxxxxxxxxxxxxx> wrote:
> > that just can't be right. you probably mean
> > + *y = pkt | ((pkt & 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 & 0xFF) | ((pkt & 0x0F) << 8);
> > + *y = (pkt & 0xFF) | ((pkt & 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 | ((pkt & 0x0F) << 8);
but i changed the whole thing to unsigned char all over the place.
it's better anyway.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/