linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Len Brown <lenb@kernel.org>
To: srinivas pandruvada <srinivas.pandruvada@intel.com>
Cc: linux-acpi@vger.kernel.org
Subject: Re: [PATCH] ACPI Battery: Added capacity
Date: Fri, 06 Apr 2012 21:28:44 -0400	[thread overview]
Message-ID: <4F7F984C.5010907@kernel.org> (raw)
In-Reply-To: <1333672734-10536-1-git-send-email-srinivas.pandruvada@intel.com>

Can't this be computed in user-space?

-L

On 04/05/2012 08:38 PM, srinivas pandruvada wrote:

> Added Capacity field, which is a pre-defined power_supply
> property. Calculating capacity using current charge/energy and
> full charge/energy.
> Some user mode implementations are relying on capacity field to
> show battery strength and power down decision.
> 
> Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
> ---
>  drivers/acpi/battery.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index fcc13ac..997b369 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -251,6 +251,13 @@ static int acpi_battery_get_property(struct power_supply *psy,
>  		else
>  			val->intval = battery->capacity_now * 1000;
>  		break;
> +	case POWER_SUPPLY_PROP_CAPACITY:
> +		if (battery->capacity_now && battery->full_charge_capacity)
> +			val->intval = battery->capacity_now * 100/
> +					battery->full_charge_capacity;
> +		else
> +			val->intval = 0;
> +		break;
>  	case POWER_SUPPLY_PROP_MODEL_NAME:
>  		val->strval = battery->model_number;
>  		break;
> @@ -277,6 +284,7 @@ static enum power_supply_property charge_battery_props[] = {
>  	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
>  	POWER_SUPPLY_PROP_CHARGE_FULL,
>  	POWER_SUPPLY_PROP_CHARGE_NOW,
> +	POWER_SUPPLY_PROP_CAPACITY,
>  	POWER_SUPPLY_PROP_MODEL_NAME,
>  	POWER_SUPPLY_PROP_MANUFACTURER,
>  	POWER_SUPPLY_PROP_SERIAL_NUMBER,
> @@ -293,6 +301,7 @@ static enum power_supply_property energy_battery_props[] = {
>  	POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
>  	POWER_SUPPLY_PROP_ENERGY_FULL,
>  	POWER_SUPPLY_PROP_ENERGY_NOW,
> +	POWER_SUPPLY_PROP_CAPACITY,
>  	POWER_SUPPLY_PROP_MODEL_NAME,
>  	POWER_SUPPLY_PROP_MANUFACTURER,
>  	POWER_SUPPLY_PROP_SERIAL_NUMBER,



  reply	other threads:[~2012-04-07  1:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-06  0:38 [PATCH] ACPI Battery: Added capacity srinivas pandruvada
2012-04-07  1:28 ` Len Brown [this message]
2012-04-09 14:59   ` Pandruvada, Srinivas
2012-06-01 23:00     ` Len Brown

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=4F7F984C.5010907@kernel.org \
    --to=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=srinivas.pandruvada@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;
as well as URLs for NNTP newsgroup(s).