Re: [PATCH v1 08/43] acpi: Export functions to write sized values

2020-07-07 Thread Simon Glass
Hi Bin,

On Mon, 29 Jun 2020 at 20:49, Bin Meng  wrote:
>
> Hi Simon,
>
> On Mon, Jun 15, 2020 at 11:57 AM Simon Glass  wrote:
> >
> > At present only acpigen_write_integer() is exported for use by other code.
> > But in some cases it is useful to call the specific function depending on
> > the size of the value.
> >
> > Export these functions and add a test.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >  include/acpi/acpigen.h | 46 ++
> >  test/dm/acpigen.c  | 45 -
> >  2 files changed, 90 insertions(+), 1 deletion(-)
> >
>
> Since the acpigen_write_integer() patch has not been applied, could
> you please squash this patch into:
>
> [v3,15/35] acpi: Support writing an integer
> http://patchwork.ozlabs.org/project/uboot/patch/20200614025523.40183-5-...@chromium.org/

Oh, I've already resent that series. I tend to work one at a time.
Feel free to squash if you like but I think this merits a different
patch.

Regards,
SImon


Re: [PATCH v1 08/43] acpi: Export functions to write sized values

2020-06-29 Thread Bin Meng
Hi Simon,

On Mon, Jun 15, 2020 at 11:57 AM Simon Glass  wrote:
>
> At present only acpigen_write_integer() is exported for use by other code.
> But in some cases it is useful to call the specific function depending on
> the size of the value.
>
> Export these functions and add a test.
>
> Signed-off-by: Simon Glass 
> ---
>
>  include/acpi/acpigen.h | 46 ++
>  test/dm/acpigen.c  | 45 -
>  2 files changed, 90 insertions(+), 1 deletion(-)
>

Since the acpigen_write_integer() patch has not been applied, could
you please squash this patch into:

[v3,15/35] acpi: Support writing an integer
http://patchwork.ozlabs.org/project/uboot/patch/20200614025523.40183-5-...@chromium.org/

Regards,
Bin


Re: [PATCH v1 08/43] acpi: Export functions to write sized values

2020-06-25 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v1 08/43] acpi: Export functions to write sized values
> 
> At present only acpigen_write_integer() is exported for use by other code.
> But in some cases it is useful to call the specific function depending on
> the size of the value.
> 
> Export these functions and add a test.
> 
> Signed-off-by: Simon Glass 
> ---
> 
>  include/acpi/acpigen.h | 46 ++
>  test/dm/acpigen.c  | 45 -
>  2 files changed, 90 insertions(+), 1 deletion(-)

Reviewed-by: Wolfgang Wallner 



[PATCH v1 08/43] acpi: Export functions to write sized values

2020-06-14 Thread Simon Glass
At present only acpigen_write_integer() is exported for use by other code.
But in some cases it is useful to call the specific function depending on
the size of the value.

Export these functions and add a test.

Signed-off-by: Simon Glass 
---

 include/acpi/acpigen.h | 46 ++
 test/dm/acpigen.c  | 45 -
 2 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/include/acpi/acpigen.h b/include/acpi/acpigen.h
index d68dca5dde..7c117c1cf6 100644
--- a/include/acpi/acpigen.h
+++ b/include/acpi/acpigen.h
@@ -169,6 +169,52 @@ void acpigen_pop_len(struct acpi_ctx *ctx);
  */
 char *acpigen_write_package(struct acpi_ctx *ctx, int nr_el);
 
+/**
+ * acpigen_write_byte() - Write a byte
+ *
+ * @ctx: ACPI context pointer
+ * @data: Value to write
+ */
+void acpigen_write_byte(struct acpi_ctx *ctx, unsigned int data);
+
+/**
+ * acpigen_write_word() - Write a word
+ *
+ * @ctx: ACPI context pointer
+ * @data: Value to write
+ */
+void acpigen_write_word(struct acpi_ctx *ctx, unsigned int data);
+
+/**
+ * acpigen_write_dword() - Write a dword
+ *
+ * @ctx: ACPI context pointer
+ * @data: Value to write
+ */
+void acpigen_write_dword(struct acpi_ctx *ctx, unsigned int data);
+
+/**
+ * acpigen_write_qword() - Write a qword
+ *
+ * @ctx: ACPI context pointer
+ * @data: Value to write
+ */
+void acpigen_write_qword(struct acpi_ctx *ctx, u64 data);
+
+/**
+ * acpigen_write_zero() - Write zero
+ *
+ * @ctx: ACPI context pointer
+ */
+void acpigen_write_zero(struct acpi_ctx *ctx);
+
+/**
+ * acpigen_write_one() - Write one
+ *
+ * @ctx: ACPI context pointer
+ */
+void acpigen_write_one(struct acpi_ctx *ctx);
+
 /**
  * acpigen_write_integer() - Write an integer
  *
diff --git a/test/dm/acpigen.c b/test/dm/acpigen.c
index ea2033a27c..0322dd4f60 100644
--- a/test/dm/acpigen.c
+++ b/test/dm/acpigen.c
@@ -861,5 +861,48 @@ static int dm_test_acpi_power_seq(struct unit_test_state 
*uts)
 
return 0;
 }
-
 DM_TEST(dm_test_acpi_power_seq, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test writing values */
+static int dm_test_acpi_write_values(struct unit_test_state *uts)
+{
+   struct acpi_ctx *ctx;
+   u8 *ptr;
+
+   ut_assertok(alloc_context());
+   ptr = acpigen_get_current(ctx);
+
+   acpigen_write_zero(ctx);
+   acpigen_write_one(ctx);
+   acpigen_write_byte(ctx, TEST_INT8);
+   acpigen_write_word(ctx, TEST_INT16);
+   acpigen_write_dword(ctx, TEST_INT32);
+   acpigen_write_qword(ctx, TEST_INT64);
+
+   ut_asserteq(ZERO_OP, *ptr++);
+
+   ut_asserteq(ONE_OP, *ptr++);
+
+   ut_asserteq(BYTE_PREFIX, *ptr++);
+   ut_asserteq(TEST_INT8, *ptr++);
+
+   ut_asserteq(WORD_PREFIX, *ptr++);
+   ut_asserteq(TEST_INT16, get_unaligned((u16 *)ptr));
+   ptr += 2;
+
+   ut_asserteq(DWORD_PREFIX, *ptr++);
+   ut_asserteq(TEST_INT32, get_unaligned((u32 *)ptr));
+   ptr += 4;
+
+   ut_asserteq(QWORD_PREFIX, *ptr++);
+   ut_asserteq_64(TEST_INT64, get_unaligned((u64 *)ptr));
+   ptr += 8;
+
+   ut_asserteq_ptr(ptr, ctx->current);
+
+   free_context();
+
+   return 0;
+}
+DM_TEST(dm_test_acpi_write_values, 0);
+
-- 
2.27.0.290.gba653c62da-goog