diff options
author | Tzung-Bi Shih <tzungbi@kernel.org> | 2023-08-03 09:12:45 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-09-13 09:43:03 +0200 |
commit | a3f6c1447db81028dfa9d01efed5faa30c367547 (patch) | |
tree | 06bda555a11f0b3d9042dac983555f092bf80c5f /drivers | |
parent | e6e6a5f50f58fadec397b23064b7e4830292863d (diff) | |
download | linux-stable-a3f6c1447db81028dfa9d01efed5faa30c367547.tar.gz linux-stable-a3f6c1447db81028dfa9d01efed5faa30c367547.tar.bz2 linux-stable-a3f6c1447db81028dfa9d01efed5faa30c367547.zip |
platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER
commit 0820debb7d489e9eb1f68b7bb69e6ae210699b3f upstream.
`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")
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/platform/chrome/chromeos_acpi.c | 31 |
1 files changed, 30 insertions, 1 deletions
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; |