Skip to contentSkip to conversation

input: i8042 possible bug

DISCUSSION Andrey Moiseev 2 participants 2 messages Sep 3, 2013 HID

lore
Share & tools
lore
#0 lore raw

Here is an extract from drivers/input/serio/i8042.c:

Quoted 22 lines

static int i8042_flush(void)

{
	unsigned long flags;
	unsigned char data, str;
	int i = 0;

	spin_lock_irqsave(&i8042_lock, flags);

	while (((str = i8042_read_status()) & I8042_STR_OBF) && (i < I8042_BUFFER_SIZE)) {
		udelay(50);
		data = i8042_read_data();
		i++;
		dbg("%02x <- i8042 (flush, %s)\n",
		    data, str & I8042_STR_AUXDATA ? "aux" : "kbd");
	}

	spin_unlock_irqrestore(&i8042_lock, flags);

	return i;
}
Quoted 3 lines

static int i8042_controller_check(void)

{
	if (i8042_flush() == I8042_BUFFER_SIZE) {

Doesn't it panic needlessly, while the buffer was initially full?

Quoted 6 lines
		pr_err("No controller found\n");
		return -ENODEV;
	}

	return 0;
}
#1 lore raw
Quoted 20 lines · Andrey Moiseev

Here is an extract from drivers/input/serio/i8042.c:

Quoted 19 lines

static int i8042_flush(void)

{
	unsigned long flags;
	unsigned char data, str;
	int i = 0;

	spin_lock_irqsave(&i8042_lock, flags);

	while (((str = i8042_read_status()) & I8042_STR_OBF) && (i < I8042_BUFFER_SIZE)) {
		udelay(50);
		data = i8042_read_data();
		i++;
		dbg("%02x <- i8042 (flush, %s)\n",
		    data, str & I8042_STR_AUXDATA ? "aux" : "kbd");
	}

	spin_unlock_irqrestore(&i8042_lock, flags);
Quoted 7 lines
Quoted 6 lines
	return i;
}

static int i8042_controller_check(void)

{
	if (i8042_flush() == I8042_BUFFER_SIZE) {

Doesn't it panic needlessly, while the buffer was initially full?

It appears so. We probably want to change it to return -1 if we still see OBF after fetching I8042_BUFFER_SIZE characters.

Thanks.

Signature · 1 line
Dmitry