diff mbox

[21/23] cirrus_vga: rename cirrus_hook_read_cr() cirrus_vga_read_cr()

Message ID 3df23bf582d1ebff74075ac1a7920aef9aabf619.1251725416.git.quintela@redhat.com
State Superseded
Headers show

Commit Message

Juan Quintela Aug. 31, 2009, 2:07 p.m. UTC
Simplify the logic to do everything inside the function.  Return 0xff if index is out of range independetly of DEBUG_CIRRUS

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/cirrus_vga.c |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)
diff mbox

Patch

diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 759da4a..86ab127 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -1583,8 +1583,7 @@  cirrus_vga_write_gr(CirrusVGAState * s, unsigned reg_index, int reg_value)
  *
  ***************************************/

-static int
-cirrus_hook_read_cr(CirrusVGAState * s, unsigned reg_index, int *reg_value)
+static int cirrus_vga_read_cr(CirrusVGAState * s, unsigned reg_index)
 {
     switch (reg_index) {
     case 0x00:			// Standard VGA
@@ -1612,10 +1611,9 @@  cirrus_hook_read_cr(CirrusVGAState * s, unsigned reg_index, int *reg_value)
     case 0x16:			// Standard VGA
     case 0x17:			// Standard VGA
     case 0x18:			// Standard VGA
-	return CIRRUS_HOOK_NOT_HANDLED;
+	return s->vga.cr[s->vga.cr_index];
     case 0x24:			// Attribute Controller Toggle Readback (R)
-        *reg_value = (s->vga.ar_flip_flop << 7);
-        break;
+        return (s->vga.ar_flip_flop << 7);
     case 0x19:			// Interlace End
     case 0x1a:			// Miscellaneous Control
     case 0x1b:			// Extended Display Control
@@ -1624,20 +1622,16 @@  cirrus_hook_read_cr(CirrusVGAState * s, unsigned reg_index, int *reg_value)
     case 0x22:			// Graphics Data Latches Readback (R)
     case 0x25:			// Part Status
     case 0x27:			// Part ID (R)
-	*reg_value = s->vga.cr[reg_index];
-	break;
+	return s->vga.cr[s->vga.cr_index];
     case 0x26:			// Attribute Controller Index Readback (R)
-	*reg_value = s->vga.ar_index & 0x3f;
+	return s->vga.ar_index & 0x3f;
 	break;
     default:
 #ifdef DEBUG_CIRRUS
 	printf("cirrus: inport cr_index %02x\n", reg_index);
-	*reg_value = 0xff;
 #endif
-	break;
+	return 0xff;
     }
-
-    return CIRRUS_HOOK_HANDLED;
 }

 static int
@@ -2719,9 +2713,7 @@  static uint32_t cirrus_vga_ioport_read(void *opaque, uint32_t addr)
 	    break;
 	case 0x3b5:
 	case 0x3d5:
-	    if (cirrus_hook_read_cr(c, s->cr_index, &val))
-		break;
-	    val = s->cr[s->cr_index];
+            val = cirrus_vga_read_cr(c, s->cr_index);
 #ifdef DEBUG_VGA_REG
 	    printf("vga: read CR%x = 0x%02x\n", s->cr_index, val);
 #endif