acpigen: Add and use acpigen_write_device.

The sequence of bytes to create a method is used several times in codebase.
Put it into a function with logical arguments rather than duplicating magic
bytes everywhere.

Change-Id: I2c33fa403832eb1cfadfbf8d9adef5b63fb9cb24
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-on: http://review.coreboot.org/7348
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Tested-by: build bot (Jenkins)
diff --git a/src/arch/x86/boot/acpigen.c b/src/arch/x86/boot/acpigen.c
index 0eee78a..f714d59 100644
--- a/src/arch/x86/boot/acpigen.c
+++ b/src/arch/x86/boot/acpigen.c
@@ -408,6 +408,19 @@
 	return len;
 }
 
+int acpigen_write_device(const char *name)
+{
+	int len;
+
+	/* method op */
+	len = acpigen_emit_byte(0x5b);
+	len += acpigen_emit_byte(0x82);
+	len += acpigen_write_len_f();
+	len += acpigen_emit_namestring(name);
+
+	return len;
+}
+
 /*
  * Generates a func with max supported P-states.
  */