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]
Date: Tue, 4 Jun 2024 14:02:02 +0200
From: Armin Wolf <W_Armin@....de>
To: sre@...nel.org
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] power: supply: hwmon: Add support for power sensors

Am 29.05.24 um 00:21 schrieb Armin Wolf:

> Currently, more than seven power supply drivers are supporting
> POWER_SUPPLY_PROP_POWER_NOW, but their power readings are not being
> reported through the hwmon subsystem.
>
> Fix this by adding support for power sensors to the power supply
> hwmon integration.

Hi, what is the status of this patch? Are there any obvious errors which
need to be fixed?

Thanks,
Armin Wolf

> Signed-off-by: Armin Wolf <W_Armin@....de>
> ---
>   drivers/power/supply/power_supply_hwmon.c | 25 +++++++++++++++++++++++
>   1 file changed, 25 insertions(+)
>
> diff --git a/drivers/power/supply/power_supply_hwmon.c b/drivers/power/supply/power_supply_hwmon.c
> index c97893d4c25e..baacefbdf768 100644
> --- a/drivers/power/supply/power_supply_hwmon.c
> +++ b/drivers/power/supply/power_supply_hwmon.c
> @@ -48,6 +48,18 @@ static int power_supply_hwmon_curr_to_property(u32 attr)
>   	}
>   }
>
> +static int power_supply_hwmon_power_to_property(u32 attr)
> +{
> +	switch (attr) {
> +	case hwmon_power_input:
> +		return POWER_SUPPLY_PROP_POWER_NOW;
> +	case hwmon_power_average:
> +		return POWER_SUPPLY_PROP_POWER_AVG;
> +	default:
> +		return -EINVAL;
> +	}
> +}
> +
>   static int power_supply_hwmon_temp_to_property(u32 attr, int channel)
>   {
>   	if (channel) {
> @@ -90,6 +102,8 @@ power_supply_hwmon_to_property(enum hwmon_sensor_types type,
>   		return power_supply_hwmon_in_to_property(attr);
>   	case hwmon_curr:
>   		return power_supply_hwmon_curr_to_property(attr);
> +	case hwmon_power:
> +		return power_supply_hwmon_power_to_property(attr);
>   	case hwmon_temp:
>   		return power_supply_hwmon_temp_to_property(attr, channel);
>   	default:
> @@ -229,6 +243,11 @@ power_supply_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
>   	case hwmon_in:
>   		pspval.intval = DIV_ROUND_CLOSEST(pspval.intval, 1000);
>   		break;
> +	case hwmon_power:
> +		/*
> +		 * Power properties are already in microwatts.
> +		 */
> +		break;
>   	/*
>   	 * Temp needs to be converted from 1/10 C to milli-C
>   	 */
> @@ -311,6 +330,10 @@ static const struct hwmon_channel_info * const power_supply_hwmon_info[] = {
>   			   HWMON_C_MAX     |
>   			   HWMON_C_INPUT),
>
> +	HWMON_CHANNEL_INFO(power,
> +			   HWMON_P_INPUT |
> +			   HWMON_P_AVERAGE),
> +
>   	HWMON_CHANNEL_INFO(in,
>   			   HWMON_I_AVERAGE |
>   			   HWMON_I_MIN     |
> @@ -359,6 +382,8 @@ int power_supply_add_hwmon_sysfs(struct power_supply *psy)
>   		case POWER_SUPPLY_PROP_CURRENT_AVG:
>   		case POWER_SUPPLY_PROP_CURRENT_MAX:
>   		case POWER_SUPPLY_PROP_CURRENT_NOW:
> +		case POWER_SUPPLY_PROP_POWER_AVG:
> +		case POWER_SUPPLY_PROP_POWER_NOW:
>   		case POWER_SUPPLY_PROP_TEMP:
>   		case POWER_SUPPLY_PROP_TEMP_MAX:
>   		case POWER_SUPPLY_PROP_TEMP_MIN:
> --
> 2.39.2
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ