From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Pooja Katiyar <pooja.katiyar@intel.com>
Cc: linux-usb@vger.kernel.org, gregkh@linuxfoundation.org,
dmitry.baryshkov@oss.qualcomm.com
Subject: Re: [PATCH v4 3/4] usb: typec: ucsi: Enable debugfs for message_out data structure
Date: Mon, 15 Sep 2025 15:20:57 +0300 [thread overview]
Message-ID: <aMgEqYsdQhzK_QZI@kuha.fi.intel.com> (raw)
In-Reply-To: <1746700c747e0be20af39abb0fe8d4f4dd54262a.1757374784.git.pooja.katiyar@intel.com>
On Tue, Sep 09, 2025 at 06:52:06PM -0700, Pooja Katiyar wrote:
> Add debugfs entry for writing message_out data structure to handle
> UCSI 2.1 and 3.0 commands through debugfs interface.
>
> Users writing to the message_out debugfs file should ensure the input
> data adheres to the following format:
> 1. Input must be a non-empty valid hexadecimal string.
> 2. Input length of hexadecimal string must not exceed 256 bytes of
> length to be in alignment with the message out data structure size
> as per the UCSI specification v2.1.
> 3. If the input string length is odd, then user needs to prepend a
> '0' to the first character for proper hex conversion.
>
> Below are examples of valid hex strings. Note that these values are
> just examples. The exact values depend on specific command use case.
>
> #echo 1A2B3C4D > message_out
> #echo 01234567 > message_out
>
> Signed-off-by: Pooja Katiyar <pooja.katiyar@intel.com>
> ---
> Changelog v4:
> - Fixed build errors reported by kernel test robot.
> - Added changelogs.
Ah, you just copied the same changelog to all patches. You could just
put the log to the cover letter in that case IMO.
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Changelog v3:
> - Updated debugfs message_out write handler to use message_out fields in
> UCSI structure.
>
> Changelog v2:
> - No changes.
>
> drivers/usb/typec/ucsi/debugfs.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/drivers/usb/typec/ucsi/debugfs.c b/drivers/usb/typec/ucsi/debugfs.c
> index 4bf3a8f65a4e..0693acf04c37 100644
> --- a/drivers/usb/typec/ucsi/debugfs.c
> +++ b/drivers/usb/typec/ucsi/debugfs.c
> @@ -109,6 +109,30 @@ static int ucsi_vbus_volt_show(struct seq_file *m, void *v)
> }
> DEFINE_SHOW_ATTRIBUTE(ucsi_vbus_volt);
>
> +static ssize_t ucsi_message_out_write(struct file *file,
> + const char __user *data, size_t count, loff_t *ppos)
> +{
> + struct ucsi *ucsi = file->private_data;
> + int ret;
> +
> + char *buf __free(kfree) = memdup_user_nul(data, count);
> + if (IS_ERR(buf))
> + return PTR_ERR(buf);
> +
> + ucsi->message_out_size = min(count / 2, UCSI_MAX_MESSAGE_OUT_LENGTH);
> + ret = hex2bin(ucsi->message_out, buf, ucsi->message_out_size);
> + if (ret)
> + return ret;
> +
> + return count;
> +}
> +
> +static const struct file_operations ucsi_message_out_fops = {
> + .open = simple_open,
> + .write = ucsi_message_out_write,
> + .llseek = generic_file_llseek,
> +};
> +
> void ucsi_debugfs_register(struct ucsi *ucsi)
> {
> ucsi->debugfs = kzalloc(sizeof(*ucsi->debugfs), GFP_KERNEL);
> @@ -121,6 +145,8 @@ void ucsi_debugfs_register(struct ucsi *ucsi)
> debugfs_create_file("peak_current", 0400, ucsi->debugfs->dentry, ucsi, &ucsi_peak_curr_fops);
> debugfs_create_file("avg_current", 0400, ucsi->debugfs->dentry, ucsi, &ucsi_avg_curr_fops);
> debugfs_create_file("vbus_voltage", 0400, ucsi->debugfs->dentry, ucsi, &ucsi_vbus_volt_fops);
> + debugfs_create_file("message_out", 0200, ucsi->debugfs->dentry, ucsi,
> + &ucsi_message_out_fops);
> }
>
> void ucsi_debugfs_unregister(struct ucsi *ucsi)
> --
> 2.43.0
--
heikki
next prev parent reply other threads:[~2025-09-15 12:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-10 1:52 [PATCH v4 0/4] usb: typec: ucsi: Add support for SET_PDOS command Pooja Katiyar
2025-09-10 1:52 ` [PATCH v4 1/4] usb: typec: ucsi: Update UCSI structure to have message in and message out fields Pooja Katiyar
2025-09-15 12:16 ` Heikki Krogerus
2025-09-10 1:52 ` [PATCH v4 2/4] usb: typec: ucsi: Add support for message out data structure Pooja Katiyar
2025-09-15 12:18 ` Heikki Krogerus
2025-09-10 1:52 ` [PATCH v4 3/4] usb: typec: ucsi: Enable debugfs for message_out " Pooja Katiyar
2025-09-15 12:20 ` Heikki Krogerus [this message]
2025-09-10 1:52 ` [PATCH v4 4/4] usb: typec: ucsi: Add support for SET_PDOS command Pooja Katiyar
2025-09-15 12:21 ` Heikki Krogerus
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=aMgEqYsdQhzK_QZI@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=pooja.katiyar@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox