mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Armin Wolf <W_Armin@gmx.de>
To: sre@kernel.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] power: supply: hwmon: Add support for power sensors
Date: Tue, 4 Jun 2024 14:02:02 +0200	[thread overview]
Message-ID: <dbb9dfe5-8812-482a-b384-8e86e0a8eb8f@gmx.de> (raw)
In-Reply-To: <20240528222115.791511-1-W_Armin@gmx.de>

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@gmx.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
>
>

  reply	other threads:[~2024-06-04 12:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-28 22:21 Armin Wolf
2024-06-04 12:02 ` Armin Wolf [this message]
2024-06-05 21:38 ` Sebastian Reichel

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=dbb9dfe5-8812-482a-b384-8e86e0a8eb8f@gmx.de \
    --to=w_armin@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@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

all inboxes | Powered by JetHome®