public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Venkat Jayaraman <venkat.jayaraman@intel.com>
Cc: linux-usb@vger.kernel.org, pse.type-c.linux@intel.com,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>
Subject: Re: [PATCH] usb: typec: ucsi: Add support for READ_POWER_LEVEL command
Date: Mon, 30 Jun 2025 07:04:14 +0200	[thread overview]
Message-ID: <2025063018-stunt-hamstring-0331@gregkh> (raw)
In-Reply-To: <20250630001556.651826-1-venkat.jayaraman@intel.com>

On Sun, Jun 29, 2025 at 05:15:56PM -0700, Venkat Jayaraman wrote:
> @@ -89,6 +117,12 @@ void ucsi_debugfs_register(struct ucsi *ucsi)
>  	ucsi->debugfs->dentry = debugfs_create_dir(dev_name(ucsi->dev), ucsi_debugfs_root);
>  	debugfs_create_file("command", 0200, ucsi->debugfs->dentry, ucsi, &ucsi_cmd_fops);
>  	debugfs_create_file("response", 0400, ucsi->debugfs->dentry, ucsi, &ucsi_resp_fops);
> +	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);

You can have these all on one line, but not a big deal :)

And what are the units of these files?

> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 01ce858a1a2b..8e0f0289a11a 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1218,9 +1218,11 @@ static void ucsi_handle_connector_change(struct work_struct *work)
>  	struct ucsi_connector *con = container_of(work, struct ucsi_connector,
>  						  work);
>  	struct ucsi *ucsi = con->ucsi;
> +	u8  curr_scale, volt_scale;

Odd extra ' '

> +	if (UCSI_CONSTAT(con, PWR_READING_READY_V2_1)) {
> +		curr_scale = UCSI_CONSTAT(con, CURRENT_SCALE_V2_1);
> +		volt_scale = UCSI_CONSTAT(con, VOLTAGE_SCALE_V2_1);
> +
> +		val = UCSI_CONSTAT(con, PEAK_CURRENT_V2_1);
> +		con->peak_current = UCSI_CONSTAT_CURR_SCALE_MULT * curr_scale * val;
> +
> +		val = UCSI_CONSTAT(con, AVG_CURRENT_V2_1);
> +		con->avg_current = UCSI_CONSTAT_CURR_SCALE_MULT * curr_scale * val;
> +
> +		val = UCSI_CONSTAT(con, VBUS_VOLTAGE_V2_1);
> +		con->vbus_voltage = UCSI_CONSTAT_VOLT_SCALE_MULT * volt_scale * val;

These will never overflow, right?

thanks,

greg k-h

  reply	other threads:[~2025-06-30  5:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-30  0:15 [PATCH] usb: typec: ucsi: Add support for READ_POWER_LEVEL command Venkat Jayaraman
2025-06-30  5:04 ` Greg KH [this message]
2025-06-30  5:04   ` Greg KH
2025-07-02 18:25   ` Jayaraman, Venkat

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=2025063018-stunt-hamstring-0331@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=pse.type-c.linux@intel.com \
    --cc=venkat.jayaraman@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