[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 31/37] ehci: add ehci_*_enabled() helpers
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 31/37] ehci: add ehci_*_enabled() helpers |
Date: |
Thu, 7 Jun 2012 11:31:20 +0200 |
Add helper functions to query whenever the async / periodic schedule
is enabled or not. Put them into use too.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb/hcd-ehci.c | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 3b602b0..d9c0f0f 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -667,6 +667,21 @@ static void ehci_trace_sitd(EHCIState *s,
target_phys_addr_t addr,
(bool)(sitd->results & SITD_RESULTS_ACTIVE));
}
+static inline bool ehci_enabled(EHCIState *s)
+{
+ return s->usbcmd & USBCMD_RUNSTOP;
+}
+
+static inline bool ehci_async_enabled(EHCIState *s)
+{
+ return ehci_enabled(s) && (s->usbcmd & USBCMD_ASE);
+}
+
+static inline bool ehci_periodic_enabled(EHCIState *s)
+{
+ return ehci_enabled(s) && (s->usbcmd & USBCMD_PSE);
+}
+
/* packet management */
static EHCIPacket *ehci_alloc_packet(EHCIQueue *q)
@@ -1160,7 +1175,7 @@ static void ehci_mem_writel(void *ptr, target_phys_addr_t
addr, uint32_t val)
break;
case PERIODICLISTBASE:
- if ((s->usbcmd & USBCMD_PSE) && (s->usbcmd & USBCMD_RUNSTOP)) {
+ if (ehci_periodic_enabled(s)) {
fprintf(stderr,
"ehci: PERIODIC list base register set while periodic schedule\n"
" is enabled and HC is enabled\n");
@@ -1168,7 +1183,7 @@ static void ehci_mem_writel(void *ptr, target_phys_addr_t
addr, uint32_t val)
break;
case ASYNCLISTADDR:
- if ((s->usbcmd & USBCMD_ASE) && (s->usbcmd & USBCMD_RUNSTOP)) {
+ if (ehci_async_enabled(s)) {
fprintf(stderr,
"ehci: ASYNC list address register set while async schedule\n"
" is enabled and HC is enabled\n");
@@ -2152,7 +2167,7 @@ static void ehci_advance_async_state(EHCIState *ehci)
switch(ehci_get_state(ehci, async)) {
case EST_INACTIVE:
- if (!(ehci->usbcmd & USBCMD_ASE)) {
+ if (!ehci_async_enabled(ehci)) {
break;
}
ehci_set_usbsts(ehci, USBSTS_ASS);
@@ -2160,7 +2175,7 @@ static void ehci_advance_async_state(EHCIState *ehci)
// No break, fall through to ACTIVE
case EST_ACTIVE:
- if ( !(ehci->usbcmd & USBCMD_ASE)) {
+ if (!ehci_async_enabled(ehci)) {
ehci_queues_rip_all(ehci, async);
ehci_clear_usbsts(ehci, USBSTS_ASS);
ehci_set_state(ehci, async, EST_INACTIVE);
@@ -2213,7 +2228,7 @@ static void ehci_advance_periodic_state(EHCIState *ehci)
switch(ehci_get_state(ehci, async)) {
case EST_INACTIVE:
- if ( !(ehci->frindex & 7) && (ehci->usbcmd & USBCMD_PSE)) {
+ if (!(ehci->frindex & 7) && ehci_periodic_enabled(ehci)) {
ehci_set_usbsts(ehci, USBSTS_PSS);
ehci_set_state(ehci, async, EST_ACTIVE);
// No break, fall through to ACTIVE
@@ -2221,7 +2236,7 @@ static void ehci_advance_periodic_state(EHCIState *ehci)
break;
case EST_ACTIVE:
- if ( !(ehci->frindex & 7) && !(ehci->usbcmd & USBCMD_PSE)) {
+ if (!(ehci->frindex & 7) && !ehci_periodic_enabled(ehci)) {
ehci_queues_rip_all(ehci, async);
ehci_clear_usbsts(ehci, USBSTS_PSS);
ehci_set_state(ehci, async, EST_INACTIVE);
--
1.7.1
- [Qemu-devel] [PATCH 10/37] usb-storage: add scsi_off, remove scsi_buf, (continued)
- [Qemu-devel] [PATCH 10/37] usb-storage: add scsi_off, remove scsi_buf, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 06/37] uhci: fix irq routing, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 18/37] xhci: trace: transfers, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 26/37] ehci: add async field to EHCIQueue, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 12/37] xhci: Clean up reset function, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 21/37] ehci: make ehci_execute work on EHCIPacket instead of EHCIQueue, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 11/37] usb-storage: migration support, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 07/37] scsi: prepare migration code for usb-storage support, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 16/37] xhci: trace: ring fetch, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 36/37] ehci: adaptive wakeup rate., Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 31/37] ehci: add ehci_*_enabled() helpers,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 34/37] ehci: remove unused attach_poll_counter, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 15/37] xhci: trace: irq + events, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 37/37] ehci: rework frame skipping, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 33/37] ehci: fix halt status handling, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 24/37] ehci: add queuing support, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 35/37] ehci: create ehci_update_frindex, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 19/37] xhci: trace: slots, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 13/37] xhci: trace: mmio reads+writes, Gerd Hoffmann, 2012/06/07
- [Qemu-devel] [PATCH 20/37] ehci: add EHCIPacket, Gerd Hoffmann, 2012/06/07
- Re: [Qemu-devel] [PULL 00/37] usb patch queue, Anthony Liguori, 2012/06/11