public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <me@felipebalbi.com>
To: Felipe Balbi <me@felipebalbi.com>
Cc: dwmw2@infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [rfc/patch 12/15] power: bq27200: add power property
Date: Sun, 12 Jul 2009 23:11:46 +0300	[thread overview]
Message-ID: <20090712201145.GA11865@gandalf> (raw)
In-Reply-To: <1247422177-7329-12-git-send-email-me@felipebalbi.com>

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

Hi,

On Sun, Jul 12, 2009 at 09:09:34PM +0300, Felipe Balbi wrote:
> @@ -190,6 +205,8 @@ static int bq27200_get_property(struct power_supply *psy,
>  	case POWER_SUPPLY_PROP_TEMP:
>  		val->intval = bq27200_temperature(bq);
>  		break;
> +	case POWER_SUPPLY_PROP_POWER_AVG:
> +		val->intval = bq27200_power(bq);

missing break here. Updated patch attached.

-- 
balbi

[-- Attachment #2: 0012-power-bq27200-add-power-property.diff --]
[-- Type: text/x-diff, Size: 1929 bytes --]

From c28459cbfa2dcdbb0c3f6ea7f662fb4f9a582ede Mon Sep 17 00:00:00 2001
From: Felipe Balbi <me@felipebalbi.com>
Date: Wed, 8 Jul 2009 13:33:38 +0300
Subject: [PATCH 12/15] power: bq27200: add power property

report power average to userland.

Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
 drivers/power/bq27200_battery.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/power/bq27200_battery.c b/drivers/power/bq27200_battery.c
index 658c2c5..1b08f39 100644
--- a/drivers/power/bq27200_battery.c
+++ b/drivers/power/bq27200_battery.c
@@ -54,6 +54,7 @@
 
 #define BQ27200_SENSING_RESISTOR	(20)	/* 20 mOhms */
 #define BQ27200_CURRENT_CONSTANT	(256 * 3570 / 1000) /* 256 * 3.57 uV */
+#define BQ27200_POWER_CONSTANT		(256 * 29200 / 1000) /* 256 * 29.2 uVVh */
 
 struct bq27200 {
 	struct power_supply	bat;
@@ -73,6 +74,7 @@ static enum power_supply_property bq27200_props[] = {
 	POWER_SUPPLY_PROP_CURRENT_NOW,
 	POWER_SUPPLY_PROP_CAPACITY,
 	POWER_SUPPLY_PROP_TEMP,
+	POWER_SUPPLY_PROP_POWER_AVG,
 };
 
 /*
@@ -166,6 +168,19 @@ static int bq27200_rsoc(struct bq27200 *bq)
 	return ret >> 8;
 }
 
+static int bq27200_power(struct bq27200 *bq)
+{
+	int ret;
+
+	ret = bq27200_readw(bq, BQ27200_REG_AP);
+	if (ret < 0) {
+		dev_err(&bq->client->dev, "error reading average power\n");
+		return ret;
+	}
+
+	return (ret * BQ27200_POWER_CONSTANT) / BQ27200_SENSING_RESISTOR;
+}
+
 static int bq27200_get_property(struct power_supply *psy,
 		enum power_supply_property psp, union power_supply_propval *val)
 {
@@ -190,6 +205,9 @@ static int bq27200_get_property(struct power_supply *psy,
 	case POWER_SUPPLY_PROP_TEMP:
 		val->intval = bq27200_temperature(bq);
 		break;
+	case POWER_SUPPLY_PROP_POWER_AVG:
+		val->intval = bq27200_power(bq);
+		break;
 	default:
 		return -EINVAL;
 	}
-- 
1.6.4.rc0.17.gd9eb0


  parent reply	other threads:[~2009-07-12 20:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-12 18:09 [rfc/patch 01/15] power: bq27x00: rename to bq27200.c Felipe Balbi
2009-07-12 18:09 ` [rfc/patch 02/15] power: bq27200: this is an i2c device Felipe Balbi
2009-07-12 18:09   ` [rfc/patch 03/15] power: bq27200: misc cleanup Felipe Balbi
2009-07-12 18:09     ` [rfc/patch 04/15] power: bq27200: simplify read by using smbus Felipe Balbi
2009-07-12 18:09       ` [rfc/patch 05/15] power: bq27200: remove unnecessary function Felipe Balbi
2009-07-12 18:09         ` [rfc/patch 06/15] power: bq27200: rename structure to something smaller Felipe Balbi
2009-07-12 18:09           ` [rfc/patch 07/15] power: bq27200: add missing suplicants Felipe Balbi
2009-07-12 18:09             ` [rfc/patch 08/15] power: bq27200: define all register space Felipe Balbi
2009-07-12 18:09               ` [rfc/patch 09/15] power: bq27200: fix up current reporting Felipe Balbi
2009-07-12 18:09                 ` [rfc/patch 10/15] power: bq27200: voltage should be expressed in uV Felipe Balbi
2009-07-12 18:09                   ` [rfc/patch 11/15] power: bq27200: temperature in tenths of degrees Felipe Balbi
2009-07-12 18:09                     ` [rfc/patch 12/15] power: bq27200: add power property Felipe Balbi
2009-07-12 18:09                       ` [rfc/patch 13/15] power: bq27200: RSOC is 8-bit wide Felipe Balbi
2009-07-12 18:09                         ` [rfc/patch 14/15] power: bq27200: add time to empty/full Felipe Balbi
2009-07-12 18:09                           ` [rfc/patch 15/15] power: bq27200: add energy average Felipe Balbi
2009-07-12 20:12                           ` [rfc/patch 14/15] power: bq27200: add time to empty/full Felipe Balbi
2009-07-12 20:11                       ` Felipe Balbi [this message]
2009-07-12 18:47   ` [rfc/patch 02/15] power: bq27200: this is an i2c device Linus Walleij
2009-07-12 19:49     ` Felipe Balbi

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=20090712201145.GA11865@gandalf \
    --to=me@felipebalbi.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.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