public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power: supply: max17042_battery: Add support for the TTE_NOW prop
@ 2020-03-30  5:33 Geordan Neukum
  2020-04-29 18:28 ` Sebastian Reichel
  0 siblings, 1 reply; 2+ messages in thread
From: Geordan Neukum @ 2020-03-30  5:33 UTC (permalink / raw)
  To: Sebastian Reichel, linux-pm, linux-kernel; +Cc: gneukum1

The max170{42,47,50,55} family of fuel gauges all provide time-to-empty
estimation. As such, let's export this as a property.

Signed-off-by: Geordan Neukum <gneukum1@gmail.com>
---
 drivers/power/supply/max17042_battery.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 69ec4295d55d..f284547913d6 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -87,6 +87,7 @@ static enum power_supply_property max17042_battery_props[] = {
 	POWER_SUPPLY_PROP_SCOPE,
 	POWER_SUPPLY_PROP_CURRENT_NOW,
 	POWER_SUPPLY_PROP_CURRENT_AVG,
+	POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
 };

 static int max17042_get_temperature(struct max17042_chip *chip, int *temp)
@@ -411,6 +412,13 @@ static int max17042_get_property(struct power_supply *psy,
 			return -EINVAL;
 		}
 		break;
+	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
+		ret = regmap_read(map, MAX17042_TTE, &data);
+		if (ret < 0)
+			return ret;
+
+		val->intval = data * 5625 / 1000;
+		break;
 	default:
 		return -EINVAL;
 	}
--
2.18.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] power: supply: max17042_battery: Add support for the TTE_NOW prop
  2020-03-30  5:33 [PATCH] power: supply: max17042_battery: Add support for the TTE_NOW prop Geordan Neukum
@ 2020-04-29 18:28 ` Sebastian Reichel
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2020-04-29 18:28 UTC (permalink / raw)
  To: Geordan Neukum; +Cc: linux-pm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1344 bytes --]

Hi,

On Mon, Mar 30, 2020 at 01:33:55AM -0400, Geordan Neukum wrote:
> The max170{42,47,50,55} family of fuel gauges all provide time-to-empty
> estimation. As such, let's export this as a property.
> 
> Signed-off-by: Geordan Neukum <gneukum1@gmail.com>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/max17042_battery.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
> index 69ec4295d55d..f284547913d6 100644
> --- a/drivers/power/supply/max17042_battery.c
> +++ b/drivers/power/supply/max17042_battery.c
> @@ -87,6 +87,7 @@ static enum power_supply_property max17042_battery_props[] = {
>  	POWER_SUPPLY_PROP_SCOPE,
>  	POWER_SUPPLY_PROP_CURRENT_NOW,
>  	POWER_SUPPLY_PROP_CURRENT_AVG,
> +	POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
>  };
> 
>  static int max17042_get_temperature(struct max17042_chip *chip, int *temp)
> @@ -411,6 +412,13 @@ static int max17042_get_property(struct power_supply *psy,
>  			return -EINVAL;
>  		}
>  		break;
> +	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
> +		ret = regmap_read(map, MAX17042_TTE, &data);
> +		if (ret < 0)
> +			return ret;
> +
> +		val->intval = data * 5625 / 1000;
> +		break;
>  	default:
>  		return -EINVAL;
>  	}
> --
> 2.18.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-29 18:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-30  5:33 [PATCH] power: supply: max17042_battery: Add support for the TTE_NOW prop Geordan Neukum
2020-04-29 18:28 ` Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox