platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER
Subsystems (2)
Tzung-Bi Shih
maintainerPATCH v2 1/1 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.
---
Changes from v1[1]:
- Use hex_dump_to_buffer().
- Rewrite the loop for catching edge cases for truncating.
[1]: https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/
drivers/platform/chrome/chromeos_acpi.c | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
drivers/platform/chrome/chromeos_acpi.c +30 -1
@@ -90,7 +90,36 @@ static int chromeos_acpi_handle_package(struct device *dev, union acpi_object *ocase 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 (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 ;
Signature · 1 line
2.41.0.585.gd2178a4bd4-goog
Quoted 6 lines · Tzung-Bi Shih
element->buffer.pointershould be binary blob.%sdoesn't work perfect for them.Print hex string for
ACPI_TYPE_BUFFER.Signed-off-by Tzung-Bi Shih <[email protected]>
Please add fixes tag and CC stable as well ([email protected]) in next revision.
Quoted 52 lines
---
Changes from v1[1]:
- Usehex_dump_to_buffer().
- Rewrite the loop for catching edge cases for truncating.[1]: https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/
drivers/platform/chrome/chromeos_acpi.c | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)drivers/platform/chrome/chromeos_acpi.c +30
-1@@ -90,7 +90,36 @@ static int chromeos_acpi_handle_package(struct device *dev, union acpi_object *ocase 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 (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 ;
Signature · 2 lines
BR, Muhammad Usama Anjum
Tzung-Bi Shih
maintainerQuoted 11 lines · Muhammad Usama Anjum
Quoted 6 lines · Tzung-Bi Shih
element->buffer.pointershould be binary blob.%sdoesn't work perfect for them.Print hex string for
ACPI_TYPE_BUFFER.Signed-off-by Tzung-Bi Shih <[email protected]>Please add fixes tag and CC stable as well ([email protected]) in next revision.
Fixes 0a4cad9c11ad ("platform/chrome: Add ChromeOS ACPI device driver")
I think a Fixes tag should be sufficient.
Fix in v3 (https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/).
Quoted 7 lines · Tzung-Bi Shih
Quoted 6 lines · Muhammad Usama Anjum
Quoted 5 lines · Tzung-Bi Shih
element->buffer.pointershould be binary blob.%sdoesn't work perfect for them.Print hex string for
ACPI_TYPE_BUFFER.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Tzung-Bi Shih <[email protected]>Please add fixes tag and CC stable as well ([email protected]) in next revision.
Fixes 0a4cad9c11ad ("platform/chrome: Add ChromeOS ACPI device driver")I think a Fixes tag should be sufficient.
Why do you think so? As this is a bug fix which exists in the driver since it was written, if we add fixes tag and probably cc stable as well, the patch will be applied to all LTS kernels which we really want. In this way, the bug would be fixed on all LTS kernels not just the latest kernel.
Quoted 2 lines
Fix in v3 (https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/).
Signature · 2 lines
BR, Muhammad Usama Anjum
Tzung-Bi Shih
maintainerQuoted 12 lines · Muhammad Usama Anjum
Quoted 11 lines · Tzung-Bi Shih
Quoted 10 lines · Muhammad Usama Anjum
Quoted 6 lines · Tzung-Bi Shih
element->buffer.pointershould be binary blob.%sdoesn't work perfect for them.Print hex string for
ACPI_TYPE_BUFFER.Signed-off-by Tzung-Bi Shih <[email protected]>Please add fixes tag and CC stable as well ([email protected]) in next revision.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Fixes 0a4cad9c11ad ("platform/chrome: Add ChromeOS ACPI device driver")I think a Fixes tag should be sufficient.
Why do you think so? As this is a bug fix which exists in the driver since it was written, if we add fixes tag and probably cc stable as well, the patch will be applied to all LTS kernels which we really want. In this way, the bug would be fixed on all LTS kernels not just the latest kernel.
Without the patch, I observed some malfunctions of ChromiumOS userland program crossystem. There is no kernel crashes and the system is bootable. Thus, I think a Fixes tag should be sufficient.
Tzung-Bi Shih
maintainerQuoted 16 lines · Tzung-Bi Shih
Quoted 15 lines · Muhammad Usama Anjum
Quoted 14 lines · Tzung-Bi Shih
Quoted 11 lines · Muhammad Usama Anjum
Quoted 6 lines · Tzung-Bi Shih
element->buffer.pointershould be binary blob.%sdoesn't work perfect for them.Print hex string for
ACPI_TYPE_BUFFER.Signed-off-by Tzung-Bi Shih <[email protected]>Please add fixes tag and CC stable as well ([email protected]) in next revision.
Fixes 0a4cad9c11ad ("platform/chrome: Add ChromeOS ACPI device driver")I think a Fixes tag should be sufficient.
Quoted 8 lines
Quoted 4 lines
Why do you think so? As this is a bug fix which exists in the driver since it was written, if we add fixes tag and probably cc stable as well, the patch will be applied to all LTS kernels which we really want. In this way, the bug would be fixed on all LTS kernels not just the latest kernel.
Without the patch, I observed some malfunctions of ChromiumOS userland program
crossystem. There is no kernel crashes and the system is bootable. Thus, I think a Fixes tag should be sufficient.
Let's cc stable as well.
Quoted 43 lines · Tzung-Bi Shih
element->buffer.pointershould be binary blob.%sdoesn't work perfect for them.Print hex string for
ACPI_TYPE_BUFFER.Signed-off-by Tzung-Bi Shih <[email protected]>---
Changes from v1[1]:
- Usehex_dump_to_buffer().
- Rewrite the loop for catching edge cases for truncating.[1]: https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/
drivers/platform/chrome/chromeos_acpi.c | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)drivers/platform/chrome/chromeos_acpi.c +17
-1@@ -90,7 +90,36 @@ static int chromeos_acpi_handle_package(struct device *dev, union acpi_object *ocase 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" );
drivers/platform/chrome/chromeos_acpi.c static int chromeos_acpi_handle_package(struct device *dev, union acpi_object *o · line 119
Quoted 10 lines
drivers/platform/chrome/chromeos_acpi.c +10
-0+if (!r) + goto truncating; + at += r; + room_left -= r; + } + + buf[at] =0 ; +return at; +truncating: +dev_info (dev,"truncating sysfs content for %s\n" , name);
I really dislike that because it will, if it happens, clog the log (the condition will be permanent). How about using dev_info_once() ?
Thanks,
Guenter
Quoted 9 lines
drivers/platform/chrome/chromeos_acpi.c +3
-1+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
Tzung-Bi Shih
maintainerQuoted 6 lines · Guenter Roeck
drivers/platform/chrome/chromeos_acpi.c static int chromeos_acpi_handle_package(struct device *dev, union acpi_object *o · line 119
Quoted 2 lines · Tzung-Bi Shih
drivers/platform/chrome/chromeos_acpi.c +2
-0+truncating: +dev_info (dev,"truncating sysfs content for %s\n" , name);I really dislike that because it will, if it happens, clog the log (the condition will be permanent). How about using
dev_info_once()?
Fix in v3(https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/).