lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <df28b348-28c4-a1ef-1d7e-46a60911ebc4@roeck-us.net>
Date:   Fri, 16 Jun 2023 01:36:54 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Frank Wang <frank.wang@...k-chips.com>,
        heikki.krogerus@...ux.intel.com, gregkh@...uxfoundation.org,
        sebastian.reichel@...labora.com, heiko@...ech.de
Cc:     linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-rockchip@...ts.infradead.org, huangtao@...k-chips.com,
        william.wu@...k-chips.com, jianwei.zheng@...k-chips.com,
        yubing.zhang@...k-chips.com, wmc@...k-chips.com
Subject: Re: [v4,2/2] usb: typec: tcpm: add get max power support

On 6/16/23 00:52, Frank Wang wrote:
> Traverse fixed pdos to calculate the maximum power that the charger
> can provide, and it can be get by POWER_SUPPLY_PROP_INPUT_POWER_LIMIT
> property.
> 
> Signed-off-by: Frank Wang <frank.wang@...k-chips.com>

Reviewed-by: Guenter Roeck <linux@...ck-us.net>

> ---
> Changelog:
> v4:
>   - No change
> 
> v3:
>   - Use Microwatts instead of Milliwatts to follow the ABI, commented by Sebastian Reichel.
> 
> v2:
>   - No change
> 
> v1:
>   - https://patchwork.kernel.org/project/linux-usb/patch/20230313025843.17162-4-frank.wang@rock-chips.com/
> 
>   drivers/usb/typec/tcpm/tcpm.c | 24 ++++++++++++++++++++++++
>   1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 9f6aaa3e70ca8..829d75ebab422 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -6340,6 +6340,27 @@ static int tcpm_psy_get_current_now(struct tcpm_port *port,
>   	return 0;
>   }
>   
> +static int tcpm_psy_get_input_power_limit(struct tcpm_port *port,
> +					  union power_supply_propval *val)
> +{
> +	unsigned int src_mv, src_ma, max_src_uw = 0;
> +	unsigned int i, tmp;
> +
> +	for (i = 0; i < port->nr_source_caps; i++) {
> +		u32 pdo = port->source_caps[i];
> +
> +		if (pdo_type(pdo) == PDO_TYPE_FIXED) {
> +			src_mv = pdo_fixed_voltage(pdo);
> +			src_ma = pdo_max_current(pdo);
> +			tmp = src_mv * src_ma;
> +			max_src_uw = tmp > max_src_uw ? tmp : max_src_uw;
> +		}
> +	}
> +
> +	val->intval = max_src_uw;
> +	return 0;
> +}
> +
>   static int tcpm_psy_get_prop(struct power_supply *psy,
>   			     enum power_supply_property psp,
>   			     union power_supply_propval *val)
> @@ -6369,6 +6390,9 @@ static int tcpm_psy_get_prop(struct power_supply *psy,
>   	case POWER_SUPPLY_PROP_CURRENT_NOW:
>   		ret = tcpm_psy_get_current_now(port, val);
>   		break;
> +	case POWER_SUPPLY_PROP_INPUT_POWER_LIMIT:
> +		tcpm_psy_get_input_power_limit(port, val);
> +		break;
>   	default:
>   		ret = -EINVAL;
>   		break;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ