Skip to content

Commit 624cf5b

Browse files
Finn Thainmpe
authored andcommitted
macintosh/via-macii: Handle poll replies correctly
Userspace applications may use /dev/adb to send Talk requests. Such requests always have req->reply_expected == 1. The same is true of Talk requests sent by the kernel, except for poll requests queued internally by the via-macii driver. Those requests have req->reply_expected == 0. Consequently, poll reply packets get treated like autopoll reply packets. (It doesn't make sense to try to distinguish them.) Always enter 'reading' state after a poll request, so that the reply gets collected and passed to adb_input(), and none go missing. All Talk replies passed to adb_input() come from polling or autopolling, so call adb_input() with the autopoll parameter set to 1. Fixes: d95fd5f ("m68k: Mac II ADB fixes") # v5.0+ Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Tested-by: Stan Johnson <userm57@yahoo.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/754cddfa045e5bfa53e5da199831de02e7d2f27f.1593318192.git.fthain@telegraphics.com.au
1 parent b16b676 commit 624cf5b

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

‎drivers/macintosh/via-macii.c‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,21 @@ static irqreturn_t macii_interrupt(int irq, void *arg)
463463

464464
via[ACR] &= ~SR_OUT;
465465
x = via[SR];
466+
} else if ((req->data[1] & OP_MASK) == TALK) {
467+
macii_state = reading;
468+
469+
reading_reply = 0;
470+
reply_ptr = reply_buf;
471+
*reply_ptr = req->data[1];
472+
reply_len = 1;
473+
474+
via[ACR] &= ~SR_OUT;
475+
x = via[SR];
476+
477+
req->complete = 1;
478+
current_req = req->next;
479+
if (req->done)
480+
(*req->done)(req);
466481
} else {
467482
macii_state = idle;
468483

@@ -510,8 +525,9 @@ static irqreturn_t macii_interrupt(int irq, void *arg)
510525
current_req = req->next;
511526
if (req->done)
512527
(*req->done)(req);
513-
} else if (reply_len && autopoll_devs) {
514-
adb_input(reply_buf, reply_len, 0);
528+
} else if (reply_len && autopoll_devs &&
529+
reply_buf[0] == last_poll_cmd) {
530+
adb_input(reply_buf, reply_len, 1);
515531
}
516532
break;
517533
}

0 commit comments

Comments
 (0)