diff mbox series

[v2,16/39] acpi: Add an __ACPI__ preprocessor symbol

Message ID 20200308214442.v2.16.I6e674b2388c5a74a6912deb2dcc9c8acc8875da0@changeid
State Superseded
Headers show
Series dm: Add programmatic generation of ACPI tables (part A) | expand

Commit Message

Simon Glass March 9, 2020, 3:44 a.m. UTC
The ASL compiler cannot handle C structures and the like so needs some
sort of header guard around these.

We already have an __ASSEMBLY__ #define but it seems best to create a new
one for ACPI since the rules may be different.

Add the check to a few files that ACPI always includes.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
---

Changes in v2: None

 include/acpi_table.h | 4 ++++
 include/dm/acpi.h    | 4 ++++
 scripts/Makefile.lib | 4 ++--
 3 files changed, 10 insertions(+), 2 deletions(-)

Comments

Wolfgang Wallner March 10, 2020, 9:17 a.m. UTC | #1
Hi Simon,

> -----"Simon Glass" <sjg at chromium.org> schrieb: -----
> 
> The ASL compiler cannot handle C structures and the like so needs some
> sort of header guard around these.
> 
> We already have an __ASSEMBLY__ #define but it seems best to create a new
> one for ACPI since the rules may be different.
> 
> Add the check to a few files that ACPI always includes.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> ---
> 
> Changes in v2: None
> 
>  include/acpi_table.h | 4 ++++
>  include/dm/acpi.h    | 4 ++++
>  scripts/Makefile.lib | 4 ++--
>  3 files changed, 10 insertions(+), 2 deletions(-)

Reviewed-by: Wolfgang Wallner <wolfgang.wallner at br-automation.com>
diff mbox series

Patch

diff --git a/include/acpi_table.h b/include/acpi_table.h
index b4404a632c..dd74895813 100644
--- a/include/acpi_table.h
+++ b/include/acpi_table.h
@@ -21,6 +21,8 @@ 
 #define ACPI_RSDP_REV_ACPI_1_0	0
 #define ACPI_RSDP_REV_ACPI_2_0	2
 
+#if !defined(__ACPI__)
+
 /*
  * RSDP (Root System Description Pointer)
  * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum
@@ -389,6 +391,8 @@  struct __packed acpi_spcr {
 	u32 reserved2;
 };
 
+#endif /* !__ACPI__*/
+
 #include <asm/acpi_table.h>
 
 #endif /* __ACPI_TABLE_H__ */
diff --git a/include/dm/acpi.h b/include/dm/acpi.h
index 120576adc0..8d6c3fd424 100644
--- a/include/dm/acpi.h
+++ b/include/dm/acpi.h
@@ -22,6 +22,8 @@ 
 /* Length of an ACPI name string including nul terminator */
 #define ACPI_NAME_MAX	5
 
+#if !defined(__ACPI__)
+
 /**
  * struct acpi_ops - ACPI operations supported by driver model
  */
@@ -70,4 +72,6 @@  int acpi_get_name(const struct udevice *dev, char *out_name);
  */
 int acpi_return_name(char *out_name, const char *name);
 
+#endif /* __ACPI__ */
+
 #endif
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 30f392fdfb..aebdb38d0d 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -413,8 +413,8 @@  ASL_TMP = $(patsubst %.c,%.asl.tmp,$@)
 
 quiet_cmd_acpi_c_asl= ASL     $<
 cmd_acpi_c_asl=         \
-	$(CPP) -x assembler-with-cpp -D__ASSEMBLY__ -P $(UBOOTINCLUDE) \
-		-o $(ASL_TMP) $< && \
+	$(CPP) -x assembler-with-cpp -D__ASSEMBLY__ -D__ACPI__ \
+		-P $(UBOOTINCLUDE) -o $(ASL_TMP) $< && \
 	iasl -p $@ -tc $(ASL_TMP) $(if $(KBUILD_VERBOSE:1=), >/dev/null) && \
 	mv $(patsubst %.c,%.hex,$@) $@