diff mbox series

[1/5] acpi: new function acpi_update_checksum()

Message ID 20250321232121.251800-2-heinrich.schuchardt@canonical.com
State Accepted
Commit 69e61d46d2dcdcf84a3a7aed7cf74ac3b3b850fd
Delegated to: Tom Rini
Headers show
Series acpi: simplify updating ACPI table header checksum | expand

Commit Message

Heinrich Schuchardt March 21, 2025, 11:21 p.m. UTC
Introduce a new function to update ACPI table headers.
This allows to simplify the existing code.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 include/acpi/acpi_table.h | 7 +++++++
 lib/acpi/acpi.c           | 7 +++++++
 2 files changed, 14 insertions(+)

Comments

Matthias Brugger March 25, 2025, 2:49 p.m. UTC | #1
On 22/03/2025 00:21, Heinrich Schuchardt wrote:
> Introduce a new function to update ACPI table headers.
> This allows to simplify the existing code.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

Reviewed-by: Matthias Brugger <mbrugger@suse.com>

> ---
>   include/acpi/acpi_table.h | 7 +++++++
>   lib/acpi/acpi.c           | 7 +++++++
>   2 files changed, 14 insertions(+)
> 
> diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h
> index b8b1f1338c6..f8e5f552ab1 100644
> --- a/include/acpi/acpi_table.h
> +++ b/include/acpi/acpi_table.h
> @@ -1274,6 +1274,13 @@ ulong write_acpi_tables(ulong start);
>    */
>   struct acpi_table_header *acpi_find_table(const char *sig);
>   
> +/**
> + * acpi_update_checksum() - update ACPI table checksum
> + *
> + * @header - header of an ACPI table
> + */
> +void acpi_update_checksum(struct acpi_table_header *header);
> +
>   #endif /* !__ACPI__*/
>   
>   #include <asm/acpi_table.h>
> diff --git a/lib/acpi/acpi.c b/lib/acpi/acpi.c
> index f4d5c1e25d0..596301a43fe 100644
> --- a/lib/acpi/acpi.c
> +++ b/lib/acpi/acpi.c
> @@ -6,11 +6,18 @@
>    */
>   
>   #include <mapmem.h>
> +#include <tables_csum.h>
>   #include <acpi/acpi_table.h>
>   #include <asm/global_data.h>
>   
>   DECLARE_GLOBAL_DATA_PTR;
>   
> +void acpi_update_checksum(struct acpi_table_header *header)
> +{
> +	header->checksum = 0;
> +	header->checksum = table_compute_checksum(header, header->length);
> +}
> +
>   struct acpi_table_header *acpi_find_table(const char *sig)
>   {
>   	struct acpi_rsdp *rsdp;
Ilias Apalodimas March 26, 2025, 7:29 a.m. UTC | #2
On Sat, 22 Mar 2025 at 01:21, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> Introduce a new function to update ACPI table headers.
> This allows to simplify the existing code.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

> ---
>  include/acpi/acpi_table.h | 7 +++++++
>  lib/acpi/acpi.c           | 7 +++++++
>  2 files changed, 14 insertions(+)
>
> diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h
> index b8b1f1338c6..f8e5f552ab1 100644
> --- a/include/acpi/acpi_table.h
> +++ b/include/acpi/acpi_table.h
> @@ -1274,6 +1274,13 @@ ulong write_acpi_tables(ulong start);
>   */
>  struct acpi_table_header *acpi_find_table(const char *sig);
>
> +/**
> + * acpi_update_checksum() - update ACPI table checksum
> + *
> + * @header - header of an ACPI table
> + */
> +void acpi_update_checksum(struct acpi_table_header *header);
> +
>  #endif /* !__ACPI__*/
>
>  #include <asm/acpi_table.h>
> diff --git a/lib/acpi/acpi.c b/lib/acpi/acpi.c
> index f4d5c1e25d0..596301a43fe 100644
> --- a/lib/acpi/acpi.c
> +++ b/lib/acpi/acpi.c
> @@ -6,11 +6,18 @@
>   */
>
>  #include <mapmem.h>
> +#include <tables_csum.h>
>  #include <acpi/acpi_table.h>
>  #include <asm/global_data.h>
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> +void acpi_update_checksum(struct acpi_table_header *header)
> +{
> +       header->checksum = 0;
> +       header->checksum = table_compute_checksum(header, header->length);
> +}
> +
>  struct acpi_table_header *acpi_find_table(const char *sig)
>  {
>         struct acpi_rsdp *rsdp;
> --
> 2.48.1
>
diff mbox series

Patch

diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h
index b8b1f1338c6..f8e5f552ab1 100644
--- a/include/acpi/acpi_table.h
+++ b/include/acpi/acpi_table.h
@@ -1274,6 +1274,13 @@  ulong write_acpi_tables(ulong start);
  */
 struct acpi_table_header *acpi_find_table(const char *sig);
 
+/**
+ * acpi_update_checksum() - update ACPI table checksum
+ *
+ * @header - header of an ACPI table
+ */
+void acpi_update_checksum(struct acpi_table_header *header);
+
 #endif /* !__ACPI__*/
 
 #include <asm/acpi_table.h>
diff --git a/lib/acpi/acpi.c b/lib/acpi/acpi.c
index f4d5c1e25d0..596301a43fe 100644
--- a/lib/acpi/acpi.c
+++ b/lib/acpi/acpi.c
@@ -6,11 +6,18 @@ 
  */
 
 #include <mapmem.h>
+#include <tables_csum.h>
 #include <acpi/acpi_table.h>
 #include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+void acpi_update_checksum(struct acpi_table_header *header)
+{
+	header->checksum = 0;
+	header->checksum = table_compute_checksum(header, header->length);
+}
+
 struct acpi_table_header *acpi_find_table(const char *sig)
 {
 	struct acpi_rsdp *rsdp;