* [PATCH v3] platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER
@ 2023-08-03 1:12 Tzung-Bi Shih
2023-08-10 0:35 ` Guenter Roeck
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tzung-Bi Shih @ 2023-08-03 1:12 UTC (permalink / raw)
To: bleung, groeck
Cc: chrome-platform, guillaume.tucker, denys.f, ricardo.canuelo,
usama.anjum, tzungbi, briannorris
`element->buffer.pointer` should be binary blob. `%s` doesn't work
perfect for them.
Print hex string for ACPI_TYPE_BUFFER. Also update the documentation
to reflect this.
Fixes: 0a4cad9c11ad ("platform/chrome: Add ChromeOS ACPI device driver")
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
---
Changes from v2[1]:
- Use dev_info_once() instead of dev_info().
- Update documentation.
- Add Fixes tag.
Changes from v1[2]:
- Use hex_dump_to_buffer().
- Rewrite the loop for catching edge cases for truncating.
[1]: https://patchwork.kernel.org/project/chrome-platform/patch/20230802095736.3079963-1-tzungbi@kernel.org/
[2]: https://patchwork.kernel.org/project/chrome-platform/patch/20230726073127.2969387-1-tzungbi@kernel.org/
.../ABI/testing/sysfs-driver-chromeos-acpi | 2 +-
drivers/platform/chrome/chromeos_acpi.c | 31 ++++++++++++++++++-
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-driver-chromeos-acpi b/Documentation/ABI/testing/sysfs-driver-chromeos-acpi
index c308926e1568..7c8e129fc100 100644
--- a/Documentation/ABI/testing/sysfs-driver-chromeos-acpi
+++ b/Documentation/ABI/testing/sysfs-driver-chromeos-acpi
@@ -134,4 +134,4 @@ KernelVersion: 5.19
Description:
Returns the verified boot data block shared between the
firmware verification step and the kernel verification step
- (binary).
+ (hex dump).
diff --git a/drivers/platform/chrome/chromeos_acpi.c b/drivers/platform/chrome/chromeos_acpi.c
index 50d8a4d4352d..1312aaaa8750 100644
--- a/drivers/platform/chrome/chromeos_acpi.c
+++ b/drivers/platform/chrome/chromeos_acpi.c
@@ -90,7 +90,36 @@ static int chromeos_acpi_handle_package(struct device *dev, union acpi_object *o
case ACPI_TYPE_STRING:
return sysfs_emit(buf, "%s\n", element->string.pointer);
case ACPI_TYPE_BUFFER:
- return sysfs_emit(buf, "%s\n", element->buffer.pointer);
+ {
+ int i, r, at, room_left;
+ const int byte_per_line = 16;
+
+ at = 0;
+ room_left = PAGE_SIZE - 1;
+ for (i = 0; i < element->buffer.length && room_left; i += byte_per_line) {
+ r = hex_dump_to_buffer(element->buffer.pointer + i,
+ element->buffer.length - i,
+ byte_per_line, 1, buf + at, room_left,
+ false);
+ if (r > room_left)
+ goto truncating;
+ at += r;
+ room_left -= r;
+
+ r = sysfs_emit_at(buf, at, "\n");
+ if (!r)
+ goto truncating;
+ at += r;
+ room_left -= r;
+ }
+
+ buf[at] = 0;
+ return at;
+truncating:
+ dev_info_once(dev, "truncating sysfs content for %s\n", name);
+ sysfs_emit_at(buf, PAGE_SIZE - 4, "..\n");
+ return PAGE_SIZE - 1;
+ }
default:
dev_err(dev, "element type %d not supported\n", element->type);
return -EINVAL;
--
2.41.0.585.gd2178a4bd4-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER
2023-08-03 1:12 [PATCH v3] platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER Tzung-Bi Shih
@ 2023-08-10 0:35 ` Guenter Roeck
2023-08-10 3:20 ` patchwork-bot+chrome-platform
2023-08-11 4:30 ` patchwork-bot+chrome-platform
2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2023-08-10 0:35 UTC (permalink / raw)
To: Tzung-Bi Shih
Cc: bleung, groeck, chrome-platform, guillaume.tucker, denys.f,
ricardo.canuelo, usama.anjum, briannorris
On Thu, Aug 03, 2023 at 09:12:45AM +0800, Tzung-Bi Shih wrote:
> `element->buffer.pointer` should be binary blob. `%s` doesn't work
> perfect for them.
>
> Print hex string for ACPI_TYPE_BUFFER. Also update the documentation
> to reflect this.
>
> Fixes: 0a4cad9c11ad ("platform/chrome: Add ChromeOS ACPI device driver")
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> Changes from v2[1]:
> - Use dev_info_once() instead of dev_info().
> - Update documentation.
> - Add Fixes tag.
>
> Changes from v1[2]:
> - Use hex_dump_to_buffer().
> - Rewrite the loop for catching edge cases for truncating.
>
> [1]: https://patchwork.kernel.org/project/chrome-platform/patch/20230802095736.3079963-1-tzungbi@kernel.org/
> [2]: https://patchwork.kernel.org/project/chrome-platform/patch/20230726073127.2969387-1-tzungbi@kernel.org/
>
> .../ABI/testing/sysfs-driver-chromeos-acpi | 2 +-
> drivers/platform/chrome/chromeos_acpi.c | 31 ++++++++++++++++++-
> 2 files changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/ABI/testing/sysfs-driver-chromeos-acpi b/Documentation/ABI/testing/sysfs-driver-chromeos-acpi
> index c308926e1568..7c8e129fc100 100644
> --- a/Documentation/ABI/testing/sysfs-driver-chromeos-acpi
> +++ b/Documentation/ABI/testing/sysfs-driver-chromeos-acpi
> @@ -134,4 +134,4 @@ KernelVersion: 5.19
> Description:
> Returns the verified boot data block shared between the
> firmware verification step and the kernel verification step
> - (binary).
> + (hex dump).
> diff --git a/drivers/platform/chrome/chromeos_acpi.c b/drivers/platform/chrome/chromeos_acpi.c
> index 50d8a4d4352d..1312aaaa8750 100644
> --- a/drivers/platform/chrome/chromeos_acpi.c
> +++ b/drivers/platform/chrome/chromeos_acpi.c
> @@ -90,7 +90,36 @@ static int chromeos_acpi_handle_package(struct device *dev, union acpi_object *o
> case ACPI_TYPE_STRING:
> return sysfs_emit(buf, "%s\n", element->string.pointer);
> case ACPI_TYPE_BUFFER:
> - return sysfs_emit(buf, "%s\n", element->buffer.pointer);
> + {
> + int i, r, at, room_left;
> + const int byte_per_line = 16;
> +
> + at = 0;
> + room_left = PAGE_SIZE - 1;
> + for (i = 0; i < element->buffer.length && room_left; i += byte_per_line) {
> + r = hex_dump_to_buffer(element->buffer.pointer + i,
> + element->buffer.length - i,
> + byte_per_line, 1, buf + at, room_left,
> + false);
> + if (r > room_left)
> + goto truncating;
> + at += r;
> + room_left -= r;
> +
> + r = sysfs_emit_at(buf, at, "\n");
> + if (!r)
> + goto truncating;
> + at += r;
> + room_left -= r;
> + }
> +
> + buf[at] = 0;
> + return at;
> +truncating:
> + dev_info_once(dev, "truncating sysfs content for %s\n", name);
> + sysfs_emit_at(buf, PAGE_SIZE - 4, "..\n");
> + return PAGE_SIZE - 1;
> + }
> default:
> dev_err(dev, "element type %d not supported\n", element->type);
> return -EINVAL;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER
2023-08-03 1:12 [PATCH v3] platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER Tzung-Bi Shih
2023-08-10 0:35 ` Guenter Roeck
@ 2023-08-10 3:20 ` patchwork-bot+chrome-platform
2023-08-11 4:30 ` patchwork-bot+chrome-platform
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+chrome-platform @ 2023-08-10 3:20 UTC (permalink / raw)
To: Tzung-Bi Shih
Cc: bleung, groeck, chrome-platform, guillaume.tucker, denys.f,
ricardo.canuelo, usama.anjum, briannorris
Hello:
This patch was applied to chrome-platform/linux.git (for-kernelci)
by Tzung-Bi Shih <tzungbi@kernel.org>:
On Thu, 3 Aug 2023 09:12:45 +0800 you wrote:
> `element->buffer.pointer` should be binary blob. `%s` doesn't work
> perfect for them.
>
> Print hex string for ACPI_TYPE_BUFFER. Also update the documentation
> to reflect this.
>
> Fixes: 0a4cad9c11ad ("platform/chrome: Add ChromeOS ACPI device driver")
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
>
> [...]
Here is the summary with links:
- [v3] platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER
https://git.kernel.org/chrome-platform/c/0820debb7d48
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER
2023-08-03 1:12 [PATCH v3] platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER Tzung-Bi Shih
2023-08-10 0:35 ` Guenter Roeck
2023-08-10 3:20 ` patchwork-bot+chrome-platform
@ 2023-08-11 4:30 ` patchwork-bot+chrome-platform
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+chrome-platform @ 2023-08-11 4:30 UTC (permalink / raw)
To: Tzung-Bi Shih
Cc: bleung, groeck, chrome-platform, guillaume.tucker, denys.f,
ricardo.canuelo, usama.anjum, briannorris
Hello:
This patch was applied to chrome-platform/linux.git (for-next)
by Tzung-Bi Shih <tzungbi@kernel.org>:
On Thu, 3 Aug 2023 09:12:45 +0800 you wrote:
> `element->buffer.pointer` should be binary blob. `%s` doesn't work
> perfect for them.
>
> Print hex string for ACPI_TYPE_BUFFER. Also update the documentation
> to reflect this.
>
> Fixes: 0a4cad9c11ad ("platform/chrome: Add ChromeOS ACPI device driver")
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
>
> [...]
Here is the summary with links:
- [v3] platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER
https://git.kernel.org/chrome-platform/c/0820debb7d48
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-11 4:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03 1:12 [PATCH v3] platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER Tzung-Bi Shih
2023-08-10 0:35 ` Guenter Roeck
2023-08-10 3:20 ` patchwork-bot+chrome-platform
2023-08-11 4:30 ` patchwork-bot+chrome-platform
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox