pckbd: add function kbd_pending()

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>
This commit is contained in:
Volker Rümelin 2021-05-25 20:14:38 +02:00 committed by Gerd Hoffmann
parent aa67a42f8d
commit e4697fabb5

View File

@ -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;
@ -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);
}
}
@ -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);
}
}
@ -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;