Skip to content

Commit 913f47e

Browse files
committed
adb: only call autopoll callbacks when autopoll is not blocked
Handle this at the ADB bus level so that individual implementations do not need to handle this themselves. Finally add an assert() into adb_request() to prevent developers from accidentally making an explicit ADB request without blocking autopoll. Signed-off-by: Mark Cave-Ayland <[email protected]> Tested-by: Finn Thain <[email protected]> Acked-by: Laurent Vivier <[email protected]> Message-Id: <[email protected]>
1 parent 975fced commit 913f47e

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

hw/input/adb.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ static int do_adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf,
8686

8787
int adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf, int len)
8888
{
89+
assert(s->autopoll_blocked);
90+
8991
return do_adb_request(s, obuf, buf, len);
9092
}
9193

92-
/* XXX: move that to cuda ? */
9394
int adb_poll(ADBBusState *s, uint8_t *obuf, uint16_t poll_mask)
9495
{
9596
ADBDevice *d;
@@ -181,7 +182,9 @@ static void adb_autopoll(void *opaque)
181182
{
182183
ADBBusState *s = opaque;
183184

184-
s->autopoll_cb(s->autopoll_cb_opaque);
185+
if (!s->autopoll_blocked) {
186+
s->autopoll_cb(s->autopoll_cb_opaque);
187+
}
185188

186189
timer_mod(s->autopoll_timer,
187190
qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +

hw/misc/mac_via.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,7 @@ static void adb_via_poll(void *opaque)
615615
* received, however we must block autopoll until the point where
616616
* the entire reply has been read back to the host
617617
*/
618-
if (adb_bus->autopoll_blocked) {
619-
return;
620-
} else {
621-
adb_autopoll_block(adb_bus);
622-
}
618+
adb_autopoll_block(adb_bus);
623619

624620
m->adb_data_in_index = 0;
625621
m->adb_data_out_index = 0;

0 commit comments

Comments
 (0)