All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@kernel.org>
To: bleung@chromium.org, groeck@chromium.org
Cc: chrome-platform@lists.linux.dev, guillaume.tucker@collabora.com,
	denys.f@collabora.com, ricardo.canuelo@collabora.com,
	usama.anjum@collabora.com
Subject: Re: [PATCH] platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER
Date: Tue, 1 Aug 2023 11:32:40 +0800	[thread overview]
Message-ID: <ZMh82LaanrHh+33t@google.com> (raw)
In-Reply-To: <20230726073127.2969387-1-tzungbi@kernel.org>

On Wed, Jul 26, 2023 at 03:31:27PM +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.
> 
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>

Curious about does this patch make sense to folks on the mailing list?

> ---
>  drivers/platform/chrome/chromeos_acpi.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/chrome/chromeos_acpi.c b/drivers/platform/chrome/chromeos_acpi.c
> index 50d8a4d4352d..a60d344c54e4 100644
> --- a/drivers/platform/chrome/chromeos_acpi.c
> +++ b/drivers/platform/chrome/chromeos_acpi.c
> @@ -90,7 +90,25 @@ 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, n;
> +			const int char_per_line = 16;
> +
> +			for (i = 0, n = 0; i < element->buffer.length; ++i) {
> +				n += sysfs_emit_at(buf, n, " %2.2x", element->buffer.pointer[i]);
> +
> +				if (((i + 1) % char_per_line) == 0)
> +					n += sysfs_emit_at(buf, n, "\n");
> +			}
> +			n += sysfs_emit_at(buf, n, "\n");
> +
> +			if (n == PAGE_SIZE - 1) {
> +				dev_info(dev, "truncating sysfs content for %s\n", name);
> +				sysfs_emit_at(buf, n - 3, "..\n");
> +			}
> +
> +			return n;
> +		}
>  	default:
>  		dev_err(dev, "element type %d not supported\n", element->type);
>  		return -EINVAL;
> -- 
> 2.41.0.487.g6d72f3e995-goog
> 

  reply	other threads:[~2023-08-01  3:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-26  7:31 [PATCH] platform/chrome: chromeos_acpi: print hex string for ACPI_TYPE_BUFFER Tzung-Bi Shih
2023-08-01  3:32 ` Tzung-Bi Shih [this message]
2023-08-01 21:53   ` Brian Norris
2023-08-02 10:06     ` Tzung-Bi Shih
2023-08-02 18:59       ` Brian Norris
2023-08-03  1:18         ` Tzung-Bi Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZMh82LaanrHh+33t@google.com \
    --to=tzungbi@kernel.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=denys.f@collabora.com \
    --cc=groeck@chromium.org \
    --cc=guillaume.tucker@collabora.com \
    --cc=ricardo.canuelo@collabora.com \
    --cc=usama.anjum@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.