Skip to content

Commit

Permalink
pckbd: add function kbd_pending()
Browse files Browse the repository at this point in the history
Replace reads of the variable s->pending with a call to a new
function kbd_pending() to ease the review of the next patch.
There is no functional change.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20210525181441.27768-9-vr_qemu@t-online.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
Volker Rümelin authored and kraxel committed May 26, 2021
1 parent aa67a42 commit e4697fa
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions hw/input/pckbd.c
Expand Up @@ -198,21 +198,28 @@ static void kbd_deassert_irq(KBDState *s)
kbd_update_irq_lines(s);
}

static uint8_t kbd_pending(KBDState *s)
{
return s->pending;
}

/* update irq and KBD_STAT_[MOUSE_]OBF */
static void kbd_update_irq(KBDState *s)
{
uint8_t pending = kbd_pending(s);

s->status &= ~(KBD_STAT_OBF | KBD_STAT_MOUSE_OBF);
s->outport &= ~(KBD_OUT_OBF | KBD_OUT_MOUSE_OBF);
if (s->pending) {
if (pending) {
s->status |= KBD_STAT_OBF;
s->outport |= KBD_OUT_OBF;
if (s->pending & KBD_PENDING_CTRL_KBD) {
if (pending & KBD_PENDING_CTRL_KBD) {
s->obsrc = KBD_OBSRC_CTRL;
} else if (s->pending & KBD_PENDING_CTRL_AUX) {
} else if (pending & KBD_PENDING_CTRL_AUX) {
s->status |= KBD_STAT_MOUSE_OBF;
s->outport |= KBD_OUT_MOUSE_OBF;
s->obsrc = KBD_OBSRC_CTRL;
} else if (s->pending & KBD_PENDING_KBD) {
} else if (pending & KBD_PENDING_KBD) {
s->obsrc = KBD_OBSRC_KBD;
} else {
s->status |= KBD_STAT_MOUSE_OBF;
Expand All @@ -236,7 +243,7 @@ static void kbd_safe_update_irq(KBDState *s)
if (s->throttle_timer && timer_pending(s->throttle_timer)) {
return;
}
if (s->pending) {
if (kbd_pending(s)) {
kbd_update_irq(s);
}
}
Expand Down Expand Up @@ -269,7 +276,7 @@ static void kbd_throttle_timeout(void *opaque)
{
KBDState *s = opaque;

if (s->pending) {
if (kbd_pending(s)) {
kbd_update_irq(s);
}
}
Expand Down Expand Up @@ -301,7 +308,7 @@ static uint8_t kbd_dequeue(KBDState *s)
uint8_t b = s->cbdata;

s->pending &= ~KBD_PENDING_CTRL_KBD & ~KBD_PENDING_CTRL_AUX;
if (s->pending) {
if (kbd_pending(s)) {
kbd_update_irq(s);
}
return b;
Expand Down

0 comments on commit e4697fa

Please sign in to comment.