Re: [PATCH] new driver for ITM Touch touchscreen

From: Paulo Marques
Date: Tue Mar 08 2005 - 13:27:20 EST

Hans-Christian Egtvedt wrote:
Any tips are welcome. Is this done before with a touchscreen?

Just a minor nitpick, not really related to the mouse problem. More of coding style problem.

IMHO the UCP and UCOM macros just obfuscate the code. If you do not want to write "((unsigned char *) urb->transfer_buffer)[0]" every time (I can perfectly understand that), maybe using a local "u8 *" var would do the trick.

Something like this:

static void itmtouch_irq(struct urb *urb, struct pt_regs *regs)
struct itmtouch_dev * itmtouch = urb->context;
int retval;
u8 *tbuf;


input_regs(&itmtouch->inputdev, regs);

tbuf = (u8 *)(urb->transfer_buffer);

/* if pressure has been released, then don't report X/Y */
if (!(tbuf[7] & 0x20)) {
input_report_abs(&itmtouch->inputdev, ABS_X,
(tbuf[0] & 0x1F) << 7 | (tbuf[3] & 0x7F));
input_report_abs(&itmtouch->inputdev, ABS_Y,
(tbuf[1] & 0x1F) << 7 | (tbuf[4] & 0x7F));

input_report_abs(&itmtouch->inputdev, ABS_PRESSURE,
(tbuf[2] & 0x1) << 7 | (tbuf[5] & 0x7F));
input_report_key(&itmtouch->inputdev, BTN_TOUCH, !(tbuf[7] & 0x20));
/* TODO: Do we need to use input_sync() ? */
/* input_sync(&itmtouch->inputdev); */


This is perfectly readable without one having to find out what those macros mean, and it is even easier for the compiler to optimize (even though gcc will probably optimize both versions just fine).

Paulo Marques -

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at