Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd627a01 authored by Thomas Andrews's avatar Thomas Andrews Committed by Greg Kroah-Hartman
Browse files

[PATCH] scx200_acb: Fix the state machine



Fix the scx200_acb state machine:

* Nack was sent one byte too late on reads >= 2 bytes.
* Stop bit was set one byte too late on reads.

Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 39288e1a
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -184,21 +184,21 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
		break;
		break;


	case state_read:
	case state_read:
		/* Set ACK if receiving the last byte */
		/* Set ACK if _next_ byte will be the last one */
		if (iface->len == 1)
		if (iface->len == 2)
			outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1);
			outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1);
		else
		else
			outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1);
			outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1);


		*iface->ptr++ = inb(ACBSDA);
		if (iface->len == 1) {
		--iface->len;

		if (iface->len == 0) {
			iface->result = 0;
			iface->result = 0;
			iface->state = state_idle;
			iface->state = state_idle;
			outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
			outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
		}
		}


		*iface->ptr++ = inb(ACBSDA);
		--iface->len;

		break;
		break;


	case state_write:
	case state_write: