From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Mark Pearson <mpearson-lenovo@squebb.ca>
Cc: Hans de Goede <hansg@kernel.org>,
platform-driver-x86@vger.kernel.org,
ibm-acpi-devel@lists.sourceforge.net,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] platform/x86: thinkpad_acpi: Add sysfs to display HWDD raw
Date: Tue, 28 Apr 2026 16:00:31 +0300 (EEST) [thread overview]
Message-ID: <75ad46f0-2c1f-9831-eff6-92df477f7db8@linux.intel.com> (raw)
In-Reply-To: <20260428125327.1196296-1-mpearson-lenovo@squebb.ca>
On Tue, 28 Apr 2026, Mark Pearson wrote:
> The Lenovo diagnostics and support team have requested a mechanism
> to get the raw data from the HWDD commands to support customer debug
> situations.
>
> Add a sysfs entry to display the raw data.
>
> As it shouldn't be needed in normal operation, add a hwdd_raw_enable
> module parameter for when it is needed
Wouldn't debugfs be more appropriate for things like this? By using it,
you can avoid adding the module parameter as well.
--
i.
> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> ---
> drivers/platform/x86/lenovo/thinkpad_acpi.c | 31 +++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> index e1cee42a1683..299cc4022e96 100644
> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> @@ -406,6 +406,7 @@ static enum {
>
> static int experimental;
> static u32 dbg_level;
> +static bool hwdd_raw_enable;
>
> static struct workqueue_struct *tpacpi_wq;
>
> @@ -11217,18 +11218,44 @@ static ssize_t hwdd_status_show(struct device *dev,
>
> return sysfs_emit(buf, "0\n");
> }
> +
> +/* sysfs type-c damage detection raw data */
> +static ssize_t hwdd_raw_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + unsigned int damage_status;
> + int err;
> +
> + if (!ucdd_supported)
> + return -ENODEV;
> +
> + /* Get USB TYPE-C damage status */
> + err = hwdd_command(HWDD_GET_DMG_USBC, &damage_status);
> + if (err)
> + return err;
> +
> + return sysfs_emit(buf, "0x%x\n", damage_status);
> +}
> +
> +static DEVICE_ATTR_RO(hwdd_raw);
> static DEVICE_ATTR_RO(hwdd_status);
> static DEVICE_ATTR_RO(hwdd_detail);
>
> static struct attribute *hwdd_attributes[] = {
> &dev_attr_hwdd_status.attr,
> &dev_attr_hwdd_detail.attr,
> + &dev_attr_hwdd_raw.attr,
> NULL
> };
>
> static umode_t hwdd_attr_is_visible(struct kobject *kobj,
> struct attribute *attr, int n)
> {
> + /* Only display hwdd_raw if debug option has been set */
> + if (attr == &dev_attr_hwdd_raw.attr && !hwdd_raw_enable)
> + return 0;
> +
> return hwdd_support_available ? attr->mode : 0;
> }
>
> @@ -11956,6 +11983,10 @@ static int __init set_ibm_param(const char *val, const struct kernel_param *kp)
> return -EINVAL;
> }
>
> +module_param(hwdd_raw_enable, bool, 0444);
> +MODULE_PARM_DESC(hwdd_raw_enable,
> + "Enables hwdd raw output sysfs interface");
> +
> module_param(experimental, int, 0444);
> MODULE_PARM_DESC(experimental,
> "Enables experimental features when non-zero");
>
next prev parent reply other threads:[~2026-04-28 13:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 12:53 [PATCH] platform/x86: thinkpad_acpi: Add sysfs to display HWDD raw Mark Pearson
2026-04-28 13:00 ` Ilpo Järvinen [this message]
2026-04-28 13:15 ` Mark Pearson
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=75ad46f0-2c1f-9831-eff6-92df477f7db8@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=hansg@kernel.org \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mpearson-lenovo@squebb.ca \
--cc=platform-driver-x86@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox