diff mbox

[RFC,07/47] acpi: factor out ACPI const int packing out build_append_value()

Message ID 1418954562-13716-8-git-send-email-imammedo@redhat.com
State New
Headers show

Commit Message

Igor Mammedov Dec. 19, 2014, 2:02 a.m. UTC
it will be reused for adding a plain integer
value into AML.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/acpi_gen_utils.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)
diff mbox

Patch

diff --git a/hw/acpi/acpi_gen_utils.c b/hw/acpi/acpi_gen_utils.c
index cfccb42..36d7a47 100644
--- a/hw/acpi/acpi_gen_utils.c
+++ b/hw/acpi/acpi_gen_utils.c
@@ -204,24 +204,8 @@  void build_extop_package(GArray *package, uint8_t op)
 
 void build_append_value(GArray *table, uint32_t value, int size)
 {
-    uint8_t prefix;
     int i;
 
-    switch (size) {
-    case 1:
-        prefix = 0x0A; /* BytePrefix */
-        break;
-    case 2:
-        prefix = 0x0B; /* WordPrefix */
-        break;
-    case 4:
-        prefix = 0x0C; /* DWordPrefix */
-        break;
-    default:
-        assert(0);
-        return;
-    }
-    build_append_byte(table, prefix);
     for (i = 0; i < size; ++i) {
         build_append_byte(table, value & 0xFF);
         value = value >> 8;
@@ -235,10 +219,13 @@  void build_append_int(GArray *table, uint32_t value)
     } else if (value == 0x01) {
         build_append_byte(table, 0x01); /* OneOp */
     } else if (value <= 0xFF) {
+        build_append_byte(table, 0x0A); /* BytePrefix */
         build_append_value(table, value, 1);
     } else if (value <= 0xFFFF) {
+        build_append_byte(table, 0x0B); /* WordPrefix */
         build_append_value(table, value, 2);
     } else {
+        build_append_byte(table, 0x0C); /* DWordPrefix */
         build_append_value(table, value, 4);
     }
 }