/* ps2_handle_response() is supposed to be used in interrupt handler to properly store device's response to a command and notify process waiting for completion of the command.  */
int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data)
/* ps2_handle_response() is supposed to be used in interrupt handler to properly store device's response to a command and notify process waiting for completion of the command.  */
int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data)
{
	if (ps2dev->cmdcnt)
		ps2dev->cmdbuf[--ps2dev->cmdcnt] = data;
	if (ps2dev->flags & PS2_FLAG_CMD1) {
		ps2dev->flags &= ~PS2_FLAG_CMD1;
		if (ps2dev->cmdcnt)
			wake_up(&ps2dev->wait);
	}
	if (!ps2dev->cmdcnt) {
		ps2dev->flags &= ~PS2_FLAG_CMD;
		wake_up(&ps2dev->wait);
	}
	return 1;
}