/* ps2_adjust_timeout() is called after receiving 1st byte of command response and tries to reduce remaining timeout to speed up command completion.  */
static int ps2_adjust_timeout(struct ps2dev *ps2dev, int command, int timeout)
/* ps2_adjust_timeout() is called after receiving 1st byte of command response and tries to reduce remaining timeout to speed up command completion.  */
static int ps2_adjust_timeout(struct ps2dev *ps2dev, int command, int timeout)
{
	switch (command) {
		case PS2_CMD_RESET_BAT:
			if (timeout > msecs_to_jiffies(100))
				timeout = msecs_to_jiffies(100);
			break;
		case PS2_CMD_GETID:
			if (ps2dev->cmdbuf[1] == 0xaa) {
				serio_pause_rx(ps2dev->serio);
				ps2dev->flags = 0;
				serio_continue_rx(ps2dev->serio);
				timeout = 0;
			}
			if (!ps2_is_keyboard_id(ps2dev->cmdbuf[1])) {
				serio_pause_rx(ps2dev->serio);
				ps2dev->flags = ps2dev->cmdcnt = 0;
				serio_continue_rx(ps2dev->serio);
				timeout = 0;
			}
			break;
		default:
			break;
	}
	return timeout;
}