Skip to content

Commit 0820deb

Browse files
author
Tzung-Bi Shih
committed
platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER
`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: 0a4cad9 ("platform/chrome: Add ChromeOS ACPI device driver") Cc: stable@vger.kernel.org Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20230803011245.3773756-1-tzungbi@kernel.org Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
1 parent 703e771 commit 0820deb

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

Documentation/ABI/testing/sysfs-driver-chromeos-acpi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,4 @@ KernelVersion: 5.19
149149
Description:
150150
Returns the verified boot data block shared between the
151151
firmware verification step and the kernel verification step
152-
(binary).
152+
(hex dump).

drivers/platform/chrome/chromeos_acpi.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,36 @@ static int chromeos_acpi_handle_package(struct device *dev, union acpi_object *o
9090
case ACPI_TYPE_STRING:
9191
return sysfs_emit(buf, "%s\n", element->string.pointer);
9292
case ACPI_TYPE_BUFFER:
93-
return sysfs_emit(buf, "%s\n", element->buffer.pointer);
93+
{
94+
int i, r, at, room_left;
95+
const int byte_per_line = 16;
96+
97+
at = 0;
98+
room_left = PAGE_SIZE - 1;
99+
for (i = 0; i < element->buffer.length && room_left; i += byte_per_line) {
100+
r = hex_dump_to_buffer(element->buffer.pointer + i,
101+
element->buffer.length - i,
102+
byte_per_line, 1, buf + at, room_left,
103+
false);
104+
if (r > room_left)
105+
goto truncating;
106+
at += r;
107+
room_left -= r;
108+
109+
r = sysfs_emit_at(buf, at, "\n");
110+
if (!r)
111+
goto truncating;
112+
at += r;
113+
room_left -= r;
114+
}
115+
116+
buf[at] = 0;
117+
return at;
118+
truncating:
119+
dev_info_once(dev, "truncating sysfs content for %s\n", name);
120+
sysfs_emit_at(buf, PAGE_SIZE - 4, "..\n");
121+
return PAGE_SIZE - 1;
122+
}
94123
default:
95124
dev_err(dev, "element type %d not supported\n", element->type);
96125
return -EINVAL;

0 commit comments

Comments
 (0)