Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MzxW3-0006YR-TN for qemu-devel@nongnu.org; Mon, 19 Oct 2009 15:03:36 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MzxW0-0006V2-61 for qemu-devel@nongnu.org; Mon, 19 Oct 2009 15:03:35 -0400 Received: from [199.232.76.173] (port=45702 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MzxVz-0006Um-NY for qemu-devel@nongnu.org; Mon, 19 Oct 2009 15:03:31 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:51709) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MzxVy-0000cF-W6 for qemu-devel@nongnu.org; Mon, 19 Oct 2009 15:03:31 -0400 From: Stefan Weil Date: Mon, 19 Oct 2009 21:03:26 +0200 Message-Id: <1255979006-9268-1-git-send-email-weil@mail.berlios.de> Subject: [Qemu-devel] [PATCH] eepro100: Restructure code List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers This patch only moves about 150 lines of code from function eepro100_cu_command to a new function action_command. A goto statement was replaced by a for loop. There are no functional changes. Nor did I change comments starting with // (they will be removed by future patches). Signed-off-by: Stefan Weil --- hw/eepro100.c | 54 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 30 insertions(+), 24 deletions(-) diff --git a/hw/eepro100.c b/hw/eepro100.c index 62207da..ef7d131 100644 --- a/hw/eepro100.c +++ b/hw/eepro100.c @@ -626,26 +626,11 @@ static void dump_statistics(EEPRO100State * s) //~ missing("CU dump statistical counters"); } -static void eepro100_cu_command(EEPRO100State * s, uint8_t val) +static void action_command(EEPRO100State *s) { - eepro100_tx_t tx; - uint32_t cb_address; - switch (val) { - case CU_NOP: - /* No operation. */ - break; - case CU_START: - if (get_cu_state(s) != cu_idle) { - /* Intel documentation says that CU must be idle for the CU - * start command. Intel driver for Linux also starts the CU - * from suspended state. */ - logout("CU state is %u, should be %u\n", get_cu_state(s), cu_idle); - //~ assert(!"wrong CU state"); - } - set_cu_state(s, cu_active); - s->cu_offset = s->pointer; - next_command: - cb_address = s->cu_base + s->cu_offset; + for (;;) { + uint32_t cb_address = s->cu_base + s->cu_offset; + eepro100_tx_t tx; cpu_physical_memory_read(cb_address, (uint8_t *) & tx, sizeof(tx)); uint16_t status = le16_to_cpu(tx.status); uint16_t command = le16_to_cpu(tx.command); @@ -787,17 +772,38 @@ static void eepro100_cu_command(EEPRO100State * s, uint8_t val) /* CU becomes idle. Terminate command loop. */ set_cu_state(s, cu_idle); eepro100_cna_interrupt(s); + break; } else if (bit_s) { - /* CU becomes suspended. */ + /* CU becomes suspended. Terminate command loop. */ set_cu_state(s, cu_suspended); eepro100_cna_interrupt(s); + break; } else { /* More entries in list. */ TRACE(OTHER, logout("CU list with at least one more entry\n")); - goto next_command; } - TRACE(OTHER, logout("CU list empty\n")); - /* List is empty. Now CU is idle or suspended. */ + } + TRACE(OTHER, logout("CU list empty\n")); + /* List is empty. Now CU is idle or suspended. */ +} + +static void eepro100_cu_command(EEPRO100State * s, uint8_t val) +{ + switch (val) { + case CU_NOP: + /* No operation. */ + break; + case CU_START: + if (get_cu_state(s) != cu_idle) { + /* Intel documentation says that CU must be idle for the CU + * start command. Intel driver for Linux also starts the CU + * from suspended state. */ + logout("CU state is %u, should be %u\n", get_cu_state(s), cu_idle); + //~ assert(!"wrong CU state"); + } + set_cu_state(s, cu_active); + s->cu_offset = s->pointer; + action_command(s); break; case CU_RESUME: if (get_cu_state(s) != cu_suspended) { @@ -810,7 +816,7 @@ static void eepro100_cu_command(EEPRO100State * s, uint8_t val) if (get_cu_state(s) == cu_suspended) { TRACE(OTHER, logout("CU resuming\n")); set_cu_state(s, cu_active); - goto next_command; + action_command(s); } break; case CU_STATSADDR: -- 1.5.6.5